app.js 1.7 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040400414004240043400444004540046400474004840049400504005140052400534005440055400564005740058400594006040061400624006340064400654006640067400684006940070400714007240073400744007540076400774007840079400804008140082400834008440085400864008740088400894009040091400924009340094400954009640097400984009940100401014010240103401044010540106401074010840109401104011140112401134011440115401164011740118401194012040121401224012340124401254012640127401284012940130401314013240133401344013540136401374013840139401404014140142401434014440145401464014740148401494015040151401524015340154401554015640157401584015940160401614016240163401644016540166401674016840169401704017140172401734017440175401764017740178401794018040181401824018340184401854018640187401884018940190401914019240193401944019540196401974019840199402004020140202402034020440205402064020740208402094021040211402124021340214402154021640217402184021940220402214022240223402244022540226402274022840229402304023140232402334023440235402364023740238402394024040241402424024340244402454024640247402484024940250402514025240253402544025540256402574025840259402604026140262402634026440265402664026740268402694027040271402724027340274402754027640277402784027940280402814028240283402844028540286402874028840289402904029140292402934029440295402964029740298402994030040301403024030340304403054030640307403084030940310403114031240313403144031540316403174031840319403204032140322403234032440325403264032740328403294033040331403324033340334403354033640337403384033940340403414034240343403444034540346403474034840349403504035140352403534035440355403564035740358403594036040361403624036340364403654036640367403684036940370403714037240373403744037540376403774037840379403804038140382403834038440385403864038740388403894039040391403924039340394403954039640397403984039940400404014040240403404044040540406404074040840409404104041140412404134041440415404164041740418404194042040421404224042340424404254042640427404284042940430404314043240433404344043540436404374043840439404404044140442404434044440445404464044740448404494045040451404524045340454404554045640457404584045940460404614046240463404644046540466404674046840469404704047140472404734047440475404764047740478404794048040481404824048340484404854048640487404884048940490404914049240493404944049540496404974049840499405004050140502405034050440505405064050740508405094051040511405124051340514405154051640517405184051940520405214052240523405244052540526405274052840529405304053140532405334053440535405364053740538405394054040541405424054340544405454054640547405484054940550405514055240553405544055540556405574055840559405604056140562405634056440565405664056740568405694057040571405724057340574405754057640577405784057940580405814058240583405844058540586405874058840589405904059140592405934059440595405964059740598405994060040601406024060340604406054060640607406084060940610406114061240613406144061540616406174061840619406204062140622406234062440625406264062740628406294063040631406324063340634406354063640637406384063940640406414064240643406444064540646406474064840649406504065140652406534065440655406564065740658406594066040661406624066340664406654066640667406684066940670406714067240673406744067540676406774067840679406804068140682406834068440685406864068740688406894069040691406924069340694406954069640697406984069940700407014070240703407044070540706407074070840709407104071140712407134071440715407164071740718407194072040721407224072340724407254072640727407284072940730407314073240733407344073540736407374073840739407404074140742407434074440745407464074740748407494075040751407524075340754407554075640757407584075940760407614076240763407644076540766407674076840769407704077140772407734077440775407764077740778407794078040781407824078340784407854078640787407884078940790407914079240793407944079540796407974079840799408004080140802408034080440805408064080740808408094081040811408124081340814408154081640817408184081940820408214082240823408244082540826408274082840829408304083140832408334083440835408364083740838408394084040841408424084340844408454084640847408484084940850408514085240853408544085540856408574085840859408604086140862408634086440865408664086740868408694087040871408724087340874408754087640877408784087940880408814088240883408844088540886408874088840889408904089140892408934089440895408964089740898408994090040901409024090340904409054090640907409084090940910409114091240913409144091540916409174091840919409204092140922409234092440925409264092740928409294093040931409324093340934409354093640937409384093940940409414094240943409444094540946409474094840949409504095140952409534095440955409564095740958409594096040961409624096340964409654096640967409684096940970409714097240973409744097540976409774097840979409804098140982409834098440985409864098740988409894099040991409924099340994409954099640997409984099941000410014100241003410044100541006410074100841009410104101141012410134101441015410164101741018410194102041021410224102341024410254102641027410284102941030410314103241033410344103541036410374103841039410404104141042410434104441045410464104741048410494105041051410524105341054410554105641057410584105941060410614106241063410644106541066410674106841069410704107141072410734107441075410764107741078410794108041081410824108341084410854108641087410884108941090410914109241093410944109541096410974109841099411004110141102411034110441105411064110741108411094111041111411124111341114411154111641117411184111941120411214112241123411244112541126411274112841129411304113141132411334113441135411364113741138411394114041141411424114341144411454114641147411484114941150411514115241153411544115541156411574115841159411604116141162411634116441165411664116741168411694117041171411724117341174411754117641177411784117941180411814118241183411844118541186411874118841189411904119141192411934119441195411964119741198411994120041201412024120341204412054120641207412084120941210412114121241213412144121541216412174121841219412204122141222412234122441225412264122741228412294123041231412324123341234412354123641237412384123941240412414124241243412444124541246412474124841249412504125141252412534125441255412564125741258412594126041261412624126341264412654126641267412684126941270412714127241273412744127541276412774127841279412804128141282412834128441285412864128741288412894129041291412924129341294412954129641297412984129941300413014130241303413044130541306413074130841309413104131141312413134131441315413164131741318413194132041321413224132341324413254132641327413284132941330413314133241333413344133541336413374133841339413404134141342413434134441345413464134741348413494135041351413524135341354413554135641357413584135941360413614136241363413644136541366413674136841369413704137141372413734137441375413764137741378413794138041381413824138341384413854138641387413884138941390413914139241393413944139541396413974139841399414004140141402414034140441405414064140741408414094141041411414124141341414414154141641417414184141941420414214142241423414244142541426414274142841429414304143141432414334143441435414364143741438414394144041441414424144341444414454144641447414484144941450414514145241453414544145541456414574145841459414604146141462414634146441465414664146741468414694147041471414724147341474414754147641477414784147941480414814148241483414844148541486414874148841489414904149141492414934149441495414964149741498414994150041501415024150341504415054150641507415084150941510415114151241513415144151541516415174151841519415204152141522415234152441525415264152741528415294153041531415324153341534415354153641537415384153941540415414154241543415444154541546415474154841549415504155141552415534155441555415564155741558415594156041561415624156341564415654156641567415684156941570415714157241573415744157541576415774157841579415804158141582415834158441585415864158741588415894159041591415924159341594415954159641597415984159941600416014160241603416044160541606416074160841609416104161141612416134161441615416164161741618416194162041621416224162341624416254162641627416284162941630416314163241633416344163541636416374163841639416404164141642416434164441645416464164741648416494165041651416524165341654416554165641657416584165941660416614166241663416644166541666416674166841669416704167141672416734167441675416764167741678416794168041681416824168341684416854168641687416884168941690416914169241693416944169541696416974169841699417004170141702417034170441705417064170741708417094171041711417124171341714417154171641717417184171941720417214172241723417244172541726417274172841729417304173141732417334173441735417364173741738417394174041741417424174341744417454174641747417484174941750417514175241753417544175541756417574175841759417604176141762417634176441765417664176741768417694177041771417724177341774417754177641777417784177941780417814178241783417844178541786417874178841789417904179141792417934179441795417964179741798417994180041801418024180341804418054180641807418084180941810418114181241813418144181541816418174181841819418204182141822418234182441825418264182741828418294183041831418324183341834418354183641837418384183941840418414184241843418444184541846418474184841849418504185141852418534185441855418564185741858418594186041861418624186341864418654186641867418684186941870418714187241873418744187541876418774187841879418804188141882418834188441885418864188741888418894189041891418924189341894418954189641897418984189941900419014190241903419044190541906419074190841909419104191141912419134191441915419164191741918419194192041921419224192341924419254192641927419284192941930419314193241933419344193541936419374193841939419404194141942419434194441945419464194741948419494195041951419524195341954419554195641957419584195941960419614196241963419644196541966419674196841969419704197141972419734197441975419764197741978419794198041981419824198341984419854198641987419884198941990419914199241993419944199541996419974199841999420004200142002420034200442005420064200742008420094201042011420124201342014420154201642017420184201942020420214202242023420244202542026420274202842029420304203142032420334203442035420364203742038420394204042041420424204342044420454204642047420484204942050420514205242053420544205542056420574205842059420604206142062420634206442065420664206742068420694207042071420724207342074420754207642077420784207942080420814208242083420844208542086420874208842089420904209142092420934209442095420964209742098420994210042101421024210342104421054210642107421084210942110421114211242113421144211542116421174211842119421204212142122421234212442125421264212742128421294213042131421324213342134421354213642137421384213942140421414214242143421444214542146421474214842149421504215142152421534215442155421564215742158421594216042161421624216342164421654216642167421684216942170421714217242173421744217542176421774217842179421804218142182421834218442185421864218742188421894219042191421924219342194421954219642197421984219942200422014220242203422044220542206422074220842209422104221142212422134221442215422164221742218422194222042221422224222342224422254222642227422284222942230422314223242233422344223542236422374223842239422404224142242422434224442245422464224742248422494225042251422524225342254422554225642257422584225942260422614226242263422644226542266422674226842269422704227142272422734227442275422764227742278422794228042281422824228342284422854228642287422884228942290422914229242293422944229542296422974229842299423004230142302423034230442305423064230742308423094231042311423124231342314423154231642317423184231942320423214232242323423244232542326423274232842329423304233142332423334233442335423364233742338423394234042341423424234342344423454234642347423484234942350423514235242353423544235542356423574235842359423604236142362423634236442365423664236742368423694237042371423724237342374423754237642377423784237942380423814238242383423844238542386423874238842389423904239142392423934239442395423964239742398423994240042401424024240342404424054240642407424084240942410424114241242413424144241542416424174241842419424204242142422424234242442425424264242742428424294243042431424324243342434424354243642437424384243942440424414244242443424444244542446424474244842449424504245142452424534245442455424564245742458424594246042461424624246342464424654246642467424684246942470424714247242473424744247542476424774247842479424804248142482424834248442485424864248742488424894249042491424924249342494424954249642497424984249942500425014250242503425044250542506425074250842509425104251142512425134251442515425164251742518425194252042521425224252342524425254252642527425284252942530425314253242533425344253542536425374253842539425404254142542425434254442545425464254742548425494255042551425524255342554425554255642557425584255942560425614256242563425644256542566425674256842569425704257142572425734257442575425764257742578425794258042581425824258342584425854258642587425884258942590425914259242593425944259542596425974259842599426004260142602426034260442605426064260742608426094261042611426124261342614426154261642617426184261942620426214262242623426244262542626426274262842629426304263142632426334263442635426364263742638426394264042641426424264342644426454264642647426484264942650426514265242653426544265542656426574265842659426604266142662426634266442665426664266742668426694267042671426724267342674426754267642677426784267942680426814268242683426844268542686426874268842689426904269142692426934269442695426964269742698426994270042701427024270342704427054270642707427084270942710427114271242713427144271542716427174271842719427204272142722427234272442725427264272742728427294273042731427324273342734427354273642737427384273942740427414274242743427444274542746427474274842749427504275142752427534275442755427564275742758427594276042761427624276342764427654276642767427684276942770427714277242773427744277542776427774277842779427804278142782427834278442785427864278742788427894279042791427924279342794427954279642797427984279942800428014280242803428044280542806428074280842809428104281142812428134281442815428164281742818428194282042821428224282342824428254282642827428284282942830428314283242833428344283542836428374283842839428404284142842428434284442845428464284742848428494285042851428524285342854428554285642857428584285942860428614286242863428644286542866428674286842869428704287142872428734287442875428764287742878428794288042881428824288342884428854288642887428884288942890428914289242893428944289542896428974289842899429004290142902429034290442905429064290742908429094291042911429124291342914429154291642917429184291942920429214292242923429244292542926429274292842929429304293142932429334293442935429364293742938429394294042941429424294342944429454294642947429484294942950429514295242953429544295542956429574295842959429604296142962429634296442965429664296742968429694297042971429724297342974429754297642977429784297942980429814298242983429844298542986429874298842989429904299142992429934299442995429964299742998429994300043001430024300343004430054300643007430084300943010430114301243013430144301543016430174301843019430204302143022430234302443025430264302743028430294303043031430324303343034430354303643037430384303943040430414304243043430444304543046430474304843049430504305143052430534305443055430564305743058430594306043061430624306343064430654306643067430684306943070430714307243073430744307543076430774307843079430804308143082430834308443085430864308743088430894309043091430924309343094430954309643097430984309943100431014310243103431044310543106431074310843109431104311143112431134311443115431164311743118431194312043121431224312343124431254312643127431284312943130431314313243133431344313543136431374313843139431404314143142431434314443145431464314743148431494315043151431524315343154431554315643157431584315943160431614316243163431644316543166431674316843169431704317143172431734317443175431764317743178431794318043181431824318343184431854318643187431884318943190431914319243193431944319543196431974319843199432004320143202432034320443205432064320743208432094321043211432124321343214432154321643217432184321943220432214322243223432244322543226432274322843229432304323143232432334323443235432364323743238432394324043241432424324343244432454324643247432484324943250432514325243253432544325543256432574325843259432604326143262432634326443265432664326743268432694327043271432724327343274432754327643277432784327943280432814328243283432844328543286432874328843289432904329143292432934329443295432964329743298432994330043301433024330343304433054330643307433084330943310433114331243313433144331543316433174331843319433204332143322433234332443325433264332743328433294333043331433324333343334433354333643337433384333943340433414334243343433444334543346433474334843349433504335143352433534335443355433564335743358433594336043361433624336343364433654336643367433684336943370433714337243373433744337543376433774337843379433804338143382433834338443385433864338743388433894339043391433924339343394433954339643397433984339943400434014340243403434044340543406434074340843409434104341143412434134341443415434164341743418434194342043421434224342343424434254342643427434284342943430434314343243433434344343543436434374343843439434404344143442434434344443445434464344743448434494345043451434524345343454434554345643457434584345943460434614346243463434644346543466434674346843469434704347143472434734347443475434764347743478434794348043481434824348343484434854348643487434884348943490434914349243493434944349543496434974349843499435004350143502435034350443505435064350743508435094351043511435124351343514435154351643517435184351943520435214352243523435244352543526435274352843529435304353143532435334353443535435364353743538435394354043541435424354343544435454354643547435484354943550435514355243553435544355543556435574355843559435604356143562435634356443565435664356743568435694357043571435724357343574435754357643577435784357943580435814358243583435844358543586435874358843589435904359143592435934359443595435964359743598435994360043601436024360343604436054360643607436084360943610436114361243613436144361543616436174361843619436204362143622436234362443625436264362743628436294363043631436324363343634436354363643637436384363943640436414364243643436444364543646436474364843649436504365143652436534365443655436564365743658436594366043661436624366343664436654366643667436684366943670436714367243673436744367543676436774367843679436804368143682436834368443685436864368743688436894369043691436924369343694436954369643697436984369943700437014370243703437044370543706437074370843709437104371143712437134371443715437164371743718437194372043721437224372343724437254372643727437284372943730437314373243733437344373543736437374373843739437404374143742437434374443745437464374743748437494375043751437524375343754437554375643757437584375943760437614376243763437644376543766437674376843769437704377143772437734377443775437764377743778437794378043781437824378343784437854378643787437884378943790437914379243793437944379543796437974379843799438004380143802438034380443805438064380743808438094381043811438124381343814438154381643817438184381943820438214382243823438244382543826438274382843829438304383143832438334383443835438364383743838438394384043841438424384343844438454384643847438484384943850438514385243853438544385543856438574385843859438604386143862438634386443865438664386743868438694387043871438724387343874438754387643877438784387943880438814388243883438844388543886438874388843889438904389143892438934389443895438964389743898438994390043901439024390343904439054390643907439084390943910439114391243913439144391543916439174391843919439204392143922439234392443925439264392743928439294393043931439324393343934439354393643937439384393943940439414394243943439444394543946439474394843949439504395143952439534395443955439564395743958439594396043961439624396343964439654396643967439684396943970439714397243973439744397543976439774397843979439804398143982439834398443985439864398743988439894399043991439924399343994439954399643997439984399944000440014400244003440044400544006440074400844009440104401144012440134401444015440164401744018440194402044021440224402344024440254402644027440284402944030440314403244033440344403544036440374403844039440404404144042440434404444045440464404744048440494405044051440524405344054440554405644057440584405944060440614406244063440644406544066440674406844069440704407144072440734407444075440764407744078440794408044081440824408344084440854408644087440884408944090440914409244093440944409544096440974409844099441004410144102441034410444105441064410744108441094411044111441124411344114441154411644117441184411944120441214412244123441244412544126441274412844129441304413144132441334413444135441364413744138441394414044141441424414344144441454414644147441484414944150441514415244153441544415544156441574415844159441604416144162441634416444165441664416744168441694417044171441724417344174441754417644177441784417944180441814418244183441844418544186441874418844189441904419144192441934419444195441964419744198441994420044201442024420344204442054420644207442084420944210442114421244213442144421544216442174421844219442204422144222442234422444225442264422744228442294423044231442324423344234442354423644237442384423944240442414424244243442444424544246442474424844249442504425144252442534425444255442564425744258442594426044261442624426344264442654426644267442684426944270442714427244273442744427544276442774427844279442804428144282442834428444285442864428744288442894429044291442924429344294442954429644297442984429944300443014430244303443044430544306443074430844309443104431144312443134431444315443164431744318443194432044321443224432344324443254432644327443284432944330443314433244333443344433544336443374433844339443404434144342443434434444345443464434744348443494435044351443524435344354443554435644357443584435944360443614436244363443644436544366443674436844369443704437144372443734437444375443764437744378443794438044381443824438344384443854438644387443884438944390443914439244393443944439544396443974439844399444004440144402444034440444405444064440744408444094441044411444124441344414444154441644417444184441944420444214442244423444244442544426444274442844429444304443144432444334443444435444364443744438444394444044441444424444344444444454444644447444484444944450444514445244453444544445544456444574445844459444604446144462444634446444465444664446744468444694447044471444724447344474444754447644477444784447944480444814448244483444844448544486444874448844489444904449144492444934449444495444964449744498444994450044501445024450344504445054450644507445084450944510445114451244513445144451544516445174451844519445204452144522445234452444525445264452744528445294453044531445324453344534445354453644537445384453944540445414454244543445444454544546445474454844549445504455144552445534455444555445564455744558445594456044561445624456344564445654456644567445684456944570445714457244573445744457544576445774457844579445804458144582445834458444585445864458744588445894459044591445924459344594445954459644597445984459944600446014460244603446044460544606446074460844609446104461144612446134461444615446164461744618446194462044621446224462344624446254462644627446284462944630446314463244633446344463544636446374463844639446404464144642446434464444645446464464744648446494465044651446524465344654446554465644657446584465944660446614466244663446644466544666446674466844669446704467144672446734467444675446764467744678446794468044681446824468344684446854468644687446884468944690446914469244693446944469544696446974469844699447004470144702447034470444705447064470744708447094471044711447124471344714447154471644717447184471944720447214472244723447244472544726447274472844729447304473144732447334473444735447364473744738447394474044741447424474344744447454474644747447484474944750447514475244753447544475544756447574475844759447604476144762447634476444765447664476744768447694477044771447724477344774447754477644777447784477944780447814478244783447844478544786447874478844789447904479144792447934479444795447964479744798447994480044801448024480344804448054480644807448084480944810448114481244813448144481544816448174481844819448204482144822448234482444825448264482744828448294483044831448324483344834448354483644837448384483944840448414484244843448444484544846448474484844849448504485144852448534485444855448564485744858448594486044861448624486344864448654486644867448684486944870448714487244873448744487544876448774487844879448804488144882448834488444885448864488744888448894489044891448924489344894448954489644897448984489944900449014490244903449044490544906449074490844909449104491144912449134491444915449164491744918449194492044921449224492344924449254492644927449284492944930449314493244933449344493544936449374493844939449404494144942449434494444945449464494744948449494495044951449524495344954449554495644957449584495944960449614496244963449644496544966449674496844969449704497144972449734497444975449764497744978449794498044981449824498344984449854498644987449884498944990449914499244993449944499544996449974499844999450004500145002450034500445005450064500745008450094501045011450124501345014450154501645017450184501945020450214502245023450244502545026450274502845029450304503145032450334503445035450364503745038450394504045041450424504345044450454504645047450484504945050450514505245053450544505545056450574505845059450604506145062450634506445065450664506745068450694507045071450724507345074450754507645077450784507945080450814508245083450844508545086450874508845089450904509145092450934509445095450964509745098450994510045101451024510345104451054510645107451084510945110451114511245113451144511545116451174511845119451204512145122451234512445125451264512745128451294513045131451324513345134451354513645137451384513945140451414514245143451444514545146451474514845149451504515145152451534515445155451564515745158451594516045161451624516345164451654516645167451684516945170451714517245173451744517545176451774517845179451804518145182451834518445185451864518745188451894519045191451924519345194451954519645197451984519945200452014520245203452044520545206452074520845209452104521145212452134521445215452164521745218452194522045221452224522345224452254522645227452284522945230452314523245233452344523545236452374523845239452404524145242452434524445245452464524745248452494525045251452524525345254452554525645257452584525945260452614526245263452644526545266452674526845269452704527145272452734527445275452764527745278452794528045281452824528345284452854528645287452884528945290452914529245293452944529545296452974529845299453004530145302453034530445305453064530745308453094531045311453124531345314453154531645317453184531945320453214532245323453244532545326453274532845329453304533145332453334533445335453364533745338453394534045341453424534345344453454534645347453484534945350453514535245353453544535545356453574535845359453604536145362453634536445365453664536745368453694537045371453724537345374453754537645377453784537945380453814538245383453844538545386453874538845389453904539145392453934539445395453964539745398453994540045401454024540345404454054540645407454084540945410454114541245413454144541545416454174541845419454204542145422454234542445425454264542745428454294543045431454324543345434454354543645437454384543945440454414544245443454444544545446454474544845449454504545145452454534545445455454564545745458454594546045461454624546345464454654546645467454684546945470454714547245473454744547545476454774547845479454804548145482454834548445485454864548745488454894549045491454924549345494454954549645497454984549945500455014550245503455044550545506455074550845509455104551145512455134551445515455164551745518455194552045521455224552345524455254552645527455284552945530455314553245533455344553545536455374553845539455404554145542455434554445545455464554745548455494555045551455524555345554455554555645557455584555945560455614556245563455644556545566455674556845569455704557145572455734557445575455764557745578455794558045581455824558345584455854558645587455884558945590455914559245593455944559545596455974559845599456004560145602456034560445605456064560745608456094561045611456124561345614456154561645617456184561945620456214562245623456244562545626456274562845629456304563145632456334563445635456364563745638456394564045641456424564345644456454564645647456484564945650456514565245653456544565545656456574565845659456604566145662456634566445665456664566745668456694567045671456724567345674456754567645677456784567945680456814568245683456844568545686456874568845689456904569145692456934569445695456964569745698456994570045701457024570345704457054570645707457084570945710457114571245713457144571545716457174571845719457204572145722457234572445725457264572745728457294573045731457324573345734457354573645737457384573945740457414574245743457444574545746457474574845749457504575145752457534575445755457564575745758457594576045761457624576345764457654576645767457684576945770457714577245773457744577545776457774577845779457804578145782457834578445785457864578745788457894579045791457924579345794457954579645797457984579945800458014580245803458044580545806458074580845809458104581145812458134581445815458164581745818458194582045821458224582345824458254582645827458284582945830458314583245833458344583545836458374583845839458404584145842458434584445845458464584745848458494585045851458524585345854458554585645857458584585945860458614586245863458644586545866458674586845869458704587145872458734587445875458764587745878458794588045881458824588345884458854588645887458884588945890458914589245893458944589545896458974589845899459004590145902459034590445905459064590745908459094591045911459124591345914459154591645917459184591945920459214592245923459244592545926459274592845929459304593145932459334593445935459364593745938459394594045941459424594345944459454594645947459484594945950459514595245953459544595545956459574595845959459604596145962459634596445965459664596745968459694597045971459724597345974459754597645977459784597945980459814598245983459844598545986459874598845989459904599145992459934599445995459964599745998459994600046001460024600346004460054600646007460084600946010460114601246013460144601546016460174601846019460204602146022460234602446025460264602746028460294603046031460324603346034460354603646037460384603946040460414604246043460444604546046460474604846049460504605146052460534605446055460564605746058460594606046061460624606346064460654606646067460684606946070460714607246073460744607546076460774607846079460804608146082460834608446085460864608746088460894609046091460924609346094460954609646097460984609946100461014610246103461044610546106461074610846109461104611146112461134611446115461164611746118461194612046121461224612346124461254612646127461284612946130461314613246133461344613546136461374613846139461404614146142461434614446145461464614746148461494615046151461524615346154461554615646157461584615946160461614616246163461644616546166461674616846169461704617146172461734617446175461764617746178461794618046181461824618346184461854618646187461884618946190461914619246193461944619546196461974619846199462004620146202462034620446205462064620746208462094621046211462124621346214462154621646217462184621946220462214622246223462244622546226462274622846229462304623146232462334623446235462364623746238462394624046241462424624346244462454624646247462484624946250462514625246253462544625546256462574625846259462604626146262462634626446265462664626746268462694627046271462724627346274462754627646277462784627946280462814628246283462844628546286462874628846289462904629146292462934629446295462964629746298462994630046301463024630346304463054630646307463084630946310463114631246313463144631546316463174631846319463204632146322463234632446325463264632746328463294633046331463324633346334463354633646337463384633946340463414634246343463444634546346463474634846349463504635146352463534635446355463564635746358463594636046361463624636346364463654636646367463684636946370463714637246373463744637546376463774637846379463804638146382463834638446385463864638746388463894639046391463924639346394463954639646397463984639946400464014640246403464044640546406464074640846409464104641146412464134641446415464164641746418464194642046421464224642346424464254642646427464284642946430464314643246433464344643546436464374643846439464404644146442464434644446445464464644746448464494645046451464524645346454464554645646457464584645946460464614646246463464644646546466464674646846469464704647146472464734647446475464764647746478464794648046481464824648346484464854648646487464884648946490464914649246493464944649546496464974649846499465004650146502465034650446505465064650746508465094651046511465124651346514465154651646517465184651946520465214652246523465244652546526465274652846529465304653146532465334653446535465364653746538465394654046541465424654346544465454654646547465484654946550465514655246553465544655546556465574655846559465604656146562465634656446565465664656746568465694657046571465724657346574465754657646577465784657946580465814658246583465844658546586465874658846589465904659146592465934659446595465964659746598465994660046601466024660346604466054660646607466084660946610466114661246613466144661546616466174661846619466204662146622466234662446625466264662746628466294663046631466324663346634466354663646637466384663946640466414664246643466444664546646466474664846649466504665146652466534665446655466564665746658466594666046661466624666346664466654666646667466684666946670466714667246673466744667546676466774667846679466804668146682466834668446685466864668746688466894669046691466924669346694466954669646697466984669946700467014670246703467044670546706467074670846709467104671146712467134671446715467164671746718467194672046721467224672346724467254672646727467284672946730467314673246733467344673546736467374673846739467404674146742467434674446745467464674746748467494675046751467524675346754467554675646757467584675946760467614676246763467644676546766467674676846769467704677146772467734677446775467764677746778467794678046781467824678346784467854678646787467884678946790467914679246793467944679546796467974679846799468004680146802468034680446805468064680746808468094681046811468124681346814468154681646817468184681946820468214682246823468244682546826468274682846829468304683146832468334683446835468364683746838468394684046841468424684346844468454684646847468484684946850468514685246853468544685546856468574685846859468604686146862468634686446865468664686746868468694687046871468724687346874468754687646877468784687946880468814688246883468844688546886468874688846889468904689146892468934689446895468964689746898468994690046901469024690346904469054690646907469084690946910469114691246913469144691546916469174691846919469204692146922469234692446925469264692746928469294693046931469324693346934469354693646937469384693946940469414694246943469444694546946469474694846949469504695146952469534695446955469564695746958469594696046961469624696346964469654696646967469684696946970469714697246973469744697546976469774697846979469804698146982469834698446985469864698746988469894699046991469924699346994469954699646997469984699947000470014700247003470044700547006470074700847009470104701147012470134701447015470164701747018470194702047021470224702347024470254702647027470284702947030470314703247033470344703547036470374703847039470404704147042470434704447045470464704747048470494705047051470524705347054470554705647057470584705947060470614706247063470644706547066470674706847069470704707147072470734707447075470764707747078470794708047081470824708347084470854708647087470884708947090470914709247093470944709547096470974709847099471004710147102471034710447105471064710747108471094711047111471124711347114471154711647117471184711947120471214712247123471244712547126471274712847129471304713147132471334713447135471364713747138471394714047141471424714347144471454714647147471484714947150471514715247153471544715547156471574715847159471604716147162471634716447165471664716747168471694717047171471724717347174471754717647177471784717947180471814718247183471844718547186471874718847189471904719147192471934719447195471964719747198471994720047201472024720347204472054720647207472084720947210472114721247213472144721547216472174721847219472204722147222472234722447225472264722747228472294723047231472324723347234472354723647237472384723947240472414724247243472444724547246472474724847249472504725147252472534725447255472564725747258472594726047261472624726347264472654726647267472684726947270472714727247273472744727547276472774727847279472804728147282472834728447285472864728747288472894729047291472924729347294472954729647297472984729947300473014730247303473044730547306473074730847309473104731147312473134731447315473164731747318473194732047321473224732347324473254732647327473284732947330473314733247333473344733547336473374733847339473404734147342473434734447345473464734747348473494735047351473524735347354473554735647357473584735947360473614736247363473644736547366473674736847369473704737147372473734737447375473764737747378473794738047381473824738347384473854738647387473884738947390473914739247393473944739547396473974739847399474004740147402474034740447405474064740747408474094741047411474124741347414474154741647417474184741947420474214742247423474244742547426474274742847429474304743147432474334743447435474364743747438474394744047441474424744347444474454744647447474484744947450474514745247453474544745547456474574745847459474604746147462474634746447465474664746747468474694747047471474724747347474474754747647477474784747947480474814748247483474844748547486474874748847489474904749147492474934749447495474964749747498474994750047501475024750347504475054750647507475084750947510475114751247513475144751547516475174751847519475204752147522475234752447525475264752747528475294753047531475324753347534475354753647537475384753947540475414754247543475444754547546475474754847549475504755147552475534755447555475564755747558475594756047561475624756347564475654756647567475684756947570475714757247573475744757547576475774757847579475804758147582475834758447585475864758747588475894759047591475924759347594475954759647597475984759947600476014760247603476044760547606476074760847609476104761147612476134761447615476164761747618476194762047621476224762347624476254762647627476284762947630476314763247633476344763547636476374763847639476404764147642476434764447645476464764747648476494765047651476524765347654476554765647657476584765947660476614766247663476644766547666476674766847669476704767147672476734767447675476764767747678476794768047681476824768347684476854768647687476884768947690476914769247693476944769547696476974769847699477004770147702477034770447705477064770747708477094771047711477124771347714477154771647717477184771947720477214772247723477244772547726477274772847729477304773147732477334773447735477364773747738477394774047741477424774347744477454774647747477484774947750477514775247753477544775547756477574775847759477604776147762477634776447765477664776747768477694777047771477724777347774477754777647777477784777947780477814778247783477844778547786477874778847789477904779147792477934779447795477964779747798477994780047801478024780347804478054780647807478084780947810478114781247813478144781547816478174781847819478204782147822478234782447825478264782747828478294783047831478324783347834478354783647837478384783947840478414784247843478444784547846478474784847849478504785147852478534785447855478564785747858478594786047861478624786347864478654786647867478684786947870478714787247873478744787547876478774787847879478804788147882478834788447885478864788747888478894789047891478924789347894478954789647897478984789947900479014790247903479044790547906479074790847909479104791147912479134791447915479164791747918479194792047921479224792347924479254792647927479284792947930479314793247933479344793547936479374793847939479404794147942479434794447945479464794747948479494795047951479524795347954479554795647957479584795947960479614796247963479644796547966479674796847969479704797147972479734797447975479764797747978479794798047981479824798347984479854798647987479884798947990479914799247993479944799547996479974799847999480004800148002480034800448005480064800748008480094801048011480124801348014480154801648017480184801948020480214802248023480244802548026480274802848029480304803148032480334803448035480364803748038480394804048041480424804348044480454804648047480484804948050480514805248053480544805548056480574805848059480604806148062480634806448065480664806748068480694807048071480724807348074480754807648077480784807948080480814808248083480844808548086480874808848089480904809148092480934809448095480964809748098480994810048101481024810348104481054810648107481084810948110481114811248113481144811548116481174811848119481204812148122481234812448125481264812748128481294813048131481324813348134481354813648137481384813948140481414814248143481444814548146481474814848149481504815148152481534815448155481564815748158481594816048161481624816348164481654816648167481684816948170481714817248173481744817548176481774817848179481804818148182481834818448185481864818748188481894819048191481924819348194481954819648197481984819948200482014820248203482044820548206482074820848209482104821148212482134821448215482164821748218482194822048221482224822348224482254822648227482284822948230482314823248233482344823548236482374823848239482404824148242482434824448245482464824748248482494825048251482524825348254482554825648257482584825948260482614826248263482644826548266482674826848269482704827148272482734827448275482764827748278482794828048281482824828348284482854828648287482884828948290482914829248293482944829548296482974829848299483004830148302483034830448305483064830748308483094831048311483124831348314483154831648317483184831948320483214832248323483244832548326483274832848329483304833148332483334833448335483364833748338483394834048341483424834348344483454834648347483484834948350483514835248353483544835548356483574835848359483604836148362483634836448365483664836748368483694837048371483724837348374483754837648377483784837948380483814838248383483844838548386483874838848389483904839148392483934839448395483964839748398483994840048401484024840348404484054840648407484084840948410484114841248413484144841548416484174841848419484204842148422484234842448425484264842748428484294843048431484324843348434484354843648437484384843948440484414844248443484444844548446484474844848449484504845148452484534845448455484564845748458484594846048461484624846348464484654846648467484684846948470484714847248473484744847548476484774847848479484804848148482484834848448485484864848748488484894849048491484924849348494484954849648497484984849948500485014850248503485044850548506485074850848509485104851148512485134851448515485164851748518485194852048521485224852348524485254852648527485284852948530485314853248533485344853548536485374853848539485404854148542485434854448545485464854748548485494855048551485524855348554485554855648557485584855948560485614856248563485644856548566485674856848569485704857148572485734857448575485764857748578485794858048581485824858348584485854858648587485884858948590485914859248593485944859548596485974859848599486004860148602486034860448605486064860748608486094861048611486124861348614486154861648617486184861948620486214862248623486244862548626486274862848629486304863148632486334863448635486364863748638486394864048641486424864348644486454864648647486484864948650486514865248653486544865548656486574865848659486604866148662486634866448665486664866748668486694867048671486724867348674486754867648677486784867948680486814868248683486844868548686486874868848689486904869148692486934869448695486964869748698486994870048701487024870348704487054870648707487084870948710487114871248713487144871548716487174871848719487204872148722487234872448725487264872748728487294873048731487324873348734487354873648737487384873948740487414874248743487444874548746487474874848749487504875148752487534875448755487564875748758487594876048761487624876348764487654876648767487684876948770487714877248773487744877548776487774877848779487804878148782487834878448785487864878748788487894879048791487924879348794487954879648797487984879948800488014880248803488044880548806488074880848809488104881148812488134881448815488164881748818488194882048821488224882348824488254882648827488284882948830488314883248833488344883548836488374883848839488404884148842488434884448845488464884748848488494885048851488524885348854488554885648857488584885948860488614886248863488644886548866488674886848869488704887148872488734887448875488764887748878488794888048881488824888348884488854888648887488884888948890488914889248893488944889548896488974889848899489004890148902489034890448905489064890748908489094891048911489124891348914489154891648917489184891948920489214892248923489244892548926489274892848929489304893148932489334893448935489364893748938489394894048941489424894348944489454894648947489484894948950489514895248953489544895548956489574895848959489604896148962489634896448965489664896748968489694897048971489724897348974489754897648977489784897948980489814898248983489844898548986489874898848989489904899148992489934899448995489964899748998489994900049001490024900349004490054900649007490084900949010490114901249013490144901549016490174901849019490204902149022490234902449025490264902749028490294903049031490324903349034490354903649037490384903949040490414904249043490444904549046490474904849049490504905149052490534905449055490564905749058490594906049061490624906349064490654906649067490684906949070490714907249073490744907549076490774907849079490804908149082490834908449085490864908749088490894909049091490924909349094490954909649097490984909949100491014910249103491044910549106491074910849109491104911149112491134911449115491164911749118491194912049121491224912349124491254912649127491284912949130491314913249133491344913549136491374913849139491404914149142491434914449145491464914749148491494915049151491524915349154491554915649157491584915949160491614916249163491644916549166491674916849169491704917149172491734917449175491764917749178491794918049181491824918349184491854918649187491884918949190491914919249193491944919549196491974919849199492004920149202492034920449205492064920749208492094921049211492124921349214492154921649217492184921949220492214922249223492244922549226492274922849229492304923149232492334923449235492364923749238492394924049241492424924349244492454924649247492484924949250492514925249253492544925549256492574925849259492604926149262492634926449265492664926749268492694927049271492724927349274492754927649277492784927949280492814928249283492844928549286492874928849289492904929149292492934929449295492964929749298492994930049301493024930349304493054930649307493084930949310493114931249313493144931549316493174931849319493204932149322493234932449325493264932749328493294933049331493324933349334493354933649337493384933949340493414934249343493444934549346493474934849349493504935149352493534935449355493564935749358493594936049361493624936349364493654936649367493684936949370493714937249373493744937549376493774937849379493804938149382493834938449385493864938749388493894939049391493924939349394493954939649397493984939949400494014940249403494044940549406494074940849409494104941149412494134941449415494164941749418494194942049421494224942349424494254942649427494284942949430494314943249433494344943549436494374943849439494404944149442494434944449445494464944749448494494945049451494524945349454494554945649457494584945949460494614946249463494644946549466494674946849469494704947149472494734947449475494764947749478494794948049481494824948349484494854948649487494884948949490494914949249493494944949549496494974949849499495004950149502495034950449505495064950749508495094951049511495124951349514495154951649517495184951949520495214952249523495244952549526495274952849529495304953149532495334953449535495364953749538495394954049541495424954349544495454954649547495484954949550495514955249553495544955549556495574955849559495604956149562495634956449565495664956749568495694957049571495724957349574495754957649577495784957949580495814958249583495844958549586495874958849589495904959149592495934959449595495964959749598495994960049601496024960349604496054960649607496084960949610496114961249613496144961549616496174961849619496204962149622496234962449625496264962749628496294963049631496324963349634496354963649637496384963949640496414964249643496444964549646496474964849649496504965149652496534965449655496564965749658496594966049661496624966349664496654966649667496684966949670496714967249673496744967549676496774967849679496804968149682496834968449685496864968749688496894969049691496924969349694496954969649697496984969949700497014970249703497044970549706497074970849709497104971149712497134971449715497164971749718497194972049721497224972349724497254972649727497284972949730497314973249733497344973549736497374973849739497404974149742497434974449745497464974749748497494975049751497524975349754497554975649757497584975949760497614976249763497644976549766497674976849769497704977149772497734977449775497764977749778497794978049781497824978349784497854978649787497884978949790497914979249793497944979549796497974979849799498004980149802498034980449805498064980749808498094981049811498124981349814498154981649817498184981949820498214982249823498244982549826498274982849829498304983149832498334983449835498364983749838498394984049841498424984349844498454984649847498484984949850498514985249853498544985549856498574985849859498604986149862498634986449865498664986749868498694987049871498724987349874498754987649877498784987949880498814988249883498844988549886498874988849889498904989149892498934989449895498964989749898498994990049901499024990349904499054990649907499084990949910499114991249913499144991549916499174991849919499204992149922499234992449925499264992749928499294993049931499324993349934499354993649937499384993949940499414994249943499444994549946499474994849949499504995149952499534995449955499564995749958499594996049961499624996349964499654996649967499684996949970499714997249973499744997549976499774997849979499804998149982499834998449985499864998749988499894999049991499924999349994499954999649997499984999950000500015000250003500045000550006500075000850009500105001150012500135001450015500165001750018500195002050021500225002350024500255002650027500285002950030500315003250033500345003550036500375003850039500405004150042500435004450045500465004750048500495005050051500525005350054500555005650057500585005950060500615006250063500645006550066500675006850069500705007150072500735007450075500765007750078500795008050081500825008350084500855008650087500885008950090500915009250093500945009550096500975009850099501005010150102501035010450105501065010750108501095011050111501125011350114501155011650117501185011950120501215012250123501245012550126501275012850129501305013150132501335013450135501365013750138501395014050141501425014350144501455014650147501485014950150501515015250153501545015550156501575015850159501605016150162501635016450165501665016750168501695017050171501725017350174501755017650177501785017950180501815018250183501845018550186501875018850189501905019150192501935019450195501965019750198501995020050201502025020350204502055020650207502085020950210502115021250213502145021550216502175021850219502205022150222502235022450225502265022750228502295023050231502325023350234502355023650237502385023950240502415024250243502445024550246502475024850249502505025150252502535025450255502565025750258502595026050261502625026350264502655026650267502685026950270502715027250273502745027550276502775027850279502805028150282502835028450285502865028750288502895029050291502925029350294502955029650297502985029950300503015030250303503045030550306503075030850309503105031150312503135031450315503165031750318503195032050321503225032350324503255032650327503285032950330503315033250333503345033550336503375033850339503405034150342503435034450345503465034750348503495035050351503525035350354503555035650357503585035950360503615036250363503645036550366503675036850369503705037150372503735037450375503765037750378503795038050381503825038350384503855038650387503885038950390503915039250393503945039550396503975039850399504005040150402504035040450405504065040750408504095041050411504125041350414504155041650417504185041950420504215042250423504245042550426504275042850429504305043150432504335043450435504365043750438504395044050441504425044350444504455044650447504485044950450504515045250453504545045550456504575045850459504605046150462504635046450465504665046750468504695047050471504725047350474504755047650477504785047950480504815048250483504845048550486504875048850489504905049150492504935049450495504965049750498504995050050501505025050350504505055050650507505085050950510505115051250513505145051550516505175051850519505205052150522505235052450525505265052750528505295053050531505325053350534505355053650537505385053950540505415054250543505445054550546505475054850549505505055150552505535055450555505565055750558505595056050561505625056350564505655056650567505685056950570505715057250573505745057550576505775057850579505805058150582505835058450585505865058750588505895059050591505925059350594505955059650597505985059950600506015060250603506045060550606506075060850609506105061150612506135061450615506165061750618506195062050621506225062350624506255062650627506285062950630506315063250633506345063550636506375063850639506405064150642506435064450645506465064750648506495065050651506525065350654506555065650657506585065950660506615066250663506645066550666506675066850669506705067150672506735067450675506765067750678506795068050681506825068350684506855068650687506885068950690506915069250693506945069550696506975069850699507005070150702507035070450705507065070750708507095071050711507125071350714507155071650717507185071950720507215072250723507245072550726507275072850729507305073150732507335073450735507365073750738507395074050741507425074350744507455074650747507485074950750507515075250753507545075550756507575075850759507605076150762507635076450765507665076750768507695077050771507725077350774507755077650777507785077950780507815078250783507845078550786507875078850789507905079150792507935079450795507965079750798507995080050801508025080350804508055080650807508085080950810508115081250813508145081550816508175081850819508205082150822508235082450825508265082750828508295083050831508325083350834508355083650837508385083950840508415084250843508445084550846508475084850849508505085150852508535085450855508565085750858508595086050861508625086350864508655086650867508685086950870508715087250873508745087550876508775087850879508805088150882508835088450885508865088750888508895089050891508925089350894508955089650897508985089950900509015090250903509045090550906509075090850909509105091150912509135091450915509165091750918509195092050921509225092350924509255092650927509285092950930509315093250933509345093550936509375093850939509405094150942509435094450945509465094750948509495095050951509525095350954509555095650957509585095950960509615096250963509645096550966509675096850969509705097150972509735097450975509765097750978509795098050981509825098350984509855098650987509885098950990509915099250993509945099550996509975099850999510005100151002510035100451005510065100751008510095101051011510125101351014510155101651017510185101951020510215102251023510245102551026510275102851029510305103151032510335103451035510365103751038510395104051041510425104351044510455104651047510485104951050510515105251053510545105551056510575105851059510605106151062510635106451065510665106751068510695107051071510725107351074510755107651077510785107951080510815108251083510845108551086510875108851089510905109151092510935109451095510965109751098510995110051101511025110351104511055110651107511085110951110511115111251113511145111551116511175111851119511205112151122511235112451125511265112751128511295113051131511325113351134511355113651137511385113951140511415114251143511445114551146511475114851149511505115151152511535115451155511565115751158511595116051161511625116351164511655116651167511685116951170511715117251173511745117551176511775117851179511805118151182511835118451185511865118751188511895119051191511925119351194511955119651197511985119951200512015120251203512045120551206512075120851209512105121151212512135121451215512165121751218512195122051221512225122351224512255122651227512285122951230512315123251233512345123551236512375123851239512405124151242512435124451245512465124751248512495125051251512525125351254512555125651257512585125951260512615126251263512645126551266512675126851269512705127151272512735127451275512765127751278512795128051281512825128351284512855128651287512885128951290512915129251293512945129551296512975129851299513005130151302513035130451305513065130751308513095131051311513125131351314513155131651317513185131951320513215132251323513245132551326513275132851329513305133151332513335133451335513365133751338513395134051341513425134351344513455134651347513485134951350513515135251353513545135551356513575135851359513605136151362513635136451365513665136751368513695137051371513725137351374513755137651377513785137951380513815138251383513845138551386513875138851389513905139151392513935139451395513965139751398513995140051401514025140351404514055140651407514085140951410514115141251413514145141551416514175141851419514205142151422514235142451425514265142751428514295143051431514325143351434514355143651437514385143951440514415144251443514445144551446514475144851449514505145151452514535145451455514565145751458514595146051461514625146351464514655146651467514685146951470514715147251473514745147551476514775147851479514805148151482514835148451485514865148751488514895149051491514925149351494514955149651497514985149951500515015150251503515045150551506515075150851509515105151151512515135151451515515165151751518515195152051521515225152351524515255152651527515285152951530515315153251533515345153551536515375153851539515405154151542515435154451545515465154751548515495155051551515525155351554515555155651557515585155951560515615156251563515645156551566515675156851569515705157151572515735157451575515765157751578515795158051581515825158351584515855158651587515885158951590515915159251593515945159551596515975159851599516005160151602516035160451605516065160751608516095161051611516125161351614516155161651617516185161951620516215162251623516245162551626516275162851629516305163151632516335163451635516365163751638516395164051641516425164351644516455164651647516485164951650516515165251653516545165551656516575165851659516605166151662516635166451665516665166751668516695167051671516725167351674516755167651677516785167951680516815168251683516845168551686516875168851689516905169151692516935169451695516965169751698516995170051701517025170351704517055170651707517085170951710517115171251713517145171551716517175171851719517205172151722517235172451725517265172751728517295173051731517325173351734517355173651737517385173951740517415174251743517445174551746517475174851749517505175151752517535175451755517565175751758517595176051761517625176351764517655176651767517685176951770517715177251773517745177551776517775177851779517805178151782517835178451785517865178751788517895179051791517925179351794517955179651797517985179951800518015180251803518045180551806518075180851809518105181151812518135181451815518165181751818518195182051821518225182351824518255182651827518285182951830518315183251833518345183551836518375183851839518405184151842518435184451845518465184751848518495185051851518525185351854518555185651857518585185951860518615186251863518645186551866518675186851869518705187151872518735187451875518765187751878518795188051881518825188351884518855188651887518885188951890518915189251893518945189551896518975189851899519005190151902519035190451905519065190751908519095191051911519125191351914519155191651917519185191951920519215192251923519245192551926519275192851929519305193151932519335193451935519365193751938519395194051941519425194351944519455194651947519485194951950519515195251953519545195551956519575195851959519605196151962519635196451965519665196751968519695197051971519725197351974519755197651977519785197951980519815198251983519845198551986519875198851989519905199151992519935199451995519965199751998519995200052001520025200352004520055200652007520085200952010520115201252013520145201552016520175201852019520205202152022520235202452025520265202752028520295203052031520325203352034520355203652037520385203952040520415204252043520445204552046520475204852049520505205152052520535205452055520565205752058520595206052061520625206352064520655206652067520685206952070520715207252073520745207552076520775207852079520805208152082520835208452085520865208752088520895209052091520925209352094520955209652097520985209952100521015210252103521045210552106521075210852109521105211152112521135211452115521165211752118521195212052121521225212352124521255212652127521285212952130521315213252133521345213552136521375213852139521405214152142521435214452145521465214752148521495215052151521525215352154521555215652157521585215952160521615216252163521645216552166521675216852169521705217152172521735217452175521765217752178521795218052181521825218352184521855218652187521885218952190521915219252193521945219552196521975219852199522005220152202522035220452205522065220752208522095221052211522125221352214522155221652217522185221952220522215222252223522245222552226522275222852229522305223152232522335223452235522365223752238522395224052241522425224352244522455224652247522485224952250522515225252253522545225552256522575225852259522605226152262522635226452265522665226752268522695227052271522725227352274522755227652277522785227952280522815228252283522845228552286522875228852289522905229152292522935229452295522965229752298522995230052301523025230352304523055230652307523085230952310523115231252313523145231552316523175231852319523205232152322523235232452325523265232752328523295233052331523325233352334523355233652337523385233952340523415234252343523445234552346523475234852349523505235152352523535235452355523565235752358523595236052361523625236352364523655236652367523685236952370523715237252373523745237552376523775237852379523805238152382523835238452385523865238752388523895239052391523925239352394523955239652397523985239952400524015240252403524045240552406524075240852409524105241152412524135241452415524165241752418524195242052421524225242352424524255242652427524285242952430524315243252433524345243552436524375243852439524405244152442524435244452445524465244752448524495245052451524525245352454524555245652457524585245952460524615246252463524645246552466524675246852469524705247152472524735247452475524765247752478524795248052481524825248352484524855248652487524885248952490524915249252493524945249552496524975249852499525005250152502525035250452505525065250752508525095251052511525125251352514525155251652517525185251952520525215252252523525245252552526525275252852529525305253152532525335253452535525365253752538525395254052541525425254352544525455254652547525485254952550525515255252553525545255552556525575255852559525605256152562525635256452565525665256752568525695257052571525725257352574525755257652577525785257952580525815258252583525845258552586525875258852589525905259152592525935259452595525965259752598525995260052601526025260352604526055260652607526085260952610526115261252613526145261552616526175261852619526205262152622526235262452625526265262752628526295263052631526325263352634526355263652637526385263952640526415264252643526445264552646526475264852649526505265152652526535265452655526565265752658526595266052661526625266352664526655266652667526685266952670526715267252673526745267552676526775267852679526805268152682526835268452685526865268752688526895269052691526925269352694526955269652697526985269952700527015270252703527045270552706527075270852709527105271152712527135271452715527165271752718527195272052721527225272352724527255272652727527285272952730527315273252733527345273552736527375273852739527405274152742527435274452745527465274752748527495275052751527525275352754527555275652757527585275952760527615276252763527645276552766527675276852769527705277152772527735277452775527765277752778527795278052781527825278352784527855278652787527885278952790527915279252793527945279552796527975279852799528005280152802528035280452805528065280752808528095281052811528125281352814528155281652817528185281952820528215282252823528245282552826528275282852829528305283152832528335283452835528365283752838528395284052841528425284352844528455284652847528485284952850528515285252853528545285552856528575285852859528605286152862528635286452865528665286752868528695287052871528725287352874528755287652877528785287952880528815288252883528845288552886528875288852889528905289152892528935289452895528965289752898528995290052901529025290352904529055290652907529085290952910529115291252913529145291552916529175291852919529205292152922529235292452925529265292752928529295293052931529325293352934529355293652937529385293952940529415294252943529445294552946529475294852949529505295152952529535295452955529565295752958529595296052961529625296352964529655296652967529685296952970529715297252973529745297552976529775297852979529805298152982529835298452985529865298752988529895299052991529925299352994529955299652997529985299953000530015300253003530045300553006530075300853009530105301153012530135301453015530165301753018530195302053021530225302353024530255302653027530285302953030530315303253033530345303553036530375303853039530405304153042530435304453045530465304753048530495305053051530525305353054530555305653057530585305953060530615306253063530645306553066530675306853069530705307153072530735307453075530765307753078530795308053081530825308353084530855308653087530885308953090530915309253093530945309553096530975309853099531005310153102531035310453105531065310753108531095311053111531125311353114531155311653117531185311953120531215312253123531245312553126531275312853129531305313153132531335313453135531365313753138531395314053141531425314353144531455314653147531485314953150531515315253153531545315553156531575315853159531605316153162531635316453165531665316753168531695317053171531725317353174531755317653177531785317953180531815318253183531845318553186531875318853189531905319153192531935319453195531965319753198531995320053201532025320353204532055320653207532085320953210532115321253213532145321553216532175321853219532205322153222532235322453225532265322753228532295323053231532325323353234532355323653237532385323953240532415324253243532445324553246532475324853249532505325153252532535325453255532565325753258532595326053261532625326353264532655326653267532685326953270532715327253273532745327553276532775327853279532805328153282532835328453285532865328753288532895329053291532925329353294532955329653297532985329953300533015330253303533045330553306533075330853309533105331153312533135331453315533165331753318533195332053321533225332353324533255332653327533285332953330533315333253333533345333553336533375333853339533405334153342533435334453345533465334753348533495335053351533525335353354533555335653357533585335953360533615336253363533645336553366533675336853369533705337153372533735337453375533765337753378533795338053381533825338353384533855338653387533885338953390533915339253393533945339553396533975339853399534005340153402534035340453405534065340753408534095341053411534125341353414534155341653417534185341953420534215342253423534245342553426534275342853429534305343153432534335343453435534365343753438534395344053441534425344353444534455344653447534485344953450534515345253453534545345553456534575345853459534605346153462534635346453465534665346753468534695347053471534725347353474534755347653477534785347953480534815348253483534845348553486534875348853489534905349153492534935349453495534965349753498534995350053501535025350353504535055350653507535085350953510535115351253513535145351553516535175351853519535205352153522535235352453525535265352753528535295353053531535325353353534535355353653537535385353953540535415354253543535445354553546535475354853549535505355153552535535355453555535565355753558535595356053561535625356353564535655356653567535685356953570535715357253573535745357553576535775357853579535805358153582535835358453585535865358753588535895359053591535925359353594535955359653597535985359953600536015360253603536045360553606536075360853609536105361153612536135361453615536165361753618536195362053621536225362353624536255362653627536285362953630536315363253633536345363553636536375363853639536405364153642536435364453645536465364753648536495365053651536525365353654536555365653657536585365953660536615366253663536645366553666536675366853669536705367153672536735367453675536765367753678536795368053681536825368353684536855368653687536885368953690536915369253693536945369553696536975369853699537005370153702537035370453705537065370753708537095371053711537125371353714537155371653717537185371953720537215372253723537245372553726537275372853729537305373153732537335373453735537365373753738537395374053741537425374353744537455374653747537485374953750537515375253753537545375553756537575375853759537605376153762537635376453765537665376753768537695377053771537725377353774537755377653777537785377953780537815378253783537845378553786537875378853789537905379153792537935379453795537965379753798537995380053801538025380353804538055380653807538085380953810538115381253813538145381553816538175381853819538205382153822538235382453825538265382753828538295383053831538325383353834538355383653837538385383953840538415384253843538445384553846538475384853849538505385153852538535385453855538565385753858538595386053861538625386353864538655386653867538685386953870538715387253873538745387553876538775387853879538805388153882538835388453885538865388753888538895389053891538925389353894538955389653897538985389953900539015390253903539045390553906539075390853909539105391153912539135391453915539165391753918539195392053921539225392353924539255392653927539285392953930539315393253933539345393553936539375393853939539405394153942539435394453945539465394753948539495395053951539525395353954539555395653957539585395953960539615396253963539645396553966539675396853969539705397153972539735397453975539765397753978539795398053981539825398353984539855398653987539885398953990539915399253993539945399553996539975399853999540005400154002540035400454005540065400754008540095401054011540125401354014540155401654017540185401954020540215402254023540245402554026540275402854029540305403154032540335403454035540365403754038540395404054041540425404354044540455404654047540485404954050540515405254053540545405554056540575405854059540605406154062540635406454065540665406754068540695407054071540725407354074540755407654077540785407954080540815408254083540845408554086540875408854089540905409154092540935409454095540965409754098540995410054101541025410354104541055410654107541085410954110541115411254113541145411554116541175411854119541205412154122541235412454125541265412754128541295413054131541325413354134541355413654137541385413954140541415414254143541445414554146541475414854149541505415154152541535415454155541565415754158541595416054161541625416354164541655416654167541685416954170541715417254173541745417554176541775417854179541805418154182541835418454185541865418754188541895419054191541925419354194541955419654197541985419954200542015420254203542045420554206542075420854209542105421154212542135421454215542165421754218542195422054221542225422354224542255422654227542285422954230542315423254233542345423554236542375423854239542405424154242542435424454245542465424754248542495425054251542525425354254542555425654257542585425954260542615426254263542645426554266542675426854269542705427154272542735427454275542765427754278542795428054281542825428354284542855428654287542885428954290542915429254293542945429554296542975429854299543005430154302543035430454305543065430754308543095431054311543125431354314543155431654317543185431954320543215432254323543245432554326543275432854329543305433154332543335433454335543365433754338543395434054341543425434354344543455434654347543485434954350543515435254353543545435554356543575435854359543605436154362543635436454365543665436754368543695437054371543725437354374543755437654377543785437954380543815438254383543845438554386543875438854389543905439154392543935439454395543965439754398543995440054401544025440354404544055440654407544085440954410544115441254413544145441554416544175441854419544205442154422544235442454425544265442754428544295443054431544325443354434544355443654437544385443954440544415444254443544445444554446544475444854449544505445154452544535445454455544565445754458544595446054461544625446354464544655446654467544685446954470544715447254473544745447554476544775447854479544805448154482544835448454485544865448754488544895449054491544925449354494544955449654497544985449954500545015450254503545045450554506545075450854509545105451154512545135451454515545165451754518545195452054521545225452354524545255452654527545285452954530545315453254533545345453554536545375453854539545405454154542545435454454545545465454754548545495455054551545525455354554545555455654557545585455954560545615456254563545645456554566545675456854569545705457154572545735457454575545765457754578545795458054581545825458354584545855458654587545885458954590545915459254593545945459554596545975459854599546005460154602546035460454605546065460754608546095461054611546125461354614546155461654617546185461954620546215462254623546245462554626546275462854629546305463154632546335463454635546365463754638546395464054641546425464354644546455464654647546485464954650546515465254653546545465554656546575465854659546605466154662546635466454665546665466754668546695467054671546725467354674546755467654677546785467954680546815468254683546845468554686546875468854689546905469154692546935469454695546965469754698546995470054701547025470354704547055470654707547085470954710547115471254713547145471554716547175471854719547205472154722547235472454725547265472754728547295473054731547325473354734547355473654737547385473954740547415474254743547445474554746547475474854749547505475154752547535475454755547565475754758547595476054761547625476354764547655476654767547685476954770547715477254773547745477554776547775477854779547805478154782547835478454785547865478754788547895479054791547925479354794547955479654797547985479954800548015480254803548045480554806548075480854809548105481154812548135481454815548165481754818548195482054821548225482354824548255482654827548285482954830548315483254833548345483554836548375483854839548405484154842548435484454845548465484754848548495485054851548525485354854548555485654857548585485954860548615486254863548645486554866548675486854869548705487154872548735487454875548765487754878548795488054881548825488354884548855488654887548885488954890548915489254893548945489554896548975489854899549005490154902549035490454905549065490754908549095491054911549125491354914549155491654917549185491954920549215492254923549245492554926549275492854929549305493154932549335493454935549365493754938549395494054941549425494354944549455494654947549485494954950549515495254953549545495554956549575495854959549605496154962549635496454965549665496754968549695497054971549725497354974549755497654977549785497954980549815498254983549845498554986549875498854989549905499154992549935499454995549965499754998549995500055001550025500355004550055500655007550085500955010550115501255013550145501555016550175501855019550205502155022550235502455025550265502755028550295503055031550325503355034550355503655037550385503955040550415504255043550445504555046550475504855049550505505155052550535505455055550565505755058550595506055061550625506355064550655506655067550685506955070550715507255073550745507555076550775507855079550805508155082550835508455085550865508755088550895509055091550925509355094550955509655097550985509955100551015510255103551045510555106551075510855109551105511155112551135511455115551165511755118551195512055121551225512355124551255512655127551285512955130551315513255133551345513555136551375513855139551405514155142551435514455145551465514755148551495515055151551525515355154551555515655157551585515955160551615516255163551645516555166551675516855169551705517155172551735517455175551765517755178551795518055181551825518355184551855518655187551885518955190551915519255193551945519555196551975519855199552005520155202552035520455205552065520755208552095521055211552125521355214552155521655217552185521955220552215522255223552245522555226552275522855229552305523155232552335523455235552365523755238552395524055241552425524355244552455524655247552485524955250552515525255253552545525555256552575525855259552605526155262552635526455265552665526755268552695527055271552725527355274552755527655277552785527955280552815528255283552845528555286552875528855289552905529155292552935529455295552965529755298552995530055301553025530355304553055530655307553085530955310553115531255313553145531555316553175531855319553205532155322553235532455325553265532755328553295533055331553325533355334553355533655337553385533955340553415534255343553445534555346553475534855349553505535155352553535535455355553565535755358553595536055361553625536355364553655536655367553685536955370553715537255373553745537555376553775537855379553805538155382553835538455385553865538755388553895539055391553925539355394553955539655397553985539955400554015540255403554045540555406554075540855409554105541155412554135541455415554165541755418554195542055421554225542355424554255542655427554285542955430554315543255433554345543555436554375543855439554405544155442554435544455445554465544755448554495545055451554525545355454554555545655457554585545955460554615546255463554645546555466554675546855469554705547155472554735547455475554765547755478554795548055481554825548355484554855548655487554885548955490554915549255493554945549555496554975549855499555005550155502555035550455505555065550755508555095551055511555125551355514555155551655517555185551955520555215552255523555245552555526555275552855529555305553155532555335553455535555365553755538555395554055541555425554355544555455554655547555485554955550555515555255553555545555555556555575555855559555605556155562555635556455565555665556755568555695557055571555725557355574555755557655577555785557955580555815558255583555845558555586555875558855589555905559155592555935559455595555965559755598555995560055601556025560355604556055560655607556085560955610556115561255613556145561555616556175561855619556205562155622556235562455625556265562755628556295563055631556325563355634556355563655637556385563955640556415564255643556445564555646556475564855649556505565155652556535565455655556565565755658556595566055661556625566355664556655566655667556685566955670556715567255673556745567555676556775567855679556805568155682556835568455685556865568755688556895569055691556925569355694556955569655697556985569955700557015570255703557045570555706557075570855709557105571155712557135571455715557165571755718557195572055721557225572355724557255572655727557285572955730557315573255733557345573555736557375573855739557405574155742557435574455745557465574755748557495575055751557525575355754557555575655757557585575955760557615576255763557645576555766557675576855769557705577155772557735577455775557765577755778557795578055781557825578355784557855578655787557885578955790557915579255793557945579555796557975579855799558005580155802558035580455805558065580755808558095581055811558125581355814558155581655817558185581955820558215582255823558245582555826558275582855829558305583155832558335583455835558365583755838558395584055841558425584355844558455584655847558485584955850558515585255853558545585555856558575585855859558605586155862558635586455865558665586755868558695587055871558725587355874558755587655877558785587955880558815588255883558845588555886558875588855889558905589155892558935589455895558965589755898558995590055901559025590355904559055590655907559085590955910559115591255913559145591555916559175591855919559205592155922559235592455925559265592755928559295593055931559325593355934559355593655937559385593955940559415594255943559445594555946559475594855949559505595155952559535595455955559565595755958559595596055961559625596355964559655596655967559685596955970559715597255973559745597555976559775597855979559805598155982559835598455985559865598755988559895599055991559925599355994559955599655997559985599956000560015600256003560045600556006560075600856009560105601156012560135601456015560165601756018560195602056021560225602356024560255602656027560285602956030560315603256033560345603556036560375603856039560405604156042560435604456045560465604756048560495605056051560525605356054560555605656057560585605956060560615606256063560645606556066560675606856069560705607156072560735607456075560765607756078560795608056081560825608356084560855608656087560885608956090560915609256093560945609556096560975609856099561005610156102561035610456105561065610756108561095611056111561125611356114561155611656117561185611956120561215612256123561245612556126561275612856129561305613156132561335613456135561365613756138561395614056141561425614356144561455614656147561485614956150561515615256153561545615556156561575615856159561605616156162561635616456165561665616756168561695617056171561725617356174561755617656177561785617956180561815618256183561845618556186561875618856189561905619156192561935619456195561965619756198561995620056201562025620356204562055620656207562085620956210562115621256213562145621556216562175621856219562205622156222562235622456225562265622756228562295623056231562325623356234562355623656237562385623956240562415624256243562445624556246562475624856249562505625156252562535625456255562565625756258562595626056261562625626356264562655626656267562685626956270562715627256273562745627556276562775627856279562805628156282562835628456285562865628756288562895629056291562925629356294562955629656297562985629956300563015630256303563045630556306563075630856309563105631156312563135631456315563165631756318563195632056321563225632356324563255632656327563285632956330563315633256333563345633556336563375633856339563405634156342563435634456345563465634756348563495635056351563525635356354563555635656357563585635956360563615636256363563645636556366563675636856369563705637156372563735637456375563765637756378563795638056381563825638356384563855638656387563885638956390563915639256393563945639556396563975639856399564005640156402564035640456405564065640756408564095641056411564125641356414564155641656417564185641956420564215642256423564245642556426564275642856429564305643156432564335643456435564365643756438564395644056441564425644356444564455644656447564485644956450564515645256453564545645556456564575645856459564605646156462564635646456465564665646756468564695647056471564725647356474564755647656477564785647956480564815648256483564845648556486564875648856489564905649156492564935649456495564965649756498564995650056501565025650356504565055650656507565085650956510565115651256513565145651556516565175651856519565205652156522565235652456525565265652756528565295653056531565325653356534565355653656537565385653956540565415654256543565445654556546565475654856549565505655156552565535655456555565565655756558565595656056561565625656356564565655656656567565685656956570565715657256573565745657556576565775657856579565805658156582565835658456585565865658756588565895659056591565925659356594565955659656597565985659956600566015660256603566045660556606566075660856609566105661156612566135661456615566165661756618566195662056621566225662356624566255662656627566285662956630566315663256633566345663556636566375663856639566405664156642566435664456645566465664756648566495665056651566525665356654566555665656657566585665956660566615666256663566645666556666566675666856669566705667156672566735667456675566765667756678566795668056681566825668356684566855668656687566885668956690566915669256693566945669556696566975669856699567005670156702567035670456705567065670756708567095671056711567125671356714567155671656717567185671956720567215672256723567245672556726567275672856729567305673156732567335673456735567365673756738567395674056741567425674356744567455674656747567485674956750567515675256753567545675556756567575675856759567605676156762567635676456765567665676756768567695677056771567725677356774567755677656777567785677956780567815678256783567845678556786567875678856789567905679156792567935679456795567965679756798567995680056801568025680356804568055680656807568085680956810568115681256813568145681556816568175681856819568205682156822568235682456825568265682756828568295683056831568325683356834568355683656837568385683956840568415684256843568445684556846568475684856849568505685156852568535685456855568565685756858568595686056861568625686356864568655686656867568685686956870568715687256873568745687556876568775687856879568805688156882568835688456885568865688756888568895689056891568925689356894568955689656897568985689956900569015690256903569045690556906569075690856909569105691156912569135691456915569165691756918569195692056921569225692356924569255692656927569285692956930569315693256933569345693556936569375693856939569405694156942569435694456945569465694756948569495695056951569525695356954569555695656957569585695956960569615696256963569645696556966569675696856969569705697156972569735697456975569765697756978569795698056981569825698356984569855698656987569885698956990569915699256993569945699556996569975699856999570005700157002570035700457005570065700757008570095701057011570125701357014570155701657017570185701957020570215702257023570245702557026570275702857029570305703157032570335703457035570365703757038570395704057041570425704357044570455704657047570485704957050570515705257053570545705557056570575705857059570605706157062570635706457065570665706757068570695707057071570725707357074570755707657077570785707957080570815708257083570845708557086570875708857089570905709157092570935709457095570965709757098570995710057101571025710357104571055710657107571085710957110571115711257113571145711557116571175711857119571205712157122571235712457125571265712757128571295713057131571325713357134571355713657137571385713957140571415714257143571445714557146571475714857149571505715157152571535715457155571565715757158571595716057161571625716357164571655716657167571685716957170571715717257173571745717557176571775717857179571805718157182571835718457185571865718757188571895719057191571925719357194571955719657197571985719957200572015720257203572045720557206572075720857209572105721157212572135721457215572165721757218572195722057221572225722357224572255722657227572285722957230572315723257233572345723557236572375723857239572405724157242572435724457245572465724757248572495725057251572525725357254572555725657257572585725957260572615726257263572645726557266572675726857269572705727157272572735727457275572765727757278572795728057281572825728357284572855728657287572885728957290572915729257293572945729557296572975729857299573005730157302573035730457305573065730757308573095731057311573125731357314573155731657317573185731957320573215732257323573245732557326573275732857329573305733157332573335733457335573365733757338573395734057341573425734357344573455734657347573485734957350573515735257353573545735557356573575735857359573605736157362573635736457365573665736757368573695737057371573725737357374573755737657377573785737957380573815738257383573845738557386573875738857389573905739157392573935739457395573965739757398573995740057401574025740357404574055740657407574085740957410574115741257413574145741557416574175741857419574205742157422574235742457425574265742757428574295743057431574325743357434574355743657437574385743957440574415744257443574445744557446574475744857449574505745157452574535745457455574565745757458574595746057461574625746357464574655746657467574685746957470574715747257473574745747557476574775747857479574805748157482574835748457485574865748757488574895749057491574925749357494574955749657497574985749957500575015750257503575045750557506575075750857509575105751157512575135751457515575165751757518575195752057521575225752357524575255752657527575285752957530575315753257533575345753557536575375753857539575405754157542575435754457545575465754757548575495755057551575525755357554575555755657557575585755957560575615756257563575645756557566575675756857569575705757157572575735757457575575765757757578575795758057581575825758357584575855758657587575885758957590575915759257593575945759557596575975759857599576005760157602576035760457605576065760757608576095761057611576125761357614576155761657617576185761957620576215762257623576245762557626576275762857629576305763157632576335763457635576365763757638576395764057641576425764357644576455764657647576485764957650576515765257653576545765557656576575765857659576605766157662576635766457665576665766757668576695767057671576725767357674576755767657677576785767957680576815768257683576845768557686576875768857689576905769157692576935769457695576965769757698576995770057701577025770357704577055770657707577085770957710577115771257713577145771557716577175771857719577205772157722577235772457725577265772757728577295773057731577325773357734577355773657737577385773957740577415774257743577445774557746577475774857749577505775157752577535775457755577565775757758577595776057761577625776357764577655776657767577685776957770577715777257773577745777557776577775777857779577805778157782577835778457785577865778757788577895779057791577925779357794577955779657797577985779957800578015780257803578045780557806578075780857809578105781157812578135781457815578165781757818578195782057821578225782357824578255782657827578285782957830578315783257833578345783557836578375783857839578405784157842578435784457845578465784757848578495785057851578525785357854578555785657857578585785957860578615786257863578645786557866578675786857869578705787157872578735787457875578765787757878578795788057881578825788357884578855788657887578885788957890578915789257893578945789557896578975789857899579005790157902579035790457905579065790757908579095791057911579125791357914579155791657917579185791957920579215792257923579245792557926579275792857929579305793157932579335793457935579365793757938579395794057941579425794357944579455794657947579485794957950579515795257953579545795557956579575795857959579605796157962579635796457965579665796757968579695797057971579725797357974579755797657977579785797957980579815798257983579845798557986579875798857989579905799157992579935799457995579965799757998579995800058001580025800358004580055800658007580085800958010580115801258013580145801558016580175801858019580205802158022580235802458025580265802758028580295803058031580325803358034580355803658037580385803958040580415804258043580445804558046580475804858049580505805158052580535805458055580565805758058580595806058061580625806358064580655806658067580685806958070580715807258073580745807558076580775807858079580805808158082580835808458085580865808758088580895809058091580925809358094580955809658097580985809958100581015810258103581045810558106581075810858109581105811158112581135811458115581165811758118581195812058121581225812358124581255812658127581285812958130581315813258133581345813558136581375813858139581405814158142581435814458145581465814758148581495815058151581525815358154581555815658157581585815958160581615816258163581645816558166581675816858169581705817158172581735817458175581765817758178581795818058181581825818358184581855818658187581885818958190581915819258193581945819558196581975819858199582005820158202582035820458205582065820758208582095821058211582125821358214582155821658217582185821958220582215822258223582245822558226582275822858229582305823158232582335823458235582365823758238582395824058241582425824358244582455824658247582485824958250582515825258253582545825558256582575825858259582605826158262582635826458265582665826758268582695827058271582725827358274582755827658277582785827958280582815828258283582845828558286582875828858289582905829158292582935829458295582965829758298582995830058301583025830358304583055830658307583085830958310583115831258313583145831558316583175831858319583205832158322583235832458325583265832758328583295833058331583325833358334583355833658337583385833958340583415834258343583445834558346583475834858349583505835158352583535835458355583565835758358583595836058361583625836358364583655836658367583685836958370583715837258373583745837558376583775837858379583805838158382583835838458385583865838758388583895839058391583925839358394583955839658397583985839958400584015840258403584045840558406584075840858409584105841158412584135841458415584165841758418584195842058421584225842358424584255842658427584285842958430584315843258433584345843558436584375843858439584405844158442584435844458445584465844758448584495845058451584525845358454584555845658457584585845958460584615846258463584645846558466584675846858469584705847158472584735847458475584765847758478584795848058481584825848358484584855848658487584885848958490584915849258493584945849558496584975849858499585005850158502585035850458505585065850758508585095851058511585125851358514585155851658517585185851958520585215852258523585245852558526585275852858529585305853158532585335853458535585365853758538585395854058541585425854358544585455854658547585485854958550585515855258553585545855558556585575855858559585605856158562585635856458565585665856758568585695857058571585725857358574585755857658577585785857958580585815858258583585845858558586585875858858589585905859158592585935859458595585965859758598585995860058601586025860358604586055860658607586085860958610586115861258613586145861558616586175861858619586205862158622586235862458625586265862758628586295863058631586325863358634586355863658637586385863958640586415864258643586445864558646586475864858649586505865158652586535865458655586565865758658586595866058661586625866358664586655866658667586685866958670586715867258673586745867558676586775867858679586805868158682586835868458685586865868758688586895869058691586925869358694586955869658697586985869958700587015870258703587045870558706587075870858709587105871158712587135871458715587165871758718587195872058721587225872358724587255872658727587285872958730587315873258733587345873558736587375873858739587405874158742587435874458745587465874758748587495875058751587525875358754587555875658757587585875958760587615876258763587645876558766587675876858769587705877158772587735877458775587765877758778587795878058781587825878358784587855878658787587885878958790587915879258793587945879558796587975879858799588005880158802588035880458805588065880758808588095881058811588125881358814588155881658817588185881958820588215882258823588245882558826588275882858829588305883158832588335883458835588365883758838588395884058841588425884358844588455884658847588485884958850588515885258853588545885558856588575885858859588605886158862588635886458865588665886758868588695887058871588725887358874588755887658877588785887958880588815888258883588845888558886588875888858889588905889158892588935889458895588965889758898588995890058901589025890358904589055890658907589085890958910589115891258913589145891558916589175891858919589205892158922589235892458925589265892758928589295893058931589325893358934589355893658937589385893958940589415894258943589445894558946589475894858949589505895158952589535895458955589565895758958589595896058961589625896358964589655896658967589685896958970589715897258973589745897558976589775897858979589805898158982589835898458985589865898758988589895899058991589925899358994589955899658997589985899959000590015900259003590045900559006590075900859009590105901159012590135901459015590165901759018590195902059021590225902359024590255902659027590285902959030590315903259033590345903559036590375903859039590405904159042590435904459045590465904759048590495905059051590525905359054590555905659057590585905959060590615906259063590645906559066590675906859069590705907159072590735907459075590765907759078590795908059081590825908359084590855908659087590885908959090590915909259093590945909559096590975909859099591005910159102591035910459105591065910759108591095911059111591125911359114591155911659117591185911959120591215912259123591245912559126591275912859129591305913159132591335913459135591365913759138591395914059141591425914359144591455914659147591485914959150591515915259153591545915559156591575915859159591605916159162591635916459165591665916759168591695917059171591725917359174591755917659177591785917959180591815918259183591845918559186591875918859189591905919159192591935919459195591965919759198591995920059201592025920359204592055920659207592085920959210592115921259213592145921559216592175921859219592205922159222592235922459225592265922759228592295923059231592325923359234592355923659237592385923959240592415924259243592445924559246592475924859249592505925159252592535925459255592565925759258592595926059261592625926359264592655926659267592685926959270592715927259273592745927559276592775927859279592805928159282592835928459285592865928759288592895929059291592925929359294592955929659297592985929959300593015930259303593045930559306593075930859309593105931159312593135931459315593165931759318593195932059321593225932359324593255932659327593285932959330593315933259333593345933559336593375933859339593405934159342593435934459345593465934759348593495935059351593525935359354593555935659357593585935959360593615936259363593645936559366593675936859369593705937159372593735937459375593765937759378593795938059381593825938359384593855938659387593885938959390593915939259393593945939559396593975939859399594005940159402594035940459405594065940759408594095941059411594125941359414594155941659417594185941959420594215942259423594245942559426594275942859429594305943159432594335943459435594365943759438594395944059441594425944359444594455944659447594485944959450594515945259453594545945559456594575945859459594605946159462594635946459465594665946759468594695947059471594725947359474594755947659477594785947959480594815948259483594845948559486594875948859489594905949159492594935949459495594965949759498594995950059501595025950359504595055950659507595085950959510595115951259513595145951559516595175951859519595205952159522595235952459525595265952759528595295953059531595325953359534595355953659537595385953959540595415954259543595445954559546595475954859549595505955159552595535955459555595565955759558595595956059561595625956359564595655956659567595685956959570595715957259573595745957559576595775957859579595805958159582595835958459585595865958759588595895959059591595925959359594595955959659597595985959959600596015960259603596045960559606596075960859609596105961159612596135961459615596165961759618596195962059621596225962359624596255962659627596285962959630596315963259633596345963559636596375963859639596405964159642596435964459645596465964759648596495965059651596525965359654596555965659657596585965959660596615966259663596645966559666596675966859669596705967159672596735967459675596765967759678596795968059681596825968359684596855968659687596885968959690596915969259693596945969559696596975969859699597005970159702597035970459705597065970759708597095971059711597125971359714597155971659717597185971959720597215972259723597245972559726597275972859729597305973159732597335973459735597365973759738597395974059741597425974359744597455974659747597485974959750597515975259753597545975559756597575975859759597605976159762597635976459765597665976759768597695977059771597725977359774597755977659777597785977959780597815978259783597845978559786597875978859789597905979159792597935979459795597965979759798597995980059801598025980359804598055980659807598085980959810598115981259813598145981559816598175981859819598205982159822598235982459825598265982759828598295983059831598325983359834598355983659837598385983959840598415984259843598445984559846598475984859849598505985159852598535985459855598565985759858598595986059861598625986359864598655986659867598685986959870598715987259873598745987559876598775987859879598805988159882598835988459885598865988759888598895989059891598925989359894598955989659897598985989959900599015990259903599045990559906599075990859909599105991159912599135991459915599165991759918599195992059921599225992359924599255992659927599285992959930
  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. /* harmony default export */ __webpack_exports__["default"] = ({
  1617. props: ['asset'],
  1618. data: function data() {
  1619. return {
  1620. data: JSON.parse(this.asset)
  1621. };
  1622. },
  1623. mounted: function mounted() {
  1624. var _this = this;
  1625. Echo.channel('assets').listen('AssetUpdated', function (e) {
  1626. _this.data = JSON.parse(e.data);
  1627. });
  1628. }
  1629. });
  1630. /***/ }),
  1631. /***/ "./node_modules/babel-loader/lib/index.js?!./node_modules/vue-loader/lib/index.js?!./resources/js/components/woinfo.vue?vue&type=script&lang=js&":
  1632. /*!*****************************************************************************************************************************************************************!*\
  1633. !*** ./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& ***!
  1634. \*****************************************************************************************************************************************************************/
  1635. /*! exports provided: default */
  1636. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1637. "use strict";
  1638. __webpack_require__.r(__webpack_exports__);
  1639. /* harmony import */ var _mixins_dateMixin__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../mixins/dateMixin */ "./resources/js/mixins/dateMixin.js");
  1640. //
  1641. //
  1642. //
  1643. //
  1644. //
  1645. //
  1646. //
  1647. //
  1648. //
  1649. //
  1650. //
  1651. //
  1652. //
  1653. //
  1654. //
  1655. //
  1656. //
  1657. //
  1658. /* harmony default export */ __webpack_exports__["default"] = ({
  1659. mixins: [_mixins_dateMixin__WEBPACK_IMPORTED_MODULE_0__["default"]],
  1660. props: ['workOrder'],
  1661. data: function data() {
  1662. return {
  1663. data: JSON.parse(this.workOrder)
  1664. };
  1665. },
  1666. mounted: function mounted() {
  1667. var _this = this;
  1668. Echo.channel('work-orders').listen('WorkOrderUpdated', function (e) {
  1669. _this.data = JSON.parse(e.data);
  1670. });
  1671. }
  1672. });
  1673. /***/ }),
  1674. /***/ "./node_modules/base64-js/index.js":
  1675. /*!*****************************************!*\
  1676. !*** ./node_modules/base64-js/index.js ***!
  1677. \*****************************************/
  1678. /*! no static exports found */
  1679. /***/ (function(module, exports, __webpack_require__) {
  1680. "use strict";
  1681. exports.byteLength = byteLength
  1682. exports.toByteArray = toByteArray
  1683. exports.fromByteArray = fromByteArray
  1684. var lookup = []
  1685. var revLookup = []
  1686. var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array
  1687. var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
  1688. for (var i = 0, len = code.length; i < len; ++i) {
  1689. lookup[i] = code[i]
  1690. revLookup[code.charCodeAt(i)] = i
  1691. }
  1692. // Support decoding URL-safe base64 strings, as Node.js does.
  1693. // See: https://en.wikipedia.org/wiki/Base64#URL_applications
  1694. revLookup['-'.charCodeAt(0)] = 62
  1695. revLookup['_'.charCodeAt(0)] = 63
  1696. function getLens (b64) {
  1697. var len = b64.length
  1698. if (len % 4 > 0) {
  1699. throw new Error('Invalid string. Length must be a multiple of 4')
  1700. }
  1701. // Trim off extra bytes after placeholder bytes are found
  1702. // See: https://github.com/beatgammit/base64-js/issues/42
  1703. var validLen = b64.indexOf('=')
  1704. if (validLen === -1) validLen = len
  1705. var placeHoldersLen = validLen === len
  1706. ? 0
  1707. : 4 - (validLen % 4)
  1708. return [validLen, placeHoldersLen]
  1709. }
  1710. // base64 is 4/3 + up to two characters of the original data
  1711. function byteLength (b64) {
  1712. var lens = getLens(b64)
  1713. var validLen = lens[0]
  1714. var placeHoldersLen = lens[1]
  1715. return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
  1716. }
  1717. function _byteLength (b64, validLen, placeHoldersLen) {
  1718. return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
  1719. }
  1720. function toByteArray (b64) {
  1721. var tmp
  1722. var lens = getLens(b64)
  1723. var validLen = lens[0]
  1724. var placeHoldersLen = lens[1]
  1725. var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen))
  1726. var curByte = 0
  1727. // if there are placeholders, only get up to the last complete 4 chars
  1728. var len = placeHoldersLen > 0
  1729. ? validLen - 4
  1730. : validLen
  1731. var i
  1732. for (i = 0; i < len; i += 4) {
  1733. tmp =
  1734. (revLookup[b64.charCodeAt(i)] << 18) |
  1735. (revLookup[b64.charCodeAt(i + 1)] << 12) |
  1736. (revLookup[b64.charCodeAt(i + 2)] << 6) |
  1737. revLookup[b64.charCodeAt(i + 3)]
  1738. arr[curByte++] = (tmp >> 16) & 0xFF
  1739. arr[curByte++] = (tmp >> 8) & 0xFF
  1740. arr[curByte++] = tmp & 0xFF
  1741. }
  1742. if (placeHoldersLen === 2) {
  1743. tmp =
  1744. (revLookup[b64.charCodeAt(i)] << 2) |
  1745. (revLookup[b64.charCodeAt(i + 1)] >> 4)
  1746. arr[curByte++] = tmp & 0xFF
  1747. }
  1748. if (placeHoldersLen === 1) {
  1749. tmp =
  1750. (revLookup[b64.charCodeAt(i)] << 10) |
  1751. (revLookup[b64.charCodeAt(i + 1)] << 4) |
  1752. (revLookup[b64.charCodeAt(i + 2)] >> 2)
  1753. arr[curByte++] = (tmp >> 8) & 0xFF
  1754. arr[curByte++] = tmp & 0xFF
  1755. }
  1756. return arr
  1757. }
  1758. function tripletToBase64 (num) {
  1759. return lookup[num >> 18 & 0x3F] +
  1760. lookup[num >> 12 & 0x3F] +
  1761. lookup[num >> 6 & 0x3F] +
  1762. lookup[num & 0x3F]
  1763. }
  1764. function encodeChunk (uint8, start, end) {
  1765. var tmp
  1766. var output = []
  1767. for (var i = start; i < end; i += 3) {
  1768. tmp =
  1769. ((uint8[i] << 16) & 0xFF0000) +
  1770. ((uint8[i + 1] << 8) & 0xFF00) +
  1771. (uint8[i + 2] & 0xFF)
  1772. output.push(tripletToBase64(tmp))
  1773. }
  1774. return output.join('')
  1775. }
  1776. function fromByteArray (uint8) {
  1777. var tmp
  1778. var len = uint8.length
  1779. var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes
  1780. var parts = []
  1781. var maxChunkLength = 16383 // must be multiple of 3
  1782. // go through the array every three bytes, we'll deal with trailing stuff later
  1783. for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {
  1784. parts.push(encodeChunk(
  1785. uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength)
  1786. ))
  1787. }
  1788. // pad the end with zeros, but make sure to not forget the extra bytes
  1789. if (extraBytes === 1) {
  1790. tmp = uint8[len - 1]
  1791. parts.push(
  1792. lookup[tmp >> 2] +
  1793. lookup[(tmp << 4) & 0x3F] +
  1794. '=='
  1795. )
  1796. } else if (extraBytes === 2) {
  1797. tmp = (uint8[len - 2] << 8) + uint8[len - 1]
  1798. parts.push(
  1799. lookup[tmp >> 10] +
  1800. lookup[(tmp >> 4) & 0x3F] +
  1801. lookup[(tmp << 2) & 0x3F] +
  1802. '='
  1803. )
  1804. }
  1805. return parts.join('')
  1806. }
  1807. /***/ }),
  1808. /***/ "./node_modules/bootstrap/dist/js/bootstrap.js":
  1809. /*!*****************************************************!*\
  1810. !*** ./node_modules/bootstrap/dist/js/bootstrap.js ***!
  1811. \*****************************************************/
  1812. /*! no static exports found */
  1813. /***/ (function(module, exports, __webpack_require__) {
  1814. /*!
  1815. * Bootstrap v4.4.1 (https://getbootstrap.com/)
  1816. * Copyright 2011-2019 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
  1817. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
  1818. */
  1819. (function (global, factory) {
  1820. true ? factory(exports, __webpack_require__(/*! jquery */ "./node_modules/jquery/dist/jquery.js"), __webpack_require__(/*! popper.js */ "./node_modules/popper.js/dist/esm/popper.js")) :
  1821. undefined;
  1822. }(this, (function (exports, $, Popper) { 'use strict';
  1823. $ = $ && $.hasOwnProperty('default') ? $['default'] : $;
  1824. Popper = Popper && Popper.hasOwnProperty('default') ? Popper['default'] : Popper;
  1825. function _defineProperties(target, props) {
  1826. for (var i = 0; i < props.length; i++) {
  1827. var descriptor = props[i];
  1828. descriptor.enumerable = descriptor.enumerable || false;
  1829. descriptor.configurable = true;
  1830. if ("value" in descriptor) descriptor.writable = true;
  1831. Object.defineProperty(target, descriptor.key, descriptor);
  1832. }
  1833. }
  1834. function _createClass(Constructor, protoProps, staticProps) {
  1835. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  1836. if (staticProps) _defineProperties(Constructor, staticProps);
  1837. return Constructor;
  1838. }
  1839. function _defineProperty(obj, key, value) {
  1840. if (key in obj) {
  1841. Object.defineProperty(obj, key, {
  1842. value: value,
  1843. enumerable: true,
  1844. configurable: true,
  1845. writable: true
  1846. });
  1847. } else {
  1848. obj[key] = value;
  1849. }
  1850. return obj;
  1851. }
  1852. function ownKeys(object, enumerableOnly) {
  1853. var keys = Object.keys(object);
  1854. if (Object.getOwnPropertySymbols) {
  1855. var symbols = Object.getOwnPropertySymbols(object);
  1856. if (enumerableOnly) symbols = symbols.filter(function (sym) {
  1857. return Object.getOwnPropertyDescriptor(object, sym).enumerable;
  1858. });
  1859. keys.push.apply(keys, symbols);
  1860. }
  1861. return keys;
  1862. }
  1863. function _objectSpread2(target) {
  1864. for (var i = 1; i < arguments.length; i++) {
  1865. var source = arguments[i] != null ? arguments[i] : {};
  1866. if (i % 2) {
  1867. ownKeys(Object(source), true).forEach(function (key) {
  1868. _defineProperty(target, key, source[key]);
  1869. });
  1870. } else if (Object.getOwnPropertyDescriptors) {
  1871. Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
  1872. } else {
  1873. ownKeys(Object(source)).forEach(function (key) {
  1874. Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
  1875. });
  1876. }
  1877. }
  1878. return target;
  1879. }
  1880. function _inheritsLoose(subClass, superClass) {
  1881. subClass.prototype = Object.create(superClass.prototype);
  1882. subClass.prototype.constructor = subClass;
  1883. subClass.__proto__ = superClass;
  1884. }
  1885. /**
  1886. * --------------------------------------------------------------------------
  1887. * Bootstrap (v4.4.1): util.js
  1888. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
  1889. * --------------------------------------------------------------------------
  1890. */
  1891. /**
  1892. * ------------------------------------------------------------------------
  1893. * Private TransitionEnd Helpers
  1894. * ------------------------------------------------------------------------
  1895. */
  1896. var TRANSITION_END = 'transitionend';
  1897. var MAX_UID = 1000000;
  1898. var MILLISECONDS_MULTIPLIER = 1000; // Shoutout AngusCroll (https://goo.gl/pxwQGp)
  1899. function toType(obj) {
  1900. return {}.toString.call(obj).match(/\s([a-z]+)/i)[1].toLowerCase();
  1901. }
  1902. function getSpecialTransitionEndEvent() {
  1903. return {
  1904. bindType: TRANSITION_END,
  1905. delegateType: TRANSITION_END,
  1906. handle: function handle(event) {
  1907. if ($(event.target).is(this)) {
  1908. return event.handleObj.handler.apply(this, arguments); // eslint-disable-line prefer-rest-params
  1909. }
  1910. return undefined; // eslint-disable-line no-undefined
  1911. }
  1912. };
  1913. }
  1914. function transitionEndEmulator(duration) {
  1915. var _this = this;
  1916. var called = false;
  1917. $(this).one(Util.TRANSITION_END, function () {
  1918. called = true;
  1919. });
  1920. setTimeout(function () {
  1921. if (!called) {
  1922. Util.triggerTransitionEnd(_this);
  1923. }
  1924. }, duration);
  1925. return this;
  1926. }
  1927. function setTransitionEndSupport() {
  1928. $.fn.emulateTransitionEnd = transitionEndEmulator;
  1929. $.event.special[Util.TRANSITION_END] = getSpecialTransitionEndEvent();
  1930. }
  1931. /**
  1932. * --------------------------------------------------------------------------
  1933. * Public Util Api
  1934. * --------------------------------------------------------------------------
  1935. */
  1936. var Util = {
  1937. TRANSITION_END: 'bsTransitionEnd',
  1938. getUID: function getUID(prefix) {
  1939. do {
  1940. // eslint-disable-next-line no-bitwise
  1941. prefix += ~~(Math.random() * MAX_UID); // "~~" acts like a faster Math.floor() here
  1942. } while (document.getElementById(prefix));
  1943. return prefix;
  1944. },
  1945. getSelectorFromElement: function getSelectorFromElement(element) {
  1946. var selector = element.getAttribute('data-target');
  1947. if (!selector || selector === '#') {
  1948. var hrefAttr = element.getAttribute('href');
  1949. selector = hrefAttr && hrefAttr !== '#' ? hrefAttr.trim() : '';
  1950. }
  1951. try {
  1952. return document.querySelector(selector) ? selector : null;
  1953. } catch (err) {
  1954. return null;
  1955. }
  1956. },
  1957. getTransitionDurationFromElement: function getTransitionDurationFromElement(element) {
  1958. if (!element) {
  1959. return 0;
  1960. } // Get transition-duration of the element
  1961. var transitionDuration = $(element).css('transition-duration');
  1962. var transitionDelay = $(element).css('transition-delay');
  1963. var floatTransitionDuration = parseFloat(transitionDuration);
  1964. var floatTransitionDelay = parseFloat(transitionDelay); // Return 0 if element or transition duration is not found
  1965. if (!floatTransitionDuration && !floatTransitionDelay) {
  1966. return 0;
  1967. } // If multiple durations are defined, take the first
  1968. transitionDuration = transitionDuration.split(',')[0];
  1969. transitionDelay = transitionDelay.split(',')[0];
  1970. return (parseFloat(transitionDuration) + parseFloat(transitionDelay)) * MILLISECONDS_MULTIPLIER;
  1971. },
  1972. reflow: function reflow(element) {
  1973. return element.offsetHeight;
  1974. },
  1975. triggerTransitionEnd: function triggerTransitionEnd(element) {
  1976. $(element).trigger(TRANSITION_END);
  1977. },
  1978. // TODO: Remove in v5
  1979. supportsTransitionEnd: function supportsTransitionEnd() {
  1980. return Boolean(TRANSITION_END);
  1981. },
  1982. isElement: function isElement(obj) {
  1983. return (obj[0] || obj).nodeType;
  1984. },
  1985. typeCheckConfig: function typeCheckConfig(componentName, config, configTypes) {
  1986. for (var property in configTypes) {
  1987. if (Object.prototype.hasOwnProperty.call(configTypes, property)) {
  1988. var expectedTypes = configTypes[property];
  1989. var value = config[property];
  1990. var valueType = value && Util.isElement(value) ? 'element' : toType(value);
  1991. if (!new RegExp(expectedTypes).test(valueType)) {
  1992. throw new Error(componentName.toUpperCase() + ": " + ("Option \"" + property + "\" provided type \"" + valueType + "\" ") + ("but expected type \"" + expectedTypes + "\"."));
  1993. }
  1994. }
  1995. }
  1996. },
  1997. findShadowRoot: function findShadowRoot(element) {
  1998. if (!document.documentElement.attachShadow) {
  1999. return null;
  2000. } // Can find the shadow root otherwise it'll return the document
  2001. if (typeof element.getRootNode === 'function') {
  2002. var root = element.getRootNode();
  2003. return root instanceof ShadowRoot ? root : null;
  2004. }
  2005. if (element instanceof ShadowRoot) {
  2006. return element;
  2007. } // when we don't find a shadow root
  2008. if (!element.parentNode) {
  2009. return null;
  2010. }
  2011. return Util.findShadowRoot(element.parentNode);
  2012. },
  2013. jQueryDetection: function jQueryDetection() {
  2014. if (typeof $ === 'undefined') {
  2015. throw new TypeError('Bootstrap\'s JavaScript requires jQuery. jQuery must be included before Bootstrap\'s JavaScript.');
  2016. }
  2017. var version = $.fn.jquery.split(' ')[0].split('.');
  2018. var minMajor = 1;
  2019. var ltMajor = 2;
  2020. var minMinor = 9;
  2021. var minPatch = 1;
  2022. var maxMajor = 4;
  2023. if (version[0] < ltMajor && version[1] < minMinor || version[0] === minMajor && version[1] === minMinor && version[2] < minPatch || version[0] >= maxMajor) {
  2024. throw new Error('Bootstrap\'s JavaScript requires at least jQuery v1.9.1 but less than v4.0.0');
  2025. }
  2026. }
  2027. };
  2028. Util.jQueryDetection();
  2029. setTransitionEndSupport();
  2030. /**
  2031. * ------------------------------------------------------------------------
  2032. * Constants
  2033. * ------------------------------------------------------------------------
  2034. */
  2035. var NAME = 'alert';
  2036. var VERSION = '4.4.1';
  2037. var DATA_KEY = 'bs.alert';
  2038. var EVENT_KEY = "." + DATA_KEY;
  2039. var DATA_API_KEY = '.data-api';
  2040. var JQUERY_NO_CONFLICT = $.fn[NAME];
  2041. var Selector = {
  2042. DISMISS: '[data-dismiss="alert"]'
  2043. };
  2044. var Event = {
  2045. CLOSE: "close" + EVENT_KEY,
  2046. CLOSED: "closed" + EVENT_KEY,
  2047. CLICK_DATA_API: "click" + EVENT_KEY + DATA_API_KEY
  2048. };
  2049. var ClassName = {
  2050. ALERT: 'alert',
  2051. FADE: 'fade',
  2052. SHOW: 'show'
  2053. };
  2054. /**
  2055. * ------------------------------------------------------------------------
  2056. * Class Definition
  2057. * ------------------------------------------------------------------------
  2058. */
  2059. var Alert =
  2060. /*#__PURE__*/
  2061. function () {
  2062. function Alert(element) {
  2063. this._element = element;
  2064. } // Getters
  2065. var _proto = Alert.prototype;
  2066. // Public
  2067. _proto.close = function close(element) {
  2068. var rootElement = this._element;
  2069. if (element) {
  2070. rootElement = this._getRootElement(element);
  2071. }
  2072. var customEvent = this._triggerCloseEvent(rootElement);
  2073. if (customEvent.isDefaultPrevented()) {
  2074. return;
  2075. }
  2076. this._removeElement(rootElement);
  2077. };
  2078. _proto.dispose = function dispose() {
  2079. $.removeData(this._element, DATA_KEY);
  2080. this._element = null;
  2081. } // Private
  2082. ;
  2083. _proto._getRootElement = function _getRootElement(element) {
  2084. var selector = Util.getSelectorFromElement(element);
  2085. var parent = false;
  2086. if (selector) {
  2087. parent = document.querySelector(selector);
  2088. }
  2089. if (!parent) {
  2090. parent = $(element).closest("." + ClassName.ALERT)[0];
  2091. }
  2092. return parent;
  2093. };
  2094. _proto._triggerCloseEvent = function _triggerCloseEvent(element) {
  2095. var closeEvent = $.Event(Event.CLOSE);
  2096. $(element).trigger(closeEvent);
  2097. return closeEvent;
  2098. };
  2099. _proto._removeElement = function _removeElement(element) {
  2100. var _this = this;
  2101. $(element).removeClass(ClassName.SHOW);
  2102. if (!$(element).hasClass(ClassName.FADE)) {
  2103. this._destroyElement(element);
  2104. return;
  2105. }
  2106. var transitionDuration = Util.getTransitionDurationFromElement(element);
  2107. $(element).one(Util.TRANSITION_END, function (event) {
  2108. return _this._destroyElement(element, event);
  2109. }).emulateTransitionEnd(transitionDuration);
  2110. };
  2111. _proto._destroyElement = function _destroyElement(element) {
  2112. $(element).detach().trigger(Event.CLOSED).remove();
  2113. } // Static
  2114. ;
  2115. Alert._jQueryInterface = function _jQueryInterface(config) {
  2116. return this.each(function () {
  2117. var $element = $(this);
  2118. var data = $element.data(DATA_KEY);
  2119. if (!data) {
  2120. data = new Alert(this);
  2121. $element.data(DATA_KEY, data);
  2122. }
  2123. if (config === 'close') {
  2124. data[config](this);
  2125. }
  2126. });
  2127. };
  2128. Alert._handleDismiss = function _handleDismiss(alertInstance) {
  2129. return function (event) {
  2130. if (event) {
  2131. event.preventDefault();
  2132. }
  2133. alertInstance.close(this);
  2134. };
  2135. };
  2136. _createClass(Alert, null, [{
  2137. key: "VERSION",
  2138. get: function get() {
  2139. return VERSION;
  2140. }
  2141. }]);
  2142. return Alert;
  2143. }();
  2144. /**
  2145. * ------------------------------------------------------------------------
  2146. * Data Api implementation
  2147. * ------------------------------------------------------------------------
  2148. */
  2149. $(document).on(Event.CLICK_DATA_API, Selector.DISMISS, Alert._handleDismiss(new Alert()));
  2150. /**
  2151. * ------------------------------------------------------------------------
  2152. * jQuery
  2153. * ------------------------------------------------------------------------
  2154. */
  2155. $.fn[NAME] = Alert._jQueryInterface;
  2156. $.fn[NAME].Constructor = Alert;
  2157. $.fn[NAME].noConflict = function () {
  2158. $.fn[NAME] = JQUERY_NO_CONFLICT;
  2159. return Alert._jQueryInterface;
  2160. };
  2161. /**
  2162. * ------------------------------------------------------------------------
  2163. * Constants
  2164. * ------------------------------------------------------------------------
  2165. */
  2166. var NAME$1 = 'button';
  2167. var VERSION$1 = '4.4.1';
  2168. var DATA_KEY$1 = 'bs.button';
  2169. var EVENT_KEY$1 = "." + DATA_KEY$1;
  2170. var DATA_API_KEY$1 = '.data-api';
  2171. var JQUERY_NO_CONFLICT$1 = $.fn[NAME$1];
  2172. var ClassName$1 = {
  2173. ACTIVE: 'active',
  2174. BUTTON: 'btn',
  2175. FOCUS: 'focus'
  2176. };
  2177. var Selector$1 = {
  2178. DATA_TOGGLE_CARROT: '[data-toggle^="button"]',
  2179. DATA_TOGGLES: '[data-toggle="buttons"]',
  2180. DATA_TOGGLE: '[data-toggle="button"]',
  2181. DATA_TOGGLES_BUTTONS: '[data-toggle="buttons"] .btn',
  2182. INPUT: 'input:not([type="hidden"])',
  2183. ACTIVE: '.active',
  2184. BUTTON: '.btn'
  2185. };
  2186. var Event$1 = {
  2187. CLICK_DATA_API: "click" + EVENT_KEY$1 + DATA_API_KEY$1,
  2188. FOCUS_BLUR_DATA_API: "focus" + EVENT_KEY$1 + DATA_API_KEY$1 + " " + ("blur" + EVENT_KEY$1 + DATA_API_KEY$1),
  2189. LOAD_DATA_API: "load" + EVENT_KEY$1 + DATA_API_KEY$1
  2190. };
  2191. /**
  2192. * ------------------------------------------------------------------------
  2193. * Class Definition
  2194. * ------------------------------------------------------------------------
  2195. */
  2196. var Button =
  2197. /*#__PURE__*/
  2198. function () {
  2199. function Button(element) {
  2200. this._element = element;
  2201. } // Getters
  2202. var _proto = Button.prototype;
  2203. // Public
  2204. _proto.toggle = function toggle() {
  2205. var triggerChangeEvent = true;
  2206. var addAriaPressed = true;
  2207. var rootElement = $(this._element).closest(Selector$1.DATA_TOGGLES)[0];
  2208. if (rootElement) {
  2209. var input = this._element.querySelector(Selector$1.INPUT);
  2210. if (input) {
  2211. if (input.type === 'radio') {
  2212. if (input.checked && this._element.classList.contains(ClassName$1.ACTIVE)) {
  2213. triggerChangeEvent = false;
  2214. } else {
  2215. var activeElement = rootElement.querySelector(Selector$1.ACTIVE);
  2216. if (activeElement) {
  2217. $(activeElement).removeClass(ClassName$1.ACTIVE);
  2218. }
  2219. }
  2220. } else if (input.type === 'checkbox') {
  2221. if (this._element.tagName === 'LABEL' && input.checked === this._element.classList.contains(ClassName$1.ACTIVE)) {
  2222. triggerChangeEvent = false;
  2223. }
  2224. } else {
  2225. // if it's not a radio button or checkbox don't add a pointless/invalid checked property to the input
  2226. triggerChangeEvent = false;
  2227. }
  2228. if (triggerChangeEvent) {
  2229. input.checked = !this._element.classList.contains(ClassName$1.ACTIVE);
  2230. $(input).trigger('change');
  2231. }
  2232. input.focus();
  2233. addAriaPressed = false;
  2234. }
  2235. }
  2236. if (!(this._element.hasAttribute('disabled') || this._element.classList.contains('disabled'))) {
  2237. if (addAriaPressed) {
  2238. this._element.setAttribute('aria-pressed', !this._element.classList.contains(ClassName$1.ACTIVE));
  2239. }
  2240. if (triggerChangeEvent) {
  2241. $(this._element).toggleClass(ClassName$1.ACTIVE);
  2242. }
  2243. }
  2244. };
  2245. _proto.dispose = function dispose() {
  2246. $.removeData(this._element, DATA_KEY$1);
  2247. this._element = null;
  2248. } // Static
  2249. ;
  2250. Button._jQueryInterface = function _jQueryInterface(config) {
  2251. return this.each(function () {
  2252. var data = $(this).data(DATA_KEY$1);
  2253. if (!data) {
  2254. data = new Button(this);
  2255. $(this).data(DATA_KEY$1, data);
  2256. }
  2257. if (config === 'toggle') {
  2258. data[config]();
  2259. }
  2260. });
  2261. };
  2262. _createClass(Button, null, [{
  2263. key: "VERSION",
  2264. get: function get() {
  2265. return VERSION$1;
  2266. }
  2267. }]);
  2268. return Button;
  2269. }();
  2270. /**
  2271. * ------------------------------------------------------------------------
  2272. * Data Api implementation
  2273. * ------------------------------------------------------------------------
  2274. */
  2275. $(document).on(Event$1.CLICK_DATA_API, Selector$1.DATA_TOGGLE_CARROT, function (event) {
  2276. var button = event.target;
  2277. if (!$(button).hasClass(ClassName$1.BUTTON)) {
  2278. button = $(button).closest(Selector$1.BUTTON)[0];
  2279. }
  2280. if (!button || button.hasAttribute('disabled') || button.classList.contains('disabled')) {
  2281. event.preventDefault(); // work around Firefox bug #1540995
  2282. } else {
  2283. var inputBtn = button.querySelector(Selector$1.INPUT);
  2284. if (inputBtn && (inputBtn.hasAttribute('disabled') || inputBtn.classList.contains('disabled'))) {
  2285. event.preventDefault(); // work around Firefox bug #1540995
  2286. return;
  2287. }
  2288. Button._jQueryInterface.call($(button), 'toggle');
  2289. }
  2290. }).on(Event$1.FOCUS_BLUR_DATA_API, Selector$1.DATA_TOGGLE_CARROT, function (event) {
  2291. var button = $(event.target).closest(Selector$1.BUTTON)[0];
  2292. $(button).toggleClass(ClassName$1.FOCUS, /^focus(in)?$/.test(event.type));
  2293. });
  2294. $(window).on(Event$1.LOAD_DATA_API, function () {
  2295. // ensure correct active class is set to match the controls' actual values/states
  2296. // find all checkboxes/readio buttons inside data-toggle groups
  2297. var buttons = [].slice.call(document.querySelectorAll(Selector$1.DATA_TOGGLES_BUTTONS));
  2298. for (var i = 0, len = buttons.length; i < len; i++) {
  2299. var button = buttons[i];
  2300. var input = button.querySelector(Selector$1.INPUT);
  2301. if (input.checked || input.hasAttribute('checked')) {
  2302. button.classList.add(ClassName$1.ACTIVE);
  2303. } else {
  2304. button.classList.remove(ClassName$1.ACTIVE);
  2305. }
  2306. } // find all button toggles
  2307. buttons = [].slice.call(document.querySelectorAll(Selector$1.DATA_TOGGLE));
  2308. for (var _i = 0, _len = buttons.length; _i < _len; _i++) {
  2309. var _button = buttons[_i];
  2310. if (_button.getAttribute('aria-pressed') === 'true') {
  2311. _button.classList.add(ClassName$1.ACTIVE);
  2312. } else {
  2313. _button.classList.remove(ClassName$1.ACTIVE);
  2314. }
  2315. }
  2316. });
  2317. /**
  2318. * ------------------------------------------------------------------------
  2319. * jQuery
  2320. * ------------------------------------------------------------------------
  2321. */
  2322. $.fn[NAME$1] = Button._jQueryInterface;
  2323. $.fn[NAME$1].Constructor = Button;
  2324. $.fn[NAME$1].noConflict = function () {
  2325. $.fn[NAME$1] = JQUERY_NO_CONFLICT$1;
  2326. return Button._jQueryInterface;
  2327. };
  2328. /**
  2329. * ------------------------------------------------------------------------
  2330. * Constants
  2331. * ------------------------------------------------------------------------
  2332. */
  2333. var NAME$2 = 'carousel';
  2334. var VERSION$2 = '4.4.1';
  2335. var DATA_KEY$2 = 'bs.carousel';
  2336. var EVENT_KEY$2 = "." + DATA_KEY$2;
  2337. var DATA_API_KEY$2 = '.data-api';
  2338. var JQUERY_NO_CONFLICT$2 = $.fn[NAME$2];
  2339. var ARROW_LEFT_KEYCODE = 37; // KeyboardEvent.which value for left arrow key
  2340. var ARROW_RIGHT_KEYCODE = 39; // KeyboardEvent.which value for right arrow key
  2341. var TOUCHEVENT_COMPAT_WAIT = 500; // Time for mouse compat events to fire after touch
  2342. var SWIPE_THRESHOLD = 40;
  2343. var Default = {
  2344. interval: 5000,
  2345. keyboard: true,
  2346. slide: false,
  2347. pause: 'hover',
  2348. wrap: true,
  2349. touch: true
  2350. };
  2351. var DefaultType = {
  2352. interval: '(number|boolean)',
  2353. keyboard: 'boolean',
  2354. slide: '(boolean|string)',
  2355. pause: '(string|boolean)',
  2356. wrap: 'boolean',
  2357. touch: 'boolean'
  2358. };
  2359. var Direction = {
  2360. NEXT: 'next',
  2361. PREV: 'prev',
  2362. LEFT: 'left',
  2363. RIGHT: 'right'
  2364. };
  2365. var Event$2 = {
  2366. SLIDE: "slide" + EVENT_KEY$2,
  2367. SLID: "slid" + EVENT_KEY$2,
  2368. KEYDOWN: "keydown" + EVENT_KEY$2,
  2369. MOUSEENTER: "mouseenter" + EVENT_KEY$2,
  2370. MOUSELEAVE: "mouseleave" + EVENT_KEY$2,
  2371. TOUCHSTART: "touchstart" + EVENT_KEY$2,
  2372. TOUCHMOVE: "touchmove" + EVENT_KEY$2,
  2373. TOUCHEND: "touchend" + EVENT_KEY$2,
  2374. POINTERDOWN: "pointerdown" + EVENT_KEY$2,
  2375. POINTERUP: "pointerup" + EVENT_KEY$2,
  2376. DRAG_START: "dragstart" + EVENT_KEY$2,
  2377. LOAD_DATA_API: "load" + EVENT_KEY$2 + DATA_API_KEY$2,
  2378. CLICK_DATA_API: "click" + EVENT_KEY$2 + DATA_API_KEY$2
  2379. };
  2380. var ClassName$2 = {
  2381. CAROUSEL: 'carousel',
  2382. ACTIVE: 'active',
  2383. SLIDE: 'slide',
  2384. RIGHT: 'carousel-item-right',
  2385. LEFT: 'carousel-item-left',
  2386. NEXT: 'carousel-item-next',
  2387. PREV: 'carousel-item-prev',
  2388. ITEM: 'carousel-item',
  2389. POINTER_EVENT: 'pointer-event'
  2390. };
  2391. var Selector$2 = {
  2392. ACTIVE: '.active',
  2393. ACTIVE_ITEM: '.active.carousel-item',
  2394. ITEM: '.carousel-item',
  2395. ITEM_IMG: '.carousel-item img',
  2396. NEXT_PREV: '.carousel-item-next, .carousel-item-prev',
  2397. INDICATORS: '.carousel-indicators',
  2398. DATA_SLIDE: '[data-slide], [data-slide-to]',
  2399. DATA_RIDE: '[data-ride="carousel"]'
  2400. };
  2401. var PointerType = {
  2402. TOUCH: 'touch',
  2403. PEN: 'pen'
  2404. };
  2405. /**
  2406. * ------------------------------------------------------------------------
  2407. * Class Definition
  2408. * ------------------------------------------------------------------------
  2409. */
  2410. var Carousel =
  2411. /*#__PURE__*/
  2412. function () {
  2413. function Carousel(element, config) {
  2414. this._items = null;
  2415. this._interval = null;
  2416. this._activeElement = null;
  2417. this._isPaused = false;
  2418. this._isSliding = false;
  2419. this.touchTimeout = null;
  2420. this.touchStartX = 0;
  2421. this.touchDeltaX = 0;
  2422. this._config = this._getConfig(config);
  2423. this._element = element;
  2424. this._indicatorsElement = this._element.querySelector(Selector$2.INDICATORS);
  2425. this._touchSupported = 'ontouchstart' in document.documentElement || navigator.maxTouchPoints > 0;
  2426. this._pointerEvent = Boolean(window.PointerEvent || window.MSPointerEvent);
  2427. this._addEventListeners();
  2428. } // Getters
  2429. var _proto = Carousel.prototype;
  2430. // Public
  2431. _proto.next = function next() {
  2432. if (!this._isSliding) {
  2433. this._slide(Direction.NEXT);
  2434. }
  2435. };
  2436. _proto.nextWhenVisible = function nextWhenVisible() {
  2437. // Don't call next when the page isn't visible
  2438. // or the carousel or its parent isn't visible
  2439. if (!document.hidden && $(this._element).is(':visible') && $(this._element).css('visibility') !== 'hidden') {
  2440. this.next();
  2441. }
  2442. };
  2443. _proto.prev = function prev() {
  2444. if (!this._isSliding) {
  2445. this._slide(Direction.PREV);
  2446. }
  2447. };
  2448. _proto.pause = function pause(event) {
  2449. if (!event) {
  2450. this._isPaused = true;
  2451. }
  2452. if (this._element.querySelector(Selector$2.NEXT_PREV)) {
  2453. Util.triggerTransitionEnd(this._element);
  2454. this.cycle(true);
  2455. }
  2456. clearInterval(this._interval);
  2457. this._interval = null;
  2458. };
  2459. _proto.cycle = function cycle(event) {
  2460. if (!event) {
  2461. this._isPaused = false;
  2462. }
  2463. if (this._interval) {
  2464. clearInterval(this._interval);
  2465. this._interval = null;
  2466. }
  2467. if (this._config.interval && !this._isPaused) {
  2468. this._interval = setInterval((document.visibilityState ? this.nextWhenVisible : this.next).bind(this), this._config.interval);
  2469. }
  2470. };
  2471. _proto.to = function to(index) {
  2472. var _this = this;
  2473. this._activeElement = this._element.querySelector(Selector$2.ACTIVE_ITEM);
  2474. var activeIndex = this._getItemIndex(this._activeElement);
  2475. if (index > this._items.length - 1 || index < 0) {
  2476. return;
  2477. }
  2478. if (this._isSliding) {
  2479. $(this._element).one(Event$2.SLID, function () {
  2480. return _this.to(index);
  2481. });
  2482. return;
  2483. }
  2484. if (activeIndex === index) {
  2485. this.pause();
  2486. this.cycle();
  2487. return;
  2488. }
  2489. var direction = index > activeIndex ? Direction.NEXT : Direction.PREV;
  2490. this._slide(direction, this._items[index]);
  2491. };
  2492. _proto.dispose = function dispose() {
  2493. $(this._element).off(EVENT_KEY$2);
  2494. $.removeData(this._element, DATA_KEY$2);
  2495. this._items = null;
  2496. this._config = null;
  2497. this._element = null;
  2498. this._interval = null;
  2499. this._isPaused = null;
  2500. this._isSliding = null;
  2501. this._activeElement = null;
  2502. this._indicatorsElement = null;
  2503. } // Private
  2504. ;
  2505. _proto._getConfig = function _getConfig(config) {
  2506. config = _objectSpread2({}, Default, {}, config);
  2507. Util.typeCheckConfig(NAME$2, config, DefaultType);
  2508. return config;
  2509. };
  2510. _proto._handleSwipe = function _handleSwipe() {
  2511. var absDeltax = Math.abs(this.touchDeltaX);
  2512. if (absDeltax <= SWIPE_THRESHOLD) {
  2513. return;
  2514. }
  2515. var direction = absDeltax / this.touchDeltaX;
  2516. this.touchDeltaX = 0; // swipe left
  2517. if (direction > 0) {
  2518. this.prev();
  2519. } // swipe right
  2520. if (direction < 0) {
  2521. this.next();
  2522. }
  2523. };
  2524. _proto._addEventListeners = function _addEventListeners() {
  2525. var _this2 = this;
  2526. if (this._config.keyboard) {
  2527. $(this._element).on(Event$2.KEYDOWN, function (event) {
  2528. return _this2._keydown(event);
  2529. });
  2530. }
  2531. if (this._config.pause === 'hover') {
  2532. $(this._element).on(Event$2.MOUSEENTER, function (event) {
  2533. return _this2.pause(event);
  2534. }).on(Event$2.MOUSELEAVE, function (event) {
  2535. return _this2.cycle(event);
  2536. });
  2537. }
  2538. if (this._config.touch) {
  2539. this._addTouchEventListeners();
  2540. }
  2541. };
  2542. _proto._addTouchEventListeners = function _addTouchEventListeners() {
  2543. var _this3 = this;
  2544. if (!this._touchSupported) {
  2545. return;
  2546. }
  2547. var start = function start(event) {
  2548. if (_this3._pointerEvent && PointerType[event.originalEvent.pointerType.toUpperCase()]) {
  2549. _this3.touchStartX = event.originalEvent.clientX;
  2550. } else if (!_this3._pointerEvent) {
  2551. _this3.touchStartX = event.originalEvent.touches[0].clientX;
  2552. }
  2553. };
  2554. var move = function move(event) {
  2555. // ensure swiping with one touch and not pinching
  2556. if (event.originalEvent.touches && event.originalEvent.touches.length > 1) {
  2557. _this3.touchDeltaX = 0;
  2558. } else {
  2559. _this3.touchDeltaX = event.originalEvent.touches[0].clientX - _this3.touchStartX;
  2560. }
  2561. };
  2562. var end = function end(event) {
  2563. if (_this3._pointerEvent && PointerType[event.originalEvent.pointerType.toUpperCase()]) {
  2564. _this3.touchDeltaX = event.originalEvent.clientX - _this3.touchStartX;
  2565. }
  2566. _this3._handleSwipe();
  2567. if (_this3._config.pause === 'hover') {
  2568. // If it's a touch-enabled device, mouseenter/leave are fired as
  2569. // part of the mouse compatibility events on first tap - the carousel
  2570. // would stop cycling until user tapped out of it;
  2571. // here, we listen for touchend, explicitly pause the carousel
  2572. // (as if it's the second time we tap on it, mouseenter compat event
  2573. // is NOT fired) and after a timeout (to allow for mouse compatibility
  2574. // events to fire) we explicitly restart cycling
  2575. _this3.pause();
  2576. if (_this3.touchTimeout) {
  2577. clearTimeout(_this3.touchTimeout);
  2578. }
  2579. _this3.touchTimeout = setTimeout(function (event) {
  2580. return _this3.cycle(event);
  2581. }, TOUCHEVENT_COMPAT_WAIT + _this3._config.interval);
  2582. }
  2583. };
  2584. $(this._element.querySelectorAll(Selector$2.ITEM_IMG)).on(Event$2.DRAG_START, function (e) {
  2585. return e.preventDefault();
  2586. });
  2587. if (this._pointerEvent) {
  2588. $(this._element).on(Event$2.POINTERDOWN, function (event) {
  2589. return start(event);
  2590. });
  2591. $(this._element).on(Event$2.POINTERUP, function (event) {
  2592. return end(event);
  2593. });
  2594. this._element.classList.add(ClassName$2.POINTER_EVENT);
  2595. } else {
  2596. $(this._element).on(Event$2.TOUCHSTART, function (event) {
  2597. return start(event);
  2598. });
  2599. $(this._element).on(Event$2.TOUCHMOVE, function (event) {
  2600. return move(event);
  2601. });
  2602. $(this._element).on(Event$2.TOUCHEND, function (event) {
  2603. return end(event);
  2604. });
  2605. }
  2606. };
  2607. _proto._keydown = function _keydown(event) {
  2608. if (/input|textarea/i.test(event.target.tagName)) {
  2609. return;
  2610. }
  2611. switch (event.which) {
  2612. case ARROW_LEFT_KEYCODE:
  2613. event.preventDefault();
  2614. this.prev();
  2615. break;
  2616. case ARROW_RIGHT_KEYCODE:
  2617. event.preventDefault();
  2618. this.next();
  2619. break;
  2620. }
  2621. };
  2622. _proto._getItemIndex = function _getItemIndex(element) {
  2623. this._items = element && element.parentNode ? [].slice.call(element.parentNode.querySelectorAll(Selector$2.ITEM)) : [];
  2624. return this._items.indexOf(element);
  2625. };
  2626. _proto._getItemByDirection = function _getItemByDirection(direction, activeElement) {
  2627. var isNextDirection = direction === Direction.NEXT;
  2628. var isPrevDirection = direction === Direction.PREV;
  2629. var activeIndex = this._getItemIndex(activeElement);
  2630. var lastItemIndex = this._items.length - 1;
  2631. var isGoingToWrap = isPrevDirection && activeIndex === 0 || isNextDirection && activeIndex === lastItemIndex;
  2632. if (isGoingToWrap && !this._config.wrap) {
  2633. return activeElement;
  2634. }
  2635. var delta = direction === Direction.PREV ? -1 : 1;
  2636. var itemIndex = (activeIndex + delta) % this._items.length;
  2637. return itemIndex === -1 ? this._items[this._items.length - 1] : this._items[itemIndex];
  2638. };
  2639. _proto._triggerSlideEvent = function _triggerSlideEvent(relatedTarget, eventDirectionName) {
  2640. var targetIndex = this._getItemIndex(relatedTarget);
  2641. var fromIndex = this._getItemIndex(this._element.querySelector(Selector$2.ACTIVE_ITEM));
  2642. var slideEvent = $.Event(Event$2.SLIDE, {
  2643. relatedTarget: relatedTarget,
  2644. direction: eventDirectionName,
  2645. from: fromIndex,
  2646. to: targetIndex
  2647. });
  2648. $(this._element).trigger(slideEvent);
  2649. return slideEvent;
  2650. };
  2651. _proto._setActiveIndicatorElement = function _setActiveIndicatorElement(element) {
  2652. if (this._indicatorsElement) {
  2653. var indicators = [].slice.call(this._indicatorsElement.querySelectorAll(Selector$2.ACTIVE));
  2654. $(indicators).removeClass(ClassName$2.ACTIVE);
  2655. var nextIndicator = this._indicatorsElement.children[this._getItemIndex(element)];
  2656. if (nextIndicator) {
  2657. $(nextIndicator).addClass(ClassName$2.ACTIVE);
  2658. }
  2659. }
  2660. };
  2661. _proto._slide = function _slide(direction, element) {
  2662. var _this4 = this;
  2663. var activeElement = this._element.querySelector(Selector$2.ACTIVE_ITEM);
  2664. var activeElementIndex = this._getItemIndex(activeElement);
  2665. var nextElement = element || activeElement && this._getItemByDirection(direction, activeElement);
  2666. var nextElementIndex = this._getItemIndex(nextElement);
  2667. var isCycling = Boolean(this._interval);
  2668. var directionalClassName;
  2669. var orderClassName;
  2670. var eventDirectionName;
  2671. if (direction === Direction.NEXT) {
  2672. directionalClassName = ClassName$2.LEFT;
  2673. orderClassName = ClassName$2.NEXT;
  2674. eventDirectionName = Direction.LEFT;
  2675. } else {
  2676. directionalClassName = ClassName$2.RIGHT;
  2677. orderClassName = ClassName$2.PREV;
  2678. eventDirectionName = Direction.RIGHT;
  2679. }
  2680. if (nextElement && $(nextElement).hasClass(ClassName$2.ACTIVE)) {
  2681. this._isSliding = false;
  2682. return;
  2683. }
  2684. var slideEvent = this._triggerSlideEvent(nextElement, eventDirectionName);
  2685. if (slideEvent.isDefaultPrevented()) {
  2686. return;
  2687. }
  2688. if (!activeElement || !nextElement) {
  2689. // Some weirdness is happening, so we bail
  2690. return;
  2691. }
  2692. this._isSliding = true;
  2693. if (isCycling) {
  2694. this.pause();
  2695. }
  2696. this._setActiveIndicatorElement(nextElement);
  2697. var slidEvent = $.Event(Event$2.SLID, {
  2698. relatedTarget: nextElement,
  2699. direction: eventDirectionName,
  2700. from: activeElementIndex,
  2701. to: nextElementIndex
  2702. });
  2703. if ($(this._element).hasClass(ClassName$2.SLIDE)) {
  2704. $(nextElement).addClass(orderClassName);
  2705. Util.reflow(nextElement);
  2706. $(activeElement).addClass(directionalClassName);
  2707. $(nextElement).addClass(directionalClassName);
  2708. var nextElementInterval = parseInt(nextElement.getAttribute('data-interval'), 10);
  2709. if (nextElementInterval) {
  2710. this._config.defaultInterval = this._config.defaultInterval || this._config.interval;
  2711. this._config.interval = nextElementInterval;
  2712. } else {
  2713. this._config.interval = this._config.defaultInterval || this._config.interval;
  2714. }
  2715. var transitionDuration = Util.getTransitionDurationFromElement(activeElement);
  2716. $(activeElement).one(Util.TRANSITION_END, function () {
  2717. $(nextElement).removeClass(directionalClassName + " " + orderClassName).addClass(ClassName$2.ACTIVE);
  2718. $(activeElement).removeClass(ClassName$2.ACTIVE + " " + orderClassName + " " + directionalClassName);
  2719. _this4._isSliding = false;
  2720. setTimeout(function () {
  2721. return $(_this4._element).trigger(slidEvent);
  2722. }, 0);
  2723. }).emulateTransitionEnd(transitionDuration);
  2724. } else {
  2725. $(activeElement).removeClass(ClassName$2.ACTIVE);
  2726. $(nextElement).addClass(ClassName$2.ACTIVE);
  2727. this._isSliding = false;
  2728. $(this._element).trigger(slidEvent);
  2729. }
  2730. if (isCycling) {
  2731. this.cycle();
  2732. }
  2733. } // Static
  2734. ;
  2735. Carousel._jQueryInterface = function _jQueryInterface(config) {
  2736. return this.each(function () {
  2737. var data = $(this).data(DATA_KEY$2);
  2738. var _config = _objectSpread2({}, Default, {}, $(this).data());
  2739. if (typeof config === 'object') {
  2740. _config = _objectSpread2({}, _config, {}, config);
  2741. }
  2742. var action = typeof config === 'string' ? config : _config.slide;
  2743. if (!data) {
  2744. data = new Carousel(this, _config);
  2745. $(this).data(DATA_KEY$2, data);
  2746. }
  2747. if (typeof config === 'number') {
  2748. data.to(config);
  2749. } else if (typeof action === 'string') {
  2750. if (typeof data[action] === 'undefined') {
  2751. throw new TypeError("No method named \"" + action + "\"");
  2752. }
  2753. data[action]();
  2754. } else if (_config.interval && _config.ride) {
  2755. data.pause();
  2756. data.cycle();
  2757. }
  2758. });
  2759. };
  2760. Carousel._dataApiClickHandler = function _dataApiClickHandler(event) {
  2761. var selector = Util.getSelectorFromElement(this);
  2762. if (!selector) {
  2763. return;
  2764. }
  2765. var target = $(selector)[0];
  2766. if (!target || !$(target).hasClass(ClassName$2.CAROUSEL)) {
  2767. return;
  2768. }
  2769. var config = _objectSpread2({}, $(target).data(), {}, $(this).data());
  2770. var slideIndex = this.getAttribute('data-slide-to');
  2771. if (slideIndex) {
  2772. config.interval = false;
  2773. }
  2774. Carousel._jQueryInterface.call($(target), config);
  2775. if (slideIndex) {
  2776. $(target).data(DATA_KEY$2).to(slideIndex);
  2777. }
  2778. event.preventDefault();
  2779. };
  2780. _createClass(Carousel, null, [{
  2781. key: "VERSION",
  2782. get: function get() {
  2783. return VERSION$2;
  2784. }
  2785. }, {
  2786. key: "Default",
  2787. get: function get() {
  2788. return Default;
  2789. }
  2790. }]);
  2791. return Carousel;
  2792. }();
  2793. /**
  2794. * ------------------------------------------------------------------------
  2795. * Data Api implementation
  2796. * ------------------------------------------------------------------------
  2797. */
  2798. $(document).on(Event$2.CLICK_DATA_API, Selector$2.DATA_SLIDE, Carousel._dataApiClickHandler);
  2799. $(window).on(Event$2.LOAD_DATA_API, function () {
  2800. var carousels = [].slice.call(document.querySelectorAll(Selector$2.DATA_RIDE));
  2801. for (var i = 0, len = carousels.length; i < len; i++) {
  2802. var $carousel = $(carousels[i]);
  2803. Carousel._jQueryInterface.call($carousel, $carousel.data());
  2804. }
  2805. });
  2806. /**
  2807. * ------------------------------------------------------------------------
  2808. * jQuery
  2809. * ------------------------------------------------------------------------
  2810. */
  2811. $.fn[NAME$2] = Carousel._jQueryInterface;
  2812. $.fn[NAME$2].Constructor = Carousel;
  2813. $.fn[NAME$2].noConflict = function () {
  2814. $.fn[NAME$2] = JQUERY_NO_CONFLICT$2;
  2815. return Carousel._jQueryInterface;
  2816. };
  2817. /**
  2818. * ------------------------------------------------------------------------
  2819. * Constants
  2820. * ------------------------------------------------------------------------
  2821. */
  2822. var NAME$3 = 'collapse';
  2823. var VERSION$3 = '4.4.1';
  2824. var DATA_KEY$3 = 'bs.collapse';
  2825. var EVENT_KEY$3 = "." + DATA_KEY$3;
  2826. var DATA_API_KEY$3 = '.data-api';
  2827. var JQUERY_NO_CONFLICT$3 = $.fn[NAME$3];
  2828. var Default$1 = {
  2829. toggle: true,
  2830. parent: ''
  2831. };
  2832. var DefaultType$1 = {
  2833. toggle: 'boolean',
  2834. parent: '(string|element)'
  2835. };
  2836. var Event$3 = {
  2837. SHOW: "show" + EVENT_KEY$3,
  2838. SHOWN: "shown" + EVENT_KEY$3,
  2839. HIDE: "hide" + EVENT_KEY$3,
  2840. HIDDEN: "hidden" + EVENT_KEY$3,
  2841. CLICK_DATA_API: "click" + EVENT_KEY$3 + DATA_API_KEY$3
  2842. };
  2843. var ClassName$3 = {
  2844. SHOW: 'show',
  2845. COLLAPSE: 'collapse',
  2846. COLLAPSING: 'collapsing',
  2847. COLLAPSED: 'collapsed'
  2848. };
  2849. var Dimension = {
  2850. WIDTH: 'width',
  2851. HEIGHT: 'height'
  2852. };
  2853. var Selector$3 = {
  2854. ACTIVES: '.show, .collapsing',
  2855. DATA_TOGGLE: '[data-toggle="collapse"]'
  2856. };
  2857. /**
  2858. * ------------------------------------------------------------------------
  2859. * Class Definition
  2860. * ------------------------------------------------------------------------
  2861. */
  2862. var Collapse =
  2863. /*#__PURE__*/
  2864. function () {
  2865. function Collapse(element, config) {
  2866. this._isTransitioning = false;
  2867. this._element = element;
  2868. this._config = this._getConfig(config);
  2869. this._triggerArray = [].slice.call(document.querySelectorAll("[data-toggle=\"collapse\"][href=\"#" + element.id + "\"]," + ("[data-toggle=\"collapse\"][data-target=\"#" + element.id + "\"]")));
  2870. var toggleList = [].slice.call(document.querySelectorAll(Selector$3.DATA_TOGGLE));
  2871. for (var i = 0, len = toggleList.length; i < len; i++) {
  2872. var elem = toggleList[i];
  2873. var selector = Util.getSelectorFromElement(elem);
  2874. var filterElement = [].slice.call(document.querySelectorAll(selector)).filter(function (foundElem) {
  2875. return foundElem === element;
  2876. });
  2877. if (selector !== null && filterElement.length > 0) {
  2878. this._selector = selector;
  2879. this._triggerArray.push(elem);
  2880. }
  2881. }
  2882. this._parent = this._config.parent ? this._getParent() : null;
  2883. if (!this._config.parent) {
  2884. this._addAriaAndCollapsedClass(this._element, this._triggerArray);
  2885. }
  2886. if (this._config.toggle) {
  2887. this.toggle();
  2888. }
  2889. } // Getters
  2890. var _proto = Collapse.prototype;
  2891. // Public
  2892. _proto.toggle = function toggle() {
  2893. if ($(this._element).hasClass(ClassName$3.SHOW)) {
  2894. this.hide();
  2895. } else {
  2896. this.show();
  2897. }
  2898. };
  2899. _proto.show = function show() {
  2900. var _this = this;
  2901. if (this._isTransitioning || $(this._element).hasClass(ClassName$3.SHOW)) {
  2902. return;
  2903. }
  2904. var actives;
  2905. var activesData;
  2906. if (this._parent) {
  2907. actives = [].slice.call(this._parent.querySelectorAll(Selector$3.ACTIVES)).filter(function (elem) {
  2908. if (typeof _this._config.parent === 'string') {
  2909. return elem.getAttribute('data-parent') === _this._config.parent;
  2910. }
  2911. return elem.classList.contains(ClassName$3.COLLAPSE);
  2912. });
  2913. if (actives.length === 0) {
  2914. actives = null;
  2915. }
  2916. }
  2917. if (actives) {
  2918. activesData = $(actives).not(this._selector).data(DATA_KEY$3);
  2919. if (activesData && activesData._isTransitioning) {
  2920. return;
  2921. }
  2922. }
  2923. var startEvent = $.Event(Event$3.SHOW);
  2924. $(this._element).trigger(startEvent);
  2925. if (startEvent.isDefaultPrevented()) {
  2926. return;
  2927. }
  2928. if (actives) {
  2929. Collapse._jQueryInterface.call($(actives).not(this._selector), 'hide');
  2930. if (!activesData) {
  2931. $(actives).data(DATA_KEY$3, null);
  2932. }
  2933. }
  2934. var dimension = this._getDimension();
  2935. $(this._element).removeClass(ClassName$3.COLLAPSE).addClass(ClassName$3.COLLAPSING);
  2936. this._element.style[dimension] = 0;
  2937. if (this._triggerArray.length) {
  2938. $(this._triggerArray).removeClass(ClassName$3.COLLAPSED).attr('aria-expanded', true);
  2939. }
  2940. this.setTransitioning(true);
  2941. var complete = function complete() {
  2942. $(_this._element).removeClass(ClassName$3.COLLAPSING).addClass(ClassName$3.COLLAPSE).addClass(ClassName$3.SHOW);
  2943. _this._element.style[dimension] = '';
  2944. _this.setTransitioning(false);
  2945. $(_this._element).trigger(Event$3.SHOWN);
  2946. };
  2947. var capitalizedDimension = dimension[0].toUpperCase() + dimension.slice(1);
  2948. var scrollSize = "scroll" + capitalizedDimension;
  2949. var transitionDuration = Util.getTransitionDurationFromElement(this._element);
  2950. $(this._element).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration);
  2951. this._element.style[dimension] = this._element[scrollSize] + "px";
  2952. };
  2953. _proto.hide = function hide() {
  2954. var _this2 = this;
  2955. if (this._isTransitioning || !$(this._element).hasClass(ClassName$3.SHOW)) {
  2956. return;
  2957. }
  2958. var startEvent = $.Event(Event$3.HIDE);
  2959. $(this._element).trigger(startEvent);
  2960. if (startEvent.isDefaultPrevented()) {
  2961. return;
  2962. }
  2963. var dimension = this._getDimension();
  2964. this._element.style[dimension] = this._element.getBoundingClientRect()[dimension] + "px";
  2965. Util.reflow(this._element);
  2966. $(this._element).addClass(ClassName$3.COLLAPSING).removeClass(ClassName$3.COLLAPSE).removeClass(ClassName$3.SHOW);
  2967. var triggerArrayLength = this._triggerArray.length;
  2968. if (triggerArrayLength > 0) {
  2969. for (var i = 0; i < triggerArrayLength; i++) {
  2970. var trigger = this._triggerArray[i];
  2971. var selector = Util.getSelectorFromElement(trigger);
  2972. if (selector !== null) {
  2973. var $elem = $([].slice.call(document.querySelectorAll(selector)));
  2974. if (!$elem.hasClass(ClassName$3.SHOW)) {
  2975. $(trigger).addClass(ClassName$3.COLLAPSED).attr('aria-expanded', false);
  2976. }
  2977. }
  2978. }
  2979. }
  2980. this.setTransitioning(true);
  2981. var complete = function complete() {
  2982. _this2.setTransitioning(false);
  2983. $(_this2._element).removeClass(ClassName$3.COLLAPSING).addClass(ClassName$3.COLLAPSE).trigger(Event$3.HIDDEN);
  2984. };
  2985. this._element.style[dimension] = '';
  2986. var transitionDuration = Util.getTransitionDurationFromElement(this._element);
  2987. $(this._element).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration);
  2988. };
  2989. _proto.setTransitioning = function setTransitioning(isTransitioning) {
  2990. this._isTransitioning = isTransitioning;
  2991. };
  2992. _proto.dispose = function dispose() {
  2993. $.removeData(this._element, DATA_KEY$3);
  2994. this._config = null;
  2995. this._parent = null;
  2996. this._element = null;
  2997. this._triggerArray = null;
  2998. this._isTransitioning = null;
  2999. } // Private
  3000. ;
  3001. _proto._getConfig = function _getConfig(config) {
  3002. config = _objectSpread2({}, Default$1, {}, config);
  3003. config.toggle = Boolean(config.toggle); // Coerce string values
  3004. Util.typeCheckConfig(NAME$3, config, DefaultType$1);
  3005. return config;
  3006. };
  3007. _proto._getDimension = function _getDimension() {
  3008. var hasWidth = $(this._element).hasClass(Dimension.WIDTH);
  3009. return hasWidth ? Dimension.WIDTH : Dimension.HEIGHT;
  3010. };
  3011. _proto._getParent = function _getParent() {
  3012. var _this3 = this;
  3013. var parent;
  3014. if (Util.isElement(this._config.parent)) {
  3015. parent = this._config.parent; // It's a jQuery object
  3016. if (typeof this._config.parent.jquery !== 'undefined') {
  3017. parent = this._config.parent[0];
  3018. }
  3019. } else {
  3020. parent = document.querySelector(this._config.parent);
  3021. }
  3022. var selector = "[data-toggle=\"collapse\"][data-parent=\"" + this._config.parent + "\"]";
  3023. var children = [].slice.call(parent.querySelectorAll(selector));
  3024. $(children).each(function (i, element) {
  3025. _this3._addAriaAndCollapsedClass(Collapse._getTargetFromElement(element), [element]);
  3026. });
  3027. return parent;
  3028. };
  3029. _proto._addAriaAndCollapsedClass = function _addAriaAndCollapsedClass(element, triggerArray) {
  3030. var isOpen = $(element).hasClass(ClassName$3.SHOW);
  3031. if (triggerArray.length) {
  3032. $(triggerArray).toggleClass(ClassName$3.COLLAPSED, !isOpen).attr('aria-expanded', isOpen);
  3033. }
  3034. } // Static
  3035. ;
  3036. Collapse._getTargetFromElement = function _getTargetFromElement(element) {
  3037. var selector = Util.getSelectorFromElement(element);
  3038. return selector ? document.querySelector(selector) : null;
  3039. };
  3040. Collapse._jQueryInterface = function _jQueryInterface(config) {
  3041. return this.each(function () {
  3042. var $this = $(this);
  3043. var data = $this.data(DATA_KEY$3);
  3044. var _config = _objectSpread2({}, Default$1, {}, $this.data(), {}, typeof config === 'object' && config ? config : {});
  3045. if (!data && _config.toggle && /show|hide/.test(config)) {
  3046. _config.toggle = false;
  3047. }
  3048. if (!data) {
  3049. data = new Collapse(this, _config);
  3050. $this.data(DATA_KEY$3, data);
  3051. }
  3052. if (typeof config === 'string') {
  3053. if (typeof data[config] === 'undefined') {
  3054. throw new TypeError("No method named \"" + config + "\"");
  3055. }
  3056. data[config]();
  3057. }
  3058. });
  3059. };
  3060. _createClass(Collapse, null, [{
  3061. key: "VERSION",
  3062. get: function get() {
  3063. return VERSION$3;
  3064. }
  3065. }, {
  3066. key: "Default",
  3067. get: function get() {
  3068. return Default$1;
  3069. }
  3070. }]);
  3071. return Collapse;
  3072. }();
  3073. /**
  3074. * ------------------------------------------------------------------------
  3075. * Data Api implementation
  3076. * ------------------------------------------------------------------------
  3077. */
  3078. $(document).on(Event$3.CLICK_DATA_API, Selector$3.DATA_TOGGLE, function (event) {
  3079. // preventDefault only for <a> elements (which change the URL) not inside the collapsible element
  3080. if (event.currentTarget.tagName === 'A') {
  3081. event.preventDefault();
  3082. }
  3083. var $trigger = $(this);
  3084. var selector = Util.getSelectorFromElement(this);
  3085. var selectors = [].slice.call(document.querySelectorAll(selector));
  3086. $(selectors).each(function () {
  3087. var $target = $(this);
  3088. var data = $target.data(DATA_KEY$3);
  3089. var config = data ? 'toggle' : $trigger.data();
  3090. Collapse._jQueryInterface.call($target, config);
  3091. });
  3092. });
  3093. /**
  3094. * ------------------------------------------------------------------------
  3095. * jQuery
  3096. * ------------------------------------------------------------------------
  3097. */
  3098. $.fn[NAME$3] = Collapse._jQueryInterface;
  3099. $.fn[NAME$3].Constructor = Collapse;
  3100. $.fn[NAME$3].noConflict = function () {
  3101. $.fn[NAME$3] = JQUERY_NO_CONFLICT$3;
  3102. return Collapse._jQueryInterface;
  3103. };
  3104. /**
  3105. * ------------------------------------------------------------------------
  3106. * Constants
  3107. * ------------------------------------------------------------------------
  3108. */
  3109. var NAME$4 = 'dropdown';
  3110. var VERSION$4 = '4.4.1';
  3111. var DATA_KEY$4 = 'bs.dropdown';
  3112. var EVENT_KEY$4 = "." + DATA_KEY$4;
  3113. var DATA_API_KEY$4 = '.data-api';
  3114. var JQUERY_NO_CONFLICT$4 = $.fn[NAME$4];
  3115. var ESCAPE_KEYCODE = 27; // KeyboardEvent.which value for Escape (Esc) key
  3116. var SPACE_KEYCODE = 32; // KeyboardEvent.which value for space key
  3117. var TAB_KEYCODE = 9; // KeyboardEvent.which value for tab key
  3118. var ARROW_UP_KEYCODE = 38; // KeyboardEvent.which value for up arrow key
  3119. var ARROW_DOWN_KEYCODE = 40; // KeyboardEvent.which value for down arrow key
  3120. var RIGHT_MOUSE_BUTTON_WHICH = 3; // MouseEvent.which value for the right button (assuming a right-handed mouse)
  3121. var REGEXP_KEYDOWN = new RegExp(ARROW_UP_KEYCODE + "|" + ARROW_DOWN_KEYCODE + "|" + ESCAPE_KEYCODE);
  3122. var Event$4 = {
  3123. HIDE: "hide" + EVENT_KEY$4,
  3124. HIDDEN: "hidden" + EVENT_KEY$4,
  3125. SHOW: "show" + EVENT_KEY$4,
  3126. SHOWN: "shown" + EVENT_KEY$4,
  3127. CLICK: "click" + EVENT_KEY$4,
  3128. CLICK_DATA_API: "click" + EVENT_KEY$4 + DATA_API_KEY$4,
  3129. KEYDOWN_DATA_API: "keydown" + EVENT_KEY$4 + DATA_API_KEY$4,
  3130. KEYUP_DATA_API: "keyup" + EVENT_KEY$4 + DATA_API_KEY$4
  3131. };
  3132. var ClassName$4 = {
  3133. DISABLED: 'disabled',
  3134. SHOW: 'show',
  3135. DROPUP: 'dropup',
  3136. DROPRIGHT: 'dropright',
  3137. DROPLEFT: 'dropleft',
  3138. MENURIGHT: 'dropdown-menu-right',
  3139. MENULEFT: 'dropdown-menu-left',
  3140. POSITION_STATIC: 'position-static'
  3141. };
  3142. var Selector$4 = {
  3143. DATA_TOGGLE: '[data-toggle="dropdown"]',
  3144. FORM_CHILD: '.dropdown form',
  3145. MENU: '.dropdown-menu',
  3146. NAVBAR_NAV: '.navbar-nav',
  3147. VISIBLE_ITEMS: '.dropdown-menu .dropdown-item:not(.disabled):not(:disabled)'
  3148. };
  3149. var AttachmentMap = {
  3150. TOP: 'top-start',
  3151. TOPEND: 'top-end',
  3152. BOTTOM: 'bottom-start',
  3153. BOTTOMEND: 'bottom-end',
  3154. RIGHT: 'right-start',
  3155. RIGHTEND: 'right-end',
  3156. LEFT: 'left-start',
  3157. LEFTEND: 'left-end'
  3158. };
  3159. var Default$2 = {
  3160. offset: 0,
  3161. flip: true,
  3162. boundary: 'scrollParent',
  3163. reference: 'toggle',
  3164. display: 'dynamic',
  3165. popperConfig: null
  3166. };
  3167. var DefaultType$2 = {
  3168. offset: '(number|string|function)',
  3169. flip: 'boolean',
  3170. boundary: '(string|element)',
  3171. reference: '(string|element)',
  3172. display: 'string',
  3173. popperConfig: '(null|object)'
  3174. };
  3175. /**
  3176. * ------------------------------------------------------------------------
  3177. * Class Definition
  3178. * ------------------------------------------------------------------------
  3179. */
  3180. var Dropdown =
  3181. /*#__PURE__*/
  3182. function () {
  3183. function Dropdown(element, config) {
  3184. this._element = element;
  3185. this._popper = null;
  3186. this._config = this._getConfig(config);
  3187. this._menu = this._getMenuElement();
  3188. this._inNavbar = this._detectNavbar();
  3189. this._addEventListeners();
  3190. } // Getters
  3191. var _proto = Dropdown.prototype;
  3192. // Public
  3193. _proto.toggle = function toggle() {
  3194. if (this._element.disabled || $(this._element).hasClass(ClassName$4.DISABLED)) {
  3195. return;
  3196. }
  3197. var isActive = $(this._menu).hasClass(ClassName$4.SHOW);
  3198. Dropdown._clearMenus();
  3199. if (isActive) {
  3200. return;
  3201. }
  3202. this.show(true);
  3203. };
  3204. _proto.show = function show(usePopper) {
  3205. if (usePopper === void 0) {
  3206. usePopper = false;
  3207. }
  3208. if (this._element.disabled || $(this._element).hasClass(ClassName$4.DISABLED) || $(this._menu).hasClass(ClassName$4.SHOW)) {
  3209. return;
  3210. }
  3211. var relatedTarget = {
  3212. relatedTarget: this._element
  3213. };
  3214. var showEvent = $.Event(Event$4.SHOW, relatedTarget);
  3215. var parent = Dropdown._getParentFromElement(this._element);
  3216. $(parent).trigger(showEvent);
  3217. if (showEvent.isDefaultPrevented()) {
  3218. return;
  3219. } // Disable totally Popper.js for Dropdown in Navbar
  3220. if (!this._inNavbar && usePopper) {
  3221. /**
  3222. * Check for Popper dependency
  3223. * Popper - https://popper.js.org
  3224. */
  3225. if (typeof Popper === 'undefined') {
  3226. throw new TypeError('Bootstrap\'s dropdowns require Popper.js (https://popper.js.org/)');
  3227. }
  3228. var referenceElement = this._element;
  3229. if (this._config.reference === 'parent') {
  3230. referenceElement = parent;
  3231. } else if (Util.isElement(this._config.reference)) {
  3232. referenceElement = this._config.reference; // Check if it's jQuery element
  3233. if (typeof this._config.reference.jquery !== 'undefined') {
  3234. referenceElement = this._config.reference[0];
  3235. }
  3236. } // If boundary is not `scrollParent`, then set position to `static`
  3237. // to allow the menu to "escape" the scroll parent's boundaries
  3238. // https://github.com/twbs/bootstrap/issues/24251
  3239. if (this._config.boundary !== 'scrollParent') {
  3240. $(parent).addClass(ClassName$4.POSITION_STATIC);
  3241. }
  3242. this._popper = new Popper(referenceElement, this._menu, this._getPopperConfig());
  3243. } // If this is a touch-enabled device we add extra
  3244. // empty mouseover listeners to the body's immediate children;
  3245. // only needed because of broken event delegation on iOS
  3246. // https://www.quirksmode.org/blog/archives/2014/02/mouse_event_bub.html
  3247. if ('ontouchstart' in document.documentElement && $(parent).closest(Selector$4.NAVBAR_NAV).length === 0) {
  3248. $(document.body).children().on('mouseover', null, $.noop);
  3249. }
  3250. this._element.focus();
  3251. this._element.setAttribute('aria-expanded', true);
  3252. $(this._menu).toggleClass(ClassName$4.SHOW);
  3253. $(parent).toggleClass(ClassName$4.SHOW).trigger($.Event(Event$4.SHOWN, relatedTarget));
  3254. };
  3255. _proto.hide = function hide() {
  3256. if (this._element.disabled || $(this._element).hasClass(ClassName$4.DISABLED) || !$(this._menu).hasClass(ClassName$4.SHOW)) {
  3257. return;
  3258. }
  3259. var relatedTarget = {
  3260. relatedTarget: this._element
  3261. };
  3262. var hideEvent = $.Event(Event$4.HIDE, relatedTarget);
  3263. var parent = Dropdown._getParentFromElement(this._element);
  3264. $(parent).trigger(hideEvent);
  3265. if (hideEvent.isDefaultPrevented()) {
  3266. return;
  3267. }
  3268. if (this._popper) {
  3269. this._popper.destroy();
  3270. }
  3271. $(this._menu).toggleClass(ClassName$4.SHOW);
  3272. $(parent).toggleClass(ClassName$4.SHOW).trigger($.Event(Event$4.HIDDEN, relatedTarget));
  3273. };
  3274. _proto.dispose = function dispose() {
  3275. $.removeData(this._element, DATA_KEY$4);
  3276. $(this._element).off(EVENT_KEY$4);
  3277. this._element = null;
  3278. this._menu = null;
  3279. if (this._popper !== null) {
  3280. this._popper.destroy();
  3281. this._popper = null;
  3282. }
  3283. };
  3284. _proto.update = function update() {
  3285. this._inNavbar = this._detectNavbar();
  3286. if (this._popper !== null) {
  3287. this._popper.scheduleUpdate();
  3288. }
  3289. } // Private
  3290. ;
  3291. _proto._addEventListeners = function _addEventListeners() {
  3292. var _this = this;
  3293. $(this._element).on(Event$4.CLICK, function (event) {
  3294. event.preventDefault();
  3295. event.stopPropagation();
  3296. _this.toggle();
  3297. });
  3298. };
  3299. _proto._getConfig = function _getConfig(config) {
  3300. config = _objectSpread2({}, this.constructor.Default, {}, $(this._element).data(), {}, config);
  3301. Util.typeCheckConfig(NAME$4, config, this.constructor.DefaultType);
  3302. return config;
  3303. };
  3304. _proto._getMenuElement = function _getMenuElement() {
  3305. if (!this._menu) {
  3306. var parent = Dropdown._getParentFromElement(this._element);
  3307. if (parent) {
  3308. this._menu = parent.querySelector(Selector$4.MENU);
  3309. }
  3310. }
  3311. return this._menu;
  3312. };
  3313. _proto._getPlacement = function _getPlacement() {
  3314. var $parentDropdown = $(this._element.parentNode);
  3315. var placement = AttachmentMap.BOTTOM; // Handle dropup
  3316. if ($parentDropdown.hasClass(ClassName$4.DROPUP)) {
  3317. placement = AttachmentMap.TOP;
  3318. if ($(this._menu).hasClass(ClassName$4.MENURIGHT)) {
  3319. placement = AttachmentMap.TOPEND;
  3320. }
  3321. } else if ($parentDropdown.hasClass(ClassName$4.DROPRIGHT)) {
  3322. placement = AttachmentMap.RIGHT;
  3323. } else if ($parentDropdown.hasClass(ClassName$4.DROPLEFT)) {
  3324. placement = AttachmentMap.LEFT;
  3325. } else if ($(this._menu).hasClass(ClassName$4.MENURIGHT)) {
  3326. placement = AttachmentMap.BOTTOMEND;
  3327. }
  3328. return placement;
  3329. };
  3330. _proto._detectNavbar = function _detectNavbar() {
  3331. return $(this._element).closest('.navbar').length > 0;
  3332. };
  3333. _proto._getOffset = function _getOffset() {
  3334. var _this2 = this;
  3335. var offset = {};
  3336. if (typeof this._config.offset === 'function') {
  3337. offset.fn = function (data) {
  3338. data.offsets = _objectSpread2({}, data.offsets, {}, _this2._config.offset(data.offsets, _this2._element) || {});
  3339. return data;
  3340. };
  3341. } else {
  3342. offset.offset = this._config.offset;
  3343. }
  3344. return offset;
  3345. };
  3346. _proto._getPopperConfig = function _getPopperConfig() {
  3347. var popperConfig = {
  3348. placement: this._getPlacement(),
  3349. modifiers: {
  3350. offset: this._getOffset(),
  3351. flip: {
  3352. enabled: this._config.flip
  3353. },
  3354. preventOverflow: {
  3355. boundariesElement: this._config.boundary
  3356. }
  3357. }
  3358. }; // Disable Popper.js if we have a static display
  3359. if (this._config.display === 'static') {
  3360. popperConfig.modifiers.applyStyle = {
  3361. enabled: false
  3362. };
  3363. }
  3364. return _objectSpread2({}, popperConfig, {}, this._config.popperConfig);
  3365. } // Static
  3366. ;
  3367. Dropdown._jQueryInterface = function _jQueryInterface(config) {
  3368. return this.each(function () {
  3369. var data = $(this).data(DATA_KEY$4);
  3370. var _config = typeof config === 'object' ? config : null;
  3371. if (!data) {
  3372. data = new Dropdown(this, _config);
  3373. $(this).data(DATA_KEY$4, data);
  3374. }
  3375. if (typeof config === 'string') {
  3376. if (typeof data[config] === 'undefined') {
  3377. throw new TypeError("No method named \"" + config + "\"");
  3378. }
  3379. data[config]();
  3380. }
  3381. });
  3382. };
  3383. Dropdown._clearMenus = function _clearMenus(event) {
  3384. if (event && (event.which === RIGHT_MOUSE_BUTTON_WHICH || event.type === 'keyup' && event.which !== TAB_KEYCODE)) {
  3385. return;
  3386. }
  3387. var toggles = [].slice.call(document.querySelectorAll(Selector$4.DATA_TOGGLE));
  3388. for (var i = 0, len = toggles.length; i < len; i++) {
  3389. var parent = Dropdown._getParentFromElement(toggles[i]);
  3390. var context = $(toggles[i]).data(DATA_KEY$4);
  3391. var relatedTarget = {
  3392. relatedTarget: toggles[i]
  3393. };
  3394. if (event && event.type === 'click') {
  3395. relatedTarget.clickEvent = event;
  3396. }
  3397. if (!context) {
  3398. continue;
  3399. }
  3400. var dropdownMenu = context._menu;
  3401. if (!$(parent).hasClass(ClassName$4.SHOW)) {
  3402. continue;
  3403. }
  3404. if (event && (event.type === 'click' && /input|textarea/i.test(event.target.tagName) || event.type === 'keyup' && event.which === TAB_KEYCODE) && $.contains(parent, event.target)) {
  3405. continue;
  3406. }
  3407. var hideEvent = $.Event(Event$4.HIDE, relatedTarget);
  3408. $(parent).trigger(hideEvent);
  3409. if (hideEvent.isDefaultPrevented()) {
  3410. continue;
  3411. } // If this is a touch-enabled device we remove the extra
  3412. // empty mouseover listeners we added for iOS support
  3413. if ('ontouchstart' in document.documentElement) {
  3414. $(document.body).children().off('mouseover', null, $.noop);
  3415. }
  3416. toggles[i].setAttribute('aria-expanded', 'false');
  3417. if (context._popper) {
  3418. context._popper.destroy();
  3419. }
  3420. $(dropdownMenu).removeClass(ClassName$4.SHOW);
  3421. $(parent).removeClass(ClassName$4.SHOW).trigger($.Event(Event$4.HIDDEN, relatedTarget));
  3422. }
  3423. };
  3424. Dropdown._getParentFromElement = function _getParentFromElement(element) {
  3425. var parent;
  3426. var selector = Util.getSelectorFromElement(element);
  3427. if (selector) {
  3428. parent = document.querySelector(selector);
  3429. }
  3430. return parent || element.parentNode;
  3431. } // eslint-disable-next-line complexity
  3432. ;
  3433. Dropdown._dataApiKeydownHandler = function _dataApiKeydownHandler(event) {
  3434. // If not input/textarea:
  3435. // - And not a key in REGEXP_KEYDOWN => not a dropdown command
  3436. // If input/textarea:
  3437. // - If space key => not a dropdown command
  3438. // - If key is other than escape
  3439. // - If key is not up or down => not a dropdown command
  3440. // - If trigger inside the menu => not a dropdown command
  3441. 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)) {
  3442. return;
  3443. }
  3444. event.preventDefault();
  3445. event.stopPropagation();
  3446. if (this.disabled || $(this).hasClass(ClassName$4.DISABLED)) {
  3447. return;
  3448. }
  3449. var parent = Dropdown._getParentFromElement(this);
  3450. var isActive = $(parent).hasClass(ClassName$4.SHOW);
  3451. if (!isActive && event.which === ESCAPE_KEYCODE) {
  3452. return;
  3453. }
  3454. if (!isActive || isActive && (event.which === ESCAPE_KEYCODE || event.which === SPACE_KEYCODE)) {
  3455. if (event.which === ESCAPE_KEYCODE) {
  3456. var toggle = parent.querySelector(Selector$4.DATA_TOGGLE);
  3457. $(toggle).trigger('focus');
  3458. }
  3459. $(this).trigger('click');
  3460. return;
  3461. }
  3462. var items = [].slice.call(parent.querySelectorAll(Selector$4.VISIBLE_ITEMS)).filter(function (item) {
  3463. return $(item).is(':visible');
  3464. });
  3465. if (items.length === 0) {
  3466. return;
  3467. }
  3468. var index = items.indexOf(event.target);
  3469. if (event.which === ARROW_UP_KEYCODE && index > 0) {
  3470. // Up
  3471. index--;
  3472. }
  3473. if (event.which === ARROW_DOWN_KEYCODE && index < items.length - 1) {
  3474. // Down
  3475. index++;
  3476. }
  3477. if (index < 0) {
  3478. index = 0;
  3479. }
  3480. items[index].focus();
  3481. };
  3482. _createClass(Dropdown, null, [{
  3483. key: "VERSION",
  3484. get: function get() {
  3485. return VERSION$4;
  3486. }
  3487. }, {
  3488. key: "Default",
  3489. get: function get() {
  3490. return Default$2;
  3491. }
  3492. }, {
  3493. key: "DefaultType",
  3494. get: function get() {
  3495. return DefaultType$2;
  3496. }
  3497. }]);
  3498. return Dropdown;
  3499. }();
  3500. /**
  3501. * ------------------------------------------------------------------------
  3502. * Data Api implementation
  3503. * ------------------------------------------------------------------------
  3504. */
  3505. $(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) {
  3506. event.preventDefault();
  3507. event.stopPropagation();
  3508. Dropdown._jQueryInterface.call($(this), 'toggle');
  3509. }).on(Event$4.CLICK_DATA_API, Selector$4.FORM_CHILD, function (e) {
  3510. e.stopPropagation();
  3511. });
  3512. /**
  3513. * ------------------------------------------------------------------------
  3514. * jQuery
  3515. * ------------------------------------------------------------------------
  3516. */
  3517. $.fn[NAME$4] = Dropdown._jQueryInterface;
  3518. $.fn[NAME$4].Constructor = Dropdown;
  3519. $.fn[NAME$4].noConflict = function () {
  3520. $.fn[NAME$4] = JQUERY_NO_CONFLICT$4;
  3521. return Dropdown._jQueryInterface;
  3522. };
  3523. /**
  3524. * ------------------------------------------------------------------------
  3525. * Constants
  3526. * ------------------------------------------------------------------------
  3527. */
  3528. var NAME$5 = 'modal';
  3529. var VERSION$5 = '4.4.1';
  3530. var DATA_KEY$5 = 'bs.modal';
  3531. var EVENT_KEY$5 = "." + DATA_KEY$5;
  3532. var DATA_API_KEY$5 = '.data-api';
  3533. var JQUERY_NO_CONFLICT$5 = $.fn[NAME$5];
  3534. var ESCAPE_KEYCODE$1 = 27; // KeyboardEvent.which value for Escape (Esc) key
  3535. var Default$3 = {
  3536. backdrop: true,
  3537. keyboard: true,
  3538. focus: true,
  3539. show: true
  3540. };
  3541. var DefaultType$3 = {
  3542. backdrop: '(boolean|string)',
  3543. keyboard: 'boolean',
  3544. focus: 'boolean',
  3545. show: 'boolean'
  3546. };
  3547. var Event$5 = {
  3548. HIDE: "hide" + EVENT_KEY$5,
  3549. HIDE_PREVENTED: "hidePrevented" + EVENT_KEY$5,
  3550. HIDDEN: "hidden" + EVENT_KEY$5,
  3551. SHOW: "show" + EVENT_KEY$5,
  3552. SHOWN: "shown" + EVENT_KEY$5,
  3553. FOCUSIN: "focusin" + EVENT_KEY$5,
  3554. RESIZE: "resize" + EVENT_KEY$5,
  3555. CLICK_DISMISS: "click.dismiss" + EVENT_KEY$5,
  3556. KEYDOWN_DISMISS: "keydown.dismiss" + EVENT_KEY$5,
  3557. MOUSEUP_DISMISS: "mouseup.dismiss" + EVENT_KEY$5,
  3558. MOUSEDOWN_DISMISS: "mousedown.dismiss" + EVENT_KEY$5,
  3559. CLICK_DATA_API: "click" + EVENT_KEY$5 + DATA_API_KEY$5
  3560. };
  3561. var ClassName$5 = {
  3562. SCROLLABLE: 'modal-dialog-scrollable',
  3563. SCROLLBAR_MEASURER: 'modal-scrollbar-measure',
  3564. BACKDROP: 'modal-backdrop',
  3565. OPEN: 'modal-open',
  3566. FADE: 'fade',
  3567. SHOW: 'show',
  3568. STATIC: 'modal-static'
  3569. };
  3570. var Selector$5 = {
  3571. DIALOG: '.modal-dialog',
  3572. MODAL_BODY: '.modal-body',
  3573. DATA_TOGGLE: '[data-toggle="modal"]',
  3574. DATA_DISMISS: '[data-dismiss="modal"]',
  3575. FIXED_CONTENT: '.fixed-top, .fixed-bottom, .is-fixed, .sticky-top',
  3576. STICKY_CONTENT: '.sticky-top'
  3577. };
  3578. /**
  3579. * ------------------------------------------------------------------------
  3580. * Class Definition
  3581. * ------------------------------------------------------------------------
  3582. */
  3583. var Modal =
  3584. /*#__PURE__*/
  3585. function () {
  3586. function Modal(element, config) {
  3587. this._config = this._getConfig(config);
  3588. this._element = element;
  3589. this._dialog = element.querySelector(Selector$5.DIALOG);
  3590. this._backdrop = null;
  3591. this._isShown = false;
  3592. this._isBodyOverflowing = false;
  3593. this._ignoreBackdropClick = false;
  3594. this._isTransitioning = false;
  3595. this._scrollbarWidth = 0;
  3596. } // Getters
  3597. var _proto = Modal.prototype;
  3598. // Public
  3599. _proto.toggle = function toggle(relatedTarget) {
  3600. return this._isShown ? this.hide() : this.show(relatedTarget);
  3601. };
  3602. _proto.show = function show(relatedTarget) {
  3603. var _this = this;
  3604. if (this._isShown || this._isTransitioning) {
  3605. return;
  3606. }
  3607. if ($(this._element).hasClass(ClassName$5.FADE)) {
  3608. this._isTransitioning = true;
  3609. }
  3610. var showEvent = $.Event(Event$5.SHOW, {
  3611. relatedTarget: relatedTarget
  3612. });
  3613. $(this._element).trigger(showEvent);
  3614. if (this._isShown || showEvent.isDefaultPrevented()) {
  3615. return;
  3616. }
  3617. this._isShown = true;
  3618. this._checkScrollbar();
  3619. this._setScrollbar();
  3620. this._adjustDialog();
  3621. this._setEscapeEvent();
  3622. this._setResizeEvent();
  3623. $(this._element).on(Event$5.CLICK_DISMISS, Selector$5.DATA_DISMISS, function (event) {
  3624. return _this.hide(event);
  3625. });
  3626. $(this._dialog).on(Event$5.MOUSEDOWN_DISMISS, function () {
  3627. $(_this._element).one(Event$5.MOUSEUP_DISMISS, function (event) {
  3628. if ($(event.target).is(_this._element)) {
  3629. _this._ignoreBackdropClick = true;
  3630. }
  3631. });
  3632. });
  3633. this._showBackdrop(function () {
  3634. return _this._showElement(relatedTarget);
  3635. });
  3636. };
  3637. _proto.hide = function hide(event) {
  3638. var _this2 = this;
  3639. if (event) {
  3640. event.preventDefault();
  3641. }
  3642. if (!this._isShown || this._isTransitioning) {
  3643. return;
  3644. }
  3645. var hideEvent = $.Event(Event$5.HIDE);
  3646. $(this._element).trigger(hideEvent);
  3647. if (!this._isShown || hideEvent.isDefaultPrevented()) {
  3648. return;
  3649. }
  3650. this._isShown = false;
  3651. var transition = $(this._element).hasClass(ClassName$5.FADE);
  3652. if (transition) {
  3653. this._isTransitioning = true;
  3654. }
  3655. this._setEscapeEvent();
  3656. this._setResizeEvent();
  3657. $(document).off(Event$5.FOCUSIN);
  3658. $(this._element).removeClass(ClassName$5.SHOW);
  3659. $(this._element).off(Event$5.CLICK_DISMISS);
  3660. $(this._dialog).off(Event$5.MOUSEDOWN_DISMISS);
  3661. if (transition) {
  3662. var transitionDuration = Util.getTransitionDurationFromElement(this._element);
  3663. $(this._element).one(Util.TRANSITION_END, function (event) {
  3664. return _this2._hideModal(event);
  3665. }).emulateTransitionEnd(transitionDuration);
  3666. } else {
  3667. this._hideModal();
  3668. }
  3669. };
  3670. _proto.dispose = function dispose() {
  3671. [window, this._element, this._dialog].forEach(function (htmlElement) {
  3672. return $(htmlElement).off(EVENT_KEY$5);
  3673. });
  3674. /**
  3675. * `document` has 2 events `Event.FOCUSIN` and `Event.CLICK_DATA_API`
  3676. * Do not move `document` in `htmlElements` array
  3677. * It will remove `Event.CLICK_DATA_API` event that should remain
  3678. */
  3679. $(document).off(Event$5.FOCUSIN);
  3680. $.removeData(this._element, DATA_KEY$5);
  3681. this._config = null;
  3682. this._element = null;
  3683. this._dialog = null;
  3684. this._backdrop = null;
  3685. this._isShown = null;
  3686. this._isBodyOverflowing = null;
  3687. this._ignoreBackdropClick = null;
  3688. this._isTransitioning = null;
  3689. this._scrollbarWidth = null;
  3690. };
  3691. _proto.handleUpdate = function handleUpdate() {
  3692. this._adjustDialog();
  3693. } // Private
  3694. ;
  3695. _proto._getConfig = function _getConfig(config) {
  3696. config = _objectSpread2({}, Default$3, {}, config);
  3697. Util.typeCheckConfig(NAME$5, config, DefaultType$3);
  3698. return config;
  3699. };
  3700. _proto._triggerBackdropTransition = function _triggerBackdropTransition() {
  3701. var _this3 = this;
  3702. if (this._config.backdrop === 'static') {
  3703. var hideEventPrevented = $.Event(Event$5.HIDE_PREVENTED);
  3704. $(this._element).trigger(hideEventPrevented);
  3705. if (hideEventPrevented.defaultPrevented) {
  3706. return;
  3707. }
  3708. this._element.classList.add(ClassName$5.STATIC);
  3709. var modalTransitionDuration = Util.getTransitionDurationFromElement(this._element);
  3710. $(this._element).one(Util.TRANSITION_END, function () {
  3711. _this3._element.classList.remove(ClassName$5.STATIC);
  3712. }).emulateTransitionEnd(modalTransitionDuration);
  3713. this._element.focus();
  3714. } else {
  3715. this.hide();
  3716. }
  3717. };
  3718. _proto._showElement = function _showElement(relatedTarget) {
  3719. var _this4 = this;
  3720. var transition = $(this._element).hasClass(ClassName$5.FADE);
  3721. var modalBody = this._dialog ? this._dialog.querySelector(Selector$5.MODAL_BODY) : null;
  3722. if (!this._element.parentNode || this._element.parentNode.nodeType !== Node.ELEMENT_NODE) {
  3723. // Don't move modal's DOM position
  3724. document.body.appendChild(this._element);
  3725. }
  3726. this._element.style.display = 'block';
  3727. this._element.removeAttribute('aria-hidden');
  3728. this._element.setAttribute('aria-modal', true);
  3729. if ($(this._dialog).hasClass(ClassName$5.SCROLLABLE) && modalBody) {
  3730. modalBody.scrollTop = 0;
  3731. } else {
  3732. this._element.scrollTop = 0;
  3733. }
  3734. if (transition) {
  3735. Util.reflow(this._element);
  3736. }
  3737. $(this._element).addClass(ClassName$5.SHOW);
  3738. if (this._config.focus) {
  3739. this._enforceFocus();
  3740. }
  3741. var shownEvent = $.Event(Event$5.SHOWN, {
  3742. relatedTarget: relatedTarget
  3743. });
  3744. var transitionComplete = function transitionComplete() {
  3745. if (_this4._config.focus) {
  3746. _this4._element.focus();
  3747. }
  3748. _this4._isTransitioning = false;
  3749. $(_this4._element).trigger(shownEvent);
  3750. };
  3751. if (transition) {
  3752. var transitionDuration = Util.getTransitionDurationFromElement(this._dialog);
  3753. $(this._dialog).one(Util.TRANSITION_END, transitionComplete).emulateTransitionEnd(transitionDuration);
  3754. } else {
  3755. transitionComplete();
  3756. }
  3757. };
  3758. _proto._enforceFocus = function _enforceFocus() {
  3759. var _this5 = this;
  3760. $(document).off(Event$5.FOCUSIN) // Guard against infinite focus loop
  3761. .on(Event$5.FOCUSIN, function (event) {
  3762. if (document !== event.target && _this5._element !== event.target && $(_this5._element).has(event.target).length === 0) {
  3763. _this5._element.focus();
  3764. }
  3765. });
  3766. };
  3767. _proto._setEscapeEvent = function _setEscapeEvent() {
  3768. var _this6 = this;
  3769. if (this._isShown && this._config.keyboard) {
  3770. $(this._element).on(Event$5.KEYDOWN_DISMISS, function (event) {
  3771. if (event.which === ESCAPE_KEYCODE$1) {
  3772. _this6._triggerBackdropTransition();
  3773. }
  3774. });
  3775. } else if (!this._isShown) {
  3776. $(this._element).off(Event$5.KEYDOWN_DISMISS);
  3777. }
  3778. };
  3779. _proto._setResizeEvent = function _setResizeEvent() {
  3780. var _this7 = this;
  3781. if (this._isShown) {
  3782. $(window).on(Event$5.RESIZE, function (event) {
  3783. return _this7.handleUpdate(event);
  3784. });
  3785. } else {
  3786. $(window).off(Event$5.RESIZE);
  3787. }
  3788. };
  3789. _proto._hideModal = function _hideModal() {
  3790. var _this8 = this;
  3791. this._element.style.display = 'none';
  3792. this._element.setAttribute('aria-hidden', true);
  3793. this._element.removeAttribute('aria-modal');
  3794. this._isTransitioning = false;
  3795. this._showBackdrop(function () {
  3796. $(document.body).removeClass(ClassName$5.OPEN);
  3797. _this8._resetAdjustments();
  3798. _this8._resetScrollbar();
  3799. $(_this8._element).trigger(Event$5.HIDDEN);
  3800. });
  3801. };
  3802. _proto._removeBackdrop = function _removeBackdrop() {
  3803. if (this._backdrop) {
  3804. $(this._backdrop).remove();
  3805. this._backdrop = null;
  3806. }
  3807. };
  3808. _proto._showBackdrop = function _showBackdrop(callback) {
  3809. var _this9 = this;
  3810. var animate = $(this._element).hasClass(ClassName$5.FADE) ? ClassName$5.FADE : '';
  3811. if (this._isShown && this._config.backdrop) {
  3812. this._backdrop = document.createElement('div');
  3813. this._backdrop.className = ClassName$5.BACKDROP;
  3814. if (animate) {
  3815. this._backdrop.classList.add(animate);
  3816. }
  3817. $(this._backdrop).appendTo(document.body);
  3818. $(this._element).on(Event$5.CLICK_DISMISS, function (event) {
  3819. if (_this9._ignoreBackdropClick) {
  3820. _this9._ignoreBackdropClick = false;
  3821. return;
  3822. }
  3823. if (event.target !== event.currentTarget) {
  3824. return;
  3825. }
  3826. _this9._triggerBackdropTransition();
  3827. });
  3828. if (animate) {
  3829. Util.reflow(this._backdrop);
  3830. }
  3831. $(this._backdrop).addClass(ClassName$5.SHOW);
  3832. if (!callback) {
  3833. return;
  3834. }
  3835. if (!animate) {
  3836. callback();
  3837. return;
  3838. }
  3839. var backdropTransitionDuration = Util.getTransitionDurationFromElement(this._backdrop);
  3840. $(this._backdrop).one(Util.TRANSITION_END, callback).emulateTransitionEnd(backdropTransitionDuration);
  3841. } else if (!this._isShown && this._backdrop) {
  3842. $(this._backdrop).removeClass(ClassName$5.SHOW);
  3843. var callbackRemove = function callbackRemove() {
  3844. _this9._removeBackdrop();
  3845. if (callback) {
  3846. callback();
  3847. }
  3848. };
  3849. if ($(this._element).hasClass(ClassName$5.FADE)) {
  3850. var _backdropTransitionDuration = Util.getTransitionDurationFromElement(this._backdrop);
  3851. $(this._backdrop).one(Util.TRANSITION_END, callbackRemove).emulateTransitionEnd(_backdropTransitionDuration);
  3852. } else {
  3853. callbackRemove();
  3854. }
  3855. } else if (callback) {
  3856. callback();
  3857. }
  3858. } // ----------------------------------------------------------------------
  3859. // the following methods are used to handle overflowing modals
  3860. // todo (fat): these should probably be refactored out of modal.js
  3861. // ----------------------------------------------------------------------
  3862. ;
  3863. _proto._adjustDialog = function _adjustDialog() {
  3864. var isModalOverflowing = this._element.scrollHeight > document.documentElement.clientHeight;
  3865. if (!this._isBodyOverflowing && isModalOverflowing) {
  3866. this._element.style.paddingLeft = this._scrollbarWidth + "px";
  3867. }
  3868. if (this._isBodyOverflowing && !isModalOverflowing) {
  3869. this._element.style.paddingRight = this._scrollbarWidth + "px";
  3870. }
  3871. };
  3872. _proto._resetAdjustments = function _resetAdjustments() {
  3873. this._element.style.paddingLeft = '';
  3874. this._element.style.paddingRight = '';
  3875. };
  3876. _proto._checkScrollbar = function _checkScrollbar() {
  3877. var rect = document.body.getBoundingClientRect();
  3878. this._isBodyOverflowing = rect.left + rect.right < window.innerWidth;
  3879. this._scrollbarWidth = this._getScrollbarWidth();
  3880. };
  3881. _proto._setScrollbar = function _setScrollbar() {
  3882. var _this10 = this;
  3883. if (this._isBodyOverflowing) {
  3884. // Note: DOMNode.style.paddingRight returns the actual value or '' if not set
  3885. // while $(DOMNode).css('padding-right') returns the calculated value or 0 if not set
  3886. var fixedContent = [].slice.call(document.querySelectorAll(Selector$5.FIXED_CONTENT));
  3887. var stickyContent = [].slice.call(document.querySelectorAll(Selector$5.STICKY_CONTENT)); // Adjust fixed content padding
  3888. $(fixedContent).each(function (index, element) {
  3889. var actualPadding = element.style.paddingRight;
  3890. var calculatedPadding = $(element).css('padding-right');
  3891. $(element).data('padding-right', actualPadding).css('padding-right', parseFloat(calculatedPadding) + _this10._scrollbarWidth + "px");
  3892. }); // Adjust sticky content margin
  3893. $(stickyContent).each(function (index, element) {
  3894. var actualMargin = element.style.marginRight;
  3895. var calculatedMargin = $(element).css('margin-right');
  3896. $(element).data('margin-right', actualMargin).css('margin-right', parseFloat(calculatedMargin) - _this10._scrollbarWidth + "px");
  3897. }); // Adjust body padding
  3898. var actualPadding = document.body.style.paddingRight;
  3899. var calculatedPadding = $(document.body).css('padding-right');
  3900. $(document.body).data('padding-right', actualPadding).css('padding-right', parseFloat(calculatedPadding) + this._scrollbarWidth + "px");
  3901. }
  3902. $(document.body).addClass(ClassName$5.OPEN);
  3903. };
  3904. _proto._resetScrollbar = function _resetScrollbar() {
  3905. // Restore fixed content padding
  3906. var fixedContent = [].slice.call(document.querySelectorAll(Selector$5.FIXED_CONTENT));
  3907. $(fixedContent).each(function (index, element) {
  3908. var padding = $(element).data('padding-right');
  3909. $(element).removeData('padding-right');
  3910. element.style.paddingRight = padding ? padding : '';
  3911. }); // Restore sticky content
  3912. var elements = [].slice.call(document.querySelectorAll("" + Selector$5.STICKY_CONTENT));
  3913. $(elements).each(function (index, element) {
  3914. var margin = $(element).data('margin-right');
  3915. if (typeof margin !== 'undefined') {
  3916. $(element).css('margin-right', margin).removeData('margin-right');
  3917. }
  3918. }); // Restore body padding
  3919. var padding = $(document.body).data('padding-right');
  3920. $(document.body).removeData('padding-right');
  3921. document.body.style.paddingRight = padding ? padding : '';
  3922. };
  3923. _proto._getScrollbarWidth = function _getScrollbarWidth() {
  3924. // thx d.walsh
  3925. var scrollDiv = document.createElement('div');
  3926. scrollDiv.className = ClassName$5.SCROLLBAR_MEASURER;
  3927. document.body.appendChild(scrollDiv);
  3928. var scrollbarWidth = scrollDiv.getBoundingClientRect().width - scrollDiv.clientWidth;
  3929. document.body.removeChild(scrollDiv);
  3930. return scrollbarWidth;
  3931. } // Static
  3932. ;
  3933. Modal._jQueryInterface = function _jQueryInterface(config, relatedTarget) {
  3934. return this.each(function () {
  3935. var data = $(this).data(DATA_KEY$5);
  3936. var _config = _objectSpread2({}, Default$3, {}, $(this).data(), {}, typeof config === 'object' && config ? config : {});
  3937. if (!data) {
  3938. data = new Modal(this, _config);
  3939. $(this).data(DATA_KEY$5, data);
  3940. }
  3941. if (typeof config === 'string') {
  3942. if (typeof data[config] === 'undefined') {
  3943. throw new TypeError("No method named \"" + config + "\"");
  3944. }
  3945. data[config](relatedTarget);
  3946. } else if (_config.show) {
  3947. data.show(relatedTarget);
  3948. }
  3949. });
  3950. };
  3951. _createClass(Modal, null, [{
  3952. key: "VERSION",
  3953. get: function get() {
  3954. return VERSION$5;
  3955. }
  3956. }, {
  3957. key: "Default",
  3958. get: function get() {
  3959. return Default$3;
  3960. }
  3961. }]);
  3962. return Modal;
  3963. }();
  3964. /**
  3965. * ------------------------------------------------------------------------
  3966. * Data Api implementation
  3967. * ------------------------------------------------------------------------
  3968. */
  3969. $(document).on(Event$5.CLICK_DATA_API, Selector$5.DATA_TOGGLE, function (event) {
  3970. var _this11 = this;
  3971. var target;
  3972. var selector = Util.getSelectorFromElement(this);
  3973. if (selector) {
  3974. target = document.querySelector(selector);
  3975. }
  3976. var config = $(target).data(DATA_KEY$5) ? 'toggle' : _objectSpread2({}, $(target).data(), {}, $(this).data());
  3977. if (this.tagName === 'A' || this.tagName === 'AREA') {
  3978. event.preventDefault();
  3979. }
  3980. var $target = $(target).one(Event$5.SHOW, function (showEvent) {
  3981. if (showEvent.isDefaultPrevented()) {
  3982. // Only register focus restorer if modal will actually get shown
  3983. return;
  3984. }
  3985. $target.one(Event$5.HIDDEN, function () {
  3986. if ($(_this11).is(':visible')) {
  3987. _this11.focus();
  3988. }
  3989. });
  3990. });
  3991. Modal._jQueryInterface.call($(target), config, this);
  3992. });
  3993. /**
  3994. * ------------------------------------------------------------------------
  3995. * jQuery
  3996. * ------------------------------------------------------------------------
  3997. */
  3998. $.fn[NAME$5] = Modal._jQueryInterface;
  3999. $.fn[NAME$5].Constructor = Modal;
  4000. $.fn[NAME$5].noConflict = function () {
  4001. $.fn[NAME$5] = JQUERY_NO_CONFLICT$5;
  4002. return Modal._jQueryInterface;
  4003. };
  4004. /**
  4005. * --------------------------------------------------------------------------
  4006. * Bootstrap (v4.4.1): tools/sanitizer.js
  4007. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
  4008. * --------------------------------------------------------------------------
  4009. */
  4010. var uriAttrs = ['background', 'cite', 'href', 'itemtype', 'longdesc', 'poster', 'src', 'xlink:href'];
  4011. var ARIA_ATTRIBUTE_PATTERN = /^aria-[\w-]*$/i;
  4012. var DefaultWhitelist = {
  4013. // Global attributes allowed on any supplied element below.
  4014. '*': ['class', 'dir', 'id', 'lang', 'role', ARIA_ATTRIBUTE_PATTERN],
  4015. a: ['target', 'href', 'title', 'rel'],
  4016. area: [],
  4017. b: [],
  4018. br: [],
  4019. col: [],
  4020. code: [],
  4021. div: [],
  4022. em: [],
  4023. hr: [],
  4024. h1: [],
  4025. h2: [],
  4026. h3: [],
  4027. h4: [],
  4028. h5: [],
  4029. h6: [],
  4030. i: [],
  4031. img: ['src', 'alt', 'title', 'width', 'height'],
  4032. li: [],
  4033. ol: [],
  4034. p: [],
  4035. pre: [],
  4036. s: [],
  4037. small: [],
  4038. span: [],
  4039. sub: [],
  4040. sup: [],
  4041. strong: [],
  4042. u: [],
  4043. ul: []
  4044. };
  4045. /**
  4046. * A pattern that recognizes a commonly useful subset of URLs that are safe.
  4047. *
  4048. * Shoutout to Angular 7 https://github.com/angular/angular/blob/7.2.4/packages/core/src/sanitization/url_sanitizer.ts
  4049. */
  4050. var SAFE_URL_PATTERN = /^(?:(?:https?|mailto|ftp|tel|file):|[^&:/?#]*(?:[/?#]|$))/gi;
  4051. /**
  4052. * A pattern that matches safe data URLs. Only matches image, video and audio types.
  4053. *
  4054. * Shoutout to Angular 7 https://github.com/angular/angular/blob/7.2.4/packages/core/src/sanitization/url_sanitizer.ts
  4055. */
  4056. 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;
  4057. function allowedAttribute(attr, allowedAttributeList) {
  4058. var attrName = attr.nodeName.toLowerCase();
  4059. if (allowedAttributeList.indexOf(attrName) !== -1) {
  4060. if (uriAttrs.indexOf(attrName) !== -1) {
  4061. return Boolean(attr.nodeValue.match(SAFE_URL_PATTERN) || attr.nodeValue.match(DATA_URL_PATTERN));
  4062. }
  4063. return true;
  4064. }
  4065. var regExp = allowedAttributeList.filter(function (attrRegex) {
  4066. return attrRegex instanceof RegExp;
  4067. }); // Check if a regular expression validates the attribute.
  4068. for (var i = 0, l = regExp.length; i < l; i++) {
  4069. if (attrName.match(regExp[i])) {
  4070. return true;
  4071. }
  4072. }
  4073. return false;
  4074. }
  4075. function sanitizeHtml(unsafeHtml, whiteList, sanitizeFn) {
  4076. if (unsafeHtml.length === 0) {
  4077. return unsafeHtml;
  4078. }
  4079. if (sanitizeFn && typeof sanitizeFn === 'function') {
  4080. return sanitizeFn(unsafeHtml);
  4081. }
  4082. var domParser = new window.DOMParser();
  4083. var createdDocument = domParser.parseFromString(unsafeHtml, 'text/html');
  4084. var whitelistKeys = Object.keys(whiteList);
  4085. var elements = [].slice.call(createdDocument.body.querySelectorAll('*'));
  4086. var _loop = function _loop(i, len) {
  4087. var el = elements[i];
  4088. var elName = el.nodeName.toLowerCase();
  4089. if (whitelistKeys.indexOf(el.nodeName.toLowerCase()) === -1) {
  4090. el.parentNode.removeChild(el);
  4091. return "continue";
  4092. }
  4093. var attributeList = [].slice.call(el.attributes);
  4094. var whitelistedAttributes = [].concat(whiteList['*'] || [], whiteList[elName] || []);
  4095. attributeList.forEach(function (attr) {
  4096. if (!allowedAttribute(attr, whitelistedAttributes)) {
  4097. el.removeAttribute(attr.nodeName);
  4098. }
  4099. });
  4100. };
  4101. for (var i = 0, len = elements.length; i < len; i++) {
  4102. var _ret = _loop(i);
  4103. if (_ret === "continue") continue;
  4104. }
  4105. return createdDocument.body.innerHTML;
  4106. }
  4107. /**
  4108. * ------------------------------------------------------------------------
  4109. * Constants
  4110. * ------------------------------------------------------------------------
  4111. */
  4112. var NAME$6 = 'tooltip';
  4113. var VERSION$6 = '4.4.1';
  4114. var DATA_KEY$6 = 'bs.tooltip';
  4115. var EVENT_KEY$6 = "." + DATA_KEY$6;
  4116. var JQUERY_NO_CONFLICT$6 = $.fn[NAME$6];
  4117. var CLASS_PREFIX = 'bs-tooltip';
  4118. var BSCLS_PREFIX_REGEX = new RegExp("(^|\\s)" + CLASS_PREFIX + "\\S+", 'g');
  4119. var DISALLOWED_ATTRIBUTES = ['sanitize', 'whiteList', 'sanitizeFn'];
  4120. var DefaultType$4 = {
  4121. animation: 'boolean',
  4122. template: 'string',
  4123. title: '(string|element|function)',
  4124. trigger: 'string',
  4125. delay: '(number|object)',
  4126. html: 'boolean',
  4127. selector: '(string|boolean)',
  4128. placement: '(string|function)',
  4129. offset: '(number|string|function)',
  4130. container: '(string|element|boolean)',
  4131. fallbackPlacement: '(string|array)',
  4132. boundary: '(string|element)',
  4133. sanitize: 'boolean',
  4134. sanitizeFn: '(null|function)',
  4135. whiteList: 'object',
  4136. popperConfig: '(null|object)'
  4137. };
  4138. var AttachmentMap$1 = {
  4139. AUTO: 'auto',
  4140. TOP: 'top',
  4141. RIGHT: 'right',
  4142. BOTTOM: 'bottom',
  4143. LEFT: 'left'
  4144. };
  4145. var Default$4 = {
  4146. animation: true,
  4147. template: '<div class="tooltip" role="tooltip">' + '<div class="arrow"></div>' + '<div class="tooltip-inner"></div></div>',
  4148. trigger: 'hover focus',
  4149. title: '',
  4150. delay: 0,
  4151. html: false,
  4152. selector: false,
  4153. placement: 'top',
  4154. offset: 0,
  4155. container: false,
  4156. fallbackPlacement: 'flip',
  4157. boundary: 'scrollParent',
  4158. sanitize: true,
  4159. sanitizeFn: null,
  4160. whiteList: DefaultWhitelist,
  4161. popperConfig: null
  4162. };
  4163. var HoverState = {
  4164. SHOW: 'show',
  4165. OUT: 'out'
  4166. };
  4167. var Event$6 = {
  4168. HIDE: "hide" + EVENT_KEY$6,
  4169. HIDDEN: "hidden" + EVENT_KEY$6,
  4170. SHOW: "show" + EVENT_KEY$6,
  4171. SHOWN: "shown" + EVENT_KEY$6,
  4172. INSERTED: "inserted" + EVENT_KEY$6,
  4173. CLICK: "click" + EVENT_KEY$6,
  4174. FOCUSIN: "focusin" + EVENT_KEY$6,
  4175. FOCUSOUT: "focusout" + EVENT_KEY$6,
  4176. MOUSEENTER: "mouseenter" + EVENT_KEY$6,
  4177. MOUSELEAVE: "mouseleave" + EVENT_KEY$6
  4178. };
  4179. var ClassName$6 = {
  4180. FADE: 'fade',
  4181. SHOW: 'show'
  4182. };
  4183. var Selector$6 = {
  4184. TOOLTIP: '.tooltip',
  4185. TOOLTIP_INNER: '.tooltip-inner',
  4186. ARROW: '.arrow'
  4187. };
  4188. var Trigger = {
  4189. HOVER: 'hover',
  4190. FOCUS: 'focus',
  4191. CLICK: 'click',
  4192. MANUAL: 'manual'
  4193. };
  4194. /**
  4195. * ------------------------------------------------------------------------
  4196. * Class Definition
  4197. * ------------------------------------------------------------------------
  4198. */
  4199. var Tooltip =
  4200. /*#__PURE__*/
  4201. function () {
  4202. function Tooltip(element, config) {
  4203. if (typeof Popper === 'undefined') {
  4204. throw new TypeError('Bootstrap\'s tooltips require Popper.js (https://popper.js.org/)');
  4205. } // private
  4206. this._isEnabled = true;
  4207. this._timeout = 0;
  4208. this._hoverState = '';
  4209. this._activeTrigger = {};
  4210. this._popper = null; // Protected
  4211. this.element = element;
  4212. this.config = this._getConfig(config);
  4213. this.tip = null;
  4214. this._setListeners();
  4215. } // Getters
  4216. var _proto = Tooltip.prototype;
  4217. // Public
  4218. _proto.enable = function enable() {
  4219. this._isEnabled = true;
  4220. };
  4221. _proto.disable = function disable() {
  4222. this._isEnabled = false;
  4223. };
  4224. _proto.toggleEnabled = function toggleEnabled() {
  4225. this._isEnabled = !this._isEnabled;
  4226. };
  4227. _proto.toggle = function toggle(event) {
  4228. if (!this._isEnabled) {
  4229. return;
  4230. }
  4231. if (event) {
  4232. var dataKey = this.constructor.DATA_KEY;
  4233. var context = $(event.currentTarget).data(dataKey);
  4234. if (!context) {
  4235. context = new this.constructor(event.currentTarget, this._getDelegateConfig());
  4236. $(event.currentTarget).data(dataKey, context);
  4237. }
  4238. context._activeTrigger.click = !context._activeTrigger.click;
  4239. if (context._isWithActiveTrigger()) {
  4240. context._enter(null, context);
  4241. } else {
  4242. context._leave(null, context);
  4243. }
  4244. } else {
  4245. if ($(this.getTipElement()).hasClass(ClassName$6.SHOW)) {
  4246. this._leave(null, this);
  4247. return;
  4248. }
  4249. this._enter(null, this);
  4250. }
  4251. };
  4252. _proto.dispose = function dispose() {
  4253. clearTimeout(this._timeout);
  4254. $.removeData(this.element, this.constructor.DATA_KEY);
  4255. $(this.element).off(this.constructor.EVENT_KEY);
  4256. $(this.element).closest('.modal').off('hide.bs.modal', this._hideModalHandler);
  4257. if (this.tip) {
  4258. $(this.tip).remove();
  4259. }
  4260. this._isEnabled = null;
  4261. this._timeout = null;
  4262. this._hoverState = null;
  4263. this._activeTrigger = null;
  4264. if (this._popper) {
  4265. this._popper.destroy();
  4266. }
  4267. this._popper = null;
  4268. this.element = null;
  4269. this.config = null;
  4270. this.tip = null;
  4271. };
  4272. _proto.show = function show() {
  4273. var _this = this;
  4274. if ($(this.element).css('display') === 'none') {
  4275. throw new Error('Please use show on visible elements');
  4276. }
  4277. var showEvent = $.Event(this.constructor.Event.SHOW);
  4278. if (this.isWithContent() && this._isEnabled) {
  4279. $(this.element).trigger(showEvent);
  4280. var shadowRoot = Util.findShadowRoot(this.element);
  4281. var isInTheDom = $.contains(shadowRoot !== null ? shadowRoot : this.element.ownerDocument.documentElement, this.element);
  4282. if (showEvent.isDefaultPrevented() || !isInTheDom) {
  4283. return;
  4284. }
  4285. var tip = this.getTipElement();
  4286. var tipId = Util.getUID(this.constructor.NAME);
  4287. tip.setAttribute('id', tipId);
  4288. this.element.setAttribute('aria-describedby', tipId);
  4289. this.setContent();
  4290. if (this.config.animation) {
  4291. $(tip).addClass(ClassName$6.FADE);
  4292. }
  4293. var placement = typeof this.config.placement === 'function' ? this.config.placement.call(this, tip, this.element) : this.config.placement;
  4294. var attachment = this._getAttachment(placement);
  4295. this.addAttachmentClass(attachment);
  4296. var container = this._getContainer();
  4297. $(tip).data(this.constructor.DATA_KEY, this);
  4298. if (!$.contains(this.element.ownerDocument.documentElement, this.tip)) {
  4299. $(tip).appendTo(container);
  4300. }
  4301. $(this.element).trigger(this.constructor.Event.INSERTED);
  4302. this._popper = new Popper(this.element, tip, this._getPopperConfig(attachment));
  4303. $(tip).addClass(ClassName$6.SHOW); // If this is a touch-enabled device we add extra
  4304. // empty mouseover listeners to the body's immediate children;
  4305. // only needed because of broken event delegation on iOS
  4306. // https://www.quirksmode.org/blog/archives/2014/02/mouse_event_bub.html
  4307. if ('ontouchstart' in document.documentElement) {
  4308. $(document.body).children().on('mouseover', null, $.noop);
  4309. }
  4310. var complete = function complete() {
  4311. if (_this.config.animation) {
  4312. _this._fixTransition();
  4313. }
  4314. var prevHoverState = _this._hoverState;
  4315. _this._hoverState = null;
  4316. $(_this.element).trigger(_this.constructor.Event.SHOWN);
  4317. if (prevHoverState === HoverState.OUT) {
  4318. _this._leave(null, _this);
  4319. }
  4320. };
  4321. if ($(this.tip).hasClass(ClassName$6.FADE)) {
  4322. var transitionDuration = Util.getTransitionDurationFromElement(this.tip);
  4323. $(this.tip).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration);
  4324. } else {
  4325. complete();
  4326. }
  4327. }
  4328. };
  4329. _proto.hide = function hide(callback) {
  4330. var _this2 = this;
  4331. var tip = this.getTipElement();
  4332. var hideEvent = $.Event(this.constructor.Event.HIDE);
  4333. var complete = function complete() {
  4334. if (_this2._hoverState !== HoverState.SHOW && tip.parentNode) {
  4335. tip.parentNode.removeChild(tip);
  4336. }
  4337. _this2._cleanTipClass();
  4338. _this2.element.removeAttribute('aria-describedby');
  4339. $(_this2.element).trigger(_this2.constructor.Event.HIDDEN);
  4340. if (_this2._popper !== null) {
  4341. _this2._popper.destroy();
  4342. }
  4343. if (callback) {
  4344. callback();
  4345. }
  4346. };
  4347. $(this.element).trigger(hideEvent);
  4348. if (hideEvent.isDefaultPrevented()) {
  4349. return;
  4350. }
  4351. $(tip).removeClass(ClassName$6.SHOW); // If this is a touch-enabled device we remove the extra
  4352. // empty mouseover listeners we added for iOS support
  4353. if ('ontouchstart' in document.documentElement) {
  4354. $(document.body).children().off('mouseover', null, $.noop);
  4355. }
  4356. this._activeTrigger[Trigger.CLICK] = false;
  4357. this._activeTrigger[Trigger.FOCUS] = false;
  4358. this._activeTrigger[Trigger.HOVER] = false;
  4359. if ($(this.tip).hasClass(ClassName$6.FADE)) {
  4360. var transitionDuration = Util.getTransitionDurationFromElement(tip);
  4361. $(tip).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration);
  4362. } else {
  4363. complete();
  4364. }
  4365. this._hoverState = '';
  4366. };
  4367. _proto.update = function update() {
  4368. if (this._popper !== null) {
  4369. this._popper.scheduleUpdate();
  4370. }
  4371. } // Protected
  4372. ;
  4373. _proto.isWithContent = function isWithContent() {
  4374. return Boolean(this.getTitle());
  4375. };
  4376. _proto.addAttachmentClass = function addAttachmentClass(attachment) {
  4377. $(this.getTipElement()).addClass(CLASS_PREFIX + "-" + attachment);
  4378. };
  4379. _proto.getTipElement = function getTipElement() {
  4380. this.tip = this.tip || $(this.config.template)[0];
  4381. return this.tip;
  4382. };
  4383. _proto.setContent = function setContent() {
  4384. var tip = this.getTipElement();
  4385. this.setElementContent($(tip.querySelectorAll(Selector$6.TOOLTIP_INNER)), this.getTitle());
  4386. $(tip).removeClass(ClassName$6.FADE + " " + ClassName$6.SHOW);
  4387. };
  4388. _proto.setElementContent = function setElementContent($element, content) {
  4389. if (typeof content === 'object' && (content.nodeType || content.jquery)) {
  4390. // Content is a DOM node or a jQuery
  4391. if (this.config.html) {
  4392. if (!$(content).parent().is($element)) {
  4393. $element.empty().append(content);
  4394. }
  4395. } else {
  4396. $element.text($(content).text());
  4397. }
  4398. return;
  4399. }
  4400. if (this.config.html) {
  4401. if (this.config.sanitize) {
  4402. content = sanitizeHtml(content, this.config.whiteList, this.config.sanitizeFn);
  4403. }
  4404. $element.html(content);
  4405. } else {
  4406. $element.text(content);
  4407. }
  4408. };
  4409. _proto.getTitle = function getTitle() {
  4410. var title = this.element.getAttribute('data-original-title');
  4411. if (!title) {
  4412. title = typeof this.config.title === 'function' ? this.config.title.call(this.element) : this.config.title;
  4413. }
  4414. return title;
  4415. } // Private
  4416. ;
  4417. _proto._getPopperConfig = function _getPopperConfig(attachment) {
  4418. var _this3 = this;
  4419. var defaultBsConfig = {
  4420. placement: attachment,
  4421. modifiers: {
  4422. offset: this._getOffset(),
  4423. flip: {
  4424. behavior: this.config.fallbackPlacement
  4425. },
  4426. arrow: {
  4427. element: Selector$6.ARROW
  4428. },
  4429. preventOverflow: {
  4430. boundariesElement: this.config.boundary
  4431. }
  4432. },
  4433. onCreate: function onCreate(data) {
  4434. if (data.originalPlacement !== data.placement) {
  4435. _this3._handlePopperPlacementChange(data);
  4436. }
  4437. },
  4438. onUpdate: function onUpdate(data) {
  4439. return _this3._handlePopperPlacementChange(data);
  4440. }
  4441. };
  4442. return _objectSpread2({}, defaultBsConfig, {}, this.config.popperConfig);
  4443. };
  4444. _proto._getOffset = function _getOffset() {
  4445. var _this4 = this;
  4446. var offset = {};
  4447. if (typeof this.config.offset === 'function') {
  4448. offset.fn = function (data) {
  4449. data.offsets = _objectSpread2({}, data.offsets, {}, _this4.config.offset(data.offsets, _this4.element) || {});
  4450. return data;
  4451. };
  4452. } else {
  4453. offset.offset = this.config.offset;
  4454. }
  4455. return offset;
  4456. };
  4457. _proto._getContainer = function _getContainer() {
  4458. if (this.config.container === false) {
  4459. return document.body;
  4460. }
  4461. if (Util.isElement(this.config.container)) {
  4462. return $(this.config.container);
  4463. }
  4464. return $(document).find(this.config.container);
  4465. };
  4466. _proto._getAttachment = function _getAttachment(placement) {
  4467. return AttachmentMap$1[placement.toUpperCase()];
  4468. };
  4469. _proto._setListeners = function _setListeners() {
  4470. var _this5 = this;
  4471. var triggers = this.config.trigger.split(' ');
  4472. triggers.forEach(function (trigger) {
  4473. if (trigger === 'click') {
  4474. $(_this5.element).on(_this5.constructor.Event.CLICK, _this5.config.selector, function (event) {
  4475. return _this5.toggle(event);
  4476. });
  4477. } else if (trigger !== Trigger.MANUAL) {
  4478. var eventIn = trigger === Trigger.HOVER ? _this5.constructor.Event.MOUSEENTER : _this5.constructor.Event.FOCUSIN;
  4479. var eventOut = trigger === Trigger.HOVER ? _this5.constructor.Event.MOUSELEAVE : _this5.constructor.Event.FOCUSOUT;
  4480. $(_this5.element).on(eventIn, _this5.config.selector, function (event) {
  4481. return _this5._enter(event);
  4482. }).on(eventOut, _this5.config.selector, function (event) {
  4483. return _this5._leave(event);
  4484. });
  4485. }
  4486. });
  4487. this._hideModalHandler = function () {
  4488. if (_this5.element) {
  4489. _this5.hide();
  4490. }
  4491. };
  4492. $(this.element).closest('.modal').on('hide.bs.modal', this._hideModalHandler);
  4493. if (this.config.selector) {
  4494. this.config = _objectSpread2({}, this.config, {
  4495. trigger: 'manual',
  4496. selector: ''
  4497. });
  4498. } else {
  4499. this._fixTitle();
  4500. }
  4501. };
  4502. _proto._fixTitle = function _fixTitle() {
  4503. var titleType = typeof this.element.getAttribute('data-original-title');
  4504. if (this.element.getAttribute('title') || titleType !== 'string') {
  4505. this.element.setAttribute('data-original-title', this.element.getAttribute('title') || '');
  4506. this.element.setAttribute('title', '');
  4507. }
  4508. };
  4509. _proto._enter = function _enter(event, context) {
  4510. var dataKey = this.constructor.DATA_KEY;
  4511. context = context || $(event.currentTarget).data(dataKey);
  4512. if (!context) {
  4513. context = new this.constructor(event.currentTarget, this._getDelegateConfig());
  4514. $(event.currentTarget).data(dataKey, context);
  4515. }
  4516. if (event) {
  4517. context._activeTrigger[event.type === 'focusin' ? Trigger.FOCUS : Trigger.HOVER] = true;
  4518. }
  4519. if ($(context.getTipElement()).hasClass(ClassName$6.SHOW) || context._hoverState === HoverState.SHOW) {
  4520. context._hoverState = HoverState.SHOW;
  4521. return;
  4522. }
  4523. clearTimeout(context._timeout);
  4524. context._hoverState = HoverState.SHOW;
  4525. if (!context.config.delay || !context.config.delay.show) {
  4526. context.show();
  4527. return;
  4528. }
  4529. context._timeout = setTimeout(function () {
  4530. if (context._hoverState === HoverState.SHOW) {
  4531. context.show();
  4532. }
  4533. }, context.config.delay.show);
  4534. };
  4535. _proto._leave = function _leave(event, context) {
  4536. var dataKey = this.constructor.DATA_KEY;
  4537. context = context || $(event.currentTarget).data(dataKey);
  4538. if (!context) {
  4539. context = new this.constructor(event.currentTarget, this._getDelegateConfig());
  4540. $(event.currentTarget).data(dataKey, context);
  4541. }
  4542. if (event) {
  4543. context._activeTrigger[event.type === 'focusout' ? Trigger.FOCUS : Trigger.HOVER] = false;
  4544. }
  4545. if (context._isWithActiveTrigger()) {
  4546. return;
  4547. }
  4548. clearTimeout(context._timeout);
  4549. context._hoverState = HoverState.OUT;
  4550. if (!context.config.delay || !context.config.delay.hide) {
  4551. context.hide();
  4552. return;
  4553. }
  4554. context._timeout = setTimeout(function () {
  4555. if (context._hoverState === HoverState.OUT) {
  4556. context.hide();
  4557. }
  4558. }, context.config.delay.hide);
  4559. };
  4560. _proto._isWithActiveTrigger = function _isWithActiveTrigger() {
  4561. for (var trigger in this._activeTrigger) {
  4562. if (this._activeTrigger[trigger]) {
  4563. return true;
  4564. }
  4565. }
  4566. return false;
  4567. };
  4568. _proto._getConfig = function _getConfig(config) {
  4569. var dataAttributes = $(this.element).data();
  4570. Object.keys(dataAttributes).forEach(function (dataAttr) {
  4571. if (DISALLOWED_ATTRIBUTES.indexOf(dataAttr) !== -1) {
  4572. delete dataAttributes[dataAttr];
  4573. }
  4574. });
  4575. config = _objectSpread2({}, this.constructor.Default, {}, dataAttributes, {}, typeof config === 'object' && config ? config : {});
  4576. if (typeof config.delay === 'number') {
  4577. config.delay = {
  4578. show: config.delay,
  4579. hide: config.delay
  4580. };
  4581. }
  4582. if (typeof config.title === 'number') {
  4583. config.title = config.title.toString();
  4584. }
  4585. if (typeof config.content === 'number') {
  4586. config.content = config.content.toString();
  4587. }
  4588. Util.typeCheckConfig(NAME$6, config, this.constructor.DefaultType);
  4589. if (config.sanitize) {
  4590. config.template = sanitizeHtml(config.template, config.whiteList, config.sanitizeFn);
  4591. }
  4592. return config;
  4593. };
  4594. _proto._getDelegateConfig = function _getDelegateConfig() {
  4595. var config = {};
  4596. if (this.config) {
  4597. for (var key in this.config) {
  4598. if (this.constructor.Default[key] !== this.config[key]) {
  4599. config[key] = this.config[key];
  4600. }
  4601. }
  4602. }
  4603. return config;
  4604. };
  4605. _proto._cleanTipClass = function _cleanTipClass() {
  4606. var $tip = $(this.getTipElement());
  4607. var tabClass = $tip.attr('class').match(BSCLS_PREFIX_REGEX);
  4608. if (tabClass !== null && tabClass.length) {
  4609. $tip.removeClass(tabClass.join(''));
  4610. }
  4611. };
  4612. _proto._handlePopperPlacementChange = function _handlePopperPlacementChange(popperData) {
  4613. var popperInstance = popperData.instance;
  4614. this.tip = popperInstance.popper;
  4615. this._cleanTipClass();
  4616. this.addAttachmentClass(this._getAttachment(popperData.placement));
  4617. };
  4618. _proto._fixTransition = function _fixTransition() {
  4619. var tip = this.getTipElement();
  4620. var initConfigAnimation = this.config.animation;
  4621. if (tip.getAttribute('x-placement') !== null) {
  4622. return;
  4623. }
  4624. $(tip).removeClass(ClassName$6.FADE);
  4625. this.config.animation = false;
  4626. this.hide();
  4627. this.show();
  4628. this.config.animation = initConfigAnimation;
  4629. } // Static
  4630. ;
  4631. Tooltip._jQueryInterface = function _jQueryInterface(config) {
  4632. return this.each(function () {
  4633. var data = $(this).data(DATA_KEY$6);
  4634. var _config = typeof config === 'object' && config;
  4635. if (!data && /dispose|hide/.test(config)) {
  4636. return;
  4637. }
  4638. if (!data) {
  4639. data = new Tooltip(this, _config);
  4640. $(this).data(DATA_KEY$6, data);
  4641. }
  4642. if (typeof config === 'string') {
  4643. if (typeof data[config] === 'undefined') {
  4644. throw new TypeError("No method named \"" + config + "\"");
  4645. }
  4646. data[config]();
  4647. }
  4648. });
  4649. };
  4650. _createClass(Tooltip, null, [{
  4651. key: "VERSION",
  4652. get: function get() {
  4653. return VERSION$6;
  4654. }
  4655. }, {
  4656. key: "Default",
  4657. get: function get() {
  4658. return Default$4;
  4659. }
  4660. }, {
  4661. key: "NAME",
  4662. get: function get() {
  4663. return NAME$6;
  4664. }
  4665. }, {
  4666. key: "DATA_KEY",
  4667. get: function get() {
  4668. return DATA_KEY$6;
  4669. }
  4670. }, {
  4671. key: "Event",
  4672. get: function get() {
  4673. return Event$6;
  4674. }
  4675. }, {
  4676. key: "EVENT_KEY",
  4677. get: function get() {
  4678. return EVENT_KEY$6;
  4679. }
  4680. }, {
  4681. key: "DefaultType",
  4682. get: function get() {
  4683. return DefaultType$4;
  4684. }
  4685. }]);
  4686. return Tooltip;
  4687. }();
  4688. /**
  4689. * ------------------------------------------------------------------------
  4690. * jQuery
  4691. * ------------------------------------------------------------------------
  4692. */
  4693. $.fn[NAME$6] = Tooltip._jQueryInterface;
  4694. $.fn[NAME$6].Constructor = Tooltip;
  4695. $.fn[NAME$6].noConflict = function () {
  4696. $.fn[NAME$6] = JQUERY_NO_CONFLICT$6;
  4697. return Tooltip._jQueryInterface;
  4698. };
  4699. /**
  4700. * ------------------------------------------------------------------------
  4701. * Constants
  4702. * ------------------------------------------------------------------------
  4703. */
  4704. var NAME$7 = 'popover';
  4705. var VERSION$7 = '4.4.1';
  4706. var DATA_KEY$7 = 'bs.popover';
  4707. var EVENT_KEY$7 = "." + DATA_KEY$7;
  4708. var JQUERY_NO_CONFLICT$7 = $.fn[NAME$7];
  4709. var CLASS_PREFIX$1 = 'bs-popover';
  4710. var BSCLS_PREFIX_REGEX$1 = new RegExp("(^|\\s)" + CLASS_PREFIX$1 + "\\S+", 'g');
  4711. var Default$5 = _objectSpread2({}, Tooltip.Default, {
  4712. placement: 'right',
  4713. trigger: 'click',
  4714. content: '',
  4715. template: '<div class="popover" role="tooltip">' + '<div class="arrow"></div>' + '<h3 class="popover-header"></h3>' + '<div class="popover-body"></div></div>'
  4716. });
  4717. var DefaultType$5 = _objectSpread2({}, Tooltip.DefaultType, {
  4718. content: '(string|element|function)'
  4719. });
  4720. var ClassName$7 = {
  4721. FADE: 'fade',
  4722. SHOW: 'show'
  4723. };
  4724. var Selector$7 = {
  4725. TITLE: '.popover-header',
  4726. CONTENT: '.popover-body'
  4727. };
  4728. var Event$7 = {
  4729. HIDE: "hide" + EVENT_KEY$7,
  4730. HIDDEN: "hidden" + EVENT_KEY$7,
  4731. SHOW: "show" + EVENT_KEY$7,
  4732. SHOWN: "shown" + EVENT_KEY$7,
  4733. INSERTED: "inserted" + EVENT_KEY$7,
  4734. CLICK: "click" + EVENT_KEY$7,
  4735. FOCUSIN: "focusin" + EVENT_KEY$7,
  4736. FOCUSOUT: "focusout" + EVENT_KEY$7,
  4737. MOUSEENTER: "mouseenter" + EVENT_KEY$7,
  4738. MOUSELEAVE: "mouseleave" + EVENT_KEY$7
  4739. };
  4740. /**
  4741. * ------------------------------------------------------------------------
  4742. * Class Definition
  4743. * ------------------------------------------------------------------------
  4744. */
  4745. var Popover =
  4746. /*#__PURE__*/
  4747. function (_Tooltip) {
  4748. _inheritsLoose(Popover, _Tooltip);
  4749. function Popover() {
  4750. return _Tooltip.apply(this, arguments) || this;
  4751. }
  4752. var _proto = Popover.prototype;
  4753. // Overrides
  4754. _proto.isWithContent = function isWithContent() {
  4755. return this.getTitle() || this._getContent();
  4756. };
  4757. _proto.addAttachmentClass = function addAttachmentClass(attachment) {
  4758. $(this.getTipElement()).addClass(CLASS_PREFIX$1 + "-" + attachment);
  4759. };
  4760. _proto.getTipElement = function getTipElement() {
  4761. this.tip = this.tip || $(this.config.template)[0];
  4762. return this.tip;
  4763. };
  4764. _proto.setContent = function setContent() {
  4765. var $tip = $(this.getTipElement()); // We use append for html objects to maintain js events
  4766. this.setElementContent($tip.find(Selector$7.TITLE), this.getTitle());
  4767. var content = this._getContent();
  4768. if (typeof content === 'function') {
  4769. content = content.call(this.element);
  4770. }
  4771. this.setElementContent($tip.find(Selector$7.CONTENT), content);
  4772. $tip.removeClass(ClassName$7.FADE + " " + ClassName$7.SHOW);
  4773. } // Private
  4774. ;
  4775. _proto._getContent = function _getContent() {
  4776. return this.element.getAttribute('data-content') || this.config.content;
  4777. };
  4778. _proto._cleanTipClass = function _cleanTipClass() {
  4779. var $tip = $(this.getTipElement());
  4780. var tabClass = $tip.attr('class').match(BSCLS_PREFIX_REGEX$1);
  4781. if (tabClass !== null && tabClass.length > 0) {
  4782. $tip.removeClass(tabClass.join(''));
  4783. }
  4784. } // Static
  4785. ;
  4786. Popover._jQueryInterface = function _jQueryInterface(config) {
  4787. return this.each(function () {
  4788. var data = $(this).data(DATA_KEY$7);
  4789. var _config = typeof config === 'object' ? config : null;
  4790. if (!data && /dispose|hide/.test(config)) {
  4791. return;
  4792. }
  4793. if (!data) {
  4794. data = new Popover(this, _config);
  4795. $(this).data(DATA_KEY$7, data);
  4796. }
  4797. if (typeof config === 'string') {
  4798. if (typeof data[config] === 'undefined') {
  4799. throw new TypeError("No method named \"" + config + "\"");
  4800. }
  4801. data[config]();
  4802. }
  4803. });
  4804. };
  4805. _createClass(Popover, null, [{
  4806. key: "VERSION",
  4807. // Getters
  4808. get: function get() {
  4809. return VERSION$7;
  4810. }
  4811. }, {
  4812. key: "Default",
  4813. get: function get() {
  4814. return Default$5;
  4815. }
  4816. }, {
  4817. key: "NAME",
  4818. get: function get() {
  4819. return NAME$7;
  4820. }
  4821. }, {
  4822. key: "DATA_KEY",
  4823. get: function get() {
  4824. return DATA_KEY$7;
  4825. }
  4826. }, {
  4827. key: "Event",
  4828. get: function get() {
  4829. return Event$7;
  4830. }
  4831. }, {
  4832. key: "EVENT_KEY",
  4833. get: function get() {
  4834. return EVENT_KEY$7;
  4835. }
  4836. }, {
  4837. key: "DefaultType",
  4838. get: function get() {
  4839. return DefaultType$5;
  4840. }
  4841. }]);
  4842. return Popover;
  4843. }(Tooltip);
  4844. /**
  4845. * ------------------------------------------------------------------------
  4846. * jQuery
  4847. * ------------------------------------------------------------------------
  4848. */
  4849. $.fn[NAME$7] = Popover._jQueryInterface;
  4850. $.fn[NAME$7].Constructor = Popover;
  4851. $.fn[NAME$7].noConflict = function () {
  4852. $.fn[NAME$7] = JQUERY_NO_CONFLICT$7;
  4853. return Popover._jQueryInterface;
  4854. };
  4855. /**
  4856. * ------------------------------------------------------------------------
  4857. * Constants
  4858. * ------------------------------------------------------------------------
  4859. */
  4860. var NAME$8 = 'scrollspy';
  4861. var VERSION$8 = '4.4.1';
  4862. var DATA_KEY$8 = 'bs.scrollspy';
  4863. var EVENT_KEY$8 = "." + DATA_KEY$8;
  4864. var DATA_API_KEY$6 = '.data-api';
  4865. var JQUERY_NO_CONFLICT$8 = $.fn[NAME$8];
  4866. var Default$6 = {
  4867. offset: 10,
  4868. method: 'auto',
  4869. target: ''
  4870. };
  4871. var DefaultType$6 = {
  4872. offset: 'number',
  4873. method: 'string',
  4874. target: '(string|element)'
  4875. };
  4876. var Event$8 = {
  4877. ACTIVATE: "activate" + EVENT_KEY$8,
  4878. SCROLL: "scroll" + EVENT_KEY$8,
  4879. LOAD_DATA_API: "load" + EVENT_KEY$8 + DATA_API_KEY$6
  4880. };
  4881. var ClassName$8 = {
  4882. DROPDOWN_ITEM: 'dropdown-item',
  4883. DROPDOWN_MENU: 'dropdown-menu',
  4884. ACTIVE: 'active'
  4885. };
  4886. var Selector$8 = {
  4887. DATA_SPY: '[data-spy="scroll"]',
  4888. ACTIVE: '.active',
  4889. NAV_LIST_GROUP: '.nav, .list-group',
  4890. NAV_LINKS: '.nav-link',
  4891. NAV_ITEMS: '.nav-item',
  4892. LIST_ITEMS: '.list-group-item',
  4893. DROPDOWN: '.dropdown',
  4894. DROPDOWN_ITEMS: '.dropdown-item',
  4895. DROPDOWN_TOGGLE: '.dropdown-toggle'
  4896. };
  4897. var OffsetMethod = {
  4898. OFFSET: 'offset',
  4899. POSITION: 'position'
  4900. };
  4901. /**
  4902. * ------------------------------------------------------------------------
  4903. * Class Definition
  4904. * ------------------------------------------------------------------------
  4905. */
  4906. var ScrollSpy =
  4907. /*#__PURE__*/
  4908. function () {
  4909. function ScrollSpy(element, config) {
  4910. var _this = this;
  4911. this._element = element;
  4912. this._scrollElement = element.tagName === 'BODY' ? window : element;
  4913. this._config = this._getConfig(config);
  4914. this._selector = this._config.target + " " + Selector$8.NAV_LINKS + "," + (this._config.target + " " + Selector$8.LIST_ITEMS + ",") + (this._config.target + " " + Selector$8.DROPDOWN_ITEMS);
  4915. this._offsets = [];
  4916. this._targets = [];
  4917. this._activeTarget = null;
  4918. this._scrollHeight = 0;
  4919. $(this._scrollElement).on(Event$8.SCROLL, function (event) {
  4920. return _this._process(event);
  4921. });
  4922. this.refresh();
  4923. this._process();
  4924. } // Getters
  4925. var _proto = ScrollSpy.prototype;
  4926. // Public
  4927. _proto.refresh = function refresh() {
  4928. var _this2 = this;
  4929. var autoMethod = this._scrollElement === this._scrollElement.window ? OffsetMethod.OFFSET : OffsetMethod.POSITION;
  4930. var offsetMethod = this._config.method === 'auto' ? autoMethod : this._config.method;
  4931. var offsetBase = offsetMethod === OffsetMethod.POSITION ? this._getScrollTop() : 0;
  4932. this._offsets = [];
  4933. this._targets = [];
  4934. this._scrollHeight = this._getScrollHeight();
  4935. var targets = [].slice.call(document.querySelectorAll(this._selector));
  4936. targets.map(function (element) {
  4937. var target;
  4938. var targetSelector = Util.getSelectorFromElement(element);
  4939. if (targetSelector) {
  4940. target = document.querySelector(targetSelector);
  4941. }
  4942. if (target) {
  4943. var targetBCR = target.getBoundingClientRect();
  4944. if (targetBCR.width || targetBCR.height) {
  4945. // TODO (fat): remove sketch reliance on jQuery position/offset
  4946. return [$(target)[offsetMethod]().top + offsetBase, targetSelector];
  4947. }
  4948. }
  4949. return null;
  4950. }).filter(function (item) {
  4951. return item;
  4952. }).sort(function (a, b) {
  4953. return a[0] - b[0];
  4954. }).forEach(function (item) {
  4955. _this2._offsets.push(item[0]);
  4956. _this2._targets.push(item[1]);
  4957. });
  4958. };
  4959. _proto.dispose = function dispose() {
  4960. $.removeData(this._element, DATA_KEY$8);
  4961. $(this._scrollElement).off(EVENT_KEY$8);
  4962. this._element = null;
  4963. this._scrollElement = null;
  4964. this._config = null;
  4965. this._selector = null;
  4966. this._offsets = null;
  4967. this._targets = null;
  4968. this._activeTarget = null;
  4969. this._scrollHeight = null;
  4970. } // Private
  4971. ;
  4972. _proto._getConfig = function _getConfig(config) {
  4973. config = _objectSpread2({}, Default$6, {}, typeof config === 'object' && config ? config : {});
  4974. if (typeof config.target !== 'string') {
  4975. var id = $(config.target).attr('id');
  4976. if (!id) {
  4977. id = Util.getUID(NAME$8);
  4978. $(config.target).attr('id', id);
  4979. }
  4980. config.target = "#" + id;
  4981. }
  4982. Util.typeCheckConfig(NAME$8, config, DefaultType$6);
  4983. return config;
  4984. };
  4985. _proto._getScrollTop = function _getScrollTop() {
  4986. return this._scrollElement === window ? this._scrollElement.pageYOffset : this._scrollElement.scrollTop;
  4987. };
  4988. _proto._getScrollHeight = function _getScrollHeight() {
  4989. return this._scrollElement.scrollHeight || Math.max(document.body.scrollHeight, document.documentElement.scrollHeight);
  4990. };
  4991. _proto._getOffsetHeight = function _getOffsetHeight() {
  4992. return this._scrollElement === window ? window.innerHeight : this._scrollElement.getBoundingClientRect().height;
  4993. };
  4994. _proto._process = function _process() {
  4995. var scrollTop = this._getScrollTop() + this._config.offset;
  4996. var scrollHeight = this._getScrollHeight();
  4997. var maxScroll = this._config.offset + scrollHeight - this._getOffsetHeight();
  4998. if (this._scrollHeight !== scrollHeight) {
  4999. this.refresh();
  5000. }
  5001. if (scrollTop >= maxScroll) {
  5002. var target = this._targets[this._targets.length - 1];
  5003. if (this._activeTarget !== target) {
  5004. this._activate(target);
  5005. }
  5006. return;
  5007. }
  5008. if (this._activeTarget && scrollTop < this._offsets[0] && this._offsets[0] > 0) {
  5009. this._activeTarget = null;
  5010. this._clear();
  5011. return;
  5012. }
  5013. var offsetLength = this._offsets.length;
  5014. for (var i = offsetLength; i--;) {
  5015. var isActiveTarget = this._activeTarget !== this._targets[i] && scrollTop >= this._offsets[i] && (typeof this._offsets[i + 1] === 'undefined' || scrollTop < this._offsets[i + 1]);
  5016. if (isActiveTarget) {
  5017. this._activate(this._targets[i]);
  5018. }
  5019. }
  5020. };
  5021. _proto._activate = function _activate(target) {
  5022. this._activeTarget = target;
  5023. this._clear();
  5024. var queries = this._selector.split(',').map(function (selector) {
  5025. return selector + "[data-target=\"" + target + "\"]," + selector + "[href=\"" + target + "\"]";
  5026. });
  5027. var $link = $([].slice.call(document.querySelectorAll(queries.join(','))));
  5028. if ($link.hasClass(ClassName$8.DROPDOWN_ITEM)) {
  5029. $link.closest(Selector$8.DROPDOWN).find(Selector$8.DROPDOWN_TOGGLE).addClass(ClassName$8.ACTIVE);
  5030. $link.addClass(ClassName$8.ACTIVE);
  5031. } else {
  5032. // Set triggered link as active
  5033. $link.addClass(ClassName$8.ACTIVE); // Set triggered links parents as active
  5034. // With both <ul> and <nav> markup a parent is the previous sibling of any nav ancestor
  5035. $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
  5036. $link.parents(Selector$8.NAV_LIST_GROUP).prev(Selector$8.NAV_ITEMS).children(Selector$8.NAV_LINKS).addClass(ClassName$8.ACTIVE);
  5037. }
  5038. $(this._scrollElement).trigger(Event$8.ACTIVATE, {
  5039. relatedTarget: target
  5040. });
  5041. };
  5042. _proto._clear = function _clear() {
  5043. [].slice.call(document.querySelectorAll(this._selector)).filter(function (node) {
  5044. return node.classList.contains(ClassName$8.ACTIVE);
  5045. }).forEach(function (node) {
  5046. return node.classList.remove(ClassName$8.ACTIVE);
  5047. });
  5048. } // Static
  5049. ;
  5050. ScrollSpy._jQueryInterface = function _jQueryInterface(config) {
  5051. return this.each(function () {
  5052. var data = $(this).data(DATA_KEY$8);
  5053. var _config = typeof config === 'object' && config;
  5054. if (!data) {
  5055. data = new ScrollSpy(this, _config);
  5056. $(this).data(DATA_KEY$8, data);
  5057. }
  5058. if (typeof config === 'string') {
  5059. if (typeof data[config] === 'undefined') {
  5060. throw new TypeError("No method named \"" + config + "\"");
  5061. }
  5062. data[config]();
  5063. }
  5064. });
  5065. };
  5066. _createClass(ScrollSpy, null, [{
  5067. key: "VERSION",
  5068. get: function get() {
  5069. return VERSION$8;
  5070. }
  5071. }, {
  5072. key: "Default",
  5073. get: function get() {
  5074. return Default$6;
  5075. }
  5076. }]);
  5077. return ScrollSpy;
  5078. }();
  5079. /**
  5080. * ------------------------------------------------------------------------
  5081. * Data Api implementation
  5082. * ------------------------------------------------------------------------
  5083. */
  5084. $(window).on(Event$8.LOAD_DATA_API, function () {
  5085. var scrollSpys = [].slice.call(document.querySelectorAll(Selector$8.DATA_SPY));
  5086. var scrollSpysLength = scrollSpys.length;
  5087. for (var i = scrollSpysLength; i--;) {
  5088. var $spy = $(scrollSpys[i]);
  5089. ScrollSpy._jQueryInterface.call($spy, $spy.data());
  5090. }
  5091. });
  5092. /**
  5093. * ------------------------------------------------------------------------
  5094. * jQuery
  5095. * ------------------------------------------------------------------------
  5096. */
  5097. $.fn[NAME$8] = ScrollSpy._jQueryInterface;
  5098. $.fn[NAME$8].Constructor = ScrollSpy;
  5099. $.fn[NAME$8].noConflict = function () {
  5100. $.fn[NAME$8] = JQUERY_NO_CONFLICT$8;
  5101. return ScrollSpy._jQueryInterface;
  5102. };
  5103. /**
  5104. * ------------------------------------------------------------------------
  5105. * Constants
  5106. * ------------------------------------------------------------------------
  5107. */
  5108. var NAME$9 = 'tab';
  5109. var VERSION$9 = '4.4.1';
  5110. var DATA_KEY$9 = 'bs.tab';
  5111. var EVENT_KEY$9 = "." + DATA_KEY$9;
  5112. var DATA_API_KEY$7 = '.data-api';
  5113. var JQUERY_NO_CONFLICT$9 = $.fn[NAME$9];
  5114. var Event$9 = {
  5115. HIDE: "hide" + EVENT_KEY$9,
  5116. HIDDEN: "hidden" + EVENT_KEY$9,
  5117. SHOW: "show" + EVENT_KEY$9,
  5118. SHOWN: "shown" + EVENT_KEY$9,
  5119. CLICK_DATA_API: "click" + EVENT_KEY$9 + DATA_API_KEY$7
  5120. };
  5121. var ClassName$9 = {
  5122. DROPDOWN_MENU: 'dropdown-menu',
  5123. ACTIVE: 'active',
  5124. DISABLED: 'disabled',
  5125. FADE: 'fade',
  5126. SHOW: 'show'
  5127. };
  5128. var Selector$9 = {
  5129. DROPDOWN: '.dropdown',
  5130. NAV_LIST_GROUP: '.nav, .list-group',
  5131. ACTIVE: '.active',
  5132. ACTIVE_UL: '> li > .active',
  5133. DATA_TOGGLE: '[data-toggle="tab"], [data-toggle="pill"], [data-toggle="list"]',
  5134. DROPDOWN_TOGGLE: '.dropdown-toggle',
  5135. DROPDOWN_ACTIVE_CHILD: '> .dropdown-menu .active'
  5136. };
  5137. /**
  5138. * ------------------------------------------------------------------------
  5139. * Class Definition
  5140. * ------------------------------------------------------------------------
  5141. */
  5142. var Tab =
  5143. /*#__PURE__*/
  5144. function () {
  5145. function Tab(element) {
  5146. this._element = element;
  5147. } // Getters
  5148. var _proto = Tab.prototype;
  5149. // Public
  5150. _proto.show = function show() {
  5151. var _this = this;
  5152. if (this._element.parentNode && this._element.parentNode.nodeType === Node.ELEMENT_NODE && $(this._element).hasClass(ClassName$9.ACTIVE) || $(this._element).hasClass(ClassName$9.DISABLED)) {
  5153. return;
  5154. }
  5155. var target;
  5156. var previous;
  5157. var listElement = $(this._element).closest(Selector$9.NAV_LIST_GROUP)[0];
  5158. var selector = Util.getSelectorFromElement(this._element);
  5159. if (listElement) {
  5160. var itemSelector = listElement.nodeName === 'UL' || listElement.nodeName === 'OL' ? Selector$9.ACTIVE_UL : Selector$9.ACTIVE;
  5161. previous = $.makeArray($(listElement).find(itemSelector));
  5162. previous = previous[previous.length - 1];
  5163. }
  5164. var hideEvent = $.Event(Event$9.HIDE, {
  5165. relatedTarget: this._element
  5166. });
  5167. var showEvent = $.Event(Event$9.SHOW, {
  5168. relatedTarget: previous
  5169. });
  5170. if (previous) {
  5171. $(previous).trigger(hideEvent);
  5172. }
  5173. $(this._element).trigger(showEvent);
  5174. if (showEvent.isDefaultPrevented() || hideEvent.isDefaultPrevented()) {
  5175. return;
  5176. }
  5177. if (selector) {
  5178. target = document.querySelector(selector);
  5179. }
  5180. this._activate(this._element, listElement);
  5181. var complete = function complete() {
  5182. var hiddenEvent = $.Event(Event$9.HIDDEN, {
  5183. relatedTarget: _this._element
  5184. });
  5185. var shownEvent = $.Event(Event$9.SHOWN, {
  5186. relatedTarget: previous
  5187. });
  5188. $(previous).trigger(hiddenEvent);
  5189. $(_this._element).trigger(shownEvent);
  5190. };
  5191. if (target) {
  5192. this._activate(target, target.parentNode, complete);
  5193. } else {
  5194. complete();
  5195. }
  5196. };
  5197. _proto.dispose = function dispose() {
  5198. $.removeData(this._element, DATA_KEY$9);
  5199. this._element = null;
  5200. } // Private
  5201. ;
  5202. _proto._activate = function _activate(element, container, callback) {
  5203. var _this2 = this;
  5204. var activeElements = container && (container.nodeName === 'UL' || container.nodeName === 'OL') ? $(container).find(Selector$9.ACTIVE_UL) : $(container).children(Selector$9.ACTIVE);
  5205. var active = activeElements[0];
  5206. var isTransitioning = callback && active && $(active).hasClass(ClassName$9.FADE);
  5207. var complete = function complete() {
  5208. return _this2._transitionComplete(element, active, callback);
  5209. };
  5210. if (active && isTransitioning) {
  5211. var transitionDuration = Util.getTransitionDurationFromElement(active);
  5212. $(active).removeClass(ClassName$9.SHOW).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration);
  5213. } else {
  5214. complete();
  5215. }
  5216. };
  5217. _proto._transitionComplete = function _transitionComplete(element, active, callback) {
  5218. if (active) {
  5219. $(active).removeClass(ClassName$9.ACTIVE);
  5220. var dropdownChild = $(active.parentNode).find(Selector$9.DROPDOWN_ACTIVE_CHILD)[0];
  5221. if (dropdownChild) {
  5222. $(dropdownChild).removeClass(ClassName$9.ACTIVE);
  5223. }
  5224. if (active.getAttribute('role') === 'tab') {
  5225. active.setAttribute('aria-selected', false);
  5226. }
  5227. }
  5228. $(element).addClass(ClassName$9.ACTIVE);
  5229. if (element.getAttribute('role') === 'tab') {
  5230. element.setAttribute('aria-selected', true);
  5231. }
  5232. Util.reflow(element);
  5233. if (element.classList.contains(ClassName$9.FADE)) {
  5234. element.classList.add(ClassName$9.SHOW);
  5235. }
  5236. if (element.parentNode && $(element.parentNode).hasClass(ClassName$9.DROPDOWN_MENU)) {
  5237. var dropdownElement = $(element).closest(Selector$9.DROPDOWN)[0];
  5238. if (dropdownElement) {
  5239. var dropdownToggleList = [].slice.call(dropdownElement.querySelectorAll(Selector$9.DROPDOWN_TOGGLE));
  5240. $(dropdownToggleList).addClass(ClassName$9.ACTIVE);
  5241. }
  5242. element.setAttribute('aria-expanded', true);
  5243. }
  5244. if (callback) {
  5245. callback();
  5246. }
  5247. } // Static
  5248. ;
  5249. Tab._jQueryInterface = function _jQueryInterface(config) {
  5250. return this.each(function () {
  5251. var $this = $(this);
  5252. var data = $this.data(DATA_KEY$9);
  5253. if (!data) {
  5254. data = new Tab(this);
  5255. $this.data(DATA_KEY$9, data);
  5256. }
  5257. if (typeof config === 'string') {
  5258. if (typeof data[config] === 'undefined') {
  5259. throw new TypeError("No method named \"" + config + "\"");
  5260. }
  5261. data[config]();
  5262. }
  5263. });
  5264. };
  5265. _createClass(Tab, null, [{
  5266. key: "VERSION",
  5267. get: function get() {
  5268. return VERSION$9;
  5269. }
  5270. }]);
  5271. return Tab;
  5272. }();
  5273. /**
  5274. * ------------------------------------------------------------------------
  5275. * Data Api implementation
  5276. * ------------------------------------------------------------------------
  5277. */
  5278. $(document).on(Event$9.CLICK_DATA_API, Selector$9.DATA_TOGGLE, function (event) {
  5279. event.preventDefault();
  5280. Tab._jQueryInterface.call($(this), 'show');
  5281. });
  5282. /**
  5283. * ------------------------------------------------------------------------
  5284. * jQuery
  5285. * ------------------------------------------------------------------------
  5286. */
  5287. $.fn[NAME$9] = Tab._jQueryInterface;
  5288. $.fn[NAME$9].Constructor = Tab;
  5289. $.fn[NAME$9].noConflict = function () {
  5290. $.fn[NAME$9] = JQUERY_NO_CONFLICT$9;
  5291. return Tab._jQueryInterface;
  5292. };
  5293. /**
  5294. * ------------------------------------------------------------------------
  5295. * Constants
  5296. * ------------------------------------------------------------------------
  5297. */
  5298. var NAME$a = 'toast';
  5299. var VERSION$a = '4.4.1';
  5300. var DATA_KEY$a = 'bs.toast';
  5301. var EVENT_KEY$a = "." + DATA_KEY$a;
  5302. var JQUERY_NO_CONFLICT$a = $.fn[NAME$a];
  5303. var Event$a = {
  5304. CLICK_DISMISS: "click.dismiss" + EVENT_KEY$a,
  5305. HIDE: "hide" + EVENT_KEY$a,
  5306. HIDDEN: "hidden" + EVENT_KEY$a,
  5307. SHOW: "show" + EVENT_KEY$a,
  5308. SHOWN: "shown" + EVENT_KEY$a
  5309. };
  5310. var ClassName$a = {
  5311. FADE: 'fade',
  5312. HIDE: 'hide',
  5313. SHOW: 'show',
  5314. SHOWING: 'showing'
  5315. };
  5316. var DefaultType$7 = {
  5317. animation: 'boolean',
  5318. autohide: 'boolean',
  5319. delay: 'number'
  5320. };
  5321. var Default$7 = {
  5322. animation: true,
  5323. autohide: true,
  5324. delay: 500
  5325. };
  5326. var Selector$a = {
  5327. DATA_DISMISS: '[data-dismiss="toast"]'
  5328. };
  5329. /**
  5330. * ------------------------------------------------------------------------
  5331. * Class Definition
  5332. * ------------------------------------------------------------------------
  5333. */
  5334. var Toast =
  5335. /*#__PURE__*/
  5336. function () {
  5337. function Toast(element, config) {
  5338. this._element = element;
  5339. this._config = this._getConfig(config);
  5340. this._timeout = null;
  5341. this._setListeners();
  5342. } // Getters
  5343. var _proto = Toast.prototype;
  5344. // Public
  5345. _proto.show = function show() {
  5346. var _this = this;
  5347. var showEvent = $.Event(Event$a.SHOW);
  5348. $(this._element).trigger(showEvent);
  5349. if (showEvent.isDefaultPrevented()) {
  5350. return;
  5351. }
  5352. if (this._config.animation) {
  5353. this._element.classList.add(ClassName$a.FADE);
  5354. }
  5355. var complete = function complete() {
  5356. _this._element.classList.remove(ClassName$a.SHOWING);
  5357. _this._element.classList.add(ClassName$a.SHOW);
  5358. $(_this._element).trigger(Event$a.SHOWN);
  5359. if (_this._config.autohide) {
  5360. _this._timeout = setTimeout(function () {
  5361. _this.hide();
  5362. }, _this._config.delay);
  5363. }
  5364. };
  5365. this._element.classList.remove(ClassName$a.HIDE);
  5366. Util.reflow(this._element);
  5367. this._element.classList.add(ClassName$a.SHOWING);
  5368. if (this._config.animation) {
  5369. var transitionDuration = Util.getTransitionDurationFromElement(this._element);
  5370. $(this._element).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration);
  5371. } else {
  5372. complete();
  5373. }
  5374. };
  5375. _proto.hide = function hide() {
  5376. if (!this._element.classList.contains(ClassName$a.SHOW)) {
  5377. return;
  5378. }
  5379. var hideEvent = $.Event(Event$a.HIDE);
  5380. $(this._element).trigger(hideEvent);
  5381. if (hideEvent.isDefaultPrevented()) {
  5382. return;
  5383. }
  5384. this._close();
  5385. };
  5386. _proto.dispose = function dispose() {
  5387. clearTimeout(this._timeout);
  5388. this._timeout = null;
  5389. if (this._element.classList.contains(ClassName$a.SHOW)) {
  5390. this._element.classList.remove(ClassName$a.SHOW);
  5391. }
  5392. $(this._element).off(Event$a.CLICK_DISMISS);
  5393. $.removeData(this._element, DATA_KEY$a);
  5394. this._element = null;
  5395. this._config = null;
  5396. } // Private
  5397. ;
  5398. _proto._getConfig = function _getConfig(config) {
  5399. config = _objectSpread2({}, Default$7, {}, $(this._element).data(), {}, typeof config === 'object' && config ? config : {});
  5400. Util.typeCheckConfig(NAME$a, config, this.constructor.DefaultType);
  5401. return config;
  5402. };
  5403. _proto._setListeners = function _setListeners() {
  5404. var _this2 = this;
  5405. $(this._element).on(Event$a.CLICK_DISMISS, Selector$a.DATA_DISMISS, function () {
  5406. return _this2.hide();
  5407. });
  5408. };
  5409. _proto._close = function _close() {
  5410. var _this3 = this;
  5411. var complete = function complete() {
  5412. _this3._element.classList.add(ClassName$a.HIDE);
  5413. $(_this3._element).trigger(Event$a.HIDDEN);
  5414. };
  5415. this._element.classList.remove(ClassName$a.SHOW);
  5416. if (this._config.animation) {
  5417. var transitionDuration = Util.getTransitionDurationFromElement(this._element);
  5418. $(this._element).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration);
  5419. } else {
  5420. complete();
  5421. }
  5422. } // Static
  5423. ;
  5424. Toast._jQueryInterface = function _jQueryInterface(config) {
  5425. return this.each(function () {
  5426. var $element = $(this);
  5427. var data = $element.data(DATA_KEY$a);
  5428. var _config = typeof config === 'object' && config;
  5429. if (!data) {
  5430. data = new Toast(this, _config);
  5431. $element.data(DATA_KEY$a, data);
  5432. }
  5433. if (typeof config === 'string') {
  5434. if (typeof data[config] === 'undefined') {
  5435. throw new TypeError("No method named \"" + config + "\"");
  5436. }
  5437. data[config](this);
  5438. }
  5439. });
  5440. };
  5441. _createClass(Toast, null, [{
  5442. key: "VERSION",
  5443. get: function get() {
  5444. return VERSION$a;
  5445. }
  5446. }, {
  5447. key: "DefaultType",
  5448. get: function get() {
  5449. return DefaultType$7;
  5450. }
  5451. }, {
  5452. key: "Default",
  5453. get: function get() {
  5454. return Default$7;
  5455. }
  5456. }]);
  5457. return Toast;
  5458. }();
  5459. /**
  5460. * ------------------------------------------------------------------------
  5461. * jQuery
  5462. * ------------------------------------------------------------------------
  5463. */
  5464. $.fn[NAME$a] = Toast._jQueryInterface;
  5465. $.fn[NAME$a].Constructor = Toast;
  5466. $.fn[NAME$a].noConflict = function () {
  5467. $.fn[NAME$a] = JQUERY_NO_CONFLICT$a;
  5468. return Toast._jQueryInterface;
  5469. };
  5470. exports.Alert = Alert;
  5471. exports.Button = Button;
  5472. exports.Carousel = Carousel;
  5473. exports.Collapse = Collapse;
  5474. exports.Dropdown = Dropdown;
  5475. exports.Modal = Modal;
  5476. exports.Popover = Popover;
  5477. exports.Scrollspy = ScrollSpy;
  5478. exports.Tab = Tab;
  5479. exports.Toast = Toast;
  5480. exports.Tooltip = Tooltip;
  5481. exports.Util = Util;
  5482. Object.defineProperty(exports, '__esModule', { value: true });
  5483. })));
  5484. //# sourceMappingURL=bootstrap.js.map
  5485. /***/ }),
  5486. /***/ "./node_modules/buffer/index.js":
  5487. /*!**************************************!*\
  5488. !*** ./node_modules/buffer/index.js ***!
  5489. \**************************************/
  5490. /*! no static exports found */
  5491. /***/ (function(module, exports, __webpack_require__) {
  5492. "use strict";
  5493. /* WEBPACK VAR INJECTION */(function(global) {/*!
  5494. * The buffer module from node.js, for the browser.
  5495. *
  5496. * @author Feross Aboukhadijeh <http://feross.org>
  5497. * @license MIT
  5498. */
  5499. /* eslint-disable no-proto */
  5500. var base64 = __webpack_require__(/*! base64-js */ "./node_modules/base64-js/index.js")
  5501. var ieee754 = __webpack_require__(/*! ieee754 */ "./node_modules/ieee754/index.js")
  5502. var isArray = __webpack_require__(/*! isarray */ "./node_modules/isarray/index.js")
  5503. exports.Buffer = Buffer
  5504. exports.SlowBuffer = SlowBuffer
  5505. exports.INSPECT_MAX_BYTES = 50
  5506. /**
  5507. * If `Buffer.TYPED_ARRAY_SUPPORT`:
  5508. * === true Use Uint8Array implementation (fastest)
  5509. * === false Use Object implementation (most compatible, even IE6)
  5510. *
  5511. * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,
  5512. * Opera 11.6+, iOS 4.2+.
  5513. *
  5514. * Due to various browser bugs, sometimes the Object implementation will be used even
  5515. * when the browser supports typed arrays.
  5516. *
  5517. * Note:
  5518. *
  5519. * - Firefox 4-29 lacks support for adding new properties to `Uint8Array` instances,
  5520. * See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438.
  5521. *
  5522. * - Chrome 9-10 is missing the `TypedArray.prototype.subarray` function.
  5523. *
  5524. * - IE10 has a broken `TypedArray.prototype.subarray` function which returns arrays of
  5525. * incorrect length in some situations.
  5526. * We detect these buggy browsers and set `Buffer.TYPED_ARRAY_SUPPORT` to `false` so they
  5527. * get the Object implementation, which is slower but behaves correctly.
  5528. */
  5529. Buffer.TYPED_ARRAY_SUPPORT = global.TYPED_ARRAY_SUPPORT !== undefined
  5530. ? global.TYPED_ARRAY_SUPPORT
  5531. : typedArraySupport()
  5532. /*
  5533. * Export kMaxLength after typed array support is determined.
  5534. */
  5535. exports.kMaxLength = kMaxLength()
  5536. function typedArraySupport () {
  5537. try {
  5538. var arr = new Uint8Array(1)
  5539. arr.__proto__ = {__proto__: Uint8Array.prototype, foo: function () { return 42 }}
  5540. return arr.foo() === 42 && // typed array instances can be augmented
  5541. typeof arr.subarray === 'function' && // chrome 9-10 lack `subarray`
  5542. arr.subarray(1, 1).byteLength === 0 // ie10 has broken `subarray`
  5543. } catch (e) {
  5544. return false
  5545. }
  5546. }
  5547. function kMaxLength () {
  5548. return Buffer.TYPED_ARRAY_SUPPORT
  5549. ? 0x7fffffff
  5550. : 0x3fffffff
  5551. }
  5552. function createBuffer (that, length) {
  5553. if (kMaxLength() < length) {
  5554. throw new RangeError('Invalid typed array length')
  5555. }
  5556. if (Buffer.TYPED_ARRAY_SUPPORT) {
  5557. // Return an augmented `Uint8Array` instance, for best performance
  5558. that = new Uint8Array(length)
  5559. that.__proto__ = Buffer.prototype
  5560. } else {
  5561. // Fallback: Return an object instance of the Buffer class
  5562. if (that === null) {
  5563. that = new Buffer(length)
  5564. }
  5565. that.length = length
  5566. }
  5567. return that
  5568. }
  5569. /**
  5570. * The Buffer constructor returns instances of `Uint8Array` that have their
  5571. * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of
  5572. * `Uint8Array`, so the returned instances will have all the node `Buffer` methods
  5573. * and the `Uint8Array` methods. Square bracket notation works as expected -- it
  5574. * returns a single octet.
  5575. *
  5576. * The `Uint8Array` prototype remains unmodified.
  5577. */
  5578. function Buffer (arg, encodingOrOffset, length) {
  5579. if (!Buffer.TYPED_ARRAY_SUPPORT && !(this instanceof Buffer)) {
  5580. return new Buffer(arg, encodingOrOffset, length)
  5581. }
  5582. // Common case.
  5583. if (typeof arg === 'number') {
  5584. if (typeof encodingOrOffset === 'string') {
  5585. throw new Error(
  5586. 'If encoding is specified then the first argument must be a string'
  5587. )
  5588. }
  5589. return allocUnsafe(this, arg)
  5590. }
  5591. return from(this, arg, encodingOrOffset, length)
  5592. }
  5593. Buffer.poolSize = 8192 // not used by this implementation
  5594. // TODO: Legacy, not needed anymore. Remove in next major version.
  5595. Buffer._augment = function (arr) {
  5596. arr.__proto__ = Buffer.prototype
  5597. return arr
  5598. }
  5599. function from (that, value, encodingOrOffset, length) {
  5600. if (typeof value === 'number') {
  5601. throw new TypeError('"value" argument must not be a number')
  5602. }
  5603. if (typeof ArrayBuffer !== 'undefined' && value instanceof ArrayBuffer) {
  5604. return fromArrayBuffer(that, value, encodingOrOffset, length)
  5605. }
  5606. if (typeof value === 'string') {
  5607. return fromString(that, value, encodingOrOffset)
  5608. }
  5609. return fromObject(that, value)
  5610. }
  5611. /**
  5612. * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError
  5613. * if value is a number.
  5614. * Buffer.from(str[, encoding])
  5615. * Buffer.from(array)
  5616. * Buffer.from(buffer)
  5617. * Buffer.from(arrayBuffer[, byteOffset[, length]])
  5618. **/
  5619. Buffer.from = function (value, encodingOrOffset, length) {
  5620. return from(null, value, encodingOrOffset, length)
  5621. }
  5622. if (Buffer.TYPED_ARRAY_SUPPORT) {
  5623. Buffer.prototype.__proto__ = Uint8Array.prototype
  5624. Buffer.__proto__ = Uint8Array
  5625. if (typeof Symbol !== 'undefined' && Symbol.species &&
  5626. Buffer[Symbol.species] === Buffer) {
  5627. // Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97
  5628. Object.defineProperty(Buffer, Symbol.species, {
  5629. value: null,
  5630. configurable: true
  5631. })
  5632. }
  5633. }
  5634. function assertSize (size) {
  5635. if (typeof size !== 'number') {
  5636. throw new TypeError('"size" argument must be a number')
  5637. } else if (size < 0) {
  5638. throw new RangeError('"size" argument must not be negative')
  5639. }
  5640. }
  5641. function alloc (that, size, fill, encoding) {
  5642. assertSize(size)
  5643. if (size <= 0) {
  5644. return createBuffer(that, size)
  5645. }
  5646. if (fill !== undefined) {
  5647. // Only pay attention to encoding if it's a string. This
  5648. // prevents accidentally sending in a number that would
  5649. // be interpretted as a start offset.
  5650. return typeof encoding === 'string'
  5651. ? createBuffer(that, size).fill(fill, encoding)
  5652. : createBuffer(that, size).fill(fill)
  5653. }
  5654. return createBuffer(that, size)
  5655. }
  5656. /**
  5657. * Creates a new filled Buffer instance.
  5658. * alloc(size[, fill[, encoding]])
  5659. **/
  5660. Buffer.alloc = function (size, fill, encoding) {
  5661. return alloc(null, size, fill, encoding)
  5662. }
  5663. function allocUnsafe (that, size) {
  5664. assertSize(size)
  5665. that = createBuffer(that, size < 0 ? 0 : checked(size) | 0)
  5666. if (!Buffer.TYPED_ARRAY_SUPPORT) {
  5667. for (var i = 0; i < size; ++i) {
  5668. that[i] = 0
  5669. }
  5670. }
  5671. return that
  5672. }
  5673. /**
  5674. * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance.
  5675. * */
  5676. Buffer.allocUnsafe = function (size) {
  5677. return allocUnsafe(null, size)
  5678. }
  5679. /**
  5680. * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
  5681. */
  5682. Buffer.allocUnsafeSlow = function (size) {
  5683. return allocUnsafe(null, size)
  5684. }
  5685. function fromString (that, string, encoding) {
  5686. if (typeof encoding !== 'string' || encoding === '') {
  5687. encoding = 'utf8'
  5688. }
  5689. if (!Buffer.isEncoding(encoding)) {
  5690. throw new TypeError('"encoding" must be a valid string encoding')
  5691. }
  5692. var length = byteLength(string, encoding) | 0
  5693. that = createBuffer(that, length)
  5694. var actual = that.write(string, encoding)
  5695. if (actual !== length) {
  5696. // Writing a hex string, for example, that contains invalid characters will
  5697. // cause everything after the first invalid character to be ignored. (e.g.
  5698. // 'abxxcd' will be treated as 'ab')
  5699. that = that.slice(0, actual)
  5700. }
  5701. return that
  5702. }
  5703. function fromArrayLike (that, array) {
  5704. var length = array.length < 0 ? 0 : checked(array.length) | 0
  5705. that = createBuffer(that, length)
  5706. for (var i = 0; i < length; i += 1) {
  5707. that[i] = array[i] & 255
  5708. }
  5709. return that
  5710. }
  5711. function fromArrayBuffer (that, array, byteOffset, length) {
  5712. array.byteLength // this throws if `array` is not a valid ArrayBuffer
  5713. if (byteOffset < 0 || array.byteLength < byteOffset) {
  5714. throw new RangeError('\'offset\' is out of bounds')
  5715. }
  5716. if (array.byteLength < byteOffset + (length || 0)) {
  5717. throw new RangeError('\'length\' is out of bounds')
  5718. }
  5719. if (byteOffset === undefined && length === undefined) {
  5720. array = new Uint8Array(array)
  5721. } else if (length === undefined) {
  5722. array = new Uint8Array(array, byteOffset)
  5723. } else {
  5724. array = new Uint8Array(array, byteOffset, length)
  5725. }
  5726. if (Buffer.TYPED_ARRAY_SUPPORT) {
  5727. // Return an augmented `Uint8Array` instance, for best performance
  5728. that = array
  5729. that.__proto__ = Buffer.prototype
  5730. } else {
  5731. // Fallback: Return an object instance of the Buffer class
  5732. that = fromArrayLike(that, array)
  5733. }
  5734. return that
  5735. }
  5736. function fromObject (that, obj) {
  5737. if (Buffer.isBuffer(obj)) {
  5738. var len = checked(obj.length) | 0
  5739. that = createBuffer(that, len)
  5740. if (that.length === 0) {
  5741. return that
  5742. }
  5743. obj.copy(that, 0, 0, len)
  5744. return that
  5745. }
  5746. if (obj) {
  5747. if ((typeof ArrayBuffer !== 'undefined' &&
  5748. obj.buffer instanceof ArrayBuffer) || 'length' in obj) {
  5749. if (typeof obj.length !== 'number' || isnan(obj.length)) {
  5750. return createBuffer(that, 0)
  5751. }
  5752. return fromArrayLike(that, obj)
  5753. }
  5754. if (obj.type === 'Buffer' && isArray(obj.data)) {
  5755. return fromArrayLike(that, obj.data)
  5756. }
  5757. }
  5758. throw new TypeError('First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.')
  5759. }
  5760. function checked (length) {
  5761. // Note: cannot use `length < kMaxLength()` here because that fails when
  5762. // length is NaN (which is otherwise coerced to zero.)
  5763. if (length >= kMaxLength()) {
  5764. throw new RangeError('Attempt to allocate Buffer larger than maximum ' +
  5765. 'size: 0x' + kMaxLength().toString(16) + ' bytes')
  5766. }
  5767. return length | 0
  5768. }
  5769. function SlowBuffer (length) {
  5770. if (+length != length) { // eslint-disable-line eqeqeq
  5771. length = 0
  5772. }
  5773. return Buffer.alloc(+length)
  5774. }
  5775. Buffer.isBuffer = function isBuffer (b) {
  5776. return !!(b != null && b._isBuffer)
  5777. }
  5778. Buffer.compare = function compare (a, b) {
  5779. if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {
  5780. throw new TypeError('Arguments must be Buffers')
  5781. }
  5782. if (a === b) return 0
  5783. var x = a.length
  5784. var y = b.length
  5785. for (var i = 0, len = Math.min(x, y); i < len; ++i) {
  5786. if (a[i] !== b[i]) {
  5787. x = a[i]
  5788. y = b[i]
  5789. break
  5790. }
  5791. }
  5792. if (x < y) return -1
  5793. if (y < x) return 1
  5794. return 0
  5795. }
  5796. Buffer.isEncoding = function isEncoding (encoding) {
  5797. switch (String(encoding).toLowerCase()) {
  5798. case 'hex':
  5799. case 'utf8':
  5800. case 'utf-8':
  5801. case 'ascii':
  5802. case 'latin1':
  5803. case 'binary':
  5804. case 'base64':
  5805. case 'ucs2':
  5806. case 'ucs-2':
  5807. case 'utf16le':
  5808. case 'utf-16le':
  5809. return true
  5810. default:
  5811. return false
  5812. }
  5813. }
  5814. Buffer.concat = function concat (list, length) {
  5815. if (!isArray(list)) {
  5816. throw new TypeError('"list" argument must be an Array of Buffers')
  5817. }
  5818. if (list.length === 0) {
  5819. return Buffer.alloc(0)
  5820. }
  5821. var i
  5822. if (length === undefined) {
  5823. length = 0
  5824. for (i = 0; i < list.length; ++i) {
  5825. length += list[i].length
  5826. }
  5827. }
  5828. var buffer = Buffer.allocUnsafe(length)
  5829. var pos = 0
  5830. for (i = 0; i < list.length; ++i) {
  5831. var buf = list[i]
  5832. if (!Buffer.isBuffer(buf)) {
  5833. throw new TypeError('"list" argument must be an Array of Buffers')
  5834. }
  5835. buf.copy(buffer, pos)
  5836. pos += buf.length
  5837. }
  5838. return buffer
  5839. }
  5840. function byteLength (string, encoding) {
  5841. if (Buffer.isBuffer(string)) {
  5842. return string.length
  5843. }
  5844. if (typeof ArrayBuffer !== 'undefined' && typeof ArrayBuffer.isView === 'function' &&
  5845. (ArrayBuffer.isView(string) || string instanceof ArrayBuffer)) {
  5846. return string.byteLength
  5847. }
  5848. if (typeof string !== 'string') {
  5849. string = '' + string
  5850. }
  5851. var len = string.length
  5852. if (len === 0) return 0
  5853. // Use a for loop to avoid recursion
  5854. var loweredCase = false
  5855. for (;;) {
  5856. switch (encoding) {
  5857. case 'ascii':
  5858. case 'latin1':
  5859. case 'binary':
  5860. return len
  5861. case 'utf8':
  5862. case 'utf-8':
  5863. case undefined:
  5864. return utf8ToBytes(string).length
  5865. case 'ucs2':
  5866. case 'ucs-2':
  5867. case 'utf16le':
  5868. case 'utf-16le':
  5869. return len * 2
  5870. case 'hex':
  5871. return len >>> 1
  5872. case 'base64':
  5873. return base64ToBytes(string).length
  5874. default:
  5875. if (loweredCase) return utf8ToBytes(string).length // assume utf8
  5876. encoding = ('' + encoding).toLowerCase()
  5877. loweredCase = true
  5878. }
  5879. }
  5880. }
  5881. Buffer.byteLength = byteLength
  5882. function slowToString (encoding, start, end) {
  5883. var loweredCase = false
  5884. // No need to verify that "this.length <= MAX_UINT32" since it's a read-only
  5885. // property of a typed array.
  5886. // This behaves neither like String nor Uint8Array in that we set start/end
  5887. // to their upper/lower bounds if the value passed is out of range.
  5888. // undefined is handled specially as per ECMA-262 6th Edition,
  5889. // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization.
  5890. if (start === undefined || start < 0) {
  5891. start = 0
  5892. }
  5893. // Return early if start > this.length. Done here to prevent potential uint32
  5894. // coercion fail below.
  5895. if (start > this.length) {
  5896. return ''
  5897. }
  5898. if (end === undefined || end > this.length) {
  5899. end = this.length
  5900. }
  5901. if (end <= 0) {
  5902. return ''
  5903. }
  5904. // Force coersion to uint32. This will also coerce falsey/NaN values to 0.
  5905. end >>>= 0
  5906. start >>>= 0
  5907. if (end <= start) {
  5908. return ''
  5909. }
  5910. if (!encoding) encoding = 'utf8'
  5911. while (true) {
  5912. switch (encoding) {
  5913. case 'hex':
  5914. return hexSlice(this, start, end)
  5915. case 'utf8':
  5916. case 'utf-8':
  5917. return utf8Slice(this, start, end)
  5918. case 'ascii':
  5919. return asciiSlice(this, start, end)
  5920. case 'latin1':
  5921. case 'binary':
  5922. return latin1Slice(this, start, end)
  5923. case 'base64':
  5924. return base64Slice(this, start, end)
  5925. case 'ucs2':
  5926. case 'ucs-2':
  5927. case 'utf16le':
  5928. case 'utf-16le':
  5929. return utf16leSlice(this, start, end)
  5930. default:
  5931. if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
  5932. encoding = (encoding + '').toLowerCase()
  5933. loweredCase = true
  5934. }
  5935. }
  5936. }
  5937. // The property is used by `Buffer.isBuffer` and `is-buffer` (in Safari 5-7) to detect
  5938. // Buffer instances.
  5939. Buffer.prototype._isBuffer = true
  5940. function swap (b, n, m) {
  5941. var i = b[n]
  5942. b[n] = b[m]
  5943. b[m] = i
  5944. }
  5945. Buffer.prototype.swap16 = function swap16 () {
  5946. var len = this.length
  5947. if (len % 2 !== 0) {
  5948. throw new RangeError('Buffer size must be a multiple of 16-bits')
  5949. }
  5950. for (var i = 0; i < len; i += 2) {
  5951. swap(this, i, i + 1)
  5952. }
  5953. return this
  5954. }
  5955. Buffer.prototype.swap32 = function swap32 () {
  5956. var len = this.length
  5957. if (len % 4 !== 0) {
  5958. throw new RangeError('Buffer size must be a multiple of 32-bits')
  5959. }
  5960. for (var i = 0; i < len; i += 4) {
  5961. swap(this, i, i + 3)
  5962. swap(this, i + 1, i + 2)
  5963. }
  5964. return this
  5965. }
  5966. Buffer.prototype.swap64 = function swap64 () {
  5967. var len = this.length
  5968. if (len % 8 !== 0) {
  5969. throw new RangeError('Buffer size must be a multiple of 64-bits')
  5970. }
  5971. for (var i = 0; i < len; i += 8) {
  5972. swap(this, i, i + 7)
  5973. swap(this, i + 1, i + 6)
  5974. swap(this, i + 2, i + 5)
  5975. swap(this, i + 3, i + 4)
  5976. }
  5977. return this
  5978. }
  5979. Buffer.prototype.toString = function toString () {
  5980. var length = this.length | 0
  5981. if (length === 0) return ''
  5982. if (arguments.length === 0) return utf8Slice(this, 0, length)
  5983. return slowToString.apply(this, arguments)
  5984. }
  5985. Buffer.prototype.equals = function equals (b) {
  5986. if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')
  5987. if (this === b) return true
  5988. return Buffer.compare(this, b) === 0
  5989. }
  5990. Buffer.prototype.inspect = function inspect () {
  5991. var str = ''
  5992. var max = exports.INSPECT_MAX_BYTES
  5993. if (this.length > 0) {
  5994. str = this.toString('hex', 0, max).match(/.{2}/g).join(' ')
  5995. if (this.length > max) str += ' ... '
  5996. }
  5997. return '<Buffer ' + str + '>'
  5998. }
  5999. Buffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) {
  6000. if (!Buffer.isBuffer(target)) {
  6001. throw new TypeError('Argument must be a Buffer')
  6002. }
  6003. if (start === undefined) {
  6004. start = 0
  6005. }
  6006. if (end === undefined) {
  6007. end = target ? target.length : 0
  6008. }
  6009. if (thisStart === undefined) {
  6010. thisStart = 0
  6011. }
  6012. if (thisEnd === undefined) {
  6013. thisEnd = this.length
  6014. }
  6015. if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {
  6016. throw new RangeError('out of range index')
  6017. }
  6018. if (thisStart >= thisEnd && start >= end) {
  6019. return 0
  6020. }
  6021. if (thisStart >= thisEnd) {
  6022. return -1
  6023. }
  6024. if (start >= end) {
  6025. return 1
  6026. }
  6027. start >>>= 0
  6028. end >>>= 0
  6029. thisStart >>>= 0
  6030. thisEnd >>>= 0
  6031. if (this === target) return 0
  6032. var x = thisEnd - thisStart
  6033. var y = end - start
  6034. var len = Math.min(x, y)
  6035. var thisCopy = this.slice(thisStart, thisEnd)
  6036. var targetCopy = target.slice(start, end)
  6037. for (var i = 0; i < len; ++i) {
  6038. if (thisCopy[i] !== targetCopy[i]) {
  6039. x = thisCopy[i]
  6040. y = targetCopy[i]
  6041. break
  6042. }
  6043. }
  6044. if (x < y) return -1
  6045. if (y < x) return 1
  6046. return 0
  6047. }
  6048. // Finds either the first index of `val` in `buffer` at offset >= `byteOffset`,
  6049. // OR the last index of `val` in `buffer` at offset <= `byteOffset`.
  6050. //
  6051. // Arguments:
  6052. // - buffer - a Buffer to search
  6053. // - val - a string, Buffer, or number
  6054. // - byteOffset - an index into `buffer`; will be clamped to an int32
  6055. // - encoding - an optional encoding, relevant is val is a string
  6056. // - dir - true for indexOf, false for lastIndexOf
  6057. function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) {
  6058. // Empty buffer means no match
  6059. if (buffer.length === 0) return -1
  6060. // Normalize byteOffset
  6061. if (typeof byteOffset === 'string') {
  6062. encoding = byteOffset
  6063. byteOffset = 0
  6064. } else if (byteOffset > 0x7fffffff) {
  6065. byteOffset = 0x7fffffff
  6066. } else if (byteOffset < -0x80000000) {
  6067. byteOffset = -0x80000000
  6068. }
  6069. byteOffset = +byteOffset // Coerce to Number.
  6070. if (isNaN(byteOffset)) {
  6071. // byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer
  6072. byteOffset = dir ? 0 : (buffer.length - 1)
  6073. }
  6074. // Normalize byteOffset: negative offsets start from the end of the buffer
  6075. if (byteOffset < 0) byteOffset = buffer.length + byteOffset
  6076. if (byteOffset >= buffer.length) {
  6077. if (dir) return -1
  6078. else byteOffset = buffer.length - 1
  6079. } else if (byteOffset < 0) {
  6080. if (dir) byteOffset = 0
  6081. else return -1
  6082. }
  6083. // Normalize val
  6084. if (typeof val === 'string') {
  6085. val = Buffer.from(val, encoding)
  6086. }
  6087. // Finally, search either indexOf (if dir is true) or lastIndexOf
  6088. if (Buffer.isBuffer(val)) {
  6089. // Special case: looking for empty string/buffer always fails
  6090. if (val.length === 0) {
  6091. return -1
  6092. }
  6093. return arrayIndexOf(buffer, val, byteOffset, encoding, dir)
  6094. } else if (typeof val === 'number') {
  6095. val = val & 0xFF // Search for a byte value [0-255]
  6096. if (Buffer.TYPED_ARRAY_SUPPORT &&
  6097. typeof Uint8Array.prototype.indexOf === 'function') {
  6098. if (dir) {
  6099. return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset)
  6100. } else {
  6101. return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset)
  6102. }
  6103. }
  6104. return arrayIndexOf(buffer, [ val ], byteOffset, encoding, dir)
  6105. }
  6106. throw new TypeError('val must be string, number or Buffer')
  6107. }
  6108. function arrayIndexOf (arr, val, byteOffset, encoding, dir) {
  6109. var indexSize = 1
  6110. var arrLength = arr.length
  6111. var valLength = val.length
  6112. if (encoding !== undefined) {
  6113. encoding = String(encoding).toLowerCase()
  6114. if (encoding === 'ucs2' || encoding === 'ucs-2' ||
  6115. encoding === 'utf16le' || encoding === 'utf-16le') {
  6116. if (arr.length < 2 || val.length < 2) {
  6117. return -1
  6118. }
  6119. indexSize = 2
  6120. arrLength /= 2
  6121. valLength /= 2
  6122. byteOffset /= 2
  6123. }
  6124. }
  6125. function read (buf, i) {
  6126. if (indexSize === 1) {
  6127. return buf[i]
  6128. } else {
  6129. return buf.readUInt16BE(i * indexSize)
  6130. }
  6131. }
  6132. var i
  6133. if (dir) {
  6134. var foundIndex = -1
  6135. for (i = byteOffset; i < arrLength; i++) {
  6136. if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {
  6137. if (foundIndex === -1) foundIndex = i
  6138. if (i - foundIndex + 1 === valLength) return foundIndex * indexSize
  6139. } else {
  6140. if (foundIndex !== -1) i -= i - foundIndex
  6141. foundIndex = -1
  6142. }
  6143. }
  6144. } else {
  6145. if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength
  6146. for (i = byteOffset; i >= 0; i--) {
  6147. var found = true
  6148. for (var j = 0; j < valLength; j++) {
  6149. if (read(arr, i + j) !== read(val, j)) {
  6150. found = false
  6151. break
  6152. }
  6153. }
  6154. if (found) return i
  6155. }
  6156. }
  6157. return -1
  6158. }
  6159. Buffer.prototype.includes = function includes (val, byteOffset, encoding) {
  6160. return this.indexOf(val, byteOffset, encoding) !== -1
  6161. }
  6162. Buffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) {
  6163. return bidirectionalIndexOf(this, val, byteOffset, encoding, true)
  6164. }
  6165. Buffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) {
  6166. return bidirectionalIndexOf(this, val, byteOffset, encoding, false)
  6167. }
  6168. function hexWrite (buf, string, offset, length) {
  6169. offset = Number(offset) || 0
  6170. var remaining = buf.length - offset
  6171. if (!length) {
  6172. length = remaining
  6173. } else {
  6174. length = Number(length)
  6175. if (length > remaining) {
  6176. length = remaining
  6177. }
  6178. }
  6179. // must be an even number of digits
  6180. var strLen = string.length
  6181. if (strLen % 2 !== 0) throw new TypeError('Invalid hex string')
  6182. if (length > strLen / 2) {
  6183. length = strLen / 2
  6184. }
  6185. for (var i = 0; i < length; ++i) {
  6186. var parsed = parseInt(string.substr(i * 2, 2), 16)
  6187. if (isNaN(parsed)) return i
  6188. buf[offset + i] = parsed
  6189. }
  6190. return i
  6191. }
  6192. function utf8Write (buf, string, offset, length) {
  6193. return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length)
  6194. }
  6195. function asciiWrite (buf, string, offset, length) {
  6196. return blitBuffer(asciiToBytes(string), buf, offset, length)
  6197. }
  6198. function latin1Write (buf, string, offset, length) {
  6199. return asciiWrite(buf, string, offset, length)
  6200. }
  6201. function base64Write (buf, string, offset, length) {
  6202. return blitBuffer(base64ToBytes(string), buf, offset, length)
  6203. }
  6204. function ucs2Write (buf, string, offset, length) {
  6205. return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length)
  6206. }
  6207. Buffer.prototype.write = function write (string, offset, length, encoding) {
  6208. // Buffer#write(string)
  6209. if (offset === undefined) {
  6210. encoding = 'utf8'
  6211. length = this.length
  6212. offset = 0
  6213. // Buffer#write(string, encoding)
  6214. } else if (length === undefined && typeof offset === 'string') {
  6215. encoding = offset
  6216. length = this.length
  6217. offset = 0
  6218. // Buffer#write(string, offset[, length][, encoding])
  6219. } else if (isFinite(offset)) {
  6220. offset = offset | 0
  6221. if (isFinite(length)) {
  6222. length = length | 0
  6223. if (encoding === undefined) encoding = 'utf8'
  6224. } else {
  6225. encoding = length
  6226. length = undefined
  6227. }
  6228. // legacy write(string, encoding, offset, length) - remove in v0.13
  6229. } else {
  6230. throw new Error(
  6231. 'Buffer.write(string, encoding, offset[, length]) is no longer supported'
  6232. )
  6233. }
  6234. var remaining = this.length - offset
  6235. if (length === undefined || length > remaining) length = remaining
  6236. if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) {
  6237. throw new RangeError('Attempt to write outside buffer bounds')
  6238. }
  6239. if (!encoding) encoding = 'utf8'
  6240. var loweredCase = false
  6241. for (;;) {
  6242. switch (encoding) {
  6243. case 'hex':
  6244. return hexWrite(this, string, offset, length)
  6245. case 'utf8':
  6246. case 'utf-8':
  6247. return utf8Write(this, string, offset, length)
  6248. case 'ascii':
  6249. return asciiWrite(this, string, offset, length)
  6250. case 'latin1':
  6251. case 'binary':
  6252. return latin1Write(this, string, offset, length)
  6253. case 'base64':
  6254. // Warning: maxLength not taken into account in base64Write
  6255. return base64Write(this, string, offset, length)
  6256. case 'ucs2':
  6257. case 'ucs-2':
  6258. case 'utf16le':
  6259. case 'utf-16le':
  6260. return ucs2Write(this, string, offset, length)
  6261. default:
  6262. if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
  6263. encoding = ('' + encoding).toLowerCase()
  6264. loweredCase = true
  6265. }
  6266. }
  6267. }
  6268. Buffer.prototype.toJSON = function toJSON () {
  6269. return {
  6270. type: 'Buffer',
  6271. data: Array.prototype.slice.call(this._arr || this, 0)
  6272. }
  6273. }
  6274. function base64Slice (buf, start, end) {
  6275. if (start === 0 && end === buf.length) {
  6276. return base64.fromByteArray(buf)
  6277. } else {
  6278. return base64.fromByteArray(buf.slice(start, end))
  6279. }
  6280. }
  6281. function utf8Slice (buf, start, end) {
  6282. end = Math.min(buf.length, end)
  6283. var res = []
  6284. var i = start
  6285. while (i < end) {
  6286. var firstByte = buf[i]
  6287. var codePoint = null
  6288. var bytesPerSequence = (firstByte > 0xEF) ? 4
  6289. : (firstByte > 0xDF) ? 3
  6290. : (firstByte > 0xBF) ? 2
  6291. : 1
  6292. if (i + bytesPerSequence <= end) {
  6293. var secondByte, thirdByte, fourthByte, tempCodePoint
  6294. switch (bytesPerSequence) {
  6295. case 1:
  6296. if (firstByte < 0x80) {
  6297. codePoint = firstByte
  6298. }
  6299. break
  6300. case 2:
  6301. secondByte = buf[i + 1]
  6302. if ((secondByte & 0xC0) === 0x80) {
  6303. tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F)
  6304. if (tempCodePoint > 0x7F) {
  6305. codePoint = tempCodePoint
  6306. }
  6307. }
  6308. break
  6309. case 3:
  6310. secondByte = buf[i + 1]
  6311. thirdByte = buf[i + 2]
  6312. if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {
  6313. tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F)
  6314. if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) {
  6315. codePoint = tempCodePoint
  6316. }
  6317. }
  6318. break
  6319. case 4:
  6320. secondByte = buf[i + 1]
  6321. thirdByte = buf[i + 2]
  6322. fourthByte = buf[i + 3]
  6323. if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {
  6324. tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F)
  6325. if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) {
  6326. codePoint = tempCodePoint
  6327. }
  6328. }
  6329. }
  6330. }
  6331. if (codePoint === null) {
  6332. // we did not generate a valid codePoint so insert a
  6333. // replacement char (U+FFFD) and advance only 1 byte
  6334. codePoint = 0xFFFD
  6335. bytesPerSequence = 1
  6336. } else if (codePoint > 0xFFFF) {
  6337. // encode to utf16 (surrogate pair dance)
  6338. codePoint -= 0x10000
  6339. res.push(codePoint >>> 10 & 0x3FF | 0xD800)
  6340. codePoint = 0xDC00 | codePoint & 0x3FF
  6341. }
  6342. res.push(codePoint)
  6343. i += bytesPerSequence
  6344. }
  6345. return decodeCodePointsArray(res)
  6346. }
  6347. // Based on http://stackoverflow.com/a/22747272/680742, the browser with
  6348. // the lowest limit is Chrome, with 0x10000 args.
  6349. // We go 1 magnitude less, for safety
  6350. var MAX_ARGUMENTS_LENGTH = 0x1000
  6351. function decodeCodePointsArray (codePoints) {
  6352. var len = codePoints.length
  6353. if (len <= MAX_ARGUMENTS_LENGTH) {
  6354. return String.fromCharCode.apply(String, codePoints) // avoid extra slice()
  6355. }
  6356. // Decode in chunks to avoid "call stack size exceeded".
  6357. var res = ''
  6358. var i = 0
  6359. while (i < len) {
  6360. res += String.fromCharCode.apply(
  6361. String,
  6362. codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)
  6363. )
  6364. }
  6365. return res
  6366. }
  6367. function asciiSlice (buf, start, end) {
  6368. var ret = ''
  6369. end = Math.min(buf.length, end)
  6370. for (var i = start; i < end; ++i) {
  6371. ret += String.fromCharCode(buf[i] & 0x7F)
  6372. }
  6373. return ret
  6374. }
  6375. function latin1Slice (buf, start, end) {
  6376. var ret = ''
  6377. end = Math.min(buf.length, end)
  6378. for (var i = start; i < end; ++i) {
  6379. ret += String.fromCharCode(buf[i])
  6380. }
  6381. return ret
  6382. }
  6383. function hexSlice (buf, start, end) {
  6384. var len = buf.length
  6385. if (!start || start < 0) start = 0
  6386. if (!end || end < 0 || end > len) end = len
  6387. var out = ''
  6388. for (var i = start; i < end; ++i) {
  6389. out += toHex(buf[i])
  6390. }
  6391. return out
  6392. }
  6393. function utf16leSlice (buf, start, end) {
  6394. var bytes = buf.slice(start, end)
  6395. var res = ''
  6396. for (var i = 0; i < bytes.length; i += 2) {
  6397. res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256)
  6398. }
  6399. return res
  6400. }
  6401. Buffer.prototype.slice = function slice (start, end) {
  6402. var len = this.length
  6403. start = ~~start
  6404. end = end === undefined ? len : ~~end
  6405. if (start < 0) {
  6406. start += len
  6407. if (start < 0) start = 0
  6408. } else if (start > len) {
  6409. start = len
  6410. }
  6411. if (end < 0) {
  6412. end += len
  6413. if (end < 0) end = 0
  6414. } else if (end > len) {
  6415. end = len
  6416. }
  6417. if (end < start) end = start
  6418. var newBuf
  6419. if (Buffer.TYPED_ARRAY_SUPPORT) {
  6420. newBuf = this.subarray(start, end)
  6421. newBuf.__proto__ = Buffer.prototype
  6422. } else {
  6423. var sliceLen = end - start
  6424. newBuf = new Buffer(sliceLen, undefined)
  6425. for (var i = 0; i < sliceLen; ++i) {
  6426. newBuf[i] = this[i + start]
  6427. }
  6428. }
  6429. return newBuf
  6430. }
  6431. /*
  6432. * Need to make sure that buffer isn't trying to write out of bounds.
  6433. */
  6434. function checkOffset (offset, ext, length) {
  6435. if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint')
  6436. if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length')
  6437. }
  6438. Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) {
  6439. offset = offset | 0
  6440. byteLength = byteLength | 0
  6441. if (!noAssert) checkOffset(offset, byteLength, this.length)
  6442. var val = this[offset]
  6443. var mul = 1
  6444. var i = 0
  6445. while (++i < byteLength && (mul *= 0x100)) {
  6446. val += this[offset + i] * mul
  6447. }
  6448. return val
  6449. }
  6450. Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) {
  6451. offset = offset | 0
  6452. byteLength = byteLength | 0
  6453. if (!noAssert) {
  6454. checkOffset(offset, byteLength, this.length)
  6455. }
  6456. var val = this[offset + --byteLength]
  6457. var mul = 1
  6458. while (byteLength > 0 && (mul *= 0x100)) {
  6459. val += this[offset + --byteLength] * mul
  6460. }
  6461. return val
  6462. }
  6463. Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) {
  6464. if (!noAssert) checkOffset(offset, 1, this.length)
  6465. return this[offset]
  6466. }
  6467. Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) {
  6468. if (!noAssert) checkOffset(offset, 2, this.length)
  6469. return this[offset] | (this[offset + 1] << 8)
  6470. }
  6471. Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) {
  6472. if (!noAssert) checkOffset(offset, 2, this.length)
  6473. return (this[offset] << 8) | this[offset + 1]
  6474. }
  6475. Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) {
  6476. if (!noAssert) checkOffset(offset, 4, this.length)
  6477. return ((this[offset]) |
  6478. (this[offset + 1] << 8) |
  6479. (this[offset + 2] << 16)) +
  6480. (this[offset + 3] * 0x1000000)
  6481. }
  6482. Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) {
  6483. if (!noAssert) checkOffset(offset, 4, this.length)
  6484. return (this[offset] * 0x1000000) +
  6485. ((this[offset + 1] << 16) |
  6486. (this[offset + 2] << 8) |
  6487. this[offset + 3])
  6488. }
  6489. Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) {
  6490. offset = offset | 0
  6491. byteLength = byteLength | 0
  6492. if (!noAssert) checkOffset(offset, byteLength, this.length)
  6493. var val = this[offset]
  6494. var mul = 1
  6495. var i = 0
  6496. while (++i < byteLength && (mul *= 0x100)) {
  6497. val += this[offset + i] * mul
  6498. }
  6499. mul *= 0x80
  6500. if (val >= mul) val -= Math.pow(2, 8 * byteLength)
  6501. return val
  6502. }
  6503. Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) {
  6504. offset = offset | 0
  6505. byteLength = byteLength | 0
  6506. if (!noAssert) checkOffset(offset, byteLength, this.length)
  6507. var i = byteLength
  6508. var mul = 1
  6509. var val = this[offset + --i]
  6510. while (i > 0 && (mul *= 0x100)) {
  6511. val += this[offset + --i] * mul
  6512. }
  6513. mul *= 0x80
  6514. if (val >= mul) val -= Math.pow(2, 8 * byteLength)
  6515. return val
  6516. }
  6517. Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) {
  6518. if (!noAssert) checkOffset(offset, 1, this.length)
  6519. if (!(this[offset] & 0x80)) return (this[offset])
  6520. return ((0xff - this[offset] + 1) * -1)
  6521. }
  6522. Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) {
  6523. if (!noAssert) checkOffset(offset, 2, this.length)
  6524. var val = this[offset] | (this[offset + 1] << 8)
  6525. return (val & 0x8000) ? val | 0xFFFF0000 : val
  6526. }
  6527. Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) {
  6528. if (!noAssert) checkOffset(offset, 2, this.length)
  6529. var val = this[offset + 1] | (this[offset] << 8)
  6530. return (val & 0x8000) ? val | 0xFFFF0000 : val
  6531. }
  6532. Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) {
  6533. if (!noAssert) checkOffset(offset, 4, this.length)
  6534. return (this[offset]) |
  6535. (this[offset + 1] << 8) |
  6536. (this[offset + 2] << 16) |
  6537. (this[offset + 3] << 24)
  6538. }
  6539. Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) {
  6540. if (!noAssert) checkOffset(offset, 4, this.length)
  6541. return (this[offset] << 24) |
  6542. (this[offset + 1] << 16) |
  6543. (this[offset + 2] << 8) |
  6544. (this[offset + 3])
  6545. }
  6546. Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) {
  6547. if (!noAssert) checkOffset(offset, 4, this.length)
  6548. return ieee754.read(this, offset, true, 23, 4)
  6549. }
  6550. Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) {
  6551. if (!noAssert) checkOffset(offset, 4, this.length)
  6552. return ieee754.read(this, offset, false, 23, 4)
  6553. }
  6554. Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) {
  6555. if (!noAssert) checkOffset(offset, 8, this.length)
  6556. return ieee754.read(this, offset, true, 52, 8)
  6557. }
  6558. Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) {
  6559. if (!noAssert) checkOffset(offset, 8, this.length)
  6560. return ieee754.read(this, offset, false, 52, 8)
  6561. }
  6562. function checkInt (buf, value, offset, ext, max, min) {
  6563. if (!Buffer.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance')
  6564. if (value > max || value < min) throw new RangeError('"value" argument is out of bounds')
  6565. if (offset + ext > buf.length) throw new RangeError('Index out of range')
  6566. }
  6567. Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) {
  6568. value = +value
  6569. offset = offset | 0
  6570. byteLength = byteLength | 0
  6571. if (!noAssert) {
  6572. var maxBytes = Math.pow(2, 8 * byteLength) - 1
  6573. checkInt(this, value, offset, byteLength, maxBytes, 0)
  6574. }
  6575. var mul = 1
  6576. var i = 0
  6577. this[offset] = value & 0xFF
  6578. while (++i < byteLength && (mul *= 0x100)) {
  6579. this[offset + i] = (value / mul) & 0xFF
  6580. }
  6581. return offset + byteLength
  6582. }
  6583. Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) {
  6584. value = +value
  6585. offset = offset | 0
  6586. byteLength = byteLength | 0
  6587. if (!noAssert) {
  6588. var maxBytes = Math.pow(2, 8 * byteLength) - 1
  6589. checkInt(this, value, offset, byteLength, maxBytes, 0)
  6590. }
  6591. var i = byteLength - 1
  6592. var mul = 1
  6593. this[offset + i] = value & 0xFF
  6594. while (--i >= 0 && (mul *= 0x100)) {
  6595. this[offset + i] = (value / mul) & 0xFF
  6596. }
  6597. return offset + byteLength
  6598. }
  6599. Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) {
  6600. value = +value
  6601. offset = offset | 0
  6602. if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0)
  6603. if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)
  6604. this[offset] = (value & 0xff)
  6605. return offset + 1
  6606. }
  6607. function objectWriteUInt16 (buf, value, offset, littleEndian) {
  6608. if (value < 0) value = 0xffff + value + 1
  6609. for (var i = 0, j = Math.min(buf.length - offset, 2); i < j; ++i) {
  6610. buf[offset + i] = (value & (0xff << (8 * (littleEndian ? i : 1 - i)))) >>>
  6611. (littleEndian ? i : 1 - i) * 8
  6612. }
  6613. }
  6614. Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) {
  6615. value = +value
  6616. offset = offset | 0
  6617. if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
  6618. if (Buffer.TYPED_ARRAY_SUPPORT) {
  6619. this[offset] = (value & 0xff)
  6620. this[offset + 1] = (value >>> 8)
  6621. } else {
  6622. objectWriteUInt16(this, value, offset, true)
  6623. }
  6624. return offset + 2
  6625. }
  6626. Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) {
  6627. value = +value
  6628. offset = offset | 0
  6629. if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
  6630. if (Buffer.TYPED_ARRAY_SUPPORT) {
  6631. this[offset] = (value >>> 8)
  6632. this[offset + 1] = (value & 0xff)
  6633. } else {
  6634. objectWriteUInt16(this, value, offset, false)
  6635. }
  6636. return offset + 2
  6637. }
  6638. function objectWriteUInt32 (buf, value, offset, littleEndian) {
  6639. if (value < 0) value = 0xffffffff + value + 1
  6640. for (var i = 0, j = Math.min(buf.length - offset, 4); i < j; ++i) {
  6641. buf[offset + i] = (value >>> (littleEndian ? i : 3 - i) * 8) & 0xff
  6642. }
  6643. }
  6644. Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) {
  6645. value = +value
  6646. offset = offset | 0
  6647. if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
  6648. if (Buffer.TYPED_ARRAY_SUPPORT) {
  6649. this[offset + 3] = (value >>> 24)
  6650. this[offset + 2] = (value >>> 16)
  6651. this[offset + 1] = (value >>> 8)
  6652. this[offset] = (value & 0xff)
  6653. } else {
  6654. objectWriteUInt32(this, value, offset, true)
  6655. }
  6656. return offset + 4
  6657. }
  6658. Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) {
  6659. value = +value
  6660. offset = offset | 0
  6661. if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
  6662. if (Buffer.TYPED_ARRAY_SUPPORT) {
  6663. this[offset] = (value >>> 24)
  6664. this[offset + 1] = (value >>> 16)
  6665. this[offset + 2] = (value >>> 8)
  6666. this[offset + 3] = (value & 0xff)
  6667. } else {
  6668. objectWriteUInt32(this, value, offset, false)
  6669. }
  6670. return offset + 4
  6671. }
  6672. Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) {
  6673. value = +value
  6674. offset = offset | 0
  6675. if (!noAssert) {
  6676. var limit = Math.pow(2, 8 * byteLength - 1)
  6677. checkInt(this, value, offset, byteLength, limit - 1, -limit)
  6678. }
  6679. var i = 0
  6680. var mul = 1
  6681. var sub = 0
  6682. this[offset] = value & 0xFF
  6683. while (++i < byteLength && (mul *= 0x100)) {
  6684. if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {
  6685. sub = 1
  6686. }
  6687. this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
  6688. }
  6689. return offset + byteLength
  6690. }
  6691. Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) {
  6692. value = +value
  6693. offset = offset | 0
  6694. if (!noAssert) {
  6695. var limit = Math.pow(2, 8 * byteLength - 1)
  6696. checkInt(this, value, offset, byteLength, limit - 1, -limit)
  6697. }
  6698. var i = byteLength - 1
  6699. var mul = 1
  6700. var sub = 0
  6701. this[offset + i] = value & 0xFF
  6702. while (--i >= 0 && (mul *= 0x100)) {
  6703. if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {
  6704. sub = 1
  6705. }
  6706. this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
  6707. }
  6708. return offset + byteLength
  6709. }
  6710. Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) {
  6711. value = +value
  6712. offset = offset | 0
  6713. if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80)
  6714. if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)
  6715. if (value < 0) value = 0xff + value + 1
  6716. this[offset] = (value & 0xff)
  6717. return offset + 1
  6718. }
  6719. Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) {
  6720. value = +value
  6721. offset = offset | 0
  6722. if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
  6723. if (Buffer.TYPED_ARRAY_SUPPORT) {
  6724. this[offset] = (value & 0xff)
  6725. this[offset + 1] = (value >>> 8)
  6726. } else {
  6727. objectWriteUInt16(this, value, offset, true)
  6728. }
  6729. return offset + 2
  6730. }
  6731. Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) {
  6732. value = +value
  6733. offset = offset | 0
  6734. if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
  6735. if (Buffer.TYPED_ARRAY_SUPPORT) {
  6736. this[offset] = (value >>> 8)
  6737. this[offset + 1] = (value & 0xff)
  6738. } else {
  6739. objectWriteUInt16(this, value, offset, false)
  6740. }
  6741. return offset + 2
  6742. }
  6743. Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) {
  6744. value = +value
  6745. offset = offset | 0
  6746. if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
  6747. if (Buffer.TYPED_ARRAY_SUPPORT) {
  6748. this[offset] = (value & 0xff)
  6749. this[offset + 1] = (value >>> 8)
  6750. this[offset + 2] = (value >>> 16)
  6751. this[offset + 3] = (value >>> 24)
  6752. } else {
  6753. objectWriteUInt32(this, value, offset, true)
  6754. }
  6755. return offset + 4
  6756. }
  6757. Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) {
  6758. value = +value
  6759. offset = offset | 0
  6760. if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
  6761. if (value < 0) value = 0xffffffff + value + 1
  6762. if (Buffer.TYPED_ARRAY_SUPPORT) {
  6763. this[offset] = (value >>> 24)
  6764. this[offset + 1] = (value >>> 16)
  6765. this[offset + 2] = (value >>> 8)
  6766. this[offset + 3] = (value & 0xff)
  6767. } else {
  6768. objectWriteUInt32(this, value, offset, false)
  6769. }
  6770. return offset + 4
  6771. }
  6772. function checkIEEE754 (buf, value, offset, ext, max, min) {
  6773. if (offset + ext > buf.length) throw new RangeError('Index out of range')
  6774. if (offset < 0) throw new RangeError('Index out of range')
  6775. }
  6776. function writeFloat (buf, value, offset, littleEndian, noAssert) {
  6777. if (!noAssert) {
  6778. checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38)
  6779. }
  6780. ieee754.write(buf, value, offset, littleEndian, 23, 4)
  6781. return offset + 4
  6782. }
  6783. Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) {
  6784. return writeFloat(this, value, offset, true, noAssert)
  6785. }
  6786. Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) {
  6787. return writeFloat(this, value, offset, false, noAssert)
  6788. }
  6789. function writeDouble (buf, value, offset, littleEndian, noAssert) {
  6790. if (!noAssert) {
  6791. checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308)
  6792. }
  6793. ieee754.write(buf, value, offset, littleEndian, 52, 8)
  6794. return offset + 8
  6795. }
  6796. Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) {
  6797. return writeDouble(this, value, offset, true, noAssert)
  6798. }
  6799. Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) {
  6800. return writeDouble(this, value, offset, false, noAssert)
  6801. }
  6802. // copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)
  6803. Buffer.prototype.copy = function copy (target, targetStart, start, end) {
  6804. if (!start) start = 0
  6805. if (!end && end !== 0) end = this.length
  6806. if (targetStart >= target.length) targetStart = target.length
  6807. if (!targetStart) targetStart = 0
  6808. if (end > 0 && end < start) end = start
  6809. // Copy 0 bytes; we're done
  6810. if (end === start) return 0
  6811. if (target.length === 0 || this.length === 0) return 0
  6812. // Fatal error conditions
  6813. if (targetStart < 0) {
  6814. throw new RangeError('targetStart out of bounds')
  6815. }
  6816. if (start < 0 || start >= this.length) throw new RangeError('sourceStart out of bounds')
  6817. if (end < 0) throw new RangeError('sourceEnd out of bounds')
  6818. // Are we oob?
  6819. if (end > this.length) end = this.length
  6820. if (target.length - targetStart < end - start) {
  6821. end = target.length - targetStart + start
  6822. }
  6823. var len = end - start
  6824. var i
  6825. if (this === target && start < targetStart && targetStart < end) {
  6826. // descending copy from end
  6827. for (i = len - 1; i >= 0; --i) {
  6828. target[i + targetStart] = this[i + start]
  6829. }
  6830. } else if (len < 1000 || !Buffer.TYPED_ARRAY_SUPPORT) {
  6831. // ascending copy from start
  6832. for (i = 0; i < len; ++i) {
  6833. target[i + targetStart] = this[i + start]
  6834. }
  6835. } else {
  6836. Uint8Array.prototype.set.call(
  6837. target,
  6838. this.subarray(start, start + len),
  6839. targetStart
  6840. )
  6841. }
  6842. return len
  6843. }
  6844. // Usage:
  6845. // buffer.fill(number[, offset[, end]])
  6846. // buffer.fill(buffer[, offset[, end]])
  6847. // buffer.fill(string[, offset[, end]][, encoding])
  6848. Buffer.prototype.fill = function fill (val, start, end, encoding) {
  6849. // Handle string cases:
  6850. if (typeof val === 'string') {
  6851. if (typeof start === 'string') {
  6852. encoding = start
  6853. start = 0
  6854. end = this.length
  6855. } else if (typeof end === 'string') {
  6856. encoding = end
  6857. end = this.length
  6858. }
  6859. if (val.length === 1) {
  6860. var code = val.charCodeAt(0)
  6861. if (code < 256) {
  6862. val = code
  6863. }
  6864. }
  6865. if (encoding !== undefined && typeof encoding !== 'string') {
  6866. throw new TypeError('encoding must be a string')
  6867. }
  6868. if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) {
  6869. throw new TypeError('Unknown encoding: ' + encoding)
  6870. }
  6871. } else if (typeof val === 'number') {
  6872. val = val & 255
  6873. }
  6874. // Invalid ranges are not set to a default, so can range check early.
  6875. if (start < 0 || this.length < start || this.length < end) {
  6876. throw new RangeError('Out of range index')
  6877. }
  6878. if (end <= start) {
  6879. return this
  6880. }
  6881. start = start >>> 0
  6882. end = end === undefined ? this.length : end >>> 0
  6883. if (!val) val = 0
  6884. var i
  6885. if (typeof val === 'number') {
  6886. for (i = start; i < end; ++i) {
  6887. this[i] = val
  6888. }
  6889. } else {
  6890. var bytes = Buffer.isBuffer(val)
  6891. ? val
  6892. : utf8ToBytes(new Buffer(val, encoding).toString())
  6893. var len = bytes.length
  6894. for (i = 0; i < end - start; ++i) {
  6895. this[i + start] = bytes[i % len]
  6896. }
  6897. }
  6898. return this
  6899. }
  6900. // HELPER FUNCTIONS
  6901. // ================
  6902. var INVALID_BASE64_RE = /[^+\/0-9A-Za-z-_]/g
  6903. function base64clean (str) {
  6904. // Node strips out invalid characters like \n and \t from the string, base64-js does not
  6905. str = stringtrim(str).replace(INVALID_BASE64_RE, '')
  6906. // Node converts strings with length < 2 to ''
  6907. if (str.length < 2) return ''
  6908. // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not
  6909. while (str.length % 4 !== 0) {
  6910. str = str + '='
  6911. }
  6912. return str
  6913. }
  6914. function stringtrim (str) {
  6915. if (str.trim) return str.trim()
  6916. return str.replace(/^\s+|\s+$/g, '')
  6917. }
  6918. function toHex (n) {
  6919. if (n < 16) return '0' + n.toString(16)
  6920. return n.toString(16)
  6921. }
  6922. function utf8ToBytes (string, units) {
  6923. units = units || Infinity
  6924. var codePoint
  6925. var length = string.length
  6926. var leadSurrogate = null
  6927. var bytes = []
  6928. for (var i = 0; i < length; ++i) {
  6929. codePoint = string.charCodeAt(i)
  6930. // is surrogate component
  6931. if (codePoint > 0xD7FF && codePoint < 0xE000) {
  6932. // last char was a lead
  6933. if (!leadSurrogate) {
  6934. // no lead yet
  6935. if (codePoint > 0xDBFF) {
  6936. // unexpected trail
  6937. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  6938. continue
  6939. } else if (i + 1 === length) {
  6940. // unpaired lead
  6941. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  6942. continue
  6943. }
  6944. // valid lead
  6945. leadSurrogate = codePoint
  6946. continue
  6947. }
  6948. // 2 leads in a row
  6949. if (codePoint < 0xDC00) {
  6950. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  6951. leadSurrogate = codePoint
  6952. continue
  6953. }
  6954. // valid surrogate pair
  6955. codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000
  6956. } else if (leadSurrogate) {
  6957. // valid bmp char, but last char was a lead
  6958. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  6959. }
  6960. leadSurrogate = null
  6961. // encode utf8
  6962. if (codePoint < 0x80) {
  6963. if ((units -= 1) < 0) break
  6964. bytes.push(codePoint)
  6965. } else if (codePoint < 0x800) {
  6966. if ((units -= 2) < 0) break
  6967. bytes.push(
  6968. codePoint >> 0x6 | 0xC0,
  6969. codePoint & 0x3F | 0x80
  6970. )
  6971. } else if (codePoint < 0x10000) {
  6972. if ((units -= 3) < 0) break
  6973. bytes.push(
  6974. codePoint >> 0xC | 0xE0,
  6975. codePoint >> 0x6 & 0x3F | 0x80,
  6976. codePoint & 0x3F | 0x80
  6977. )
  6978. } else if (codePoint < 0x110000) {
  6979. if ((units -= 4) < 0) break
  6980. bytes.push(
  6981. codePoint >> 0x12 | 0xF0,
  6982. codePoint >> 0xC & 0x3F | 0x80,
  6983. codePoint >> 0x6 & 0x3F | 0x80,
  6984. codePoint & 0x3F | 0x80
  6985. )
  6986. } else {
  6987. throw new Error('Invalid code point')
  6988. }
  6989. }
  6990. return bytes
  6991. }
  6992. function asciiToBytes (str) {
  6993. var byteArray = []
  6994. for (var i = 0; i < str.length; ++i) {
  6995. // Node's code seems to be doing this and not & 0x7F..
  6996. byteArray.push(str.charCodeAt(i) & 0xFF)
  6997. }
  6998. return byteArray
  6999. }
  7000. function utf16leToBytes (str, units) {
  7001. var c, hi, lo
  7002. var byteArray = []
  7003. for (var i = 0; i < str.length; ++i) {
  7004. if ((units -= 2) < 0) break
  7005. c = str.charCodeAt(i)
  7006. hi = c >> 8
  7007. lo = c % 256
  7008. byteArray.push(lo)
  7009. byteArray.push(hi)
  7010. }
  7011. return byteArray
  7012. }
  7013. function base64ToBytes (str) {
  7014. return base64.toByteArray(base64clean(str))
  7015. }
  7016. function blitBuffer (src, dst, offset, length) {
  7017. for (var i = 0; i < length; ++i) {
  7018. if ((i + offset >= dst.length) || (i >= src.length)) break
  7019. dst[i + offset] = src[i]
  7020. }
  7021. return i
  7022. }
  7023. function isnan (val) {
  7024. return val !== val // eslint-disable-line no-self-compare
  7025. }
  7026. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../webpack/buildin/global.js */ "./node_modules/webpack/buildin/global.js")))
  7027. /***/ }),
  7028. /***/ "./node_modules/ieee754/index.js":
  7029. /*!***************************************!*\
  7030. !*** ./node_modules/ieee754/index.js ***!
  7031. \***************************************/
  7032. /*! no static exports found */
  7033. /***/ (function(module, exports) {
  7034. exports.read = function (buffer, offset, isLE, mLen, nBytes) {
  7035. var e, m
  7036. var eLen = (nBytes * 8) - mLen - 1
  7037. var eMax = (1 << eLen) - 1
  7038. var eBias = eMax >> 1
  7039. var nBits = -7
  7040. var i = isLE ? (nBytes - 1) : 0
  7041. var d = isLE ? -1 : 1
  7042. var s = buffer[offset + i]
  7043. i += d
  7044. e = s & ((1 << (-nBits)) - 1)
  7045. s >>= (-nBits)
  7046. nBits += eLen
  7047. for (; nBits > 0; e = (e * 256) + buffer[offset + i], i += d, nBits -= 8) {}
  7048. m = e & ((1 << (-nBits)) - 1)
  7049. e >>= (-nBits)
  7050. nBits += mLen
  7051. for (; nBits > 0; m = (m * 256) + buffer[offset + i], i += d, nBits -= 8) {}
  7052. if (e === 0) {
  7053. e = 1 - eBias
  7054. } else if (e === eMax) {
  7055. return m ? NaN : ((s ? -1 : 1) * Infinity)
  7056. } else {
  7057. m = m + Math.pow(2, mLen)
  7058. e = e - eBias
  7059. }
  7060. return (s ? -1 : 1) * m * Math.pow(2, e - mLen)
  7061. }
  7062. exports.write = function (buffer, value, offset, isLE, mLen, nBytes) {
  7063. var e, m, c
  7064. var eLen = (nBytes * 8) - mLen - 1
  7065. var eMax = (1 << eLen) - 1
  7066. var eBias = eMax >> 1
  7067. var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0)
  7068. var i = isLE ? 0 : (nBytes - 1)
  7069. var d = isLE ? 1 : -1
  7070. var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0
  7071. value = Math.abs(value)
  7072. if (isNaN(value) || value === Infinity) {
  7073. m = isNaN(value) ? 1 : 0
  7074. e = eMax
  7075. } else {
  7076. e = Math.floor(Math.log(value) / Math.LN2)
  7077. if (value * (c = Math.pow(2, -e)) < 1) {
  7078. e--
  7079. c *= 2
  7080. }
  7081. if (e + eBias >= 1) {
  7082. value += rt / c
  7083. } else {
  7084. value += rt * Math.pow(2, 1 - eBias)
  7085. }
  7086. if (value * c >= 2) {
  7087. e++
  7088. c /= 2
  7089. }
  7090. if (e + eBias >= eMax) {
  7091. m = 0
  7092. e = eMax
  7093. } else if (e + eBias >= 1) {
  7094. m = ((value * c) - 1) * Math.pow(2, mLen)
  7095. e = e + eBias
  7096. } else {
  7097. m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen)
  7098. e = 0
  7099. }
  7100. }
  7101. for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}
  7102. e = (e << mLen) | m
  7103. eLen += mLen
  7104. for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}
  7105. buffer[offset + i - d] |= s * 128
  7106. }
  7107. /***/ }),
  7108. /***/ "./node_modules/isarray/index.js":
  7109. /*!***************************************!*\
  7110. !*** ./node_modules/isarray/index.js ***!
  7111. \***************************************/
  7112. /*! no static exports found */
  7113. /***/ (function(module, exports) {
  7114. var toString = {}.toString;
  7115. module.exports = Array.isArray || function (arr) {
  7116. return toString.call(arr) == '[object Array]';
  7117. };
  7118. /***/ }),
  7119. /***/ "./node_modules/jquery/dist/jquery.js":
  7120. /*!********************************************!*\
  7121. !*** ./node_modules/jquery/dist/jquery.js ***!
  7122. \********************************************/
  7123. /*! no static exports found */
  7124. /***/ (function(module, exports, __webpack_require__) {
  7125. var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/*!
  7126. * jQuery JavaScript Library v3.4.1
  7127. * https://jquery.com/
  7128. *
  7129. * Includes Sizzle.js
  7130. * https://sizzlejs.com/
  7131. *
  7132. * Copyright JS Foundation and other contributors
  7133. * Released under the MIT license
  7134. * https://jquery.org/license
  7135. *
  7136. * Date: 2019-05-01T21:04Z
  7137. */
  7138. ( function( global, factory ) {
  7139. "use strict";
  7140. if ( true && typeof module.exports === "object" ) {
  7141. // For CommonJS and CommonJS-like environments where a proper `window`
  7142. // is present, execute the factory and get jQuery.
  7143. // For environments that do not have a `window` with a `document`
  7144. // (such as Node.js), expose a factory as module.exports.
  7145. // This accentuates the need for the creation of a real `window`.
  7146. // e.g. var jQuery = require("jquery")(window);
  7147. // See ticket #14549 for more info.
  7148. module.exports = global.document ?
  7149. factory( global, true ) :
  7150. function( w ) {
  7151. if ( !w.document ) {
  7152. throw new Error( "jQuery requires a window with a document" );
  7153. }
  7154. return factory( w );
  7155. };
  7156. } else {
  7157. factory( global );
  7158. }
  7159. // Pass this if window is not defined yet
  7160. } )( typeof window !== "undefined" ? window : this, function( window, noGlobal ) {
  7161. // Edge <= 12 - 13+, Firefox <=18 - 45+, IE 10 - 11, Safari 5.1 - 9+, iOS 6 - 9.1
  7162. // throw exceptions when non-strict code (e.g., ASP.NET 4.5) accesses strict mode
  7163. // arguments.callee.caller (trac-13335). But as of jQuery 3.0 (2016), strict mode should be common
  7164. // enough that all such attempts are guarded in a try block.
  7165. "use strict";
  7166. var arr = [];
  7167. var document = window.document;
  7168. var getProto = Object.getPrototypeOf;
  7169. var slice = arr.slice;
  7170. var concat = arr.concat;
  7171. var push = arr.push;
  7172. var indexOf = arr.indexOf;
  7173. var class2type = {};
  7174. var toString = class2type.toString;
  7175. var hasOwn = class2type.hasOwnProperty;
  7176. var fnToString = hasOwn.toString;
  7177. var ObjectFunctionString = fnToString.call( Object );
  7178. var support = {};
  7179. var isFunction = function isFunction( obj ) {
  7180. // Support: Chrome <=57, Firefox <=52
  7181. // In some browsers, typeof returns "function" for HTML <object> elements
  7182. // (i.e., `typeof document.createElement( "object" ) === "function"`).
  7183. // We don't want to classify *any* DOM node as a function.
  7184. return typeof obj === "function" && typeof obj.nodeType !== "number";
  7185. };
  7186. var isWindow = function isWindow( obj ) {
  7187. return obj != null && obj === obj.window;
  7188. };
  7189. var preservedScriptAttributes = {
  7190. type: true,
  7191. src: true,
  7192. nonce: true,
  7193. noModule: true
  7194. };
  7195. function DOMEval( code, node, doc ) {
  7196. doc = doc || document;
  7197. var i, val,
  7198. script = doc.createElement( "script" );
  7199. script.text = code;
  7200. if ( node ) {
  7201. for ( i in preservedScriptAttributes ) {
  7202. // Support: Firefox 64+, Edge 18+
  7203. // Some browsers don't support the "nonce" property on scripts.
  7204. // On the other hand, just using `getAttribute` is not enough as
  7205. // the `nonce` attribute is reset to an empty string whenever it
  7206. // becomes browsing-context connected.
  7207. // See https://github.com/whatwg/html/issues/2369
  7208. // See https://html.spec.whatwg.org/#nonce-attributes
  7209. // The `node.getAttribute` check was added for the sake of
  7210. // `jQuery.globalEval` so that it can fake a nonce-containing node
  7211. // via an object.
  7212. val = node[ i ] || node.getAttribute && node.getAttribute( i );
  7213. if ( val ) {
  7214. script.setAttribute( i, val );
  7215. }
  7216. }
  7217. }
  7218. doc.head.appendChild( script ).parentNode.removeChild( script );
  7219. }
  7220. function toType( obj ) {
  7221. if ( obj == null ) {
  7222. return obj + "";
  7223. }
  7224. // Support: Android <=2.3 only (functionish RegExp)
  7225. return typeof obj === "object" || typeof obj === "function" ?
  7226. class2type[ toString.call( obj ) ] || "object" :
  7227. typeof obj;
  7228. }
  7229. /* global Symbol */
  7230. // Defining this global in .eslintrc.json would create a danger of using the global
  7231. // unguarded in another place, it seems safer to define global only for this module
  7232. var
  7233. version = "3.4.1",
  7234. // Define a local copy of jQuery
  7235. jQuery = function( selector, context ) {
  7236. // The jQuery object is actually just the init constructor 'enhanced'
  7237. // Need init if jQuery is called (just allow error to be thrown if not included)
  7238. return new jQuery.fn.init( selector, context );
  7239. },
  7240. // Support: Android <=4.0 only
  7241. // Make sure we trim BOM and NBSP
  7242. rtrim = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g;
  7243. jQuery.fn = jQuery.prototype = {
  7244. // The current version of jQuery being used
  7245. jquery: version,
  7246. constructor: jQuery,
  7247. // The default length of a jQuery object is 0
  7248. length: 0,
  7249. toArray: function() {
  7250. return slice.call( this );
  7251. },
  7252. // Get the Nth element in the matched element set OR
  7253. // Get the whole matched element set as a clean array
  7254. get: function( num ) {
  7255. // Return all the elements in a clean array
  7256. if ( num == null ) {
  7257. return slice.call( this );
  7258. }
  7259. // Return just the one element from the set
  7260. return num < 0 ? this[ num + this.length ] : this[ num ];
  7261. },
  7262. // Take an array of elements and push it onto the stack
  7263. // (returning the new matched element set)
  7264. pushStack: function( elems ) {
  7265. // Build a new jQuery matched element set
  7266. var ret = jQuery.merge( this.constructor(), elems );
  7267. // Add the old object onto the stack (as a reference)
  7268. ret.prevObject = this;
  7269. // Return the newly-formed element set
  7270. return ret;
  7271. },
  7272. // Execute a callback for every element in the matched set.
  7273. each: function( callback ) {
  7274. return jQuery.each( this, callback );
  7275. },
  7276. map: function( callback ) {
  7277. return this.pushStack( jQuery.map( this, function( elem, i ) {
  7278. return callback.call( elem, i, elem );
  7279. } ) );
  7280. },
  7281. slice: function() {
  7282. return this.pushStack( slice.apply( this, arguments ) );
  7283. },
  7284. first: function() {
  7285. return this.eq( 0 );
  7286. },
  7287. last: function() {
  7288. return this.eq( -1 );
  7289. },
  7290. eq: function( i ) {
  7291. var len = this.length,
  7292. j = +i + ( i < 0 ? len : 0 );
  7293. return this.pushStack( j >= 0 && j < len ? [ this[ j ] ] : [] );
  7294. },
  7295. end: function() {
  7296. return this.prevObject || this.constructor();
  7297. },
  7298. // For internal use only.
  7299. // Behaves like an Array's method, not like a jQuery method.
  7300. push: push,
  7301. sort: arr.sort,
  7302. splice: arr.splice
  7303. };
  7304. jQuery.extend = jQuery.fn.extend = function() {
  7305. var options, name, src, copy, copyIsArray, clone,
  7306. target = arguments[ 0 ] || {},
  7307. i = 1,
  7308. length = arguments.length,
  7309. deep = false;
  7310. // Handle a deep copy situation
  7311. if ( typeof target === "boolean" ) {
  7312. deep = target;
  7313. // Skip the boolean and the target
  7314. target = arguments[ i ] || {};
  7315. i++;
  7316. }
  7317. // Handle case when target is a string or something (possible in deep copy)
  7318. if ( typeof target !== "object" && !isFunction( target ) ) {
  7319. target = {};
  7320. }
  7321. // Extend jQuery itself if only one argument is passed
  7322. if ( i === length ) {
  7323. target = this;
  7324. i--;
  7325. }
  7326. for ( ; i < length; i++ ) {
  7327. // Only deal with non-null/undefined values
  7328. if ( ( options = arguments[ i ] ) != null ) {
  7329. // Extend the base object
  7330. for ( name in options ) {
  7331. copy = options[ name ];
  7332. // Prevent Object.prototype pollution
  7333. // Prevent never-ending loop
  7334. if ( name === "__proto__" || target === copy ) {
  7335. continue;
  7336. }
  7337. // Recurse if we're merging plain objects or arrays
  7338. if ( deep && copy && ( jQuery.isPlainObject( copy ) ||
  7339. ( copyIsArray = Array.isArray( copy ) ) ) ) {
  7340. src = target[ name ];
  7341. // Ensure proper type for the source value
  7342. if ( copyIsArray && !Array.isArray( src ) ) {
  7343. clone = [];
  7344. } else if ( !copyIsArray && !jQuery.isPlainObject( src ) ) {
  7345. clone = {};
  7346. } else {
  7347. clone = src;
  7348. }
  7349. copyIsArray = false;
  7350. // Never move original objects, clone them
  7351. target[ name ] = jQuery.extend( deep, clone, copy );
  7352. // Don't bring in undefined values
  7353. } else if ( copy !== undefined ) {
  7354. target[ name ] = copy;
  7355. }
  7356. }
  7357. }
  7358. }
  7359. // Return the modified object
  7360. return target;
  7361. };
  7362. jQuery.extend( {
  7363. // Unique for each copy of jQuery on the page
  7364. expando: "jQuery" + ( version + Math.random() ).replace( /\D/g, "" ),
  7365. // Assume jQuery is ready without the ready module
  7366. isReady: true,
  7367. error: function( msg ) {
  7368. throw new Error( msg );
  7369. },
  7370. noop: function() {},
  7371. isPlainObject: function( obj ) {
  7372. var proto, Ctor;
  7373. // Detect obvious negatives
  7374. // Use toString instead of jQuery.type to catch host objects
  7375. if ( !obj || toString.call( obj ) !== "[object Object]" ) {
  7376. return false;
  7377. }
  7378. proto = getProto( obj );
  7379. // Objects with no prototype (e.g., `Object.create( null )`) are plain
  7380. if ( !proto ) {
  7381. return true;
  7382. }
  7383. // Objects with prototype are plain iff they were constructed by a global Object function
  7384. Ctor = hasOwn.call( proto, "constructor" ) && proto.constructor;
  7385. return typeof Ctor === "function" && fnToString.call( Ctor ) === ObjectFunctionString;
  7386. },
  7387. isEmptyObject: function( obj ) {
  7388. var name;
  7389. for ( name in obj ) {
  7390. return false;
  7391. }
  7392. return true;
  7393. },
  7394. // Evaluates a script in a global context
  7395. globalEval: function( code, options ) {
  7396. DOMEval( code, { nonce: options && options.nonce } );
  7397. },
  7398. each: function( obj, callback ) {
  7399. var length, i = 0;
  7400. if ( isArrayLike( obj ) ) {
  7401. length = obj.length;
  7402. for ( ; i < length; i++ ) {
  7403. if ( callback.call( obj[ i ], i, obj[ i ] ) === false ) {
  7404. break;
  7405. }
  7406. }
  7407. } else {
  7408. for ( i in obj ) {
  7409. if ( callback.call( obj[ i ], i, obj[ i ] ) === false ) {
  7410. break;
  7411. }
  7412. }
  7413. }
  7414. return obj;
  7415. },
  7416. // Support: Android <=4.0 only
  7417. trim: function( text ) {
  7418. return text == null ?
  7419. "" :
  7420. ( text + "" ).replace( rtrim, "" );
  7421. },
  7422. // results is for internal usage only
  7423. makeArray: function( arr, results ) {
  7424. var ret = results || [];
  7425. if ( arr != null ) {
  7426. if ( isArrayLike( Object( arr ) ) ) {
  7427. jQuery.merge( ret,
  7428. typeof arr === "string" ?
  7429. [ arr ] : arr
  7430. );
  7431. } else {
  7432. push.call( ret, arr );
  7433. }
  7434. }
  7435. return ret;
  7436. },
  7437. inArray: function( elem, arr, i ) {
  7438. return arr == null ? -1 : indexOf.call( arr, elem, i );
  7439. },
  7440. // Support: Android <=4.0 only, PhantomJS 1 only
  7441. // push.apply(_, arraylike) throws on ancient WebKit
  7442. merge: function( first, second ) {
  7443. var len = +second.length,
  7444. j = 0,
  7445. i = first.length;
  7446. for ( ; j < len; j++ ) {
  7447. first[ i++ ] = second[ j ];
  7448. }
  7449. first.length = i;
  7450. return first;
  7451. },
  7452. grep: function( elems, callback, invert ) {
  7453. var callbackInverse,
  7454. matches = [],
  7455. i = 0,
  7456. length = elems.length,
  7457. callbackExpect = !invert;
  7458. // Go through the array, only saving the items
  7459. // that pass the validator function
  7460. for ( ; i < length; i++ ) {
  7461. callbackInverse = !callback( elems[ i ], i );
  7462. if ( callbackInverse !== callbackExpect ) {
  7463. matches.push( elems[ i ] );
  7464. }
  7465. }
  7466. return matches;
  7467. },
  7468. // arg is for internal usage only
  7469. map: function( elems, callback, arg ) {
  7470. var length, value,
  7471. i = 0,
  7472. ret = [];
  7473. // Go through the array, translating each of the items to their new values
  7474. if ( isArrayLike( elems ) ) {
  7475. length = elems.length;
  7476. for ( ; i < length; i++ ) {
  7477. value = callback( elems[ i ], i, arg );
  7478. if ( value != null ) {
  7479. ret.push( value );
  7480. }
  7481. }
  7482. // Go through every key on the object,
  7483. } else {
  7484. for ( i in elems ) {
  7485. value = callback( elems[ i ], i, arg );
  7486. if ( value != null ) {
  7487. ret.push( value );
  7488. }
  7489. }
  7490. }
  7491. // Flatten any nested arrays
  7492. return concat.apply( [], ret );
  7493. },
  7494. // A global GUID counter for objects
  7495. guid: 1,
  7496. // jQuery.support is not used in Core but other projects attach their
  7497. // properties to it so it needs to exist.
  7498. support: support
  7499. } );
  7500. if ( typeof Symbol === "function" ) {
  7501. jQuery.fn[ Symbol.iterator ] = arr[ Symbol.iterator ];
  7502. }
  7503. // Populate the class2type map
  7504. jQuery.each( "Boolean Number String Function Array Date RegExp Object Error Symbol".split( " " ),
  7505. function( i, name ) {
  7506. class2type[ "[object " + name + "]" ] = name.toLowerCase();
  7507. } );
  7508. function isArrayLike( obj ) {
  7509. // Support: real iOS 8.2 only (not reproducible in simulator)
  7510. // `in` check used to prevent JIT error (gh-2145)
  7511. // hasOwn isn't used here due to false negatives
  7512. // regarding Nodelist length in IE
  7513. var length = !!obj && "length" in obj && obj.length,
  7514. type = toType( obj );
  7515. if ( isFunction( obj ) || isWindow( obj ) ) {
  7516. return false;
  7517. }
  7518. return type === "array" || length === 0 ||
  7519. typeof length === "number" && length > 0 && ( length - 1 ) in obj;
  7520. }
  7521. var Sizzle =
  7522. /*!
  7523. * Sizzle CSS Selector Engine v2.3.4
  7524. * https://sizzlejs.com/
  7525. *
  7526. * Copyright JS Foundation and other contributors
  7527. * Released under the MIT license
  7528. * https://js.foundation/
  7529. *
  7530. * Date: 2019-04-08
  7531. */
  7532. (function( window ) {
  7533. var i,
  7534. support,
  7535. Expr,
  7536. getText,
  7537. isXML,
  7538. tokenize,
  7539. compile,
  7540. select,
  7541. outermostContext,
  7542. sortInput,
  7543. hasDuplicate,
  7544. // Local document vars
  7545. setDocument,
  7546. document,
  7547. docElem,
  7548. documentIsHTML,
  7549. rbuggyQSA,
  7550. rbuggyMatches,
  7551. matches,
  7552. contains,
  7553. // Instance-specific data
  7554. expando = "sizzle" + 1 * new Date(),
  7555. preferredDoc = window.document,
  7556. dirruns = 0,
  7557. done = 0,
  7558. classCache = createCache(),
  7559. tokenCache = createCache(),
  7560. compilerCache = createCache(),
  7561. nonnativeSelectorCache = createCache(),
  7562. sortOrder = function( a, b ) {
  7563. if ( a === b ) {
  7564. hasDuplicate = true;
  7565. }
  7566. return 0;
  7567. },
  7568. // Instance methods
  7569. hasOwn = ({}).hasOwnProperty,
  7570. arr = [],
  7571. pop = arr.pop,
  7572. push_native = arr.push,
  7573. push = arr.push,
  7574. slice = arr.slice,
  7575. // Use a stripped-down indexOf as it's faster than native
  7576. // https://jsperf.com/thor-indexof-vs-for/5
  7577. indexOf = function( list, elem ) {
  7578. var i = 0,
  7579. len = list.length;
  7580. for ( ; i < len; i++ ) {
  7581. if ( list[i] === elem ) {
  7582. return i;
  7583. }
  7584. }
  7585. return -1;
  7586. },
  7587. booleans = "checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",
  7588. // Regular expressions
  7589. // http://www.w3.org/TR/css3-selectors/#whitespace
  7590. whitespace = "[\\x20\\t\\r\\n\\f]",
  7591. // http://www.w3.org/TR/CSS21/syndata.html#value-def-identifier
  7592. identifier = "(?:\\\\.|[\\w-]|[^\0-\\xa0])+",
  7593. // Attribute selectors: http://www.w3.org/TR/selectors/#attribute-selectors
  7594. attributes = "\\[" + whitespace + "*(" + identifier + ")(?:" + whitespace +
  7595. // Operator (capture 2)
  7596. "*([*^$|!~]?=)" + whitespace +
  7597. // "Attribute values must be CSS identifiers [capture 5] or strings [capture 3 or capture 4]"
  7598. "*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|(" + identifier + "))|)" + whitespace +
  7599. "*\\]",
  7600. pseudos = ":(" + identifier + ")(?:\\((" +
  7601. // To reduce the number of selectors needing tokenize in the preFilter, prefer arguments:
  7602. // 1. quoted (capture 3; capture 4 or capture 5)
  7603. "('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|" +
  7604. // 2. simple (capture 6)
  7605. "((?:\\\\.|[^\\\\()[\\]]|" + attributes + ")*)|" +
  7606. // 3. anything else (capture 2)
  7607. ".*" +
  7608. ")\\)|)",
  7609. // Leading and non-escaped trailing whitespace, capturing some non-whitespace characters preceding the latter
  7610. rwhitespace = new RegExp( whitespace + "+", "g" ),
  7611. rtrim = new RegExp( "^" + whitespace + "+|((?:^|[^\\\\])(?:\\\\.)*)" + whitespace + "+$", "g" ),
  7612. rcomma = new RegExp( "^" + whitespace + "*," + whitespace + "*" ),
  7613. rcombinators = new RegExp( "^" + whitespace + "*([>+~]|" + whitespace + ")" + whitespace + "*" ),
  7614. rdescend = new RegExp( whitespace + "|>" ),
  7615. rpseudo = new RegExp( pseudos ),
  7616. ridentifier = new RegExp( "^" + identifier + "$" ),
  7617. matchExpr = {
  7618. "ID": new RegExp( "^#(" + identifier + ")" ),
  7619. "CLASS": new RegExp( "^\\.(" + identifier + ")" ),
  7620. "TAG": new RegExp( "^(" + identifier + "|[*])" ),
  7621. "ATTR": new RegExp( "^" + attributes ),
  7622. "PSEUDO": new RegExp( "^" + pseudos ),
  7623. "CHILD": new RegExp( "^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\(" + whitespace +
  7624. "*(even|odd|(([+-]|)(\\d*)n|)" + whitespace + "*(?:([+-]|)" + whitespace +
  7625. "*(\\d+)|))" + whitespace + "*\\)|)", "i" ),
  7626. "bool": new RegExp( "^(?:" + booleans + ")$", "i" ),
  7627. // For use in libraries implementing .is()
  7628. // We use this for POS matching in `select`
  7629. "needsContext": new RegExp( "^" + whitespace + "*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\(" +
  7630. whitespace + "*((?:-\\d)?\\d*)" + whitespace + "*\\)|)(?=[^-]|$)", "i" )
  7631. },
  7632. rhtml = /HTML$/i,
  7633. rinputs = /^(?:input|select|textarea|button)$/i,
  7634. rheader = /^h\d$/i,
  7635. rnative = /^[^{]+\{\s*\[native \w/,
  7636. // Easily-parseable/retrievable ID or TAG or CLASS selectors
  7637. rquickExpr = /^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,
  7638. rsibling = /[+~]/,
  7639. // CSS escapes
  7640. // http://www.w3.org/TR/CSS21/syndata.html#escaped-characters
  7641. runescape = new RegExp( "\\\\([\\da-f]{1,6}" + whitespace + "?|(" + whitespace + ")|.)", "ig" ),
  7642. funescape = function( _, escaped, escapedWhitespace ) {
  7643. var high = "0x" + escaped - 0x10000;
  7644. // NaN means non-codepoint
  7645. // Support: Firefox<24
  7646. // Workaround erroneous numeric interpretation of +"0x"
  7647. return high !== high || escapedWhitespace ?
  7648. escaped :
  7649. high < 0 ?
  7650. // BMP codepoint
  7651. String.fromCharCode( high + 0x10000 ) :
  7652. // Supplemental Plane codepoint (surrogate pair)
  7653. String.fromCharCode( high >> 10 | 0xD800, high & 0x3FF | 0xDC00 );
  7654. },
  7655. // CSS string/identifier serialization
  7656. // https://drafts.csswg.org/cssom/#common-serializing-idioms
  7657. rcssescape = /([\0-\x1f\x7f]|^-?\d)|^-$|[^\0-\x1f\x7f-\uFFFF\w-]/g,
  7658. fcssescape = function( ch, asCodePoint ) {
  7659. if ( asCodePoint ) {
  7660. // U+0000 NULL becomes U+FFFD REPLACEMENT CHARACTER
  7661. if ( ch === "\0" ) {
  7662. return "\uFFFD";
  7663. }
  7664. // Control characters and (dependent upon position) numbers get escaped as code points
  7665. return ch.slice( 0, -1 ) + "\\" + ch.charCodeAt( ch.length - 1 ).toString( 16 ) + " ";
  7666. }
  7667. // Other potentially-special ASCII characters get backslash-escaped
  7668. return "\\" + ch;
  7669. },
  7670. // Used for iframes
  7671. // See setDocument()
  7672. // Removing the function wrapper causes a "Permission Denied"
  7673. // error in IE
  7674. unloadHandler = function() {
  7675. setDocument();
  7676. },
  7677. inDisabledFieldset = addCombinator(
  7678. function( elem ) {
  7679. return elem.disabled === true && elem.nodeName.toLowerCase() === "fieldset";
  7680. },
  7681. { dir: "parentNode", next: "legend" }
  7682. );
  7683. // Optimize for push.apply( _, NodeList )
  7684. try {
  7685. push.apply(
  7686. (arr = slice.call( preferredDoc.childNodes )),
  7687. preferredDoc.childNodes
  7688. );
  7689. // Support: Android<4.0
  7690. // Detect silently failing push.apply
  7691. arr[ preferredDoc.childNodes.length ].nodeType;
  7692. } catch ( e ) {
  7693. push = { apply: arr.length ?
  7694. // Leverage slice if possible
  7695. function( target, els ) {
  7696. push_native.apply( target, slice.call(els) );
  7697. } :
  7698. // Support: IE<9
  7699. // Otherwise append directly
  7700. function( target, els ) {
  7701. var j = target.length,
  7702. i = 0;
  7703. // Can't trust NodeList.length
  7704. while ( (target[j++] = els[i++]) ) {}
  7705. target.length = j - 1;
  7706. }
  7707. };
  7708. }
  7709. function Sizzle( selector, context, results, seed ) {
  7710. var m, i, elem, nid, match, groups, newSelector,
  7711. newContext = context && context.ownerDocument,
  7712. // nodeType defaults to 9, since context defaults to document
  7713. nodeType = context ? context.nodeType : 9;
  7714. results = results || [];
  7715. // Return early from calls with invalid selector or context
  7716. if ( typeof selector !== "string" || !selector ||
  7717. nodeType !== 1 && nodeType !== 9 && nodeType !== 11 ) {
  7718. return results;
  7719. }
  7720. // Try to shortcut find operations (as opposed to filters) in HTML documents
  7721. if ( !seed ) {
  7722. if ( ( context ? context.ownerDocument || context : preferredDoc ) !== document ) {
  7723. setDocument( context );
  7724. }
  7725. context = context || document;
  7726. if ( documentIsHTML ) {
  7727. // If the selector is sufficiently simple, try using a "get*By*" DOM method
  7728. // (excepting DocumentFragment context, where the methods don't exist)
  7729. if ( nodeType !== 11 && (match = rquickExpr.exec( selector )) ) {
  7730. // ID selector
  7731. if ( (m = match[1]) ) {
  7732. // Document context
  7733. if ( nodeType === 9 ) {
  7734. if ( (elem = context.getElementById( m )) ) {
  7735. // Support: IE, Opera, Webkit
  7736. // TODO: identify versions
  7737. // getElementById can match elements by name instead of ID
  7738. if ( elem.id === m ) {
  7739. results.push( elem );
  7740. return results;
  7741. }
  7742. } else {
  7743. return results;
  7744. }
  7745. // Element context
  7746. } else {
  7747. // Support: IE, Opera, Webkit
  7748. // TODO: identify versions
  7749. // getElementById can match elements by name instead of ID
  7750. if ( newContext && (elem = newContext.getElementById( m )) &&
  7751. contains( context, elem ) &&
  7752. elem.id === m ) {
  7753. results.push( elem );
  7754. return results;
  7755. }
  7756. }
  7757. // Type selector
  7758. } else if ( match[2] ) {
  7759. push.apply( results, context.getElementsByTagName( selector ) );
  7760. return results;
  7761. // Class selector
  7762. } else if ( (m = match[3]) && support.getElementsByClassName &&
  7763. context.getElementsByClassName ) {
  7764. push.apply( results, context.getElementsByClassName( m ) );
  7765. return results;
  7766. }
  7767. }
  7768. // Take advantage of querySelectorAll
  7769. if ( support.qsa &&
  7770. !nonnativeSelectorCache[ selector + " " ] &&
  7771. (!rbuggyQSA || !rbuggyQSA.test( selector )) &&
  7772. // Support: IE 8 only
  7773. // Exclude object elements
  7774. (nodeType !== 1 || context.nodeName.toLowerCase() !== "object") ) {
  7775. newSelector = selector;
  7776. newContext = context;
  7777. // qSA considers elements outside a scoping root when evaluating child or
  7778. // descendant combinators, which is not what we want.
  7779. // In such cases, we work around the behavior by prefixing every selector in the
  7780. // list with an ID selector referencing the scope context.
  7781. // Thanks to Andrew Dupont for this technique.
  7782. if ( nodeType === 1 && rdescend.test( selector ) ) {
  7783. // Capture the context ID, setting it first if necessary
  7784. if ( (nid = context.getAttribute( "id" )) ) {
  7785. nid = nid.replace( rcssescape, fcssescape );
  7786. } else {
  7787. context.setAttribute( "id", (nid = expando) );
  7788. }
  7789. // Prefix every selector in the list
  7790. groups = tokenize( selector );
  7791. i = groups.length;
  7792. while ( i-- ) {
  7793. groups[i] = "#" + nid + " " + toSelector( groups[i] );
  7794. }
  7795. newSelector = groups.join( "," );
  7796. // Expand context for sibling selectors
  7797. newContext = rsibling.test( selector ) && testContext( context.parentNode ) ||
  7798. context;
  7799. }
  7800. try {
  7801. push.apply( results,
  7802. newContext.querySelectorAll( newSelector )
  7803. );
  7804. return results;
  7805. } catch ( qsaError ) {
  7806. nonnativeSelectorCache( selector, true );
  7807. } finally {
  7808. if ( nid === expando ) {
  7809. context.removeAttribute( "id" );
  7810. }
  7811. }
  7812. }
  7813. }
  7814. }
  7815. // All others
  7816. return select( selector.replace( rtrim, "$1" ), context, results, seed );
  7817. }
  7818. /**
  7819. * Create key-value caches of limited size
  7820. * @returns {function(string, object)} Returns the Object data after storing it on itself with
  7821. * property name the (space-suffixed) string and (if the cache is larger than Expr.cacheLength)
  7822. * deleting the oldest entry
  7823. */
  7824. function createCache() {
  7825. var keys = [];
  7826. function cache( key, value ) {
  7827. // Use (key + " ") to avoid collision with native prototype properties (see Issue #157)
  7828. if ( keys.push( key + " " ) > Expr.cacheLength ) {
  7829. // Only keep the most recent entries
  7830. delete cache[ keys.shift() ];
  7831. }
  7832. return (cache[ key + " " ] = value);
  7833. }
  7834. return cache;
  7835. }
  7836. /**
  7837. * Mark a function for special use by Sizzle
  7838. * @param {Function} fn The function to mark
  7839. */
  7840. function markFunction( fn ) {
  7841. fn[ expando ] = true;
  7842. return fn;
  7843. }
  7844. /**
  7845. * Support testing using an element
  7846. * @param {Function} fn Passed the created element and returns a boolean result
  7847. */
  7848. function assert( fn ) {
  7849. var el = document.createElement("fieldset");
  7850. try {
  7851. return !!fn( el );
  7852. } catch (e) {
  7853. return false;
  7854. } finally {
  7855. // Remove from its parent by default
  7856. if ( el.parentNode ) {
  7857. el.parentNode.removeChild( el );
  7858. }
  7859. // release memory in IE
  7860. el = null;
  7861. }
  7862. }
  7863. /**
  7864. * Adds the same handler for all of the specified attrs
  7865. * @param {String} attrs Pipe-separated list of attributes
  7866. * @param {Function} handler The method that will be applied
  7867. */
  7868. function addHandle( attrs, handler ) {
  7869. var arr = attrs.split("|"),
  7870. i = arr.length;
  7871. while ( i-- ) {
  7872. Expr.attrHandle[ arr[i] ] = handler;
  7873. }
  7874. }
  7875. /**
  7876. * Checks document order of two siblings
  7877. * @param {Element} a
  7878. * @param {Element} b
  7879. * @returns {Number} Returns less than 0 if a precedes b, greater than 0 if a follows b
  7880. */
  7881. function siblingCheck( a, b ) {
  7882. var cur = b && a,
  7883. diff = cur && a.nodeType === 1 && b.nodeType === 1 &&
  7884. a.sourceIndex - b.sourceIndex;
  7885. // Use IE sourceIndex if available on both nodes
  7886. if ( diff ) {
  7887. return diff;
  7888. }
  7889. // Check if b follows a
  7890. if ( cur ) {
  7891. while ( (cur = cur.nextSibling) ) {
  7892. if ( cur === b ) {
  7893. return -1;
  7894. }
  7895. }
  7896. }
  7897. return a ? 1 : -1;
  7898. }
  7899. /**
  7900. * Returns a function to use in pseudos for input types
  7901. * @param {String} type
  7902. */
  7903. function createInputPseudo( type ) {
  7904. return function( elem ) {
  7905. var name = elem.nodeName.toLowerCase();
  7906. return name === "input" && elem.type === type;
  7907. };
  7908. }
  7909. /**
  7910. * Returns a function to use in pseudos for buttons
  7911. * @param {String} type
  7912. */
  7913. function createButtonPseudo( type ) {
  7914. return function( elem ) {
  7915. var name = elem.nodeName.toLowerCase();
  7916. return (name === "input" || name === "button") && elem.type === type;
  7917. };
  7918. }
  7919. /**
  7920. * Returns a function to use in pseudos for :enabled/:disabled
  7921. * @param {Boolean} disabled true for :disabled; false for :enabled
  7922. */
  7923. function createDisabledPseudo( disabled ) {
  7924. // Known :disabled false positives: fieldset[disabled] > legend:nth-of-type(n+2) :can-disable
  7925. return function( elem ) {
  7926. // Only certain elements can match :enabled or :disabled
  7927. // https://html.spec.whatwg.org/multipage/scripting.html#selector-enabled
  7928. // https://html.spec.whatwg.org/multipage/scripting.html#selector-disabled
  7929. if ( "form" in elem ) {
  7930. // Check for inherited disabledness on relevant non-disabled elements:
  7931. // * listed form-associated elements in a disabled fieldset
  7932. // https://html.spec.whatwg.org/multipage/forms.html#category-listed
  7933. // https://html.spec.whatwg.org/multipage/forms.html#concept-fe-disabled
  7934. // * option elements in a disabled optgroup
  7935. // https://html.spec.whatwg.org/multipage/forms.html#concept-option-disabled
  7936. // All such elements have a "form" property.
  7937. if ( elem.parentNode && elem.disabled === false ) {
  7938. // Option elements defer to a parent optgroup if present
  7939. if ( "label" in elem ) {
  7940. if ( "label" in elem.parentNode ) {
  7941. return elem.parentNode.disabled === disabled;
  7942. } else {
  7943. return elem.disabled === disabled;
  7944. }
  7945. }
  7946. // Support: IE 6 - 11
  7947. // Use the isDisabled shortcut property to check for disabled fieldset ancestors
  7948. return elem.isDisabled === disabled ||
  7949. // Where there is no isDisabled, check manually
  7950. /* jshint -W018 */
  7951. elem.isDisabled !== !disabled &&
  7952. inDisabledFieldset( elem ) === disabled;
  7953. }
  7954. return elem.disabled === disabled;
  7955. // Try to winnow out elements that can't be disabled before trusting the disabled property.
  7956. // Some victims get caught in our net (label, legend, menu, track), but it shouldn't
  7957. // even exist on them, let alone have a boolean value.
  7958. } else if ( "label" in elem ) {
  7959. return elem.disabled === disabled;
  7960. }
  7961. // Remaining elements are neither :enabled nor :disabled
  7962. return false;
  7963. };
  7964. }
  7965. /**
  7966. * Returns a function to use in pseudos for positionals
  7967. * @param {Function} fn
  7968. */
  7969. function createPositionalPseudo( fn ) {
  7970. return markFunction(function( argument ) {
  7971. argument = +argument;
  7972. return markFunction(function( seed, matches ) {
  7973. var j,
  7974. matchIndexes = fn( [], seed.length, argument ),
  7975. i = matchIndexes.length;
  7976. // Match elements found at the specified indexes
  7977. while ( i-- ) {
  7978. if ( seed[ (j = matchIndexes[i]) ] ) {
  7979. seed[j] = !(matches[j] = seed[j]);
  7980. }
  7981. }
  7982. });
  7983. });
  7984. }
  7985. /**
  7986. * Checks a node for validity as a Sizzle context
  7987. * @param {Element|Object=} context
  7988. * @returns {Element|Object|Boolean} The input node if acceptable, otherwise a falsy value
  7989. */
  7990. function testContext( context ) {
  7991. return context && typeof context.getElementsByTagName !== "undefined" && context;
  7992. }
  7993. // Expose support vars for convenience
  7994. support = Sizzle.support = {};
  7995. /**
  7996. * Detects XML nodes
  7997. * @param {Element|Object} elem An element or a document
  7998. * @returns {Boolean} True iff elem is a non-HTML XML node
  7999. */
  8000. isXML = Sizzle.isXML = function( elem ) {
  8001. var namespace = elem.namespaceURI,
  8002. docElem = (elem.ownerDocument || elem).documentElement;
  8003. // Support: IE <=8
  8004. // Assume HTML when documentElement doesn't yet exist, such as inside loading iframes
  8005. // https://bugs.jquery.com/ticket/4833
  8006. return !rhtml.test( namespace || docElem && docElem.nodeName || "HTML" );
  8007. };
  8008. /**
  8009. * Sets document-related variables once based on the current document
  8010. * @param {Element|Object} [doc] An element or document object to use to set the document
  8011. * @returns {Object} Returns the current document
  8012. */
  8013. setDocument = Sizzle.setDocument = function( node ) {
  8014. var hasCompare, subWindow,
  8015. doc = node ? node.ownerDocument || node : preferredDoc;
  8016. // Return early if doc is invalid or already selected
  8017. if ( doc === document || doc.nodeType !== 9 || !doc.documentElement ) {
  8018. return document;
  8019. }
  8020. // Update global variables
  8021. document = doc;
  8022. docElem = document.documentElement;
  8023. documentIsHTML = !isXML( document );
  8024. // Support: IE 9-11, Edge
  8025. // Accessing iframe documents after unload throws "permission denied" errors (jQuery #13936)
  8026. if ( preferredDoc !== document &&
  8027. (subWindow = document.defaultView) && subWindow.top !== subWindow ) {
  8028. // Support: IE 11, Edge
  8029. if ( subWindow.addEventListener ) {
  8030. subWindow.addEventListener( "unload", unloadHandler, false );
  8031. // Support: IE 9 - 10 only
  8032. } else if ( subWindow.attachEvent ) {
  8033. subWindow.attachEvent( "onunload", unloadHandler );
  8034. }
  8035. }
  8036. /* Attributes
  8037. ---------------------------------------------------------------------- */
  8038. // Support: IE<8
  8039. // Verify that getAttribute really returns attributes and not properties
  8040. // (excepting IE8 booleans)
  8041. support.attributes = assert(function( el ) {
  8042. el.className = "i";
  8043. return !el.getAttribute("className");
  8044. });
  8045. /* getElement(s)By*
  8046. ---------------------------------------------------------------------- */
  8047. // Check if getElementsByTagName("*") returns only elements
  8048. support.getElementsByTagName = assert(function( el ) {
  8049. el.appendChild( document.createComment("") );
  8050. return !el.getElementsByTagName("*").length;
  8051. });
  8052. // Support: IE<9
  8053. support.getElementsByClassName = rnative.test( document.getElementsByClassName );
  8054. // Support: IE<10
  8055. // Check if getElementById returns elements by name
  8056. // The broken getElementById methods don't pick up programmatically-set names,
  8057. // so use a roundabout getElementsByName test
  8058. support.getById = assert(function( el ) {
  8059. docElem.appendChild( el ).id = expando;
  8060. return !document.getElementsByName || !document.getElementsByName( expando ).length;
  8061. });
  8062. // ID filter and find
  8063. if ( support.getById ) {
  8064. Expr.filter["ID"] = function( id ) {
  8065. var attrId = id.replace( runescape, funescape );
  8066. return function( elem ) {
  8067. return elem.getAttribute("id") === attrId;
  8068. };
  8069. };
  8070. Expr.find["ID"] = function( id, context ) {
  8071. if ( typeof context.getElementById !== "undefined" && documentIsHTML ) {
  8072. var elem = context.getElementById( id );
  8073. return elem ? [ elem ] : [];
  8074. }
  8075. };
  8076. } else {
  8077. Expr.filter["ID"] = function( id ) {
  8078. var attrId = id.replace( runescape, funescape );
  8079. return function( elem ) {
  8080. var node = typeof elem.getAttributeNode !== "undefined" &&
  8081. elem.getAttributeNode("id");
  8082. return node && node.value === attrId;
  8083. };
  8084. };
  8085. // Support: IE 6 - 7 only
  8086. // getElementById is not reliable as a find shortcut
  8087. Expr.find["ID"] = function( id, context ) {
  8088. if ( typeof context.getElementById !== "undefined" && documentIsHTML ) {
  8089. var node, i, elems,
  8090. elem = context.getElementById( id );
  8091. if ( elem ) {
  8092. // Verify the id attribute
  8093. node = elem.getAttributeNode("id");
  8094. if ( node && node.value === id ) {
  8095. return [ elem ];
  8096. }
  8097. // Fall back on getElementsByName
  8098. elems = context.getElementsByName( id );
  8099. i = 0;
  8100. while ( (elem = elems[i++]) ) {
  8101. node = elem.getAttributeNode("id");
  8102. if ( node && node.value === id ) {
  8103. return [ elem ];
  8104. }
  8105. }
  8106. }
  8107. return [];
  8108. }
  8109. };
  8110. }
  8111. // Tag
  8112. Expr.find["TAG"] = support.getElementsByTagName ?
  8113. function( tag, context ) {
  8114. if ( typeof context.getElementsByTagName !== "undefined" ) {
  8115. return context.getElementsByTagName( tag );
  8116. // DocumentFragment nodes don't have gEBTN
  8117. } else if ( support.qsa ) {
  8118. return context.querySelectorAll( tag );
  8119. }
  8120. } :
  8121. function( tag, context ) {
  8122. var elem,
  8123. tmp = [],
  8124. i = 0,
  8125. // By happy coincidence, a (broken) gEBTN appears on DocumentFragment nodes too
  8126. results = context.getElementsByTagName( tag );
  8127. // Filter out possible comments
  8128. if ( tag === "*" ) {
  8129. while ( (elem = results[i++]) ) {
  8130. if ( elem.nodeType === 1 ) {
  8131. tmp.push( elem );
  8132. }
  8133. }
  8134. return tmp;
  8135. }
  8136. return results;
  8137. };
  8138. // Class
  8139. Expr.find["CLASS"] = support.getElementsByClassName && function( className, context ) {
  8140. if ( typeof context.getElementsByClassName !== "undefined" && documentIsHTML ) {
  8141. return context.getElementsByClassName( className );
  8142. }
  8143. };
  8144. /* QSA/matchesSelector
  8145. ---------------------------------------------------------------------- */
  8146. // QSA and matchesSelector support
  8147. // matchesSelector(:active) reports false when true (IE9/Opera 11.5)
  8148. rbuggyMatches = [];
  8149. // qSa(:focus) reports false when true (Chrome 21)
  8150. // We allow this because of a bug in IE8/9 that throws an error
  8151. // whenever `document.activeElement` is accessed on an iframe
  8152. // So, we allow :focus to pass through QSA all the time to avoid the IE error
  8153. // See https://bugs.jquery.com/ticket/13378
  8154. rbuggyQSA = [];
  8155. if ( (support.qsa = rnative.test( document.querySelectorAll )) ) {
  8156. // Build QSA regex
  8157. // Regex strategy adopted from Diego Perini
  8158. assert(function( el ) {
  8159. // Select is set to empty string on purpose
  8160. // This is to test IE's treatment of not explicitly
  8161. // setting a boolean content attribute,
  8162. // since its presence should be enough
  8163. // https://bugs.jquery.com/ticket/12359
  8164. docElem.appendChild( el ).innerHTML = "<a id='" + expando + "'></a>" +
  8165. "<select id='" + expando + "-\r\\' msallowcapture=''>" +
  8166. "<option selected=''></option></select>";
  8167. // Support: IE8, Opera 11-12.16
  8168. // Nothing should be selected when empty strings follow ^= or $= or *=
  8169. // The test attribute must be unknown in Opera but "safe" for WinRT
  8170. // https://msdn.microsoft.com/en-us/library/ie/hh465388.aspx#attribute_section
  8171. if ( el.querySelectorAll("[msallowcapture^='']").length ) {
  8172. rbuggyQSA.push( "[*^$]=" + whitespace + "*(?:''|\"\")" );
  8173. }
  8174. // Support: IE8
  8175. // Boolean attributes and "value" are not treated correctly
  8176. if ( !el.querySelectorAll("[selected]").length ) {
  8177. rbuggyQSA.push( "\\[" + whitespace + "*(?:value|" + booleans + ")" );
  8178. }
  8179. // Support: Chrome<29, Android<4.4, Safari<7.0+, iOS<7.0+, PhantomJS<1.9.8+
  8180. if ( !el.querySelectorAll( "[id~=" + expando + "-]" ).length ) {
  8181. rbuggyQSA.push("~=");
  8182. }
  8183. // Webkit/Opera - :checked should return selected option elements
  8184. // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
  8185. // IE8 throws error here and will not see later tests
  8186. if ( !el.querySelectorAll(":checked").length ) {
  8187. rbuggyQSA.push(":checked");
  8188. }
  8189. // Support: Safari 8+, iOS 8+
  8190. // https://bugs.webkit.org/show_bug.cgi?id=136851
  8191. // In-page `selector#id sibling-combinator selector` fails
  8192. if ( !el.querySelectorAll( "a#" + expando + "+*" ).length ) {
  8193. rbuggyQSA.push(".#.+[+~]");
  8194. }
  8195. });
  8196. assert(function( el ) {
  8197. el.innerHTML = "<a href='' disabled='disabled'></a>" +
  8198. "<select disabled='disabled'><option/></select>";
  8199. // Support: Windows 8 Native Apps
  8200. // The type and name attributes are restricted during .innerHTML assignment
  8201. var input = document.createElement("input");
  8202. input.setAttribute( "type", "hidden" );
  8203. el.appendChild( input ).setAttribute( "name", "D" );
  8204. // Support: IE8
  8205. // Enforce case-sensitivity of name attribute
  8206. if ( el.querySelectorAll("[name=d]").length ) {
  8207. rbuggyQSA.push( "name" + whitespace + "*[*^$|!~]?=" );
  8208. }
  8209. // FF 3.5 - :enabled/:disabled and hidden elements (hidden elements are still enabled)
  8210. // IE8 throws error here and will not see later tests
  8211. if ( el.querySelectorAll(":enabled").length !== 2 ) {
  8212. rbuggyQSA.push( ":enabled", ":disabled" );
  8213. }
  8214. // Support: IE9-11+
  8215. // IE's :disabled selector does not pick up the children of disabled fieldsets
  8216. docElem.appendChild( el ).disabled = true;
  8217. if ( el.querySelectorAll(":disabled").length !== 2 ) {
  8218. rbuggyQSA.push( ":enabled", ":disabled" );
  8219. }
  8220. // Opera 10-11 does not throw on post-comma invalid pseudos
  8221. el.querySelectorAll("*,:x");
  8222. rbuggyQSA.push(",.*:");
  8223. });
  8224. }
  8225. if ( (support.matchesSelector = rnative.test( (matches = docElem.matches ||
  8226. docElem.webkitMatchesSelector ||
  8227. docElem.mozMatchesSelector ||
  8228. docElem.oMatchesSelector ||
  8229. docElem.msMatchesSelector) )) ) {
  8230. assert(function( el ) {
  8231. // Check to see if it's possible to do matchesSelector
  8232. // on a disconnected node (IE 9)
  8233. support.disconnectedMatch = matches.call( el, "*" );
  8234. // This should fail with an exception
  8235. // Gecko does not error, returns false instead
  8236. matches.call( el, "[s!='']:x" );
  8237. rbuggyMatches.push( "!=", pseudos );
  8238. });
  8239. }
  8240. rbuggyQSA = rbuggyQSA.length && new RegExp( rbuggyQSA.join("|") );
  8241. rbuggyMatches = rbuggyMatches.length && new RegExp( rbuggyMatches.join("|") );
  8242. /* Contains
  8243. ---------------------------------------------------------------------- */
  8244. hasCompare = rnative.test( docElem.compareDocumentPosition );
  8245. // Element contains another
  8246. // Purposefully self-exclusive
  8247. // As in, an element does not contain itself
  8248. contains = hasCompare || rnative.test( docElem.contains ) ?
  8249. function( a, b ) {
  8250. var adown = a.nodeType === 9 ? a.documentElement : a,
  8251. bup = b && b.parentNode;
  8252. return a === bup || !!( bup && bup.nodeType === 1 && (
  8253. adown.contains ?
  8254. adown.contains( bup ) :
  8255. a.compareDocumentPosition && a.compareDocumentPosition( bup ) & 16
  8256. ));
  8257. } :
  8258. function( a, b ) {
  8259. if ( b ) {
  8260. while ( (b = b.parentNode) ) {
  8261. if ( b === a ) {
  8262. return true;
  8263. }
  8264. }
  8265. }
  8266. return false;
  8267. };
  8268. /* Sorting
  8269. ---------------------------------------------------------------------- */
  8270. // Document order sorting
  8271. sortOrder = hasCompare ?
  8272. function( a, b ) {
  8273. // Flag for duplicate removal
  8274. if ( a === b ) {
  8275. hasDuplicate = true;
  8276. return 0;
  8277. }
  8278. // Sort on method existence if only one input has compareDocumentPosition
  8279. var compare = !a.compareDocumentPosition - !b.compareDocumentPosition;
  8280. if ( compare ) {
  8281. return compare;
  8282. }
  8283. // Calculate position if both inputs belong to the same document
  8284. compare = ( a.ownerDocument || a ) === ( b.ownerDocument || b ) ?
  8285. a.compareDocumentPosition( b ) :
  8286. // Otherwise we know they are disconnected
  8287. 1;
  8288. // Disconnected nodes
  8289. if ( compare & 1 ||
  8290. (!support.sortDetached && b.compareDocumentPosition( a ) === compare) ) {
  8291. // Choose the first element that is related to our preferred document
  8292. if ( a === document || a.ownerDocument === preferredDoc && contains(preferredDoc, a) ) {
  8293. return -1;
  8294. }
  8295. if ( b === document || b.ownerDocument === preferredDoc && contains(preferredDoc, b) ) {
  8296. return 1;
  8297. }
  8298. // Maintain original order
  8299. return sortInput ?
  8300. ( indexOf( sortInput, a ) - indexOf( sortInput, b ) ) :
  8301. 0;
  8302. }
  8303. return compare & 4 ? -1 : 1;
  8304. } :
  8305. function( a, b ) {
  8306. // Exit early if the nodes are identical
  8307. if ( a === b ) {
  8308. hasDuplicate = true;
  8309. return 0;
  8310. }
  8311. var cur,
  8312. i = 0,
  8313. aup = a.parentNode,
  8314. bup = b.parentNode,
  8315. ap = [ a ],
  8316. bp = [ b ];
  8317. // Parentless nodes are either documents or disconnected
  8318. if ( !aup || !bup ) {
  8319. return a === document ? -1 :
  8320. b === document ? 1 :
  8321. aup ? -1 :
  8322. bup ? 1 :
  8323. sortInput ?
  8324. ( indexOf( sortInput, a ) - indexOf( sortInput, b ) ) :
  8325. 0;
  8326. // If the nodes are siblings, we can do a quick check
  8327. } else if ( aup === bup ) {
  8328. return siblingCheck( a, b );
  8329. }
  8330. // Otherwise we need full lists of their ancestors for comparison
  8331. cur = a;
  8332. while ( (cur = cur.parentNode) ) {
  8333. ap.unshift( cur );
  8334. }
  8335. cur = b;
  8336. while ( (cur = cur.parentNode) ) {
  8337. bp.unshift( cur );
  8338. }
  8339. // Walk down the tree looking for a discrepancy
  8340. while ( ap[i] === bp[i] ) {
  8341. i++;
  8342. }
  8343. return i ?
  8344. // Do a sibling check if the nodes have a common ancestor
  8345. siblingCheck( ap[i], bp[i] ) :
  8346. // Otherwise nodes in our document sort first
  8347. ap[i] === preferredDoc ? -1 :
  8348. bp[i] === preferredDoc ? 1 :
  8349. 0;
  8350. };
  8351. return document;
  8352. };
  8353. Sizzle.matches = function( expr, elements ) {
  8354. return Sizzle( expr, null, null, elements );
  8355. };
  8356. Sizzle.matchesSelector = function( elem, expr ) {
  8357. // Set document vars if needed
  8358. if ( ( elem.ownerDocument || elem ) !== document ) {
  8359. setDocument( elem );
  8360. }
  8361. if ( support.matchesSelector && documentIsHTML &&
  8362. !nonnativeSelectorCache[ expr + " " ] &&
  8363. ( !rbuggyMatches || !rbuggyMatches.test( expr ) ) &&
  8364. ( !rbuggyQSA || !rbuggyQSA.test( expr ) ) ) {
  8365. try {
  8366. var ret = matches.call( elem, expr );
  8367. // IE 9's matchesSelector returns false on disconnected nodes
  8368. if ( ret || support.disconnectedMatch ||
  8369. // As well, disconnected nodes are said to be in a document
  8370. // fragment in IE 9
  8371. elem.document && elem.document.nodeType !== 11 ) {
  8372. return ret;
  8373. }
  8374. } catch (e) {
  8375. nonnativeSelectorCache( expr, true );
  8376. }
  8377. }
  8378. return Sizzle( expr, document, null, [ elem ] ).length > 0;
  8379. };
  8380. Sizzle.contains = function( context, elem ) {
  8381. // Set document vars if needed
  8382. if ( ( context.ownerDocument || context ) !== document ) {
  8383. setDocument( context );
  8384. }
  8385. return contains( context, elem );
  8386. };
  8387. Sizzle.attr = function( elem, name ) {
  8388. // Set document vars if needed
  8389. if ( ( elem.ownerDocument || elem ) !== document ) {
  8390. setDocument( elem );
  8391. }
  8392. var fn = Expr.attrHandle[ name.toLowerCase() ],
  8393. // Don't get fooled by Object.prototype properties (jQuery #13807)
  8394. val = fn && hasOwn.call( Expr.attrHandle, name.toLowerCase() ) ?
  8395. fn( elem, name, !documentIsHTML ) :
  8396. undefined;
  8397. return val !== undefined ?
  8398. val :
  8399. support.attributes || !documentIsHTML ?
  8400. elem.getAttribute( name ) :
  8401. (val = elem.getAttributeNode(name)) && val.specified ?
  8402. val.value :
  8403. null;
  8404. };
  8405. Sizzle.escape = function( sel ) {
  8406. return (sel + "").replace( rcssescape, fcssescape );
  8407. };
  8408. Sizzle.error = function( msg ) {
  8409. throw new Error( "Syntax error, unrecognized expression: " + msg );
  8410. };
  8411. /**
  8412. * Document sorting and removing duplicates
  8413. * @param {ArrayLike} results
  8414. */
  8415. Sizzle.uniqueSort = function( results ) {
  8416. var elem,
  8417. duplicates = [],
  8418. j = 0,
  8419. i = 0;
  8420. // Unless we *know* we can detect duplicates, assume their presence
  8421. hasDuplicate = !support.detectDuplicates;
  8422. sortInput = !support.sortStable && results.slice( 0 );
  8423. results.sort( sortOrder );
  8424. if ( hasDuplicate ) {
  8425. while ( (elem = results[i++]) ) {
  8426. if ( elem === results[ i ] ) {
  8427. j = duplicates.push( i );
  8428. }
  8429. }
  8430. while ( j-- ) {
  8431. results.splice( duplicates[ j ], 1 );
  8432. }
  8433. }
  8434. // Clear input after sorting to release objects
  8435. // See https://github.com/jquery/sizzle/pull/225
  8436. sortInput = null;
  8437. return results;
  8438. };
  8439. /**
  8440. * Utility function for retrieving the text value of an array of DOM nodes
  8441. * @param {Array|Element} elem
  8442. */
  8443. getText = Sizzle.getText = function( elem ) {
  8444. var node,
  8445. ret = "",
  8446. i = 0,
  8447. nodeType = elem.nodeType;
  8448. if ( !nodeType ) {
  8449. // If no nodeType, this is expected to be an array
  8450. while ( (node = elem[i++]) ) {
  8451. // Do not traverse comment nodes
  8452. ret += getText( node );
  8453. }
  8454. } else if ( nodeType === 1 || nodeType === 9 || nodeType === 11 ) {
  8455. // Use textContent for elements
  8456. // innerText usage removed for consistency of new lines (jQuery #11153)
  8457. if ( typeof elem.textContent === "string" ) {
  8458. return elem.textContent;
  8459. } else {
  8460. // Traverse its children
  8461. for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
  8462. ret += getText( elem );
  8463. }
  8464. }
  8465. } else if ( nodeType === 3 || nodeType === 4 ) {
  8466. return elem.nodeValue;
  8467. }
  8468. // Do not include comment or processing instruction nodes
  8469. return ret;
  8470. };
  8471. Expr = Sizzle.selectors = {
  8472. // Can be adjusted by the user
  8473. cacheLength: 50,
  8474. createPseudo: markFunction,
  8475. match: matchExpr,
  8476. attrHandle: {},
  8477. find: {},
  8478. relative: {
  8479. ">": { dir: "parentNode", first: true },
  8480. " ": { dir: "parentNode" },
  8481. "+": { dir: "previousSibling", first: true },
  8482. "~": { dir: "previousSibling" }
  8483. },
  8484. preFilter: {
  8485. "ATTR": function( match ) {
  8486. match[1] = match[1].replace( runescape, funescape );
  8487. // Move the given value to match[3] whether quoted or unquoted
  8488. match[3] = ( match[3] || match[4] || match[5] || "" ).replace( runescape, funescape );
  8489. if ( match[2] === "~=" ) {
  8490. match[3] = " " + match[3] + " ";
  8491. }
  8492. return match.slice( 0, 4 );
  8493. },
  8494. "CHILD": function( match ) {
  8495. /* matches from matchExpr["CHILD"]
  8496. 1 type (only|nth|...)
  8497. 2 what (child|of-type)
  8498. 3 argument (even|odd|\d*|\d*n([+-]\d+)?|...)
  8499. 4 xn-component of xn+y argument ([+-]?\d*n|)
  8500. 5 sign of xn-component
  8501. 6 x of xn-component
  8502. 7 sign of y-component
  8503. 8 y of y-component
  8504. */
  8505. match[1] = match[1].toLowerCase();
  8506. if ( match[1].slice( 0, 3 ) === "nth" ) {
  8507. // nth-* requires argument
  8508. if ( !match[3] ) {
  8509. Sizzle.error( match[0] );
  8510. }
  8511. // numeric x and y parameters for Expr.filter.CHILD
  8512. // remember that false/true cast respectively to 0/1
  8513. match[4] = +( match[4] ? match[5] + (match[6] || 1) : 2 * ( match[3] === "even" || match[3] === "odd" ) );
  8514. match[5] = +( ( match[7] + match[8] ) || match[3] === "odd" );
  8515. // other types prohibit arguments
  8516. } else if ( match[3] ) {
  8517. Sizzle.error( match[0] );
  8518. }
  8519. return match;
  8520. },
  8521. "PSEUDO": function( match ) {
  8522. var excess,
  8523. unquoted = !match[6] && match[2];
  8524. if ( matchExpr["CHILD"].test( match[0] ) ) {
  8525. return null;
  8526. }
  8527. // Accept quoted arguments as-is
  8528. if ( match[3] ) {
  8529. match[2] = match[4] || match[5] || "";
  8530. // Strip excess characters from unquoted arguments
  8531. } else if ( unquoted && rpseudo.test( unquoted ) &&
  8532. // Get excess from tokenize (recursively)
  8533. (excess = tokenize( unquoted, true )) &&
  8534. // advance to the next closing parenthesis
  8535. (excess = unquoted.indexOf( ")", unquoted.length - excess ) - unquoted.length) ) {
  8536. // excess is a negative index
  8537. match[0] = match[0].slice( 0, excess );
  8538. match[2] = unquoted.slice( 0, excess );
  8539. }
  8540. // Return only captures needed by the pseudo filter method (type and argument)
  8541. return match.slice( 0, 3 );
  8542. }
  8543. },
  8544. filter: {
  8545. "TAG": function( nodeNameSelector ) {
  8546. var nodeName = nodeNameSelector.replace( runescape, funescape ).toLowerCase();
  8547. return nodeNameSelector === "*" ?
  8548. function() { return true; } :
  8549. function( elem ) {
  8550. return elem.nodeName && elem.nodeName.toLowerCase() === nodeName;
  8551. };
  8552. },
  8553. "CLASS": function( className ) {
  8554. var pattern = classCache[ className + " " ];
  8555. return pattern ||
  8556. (pattern = new RegExp( "(^|" + whitespace + ")" + className + "(" + whitespace + "|$)" )) &&
  8557. classCache( className, function( elem ) {
  8558. return pattern.test( typeof elem.className === "string" && elem.className || typeof elem.getAttribute !== "undefined" && elem.getAttribute("class") || "" );
  8559. });
  8560. },
  8561. "ATTR": function( name, operator, check ) {
  8562. return function( elem ) {
  8563. var result = Sizzle.attr( elem, name );
  8564. if ( result == null ) {
  8565. return operator === "!=";
  8566. }
  8567. if ( !operator ) {
  8568. return true;
  8569. }
  8570. result += "";
  8571. return operator === "=" ? result === check :
  8572. operator === "!=" ? result !== check :
  8573. operator === "^=" ? check && result.indexOf( check ) === 0 :
  8574. operator === "*=" ? check && result.indexOf( check ) > -1 :
  8575. operator === "$=" ? check && result.slice( -check.length ) === check :
  8576. operator === "~=" ? ( " " + result.replace( rwhitespace, " " ) + " " ).indexOf( check ) > -1 :
  8577. operator === "|=" ? result === check || result.slice( 0, check.length + 1 ) === check + "-" :
  8578. false;
  8579. };
  8580. },
  8581. "CHILD": function( type, what, argument, first, last ) {
  8582. var simple = type.slice( 0, 3 ) !== "nth",
  8583. forward = type.slice( -4 ) !== "last",
  8584. ofType = what === "of-type";
  8585. return first === 1 && last === 0 ?
  8586. // Shortcut for :nth-*(n)
  8587. function( elem ) {
  8588. return !!elem.parentNode;
  8589. } :
  8590. function( elem, context, xml ) {
  8591. var cache, uniqueCache, outerCache, node, nodeIndex, start,
  8592. dir = simple !== forward ? "nextSibling" : "previousSibling",
  8593. parent = elem.parentNode,
  8594. name = ofType && elem.nodeName.toLowerCase(),
  8595. useCache = !xml && !ofType,
  8596. diff = false;
  8597. if ( parent ) {
  8598. // :(first|last|only)-(child|of-type)
  8599. if ( simple ) {
  8600. while ( dir ) {
  8601. node = elem;
  8602. while ( (node = node[ dir ]) ) {
  8603. if ( ofType ?
  8604. node.nodeName.toLowerCase() === name :
  8605. node.nodeType === 1 ) {
  8606. return false;
  8607. }
  8608. }
  8609. // Reverse direction for :only-* (if we haven't yet done so)
  8610. start = dir = type === "only" && !start && "nextSibling";
  8611. }
  8612. return true;
  8613. }
  8614. start = [ forward ? parent.firstChild : parent.lastChild ];
  8615. // non-xml :nth-child(...) stores cache data on `parent`
  8616. if ( forward && useCache ) {
  8617. // Seek `elem` from a previously-cached index
  8618. // ...in a gzip-friendly way
  8619. node = parent;
  8620. outerCache = node[ expando ] || (node[ expando ] = {});
  8621. // Support: IE <9 only
  8622. // Defend against cloned attroperties (jQuery gh-1709)
  8623. uniqueCache = outerCache[ node.uniqueID ] ||
  8624. (outerCache[ node.uniqueID ] = {});
  8625. cache = uniqueCache[ type ] || [];
  8626. nodeIndex = cache[ 0 ] === dirruns && cache[ 1 ];
  8627. diff = nodeIndex && cache[ 2 ];
  8628. node = nodeIndex && parent.childNodes[ nodeIndex ];
  8629. while ( (node = ++nodeIndex && node && node[ dir ] ||
  8630. // Fallback to seeking `elem` from the start
  8631. (diff = nodeIndex = 0) || start.pop()) ) {
  8632. // When found, cache indexes on `parent` and break
  8633. if ( node.nodeType === 1 && ++diff && node === elem ) {
  8634. uniqueCache[ type ] = [ dirruns, nodeIndex, diff ];
  8635. break;
  8636. }
  8637. }
  8638. } else {
  8639. // Use previously-cached element index if available
  8640. if ( useCache ) {
  8641. // ...in a gzip-friendly way
  8642. node = elem;
  8643. outerCache = node[ expando ] || (node[ expando ] = {});
  8644. // Support: IE <9 only
  8645. // Defend against cloned attroperties (jQuery gh-1709)
  8646. uniqueCache = outerCache[ node.uniqueID ] ||
  8647. (outerCache[ node.uniqueID ] = {});
  8648. cache = uniqueCache[ type ] || [];
  8649. nodeIndex = cache[ 0 ] === dirruns && cache[ 1 ];
  8650. diff = nodeIndex;
  8651. }
  8652. // xml :nth-child(...)
  8653. // or :nth-last-child(...) or :nth(-last)?-of-type(...)
  8654. if ( diff === false ) {
  8655. // Use the same loop as above to seek `elem` from the start
  8656. while ( (node = ++nodeIndex && node && node[ dir ] ||
  8657. (diff = nodeIndex = 0) || start.pop()) ) {
  8658. if ( ( ofType ?
  8659. node.nodeName.toLowerCase() === name :
  8660. node.nodeType === 1 ) &&
  8661. ++diff ) {
  8662. // Cache the index of each encountered element
  8663. if ( useCache ) {
  8664. outerCache = node[ expando ] || (node[ expando ] = {});
  8665. // Support: IE <9 only
  8666. // Defend against cloned attroperties (jQuery gh-1709)
  8667. uniqueCache = outerCache[ node.uniqueID ] ||
  8668. (outerCache[ node.uniqueID ] = {});
  8669. uniqueCache[ type ] = [ dirruns, diff ];
  8670. }
  8671. if ( node === elem ) {
  8672. break;
  8673. }
  8674. }
  8675. }
  8676. }
  8677. }
  8678. // Incorporate the offset, then check against cycle size
  8679. diff -= last;
  8680. return diff === first || ( diff % first === 0 && diff / first >= 0 );
  8681. }
  8682. };
  8683. },
  8684. "PSEUDO": function( pseudo, argument ) {
  8685. // pseudo-class names are case-insensitive
  8686. // http://www.w3.org/TR/selectors/#pseudo-classes
  8687. // Prioritize by case sensitivity in case custom pseudos are added with uppercase letters
  8688. // Remember that setFilters inherits from pseudos
  8689. var args,
  8690. fn = Expr.pseudos[ pseudo ] || Expr.setFilters[ pseudo.toLowerCase() ] ||
  8691. Sizzle.error( "unsupported pseudo: " + pseudo );
  8692. // The user may use createPseudo to indicate that
  8693. // arguments are needed to create the filter function
  8694. // just as Sizzle does
  8695. if ( fn[ expando ] ) {
  8696. return fn( argument );
  8697. }
  8698. // But maintain support for old signatures
  8699. if ( fn.length > 1 ) {
  8700. args = [ pseudo, pseudo, "", argument ];
  8701. return Expr.setFilters.hasOwnProperty( pseudo.toLowerCase() ) ?
  8702. markFunction(function( seed, matches ) {
  8703. var idx,
  8704. matched = fn( seed, argument ),
  8705. i = matched.length;
  8706. while ( i-- ) {
  8707. idx = indexOf( seed, matched[i] );
  8708. seed[ idx ] = !( matches[ idx ] = matched[i] );
  8709. }
  8710. }) :
  8711. function( elem ) {
  8712. return fn( elem, 0, args );
  8713. };
  8714. }
  8715. return fn;
  8716. }
  8717. },
  8718. pseudos: {
  8719. // Potentially complex pseudos
  8720. "not": markFunction(function( selector ) {
  8721. // Trim the selector passed to compile
  8722. // to avoid treating leading and trailing
  8723. // spaces as combinators
  8724. var input = [],
  8725. results = [],
  8726. matcher = compile( selector.replace( rtrim, "$1" ) );
  8727. return matcher[ expando ] ?
  8728. markFunction(function( seed, matches, context, xml ) {
  8729. var elem,
  8730. unmatched = matcher( seed, null, xml, [] ),
  8731. i = seed.length;
  8732. // Match elements unmatched by `matcher`
  8733. while ( i-- ) {
  8734. if ( (elem = unmatched[i]) ) {
  8735. seed[i] = !(matches[i] = elem);
  8736. }
  8737. }
  8738. }) :
  8739. function( elem, context, xml ) {
  8740. input[0] = elem;
  8741. matcher( input, null, xml, results );
  8742. // Don't keep the element (issue #299)
  8743. input[0] = null;
  8744. return !results.pop();
  8745. };
  8746. }),
  8747. "has": markFunction(function( selector ) {
  8748. return function( elem ) {
  8749. return Sizzle( selector, elem ).length > 0;
  8750. };
  8751. }),
  8752. "contains": markFunction(function( text ) {
  8753. text = text.replace( runescape, funescape );
  8754. return function( elem ) {
  8755. return ( elem.textContent || getText( elem ) ).indexOf( text ) > -1;
  8756. };
  8757. }),
  8758. // "Whether an element is represented by a :lang() selector
  8759. // is based solely on the element's language value
  8760. // being equal to the identifier C,
  8761. // or beginning with the identifier C immediately followed by "-".
  8762. // The matching of C against the element's language value is performed case-insensitively.
  8763. // The identifier C does not have to be a valid language name."
  8764. // http://www.w3.org/TR/selectors/#lang-pseudo
  8765. "lang": markFunction( function( lang ) {
  8766. // lang value must be a valid identifier
  8767. if ( !ridentifier.test(lang || "") ) {
  8768. Sizzle.error( "unsupported lang: " + lang );
  8769. }
  8770. lang = lang.replace( runescape, funescape ).toLowerCase();
  8771. return function( elem ) {
  8772. var elemLang;
  8773. do {
  8774. if ( (elemLang = documentIsHTML ?
  8775. elem.lang :
  8776. elem.getAttribute("xml:lang") || elem.getAttribute("lang")) ) {
  8777. elemLang = elemLang.toLowerCase();
  8778. return elemLang === lang || elemLang.indexOf( lang + "-" ) === 0;
  8779. }
  8780. } while ( (elem = elem.parentNode) && elem.nodeType === 1 );
  8781. return false;
  8782. };
  8783. }),
  8784. // Miscellaneous
  8785. "target": function( elem ) {
  8786. var hash = window.location && window.location.hash;
  8787. return hash && hash.slice( 1 ) === elem.id;
  8788. },
  8789. "root": function( elem ) {
  8790. return elem === docElem;
  8791. },
  8792. "focus": function( elem ) {
  8793. return elem === document.activeElement && (!document.hasFocus || document.hasFocus()) && !!(elem.type || elem.href || ~elem.tabIndex);
  8794. },
  8795. // Boolean properties
  8796. "enabled": createDisabledPseudo( false ),
  8797. "disabled": createDisabledPseudo( true ),
  8798. "checked": function( elem ) {
  8799. // In CSS3, :checked should return both checked and selected elements
  8800. // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
  8801. var nodeName = elem.nodeName.toLowerCase();
  8802. return (nodeName === "input" && !!elem.checked) || (nodeName === "option" && !!elem.selected);
  8803. },
  8804. "selected": function( elem ) {
  8805. // Accessing this property makes selected-by-default
  8806. // options in Safari work properly
  8807. if ( elem.parentNode ) {
  8808. elem.parentNode.selectedIndex;
  8809. }
  8810. return elem.selected === true;
  8811. },
  8812. // Contents
  8813. "empty": function( elem ) {
  8814. // http://www.w3.org/TR/selectors/#empty-pseudo
  8815. // :empty is negated by element (1) or content nodes (text: 3; cdata: 4; entity ref: 5),
  8816. // but not by others (comment: 8; processing instruction: 7; etc.)
  8817. // nodeType < 6 works because attributes (2) do not appear as children
  8818. for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
  8819. if ( elem.nodeType < 6 ) {
  8820. return false;
  8821. }
  8822. }
  8823. return true;
  8824. },
  8825. "parent": function( elem ) {
  8826. return !Expr.pseudos["empty"]( elem );
  8827. },
  8828. // Element/input types
  8829. "header": function( elem ) {
  8830. return rheader.test( elem.nodeName );
  8831. },
  8832. "input": function( elem ) {
  8833. return rinputs.test( elem.nodeName );
  8834. },
  8835. "button": function( elem ) {
  8836. var name = elem.nodeName.toLowerCase();
  8837. return name === "input" && elem.type === "button" || name === "button";
  8838. },
  8839. "text": function( elem ) {
  8840. var attr;
  8841. return elem.nodeName.toLowerCase() === "input" &&
  8842. elem.type === "text" &&
  8843. // Support: IE<8
  8844. // New HTML5 attribute values (e.g., "search") appear with elem.type === "text"
  8845. ( (attr = elem.getAttribute("type")) == null || attr.toLowerCase() === "text" );
  8846. },
  8847. // Position-in-collection
  8848. "first": createPositionalPseudo(function() {
  8849. return [ 0 ];
  8850. }),
  8851. "last": createPositionalPseudo(function( matchIndexes, length ) {
  8852. return [ length - 1 ];
  8853. }),
  8854. "eq": createPositionalPseudo(function( matchIndexes, length, argument ) {
  8855. return [ argument < 0 ? argument + length : argument ];
  8856. }),
  8857. "even": createPositionalPseudo(function( matchIndexes, length ) {
  8858. var i = 0;
  8859. for ( ; i < length; i += 2 ) {
  8860. matchIndexes.push( i );
  8861. }
  8862. return matchIndexes;
  8863. }),
  8864. "odd": createPositionalPseudo(function( matchIndexes, length ) {
  8865. var i = 1;
  8866. for ( ; i < length; i += 2 ) {
  8867. matchIndexes.push( i );
  8868. }
  8869. return matchIndexes;
  8870. }),
  8871. "lt": createPositionalPseudo(function( matchIndexes, length, argument ) {
  8872. var i = argument < 0 ?
  8873. argument + length :
  8874. argument > length ?
  8875. length :
  8876. argument;
  8877. for ( ; --i >= 0; ) {
  8878. matchIndexes.push( i );
  8879. }
  8880. return matchIndexes;
  8881. }),
  8882. "gt": createPositionalPseudo(function( matchIndexes, length, argument ) {
  8883. var i = argument < 0 ? argument + length : argument;
  8884. for ( ; ++i < length; ) {
  8885. matchIndexes.push( i );
  8886. }
  8887. return matchIndexes;
  8888. })
  8889. }
  8890. };
  8891. Expr.pseudos["nth"] = Expr.pseudos["eq"];
  8892. // Add button/input type pseudos
  8893. for ( i in { radio: true, checkbox: true, file: true, password: true, image: true } ) {
  8894. Expr.pseudos[ i ] = createInputPseudo( i );
  8895. }
  8896. for ( i in { submit: true, reset: true } ) {
  8897. Expr.pseudos[ i ] = createButtonPseudo( i );
  8898. }
  8899. // Easy API for creating new setFilters
  8900. function setFilters() {}
  8901. setFilters.prototype = Expr.filters = Expr.pseudos;
  8902. Expr.setFilters = new setFilters();
  8903. tokenize = Sizzle.tokenize = function( selector, parseOnly ) {
  8904. var matched, match, tokens, type,
  8905. soFar, groups, preFilters,
  8906. cached = tokenCache[ selector + " " ];
  8907. if ( cached ) {
  8908. return parseOnly ? 0 : cached.slice( 0 );
  8909. }
  8910. soFar = selector;
  8911. groups = [];
  8912. preFilters = Expr.preFilter;
  8913. while ( soFar ) {
  8914. // Comma and first run
  8915. if ( !matched || (match = rcomma.exec( soFar )) ) {
  8916. if ( match ) {
  8917. // Don't consume trailing commas as valid
  8918. soFar = soFar.slice( match[0].length ) || soFar;
  8919. }
  8920. groups.push( (tokens = []) );
  8921. }
  8922. matched = false;
  8923. // Combinators
  8924. if ( (match = rcombinators.exec( soFar )) ) {
  8925. matched = match.shift();
  8926. tokens.push({
  8927. value: matched,
  8928. // Cast descendant combinators to space
  8929. type: match[0].replace( rtrim, " " )
  8930. });
  8931. soFar = soFar.slice( matched.length );
  8932. }
  8933. // Filters
  8934. for ( type in Expr.filter ) {
  8935. if ( (match = matchExpr[ type ].exec( soFar )) && (!preFilters[ type ] ||
  8936. (match = preFilters[ type ]( match ))) ) {
  8937. matched = match.shift();
  8938. tokens.push({
  8939. value: matched,
  8940. type: type,
  8941. matches: match
  8942. });
  8943. soFar = soFar.slice( matched.length );
  8944. }
  8945. }
  8946. if ( !matched ) {
  8947. break;
  8948. }
  8949. }
  8950. // Return the length of the invalid excess
  8951. // if we're just parsing
  8952. // Otherwise, throw an error or return tokens
  8953. return parseOnly ?
  8954. soFar.length :
  8955. soFar ?
  8956. Sizzle.error( selector ) :
  8957. // Cache the tokens
  8958. tokenCache( selector, groups ).slice( 0 );
  8959. };
  8960. function toSelector( tokens ) {
  8961. var i = 0,
  8962. len = tokens.length,
  8963. selector = "";
  8964. for ( ; i < len; i++ ) {
  8965. selector += tokens[i].value;
  8966. }
  8967. return selector;
  8968. }
  8969. function addCombinator( matcher, combinator, base ) {
  8970. var dir = combinator.dir,
  8971. skip = combinator.next,
  8972. key = skip || dir,
  8973. checkNonElements = base && key === "parentNode",
  8974. doneName = done++;
  8975. return combinator.first ?
  8976. // Check against closest ancestor/preceding element
  8977. function( elem, context, xml ) {
  8978. while ( (elem = elem[ dir ]) ) {
  8979. if ( elem.nodeType === 1 || checkNonElements ) {
  8980. return matcher( elem, context, xml );
  8981. }
  8982. }
  8983. return false;
  8984. } :
  8985. // Check against all ancestor/preceding elements
  8986. function( elem, context, xml ) {
  8987. var oldCache, uniqueCache, outerCache,
  8988. newCache = [ dirruns, doneName ];
  8989. // We can't set arbitrary data on XML nodes, so they don't benefit from combinator caching
  8990. if ( xml ) {
  8991. while ( (elem = elem[ dir ]) ) {
  8992. if ( elem.nodeType === 1 || checkNonElements ) {
  8993. if ( matcher( elem, context, xml ) ) {
  8994. return true;
  8995. }
  8996. }
  8997. }
  8998. } else {
  8999. while ( (elem = elem[ dir ]) ) {
  9000. if ( elem.nodeType === 1 || checkNonElements ) {
  9001. outerCache = elem[ expando ] || (elem[ expando ] = {});
  9002. // Support: IE <9 only
  9003. // Defend against cloned attroperties (jQuery gh-1709)
  9004. uniqueCache = outerCache[ elem.uniqueID ] || (outerCache[ elem.uniqueID ] = {});
  9005. if ( skip && skip === elem.nodeName.toLowerCase() ) {
  9006. elem = elem[ dir ] || elem;
  9007. } else if ( (oldCache = uniqueCache[ key ]) &&
  9008. oldCache[ 0 ] === dirruns && oldCache[ 1 ] === doneName ) {
  9009. // Assign to newCache so results back-propagate to previous elements
  9010. return (newCache[ 2 ] = oldCache[ 2 ]);
  9011. } else {
  9012. // Reuse newcache so results back-propagate to previous elements
  9013. uniqueCache[ key ] = newCache;
  9014. // A match means we're done; a fail means we have to keep checking
  9015. if ( (newCache[ 2 ] = matcher( elem, context, xml )) ) {
  9016. return true;
  9017. }
  9018. }
  9019. }
  9020. }
  9021. }
  9022. return false;
  9023. };
  9024. }
  9025. function elementMatcher( matchers ) {
  9026. return matchers.length > 1 ?
  9027. function( elem, context, xml ) {
  9028. var i = matchers.length;
  9029. while ( i-- ) {
  9030. if ( !matchers[i]( elem, context, xml ) ) {
  9031. return false;
  9032. }
  9033. }
  9034. return true;
  9035. } :
  9036. matchers[0];
  9037. }
  9038. function multipleContexts( selector, contexts, results ) {
  9039. var i = 0,
  9040. len = contexts.length;
  9041. for ( ; i < len; i++ ) {
  9042. Sizzle( selector, contexts[i], results );
  9043. }
  9044. return results;
  9045. }
  9046. function condense( unmatched, map, filter, context, xml ) {
  9047. var elem,
  9048. newUnmatched = [],
  9049. i = 0,
  9050. len = unmatched.length,
  9051. mapped = map != null;
  9052. for ( ; i < len; i++ ) {
  9053. if ( (elem = unmatched[i]) ) {
  9054. if ( !filter || filter( elem, context, xml ) ) {
  9055. newUnmatched.push( elem );
  9056. if ( mapped ) {
  9057. map.push( i );
  9058. }
  9059. }
  9060. }
  9061. }
  9062. return newUnmatched;
  9063. }
  9064. function setMatcher( preFilter, selector, matcher, postFilter, postFinder, postSelector ) {
  9065. if ( postFilter && !postFilter[ expando ] ) {
  9066. postFilter = setMatcher( postFilter );
  9067. }
  9068. if ( postFinder && !postFinder[ expando ] ) {
  9069. postFinder = setMatcher( postFinder, postSelector );
  9070. }
  9071. return markFunction(function( seed, results, context, xml ) {
  9072. var temp, i, elem,
  9073. preMap = [],
  9074. postMap = [],
  9075. preexisting = results.length,
  9076. // Get initial elements from seed or context
  9077. elems = seed || multipleContexts( selector || "*", context.nodeType ? [ context ] : context, [] ),
  9078. // Prefilter to get matcher input, preserving a map for seed-results synchronization
  9079. matcherIn = preFilter && ( seed || !selector ) ?
  9080. condense( elems, preMap, preFilter, context, xml ) :
  9081. elems,
  9082. matcherOut = matcher ?
  9083. // If we have a postFinder, or filtered seed, or non-seed postFilter or preexisting results,
  9084. postFinder || ( seed ? preFilter : preexisting || postFilter ) ?
  9085. // ...intermediate processing is necessary
  9086. [] :
  9087. // ...otherwise use results directly
  9088. results :
  9089. matcherIn;
  9090. // Find primary matches
  9091. if ( matcher ) {
  9092. matcher( matcherIn, matcherOut, context, xml );
  9093. }
  9094. // Apply postFilter
  9095. if ( postFilter ) {
  9096. temp = condense( matcherOut, postMap );
  9097. postFilter( temp, [], context, xml );
  9098. // Un-match failing elements by moving them back to matcherIn
  9099. i = temp.length;
  9100. while ( i-- ) {
  9101. if ( (elem = temp[i]) ) {
  9102. matcherOut[ postMap[i] ] = !(matcherIn[ postMap[i] ] = elem);
  9103. }
  9104. }
  9105. }
  9106. if ( seed ) {
  9107. if ( postFinder || preFilter ) {
  9108. if ( postFinder ) {
  9109. // Get the final matcherOut by condensing this intermediate into postFinder contexts
  9110. temp = [];
  9111. i = matcherOut.length;
  9112. while ( i-- ) {
  9113. if ( (elem = matcherOut[i]) ) {
  9114. // Restore matcherIn since elem is not yet a final match
  9115. temp.push( (matcherIn[i] = elem) );
  9116. }
  9117. }
  9118. postFinder( null, (matcherOut = []), temp, xml );
  9119. }
  9120. // Move matched elements from seed to results to keep them synchronized
  9121. i = matcherOut.length;
  9122. while ( i-- ) {
  9123. if ( (elem = matcherOut[i]) &&
  9124. (temp = postFinder ? indexOf( seed, elem ) : preMap[i]) > -1 ) {
  9125. seed[temp] = !(results[temp] = elem);
  9126. }
  9127. }
  9128. }
  9129. // Add elements to results, through postFinder if defined
  9130. } else {
  9131. matcherOut = condense(
  9132. matcherOut === results ?
  9133. matcherOut.splice( preexisting, matcherOut.length ) :
  9134. matcherOut
  9135. );
  9136. if ( postFinder ) {
  9137. postFinder( null, results, matcherOut, xml );
  9138. } else {
  9139. push.apply( results, matcherOut );
  9140. }
  9141. }
  9142. });
  9143. }
  9144. function matcherFromTokens( tokens ) {
  9145. var checkContext, matcher, j,
  9146. len = tokens.length,
  9147. leadingRelative = Expr.relative[ tokens[0].type ],
  9148. implicitRelative = leadingRelative || Expr.relative[" "],
  9149. i = leadingRelative ? 1 : 0,
  9150. // The foundational matcher ensures that elements are reachable from top-level context(s)
  9151. matchContext = addCombinator( function( elem ) {
  9152. return elem === checkContext;
  9153. }, implicitRelative, true ),
  9154. matchAnyContext = addCombinator( function( elem ) {
  9155. return indexOf( checkContext, elem ) > -1;
  9156. }, implicitRelative, true ),
  9157. matchers = [ function( elem, context, xml ) {
  9158. var ret = ( !leadingRelative && ( xml || context !== outermostContext ) ) || (
  9159. (checkContext = context).nodeType ?
  9160. matchContext( elem, context, xml ) :
  9161. matchAnyContext( elem, context, xml ) );
  9162. // Avoid hanging onto element (issue #299)
  9163. checkContext = null;
  9164. return ret;
  9165. } ];
  9166. for ( ; i < len; i++ ) {
  9167. if ( (matcher = Expr.relative[ tokens[i].type ]) ) {
  9168. matchers = [ addCombinator(elementMatcher( matchers ), matcher) ];
  9169. } else {
  9170. matcher = Expr.filter[ tokens[i].type ].apply( null, tokens[i].matches );
  9171. // Return special upon seeing a positional matcher
  9172. if ( matcher[ expando ] ) {
  9173. // Find the next relative operator (if any) for proper handling
  9174. j = ++i;
  9175. for ( ; j < len; j++ ) {
  9176. if ( Expr.relative[ tokens[j].type ] ) {
  9177. break;
  9178. }
  9179. }
  9180. return setMatcher(
  9181. i > 1 && elementMatcher( matchers ),
  9182. i > 1 && toSelector(
  9183. // If the preceding token was a descendant combinator, insert an implicit any-element `*`
  9184. tokens.slice( 0, i - 1 ).concat({ value: tokens[ i - 2 ].type === " " ? "*" : "" })
  9185. ).replace( rtrim, "$1" ),
  9186. matcher,
  9187. i < j && matcherFromTokens( tokens.slice( i, j ) ),
  9188. j < len && matcherFromTokens( (tokens = tokens.slice( j )) ),
  9189. j < len && toSelector( tokens )
  9190. );
  9191. }
  9192. matchers.push( matcher );
  9193. }
  9194. }
  9195. return elementMatcher( matchers );
  9196. }
  9197. function matcherFromGroupMatchers( elementMatchers, setMatchers ) {
  9198. var bySet = setMatchers.length > 0,
  9199. byElement = elementMatchers.length > 0,
  9200. superMatcher = function( seed, context, xml, results, outermost ) {
  9201. var elem, j, matcher,
  9202. matchedCount = 0,
  9203. i = "0",
  9204. unmatched = seed && [],
  9205. setMatched = [],
  9206. contextBackup = outermostContext,
  9207. // We must always have either seed elements or outermost context
  9208. elems = seed || byElement && Expr.find["TAG"]( "*", outermost ),
  9209. // Use integer dirruns iff this is the outermost matcher
  9210. dirrunsUnique = (dirruns += contextBackup == null ? 1 : Math.random() || 0.1),
  9211. len = elems.length;
  9212. if ( outermost ) {
  9213. outermostContext = context === document || context || outermost;
  9214. }
  9215. // Add elements passing elementMatchers directly to results
  9216. // Support: IE<9, Safari
  9217. // Tolerate NodeList properties (IE: "length"; Safari: <number>) matching elements by id
  9218. for ( ; i !== len && (elem = elems[i]) != null; i++ ) {
  9219. if ( byElement && elem ) {
  9220. j = 0;
  9221. if ( !context && elem.ownerDocument !== document ) {
  9222. setDocument( elem );
  9223. xml = !documentIsHTML;
  9224. }
  9225. while ( (matcher = elementMatchers[j++]) ) {
  9226. if ( matcher( elem, context || document, xml) ) {
  9227. results.push( elem );
  9228. break;
  9229. }
  9230. }
  9231. if ( outermost ) {
  9232. dirruns = dirrunsUnique;
  9233. }
  9234. }
  9235. // Track unmatched elements for set filters
  9236. if ( bySet ) {
  9237. // They will have gone through all possible matchers
  9238. if ( (elem = !matcher && elem) ) {
  9239. matchedCount--;
  9240. }
  9241. // Lengthen the array for every element, matched or not
  9242. if ( seed ) {
  9243. unmatched.push( elem );
  9244. }
  9245. }
  9246. }
  9247. // `i` is now the count of elements visited above, and adding it to `matchedCount`
  9248. // makes the latter nonnegative.
  9249. matchedCount += i;
  9250. // Apply set filters to unmatched elements
  9251. // NOTE: This can be skipped if there are no unmatched elements (i.e., `matchedCount`
  9252. // equals `i`), unless we didn't visit _any_ elements in the above loop because we have
  9253. // no element matchers and no seed.
  9254. // Incrementing an initially-string "0" `i` allows `i` to remain a string only in that
  9255. // case, which will result in a "00" `matchedCount` that differs from `i` but is also
  9256. // numerically zero.
  9257. if ( bySet && i !== matchedCount ) {
  9258. j = 0;
  9259. while ( (matcher = setMatchers[j++]) ) {
  9260. matcher( unmatched, setMatched, context, xml );
  9261. }
  9262. if ( seed ) {
  9263. // Reintegrate element matches to eliminate the need for sorting
  9264. if ( matchedCount > 0 ) {
  9265. while ( i-- ) {
  9266. if ( !(unmatched[i] || setMatched[i]) ) {
  9267. setMatched[i] = pop.call( results );
  9268. }
  9269. }
  9270. }
  9271. // Discard index placeholder values to get only actual matches
  9272. setMatched = condense( setMatched );
  9273. }
  9274. // Add matches to results
  9275. push.apply( results, setMatched );
  9276. // Seedless set matches succeeding multiple successful matchers stipulate sorting
  9277. if ( outermost && !seed && setMatched.length > 0 &&
  9278. ( matchedCount + setMatchers.length ) > 1 ) {
  9279. Sizzle.uniqueSort( results );
  9280. }
  9281. }
  9282. // Override manipulation of globals by nested matchers
  9283. if ( outermost ) {
  9284. dirruns = dirrunsUnique;
  9285. outermostContext = contextBackup;
  9286. }
  9287. return unmatched;
  9288. };
  9289. return bySet ?
  9290. markFunction( superMatcher ) :
  9291. superMatcher;
  9292. }
  9293. compile = Sizzle.compile = function( selector, match /* Internal Use Only */ ) {
  9294. var i,
  9295. setMatchers = [],
  9296. elementMatchers = [],
  9297. cached = compilerCache[ selector + " " ];
  9298. if ( !cached ) {
  9299. // Generate a function of recursive functions that can be used to check each element
  9300. if ( !match ) {
  9301. match = tokenize( selector );
  9302. }
  9303. i = match.length;
  9304. while ( i-- ) {
  9305. cached = matcherFromTokens( match[i] );
  9306. if ( cached[ expando ] ) {
  9307. setMatchers.push( cached );
  9308. } else {
  9309. elementMatchers.push( cached );
  9310. }
  9311. }
  9312. // Cache the compiled function
  9313. cached = compilerCache( selector, matcherFromGroupMatchers( elementMatchers, setMatchers ) );
  9314. // Save selector and tokenization
  9315. cached.selector = selector;
  9316. }
  9317. return cached;
  9318. };
  9319. /**
  9320. * A low-level selection function that works with Sizzle's compiled
  9321. * selector functions
  9322. * @param {String|Function} selector A selector or a pre-compiled
  9323. * selector function built with Sizzle.compile
  9324. * @param {Element} context
  9325. * @param {Array} [results]
  9326. * @param {Array} [seed] A set of elements to match against
  9327. */
  9328. select = Sizzle.select = function( selector, context, results, seed ) {
  9329. var i, tokens, token, type, find,
  9330. compiled = typeof selector === "function" && selector,
  9331. match = !seed && tokenize( (selector = compiled.selector || selector) );
  9332. results = results || [];
  9333. // Try to minimize operations if there is only one selector in the list and no seed
  9334. // (the latter of which guarantees us context)
  9335. if ( match.length === 1 ) {
  9336. // Reduce context if the leading compound selector is an ID
  9337. tokens = match[0] = match[0].slice( 0 );
  9338. if ( tokens.length > 2 && (token = tokens[0]).type === "ID" &&
  9339. context.nodeType === 9 && documentIsHTML && Expr.relative[ tokens[1].type ] ) {
  9340. context = ( Expr.find["ID"]( token.matches[0].replace(runescape, funescape), context ) || [] )[0];
  9341. if ( !context ) {
  9342. return results;
  9343. // Precompiled matchers will still verify ancestry, so step up a level
  9344. } else if ( compiled ) {
  9345. context = context.parentNode;
  9346. }
  9347. selector = selector.slice( tokens.shift().value.length );
  9348. }
  9349. // Fetch a seed set for right-to-left matching
  9350. i = matchExpr["needsContext"].test( selector ) ? 0 : tokens.length;
  9351. while ( i-- ) {
  9352. token = tokens[i];
  9353. // Abort if we hit a combinator
  9354. if ( Expr.relative[ (type = token.type) ] ) {
  9355. break;
  9356. }
  9357. if ( (find = Expr.find[ type ]) ) {
  9358. // Search, expanding context for leading sibling combinators
  9359. if ( (seed = find(
  9360. token.matches[0].replace( runescape, funescape ),
  9361. rsibling.test( tokens[0].type ) && testContext( context.parentNode ) || context
  9362. )) ) {
  9363. // If seed is empty or no tokens remain, we can return early
  9364. tokens.splice( i, 1 );
  9365. selector = seed.length && toSelector( tokens );
  9366. if ( !selector ) {
  9367. push.apply( results, seed );
  9368. return results;
  9369. }
  9370. break;
  9371. }
  9372. }
  9373. }
  9374. }
  9375. // Compile and execute a filtering function if one is not provided
  9376. // Provide `match` to avoid retokenization if we modified the selector above
  9377. ( compiled || compile( selector, match ) )(
  9378. seed,
  9379. context,
  9380. !documentIsHTML,
  9381. results,
  9382. !context || rsibling.test( selector ) && testContext( context.parentNode ) || context
  9383. );
  9384. return results;
  9385. };
  9386. // One-time assignments
  9387. // Sort stability
  9388. support.sortStable = expando.split("").sort( sortOrder ).join("") === expando;
  9389. // Support: Chrome 14-35+
  9390. // Always assume duplicates if they aren't passed to the comparison function
  9391. support.detectDuplicates = !!hasDuplicate;
  9392. // Initialize against the default document
  9393. setDocument();
  9394. // Support: Webkit<537.32 - Safari 6.0.3/Chrome 25 (fixed in Chrome 27)
  9395. // Detached nodes confoundingly follow *each other*
  9396. support.sortDetached = assert(function( el ) {
  9397. // Should return 1, but returns 4 (following)
  9398. return el.compareDocumentPosition( document.createElement("fieldset") ) & 1;
  9399. });
  9400. // Support: IE<8
  9401. // Prevent attribute/property "interpolation"
  9402. // https://msdn.microsoft.com/en-us/library/ms536429%28VS.85%29.aspx
  9403. if ( !assert(function( el ) {
  9404. el.innerHTML = "<a href='#'></a>";
  9405. return el.firstChild.getAttribute("href") === "#" ;
  9406. }) ) {
  9407. addHandle( "type|href|height|width", function( elem, name, isXML ) {
  9408. if ( !isXML ) {
  9409. return elem.getAttribute( name, name.toLowerCase() === "type" ? 1 : 2 );
  9410. }
  9411. });
  9412. }
  9413. // Support: IE<9
  9414. // Use defaultValue in place of getAttribute("value")
  9415. if ( !support.attributes || !assert(function( el ) {
  9416. el.innerHTML = "<input/>";
  9417. el.firstChild.setAttribute( "value", "" );
  9418. return el.firstChild.getAttribute( "value" ) === "";
  9419. }) ) {
  9420. addHandle( "value", function( elem, name, isXML ) {
  9421. if ( !isXML && elem.nodeName.toLowerCase() === "input" ) {
  9422. return elem.defaultValue;
  9423. }
  9424. });
  9425. }
  9426. // Support: IE<9
  9427. // Use getAttributeNode to fetch booleans when getAttribute lies
  9428. if ( !assert(function( el ) {
  9429. return el.getAttribute("disabled") == null;
  9430. }) ) {
  9431. addHandle( booleans, function( elem, name, isXML ) {
  9432. var val;
  9433. if ( !isXML ) {
  9434. return elem[ name ] === true ? name.toLowerCase() :
  9435. (val = elem.getAttributeNode( name )) && val.specified ?
  9436. val.value :
  9437. null;
  9438. }
  9439. });
  9440. }
  9441. return Sizzle;
  9442. })( window );
  9443. jQuery.find = Sizzle;
  9444. jQuery.expr = Sizzle.selectors;
  9445. // Deprecated
  9446. jQuery.expr[ ":" ] = jQuery.expr.pseudos;
  9447. jQuery.uniqueSort = jQuery.unique = Sizzle.uniqueSort;
  9448. jQuery.text = Sizzle.getText;
  9449. jQuery.isXMLDoc = Sizzle.isXML;
  9450. jQuery.contains = Sizzle.contains;
  9451. jQuery.escapeSelector = Sizzle.escape;
  9452. var dir = function( elem, dir, until ) {
  9453. var matched = [],
  9454. truncate = until !== undefined;
  9455. while ( ( elem = elem[ dir ] ) && elem.nodeType !== 9 ) {
  9456. if ( elem.nodeType === 1 ) {
  9457. if ( truncate && jQuery( elem ).is( until ) ) {
  9458. break;
  9459. }
  9460. matched.push( elem );
  9461. }
  9462. }
  9463. return matched;
  9464. };
  9465. var siblings = function( n, elem ) {
  9466. var matched = [];
  9467. for ( ; n; n = n.nextSibling ) {
  9468. if ( n.nodeType === 1 && n !== elem ) {
  9469. matched.push( n );
  9470. }
  9471. }
  9472. return matched;
  9473. };
  9474. var rneedsContext = jQuery.expr.match.needsContext;
  9475. function nodeName( elem, name ) {
  9476. return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase();
  9477. };
  9478. var rsingleTag = ( /^<([a-z][^\/\0>:\x20\t\r\n\f]*)[\x20\t\r\n\f]*\/?>(?:<\/\1>|)$/i );
  9479. // Implement the identical functionality for filter and not
  9480. function winnow( elements, qualifier, not ) {
  9481. if ( isFunction( qualifier ) ) {
  9482. return jQuery.grep( elements, function( elem, i ) {
  9483. return !!qualifier.call( elem, i, elem ) !== not;
  9484. } );
  9485. }
  9486. // Single element
  9487. if ( qualifier.nodeType ) {
  9488. return jQuery.grep( elements, function( elem ) {
  9489. return ( elem === qualifier ) !== not;
  9490. } );
  9491. }
  9492. // Arraylike of elements (jQuery, arguments, Array)
  9493. if ( typeof qualifier !== "string" ) {
  9494. return jQuery.grep( elements, function( elem ) {
  9495. return ( indexOf.call( qualifier, elem ) > -1 ) !== not;
  9496. } );
  9497. }
  9498. // Filtered directly for both simple and complex selectors
  9499. return jQuery.filter( qualifier, elements, not );
  9500. }
  9501. jQuery.filter = function( expr, elems, not ) {
  9502. var elem = elems[ 0 ];
  9503. if ( not ) {
  9504. expr = ":not(" + expr + ")";
  9505. }
  9506. if ( elems.length === 1 && elem.nodeType === 1 ) {
  9507. return jQuery.find.matchesSelector( elem, expr ) ? [ elem ] : [];
  9508. }
  9509. return jQuery.find.matches( expr, jQuery.grep( elems, function( elem ) {
  9510. return elem.nodeType === 1;
  9511. } ) );
  9512. };
  9513. jQuery.fn.extend( {
  9514. find: function( selector ) {
  9515. var i, ret,
  9516. len = this.length,
  9517. self = this;
  9518. if ( typeof selector !== "string" ) {
  9519. return this.pushStack( jQuery( selector ).filter( function() {
  9520. for ( i = 0; i < len; i++ ) {
  9521. if ( jQuery.contains( self[ i ], this ) ) {
  9522. return true;
  9523. }
  9524. }
  9525. } ) );
  9526. }
  9527. ret = this.pushStack( [] );
  9528. for ( i = 0; i < len; i++ ) {
  9529. jQuery.find( selector, self[ i ], ret );
  9530. }
  9531. return len > 1 ? jQuery.uniqueSort( ret ) : ret;
  9532. },
  9533. filter: function( selector ) {
  9534. return this.pushStack( winnow( this, selector || [], false ) );
  9535. },
  9536. not: function( selector ) {
  9537. return this.pushStack( winnow( this, selector || [], true ) );
  9538. },
  9539. is: function( selector ) {
  9540. return !!winnow(
  9541. this,
  9542. // If this is a positional/relative selector, check membership in the returned set
  9543. // so $("p:first").is("p:last") won't return true for a doc with two "p".
  9544. typeof selector === "string" && rneedsContext.test( selector ) ?
  9545. jQuery( selector ) :
  9546. selector || [],
  9547. false
  9548. ).length;
  9549. }
  9550. } );
  9551. // Initialize a jQuery object
  9552. // A central reference to the root jQuery(document)
  9553. var rootjQuery,
  9554. // A simple way to check for HTML strings
  9555. // Prioritize #id over <tag> to avoid XSS via location.hash (#9521)
  9556. // Strict HTML recognition (#11290: must start with <)
  9557. // Shortcut simple #id case for speed
  9558. rquickExpr = /^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]+))$/,
  9559. init = jQuery.fn.init = function( selector, context, root ) {
  9560. var match, elem;
  9561. // HANDLE: $(""), $(null), $(undefined), $(false)
  9562. if ( !selector ) {
  9563. return this;
  9564. }
  9565. // Method init() accepts an alternate rootjQuery
  9566. // so migrate can support jQuery.sub (gh-2101)
  9567. root = root || rootjQuery;
  9568. // Handle HTML strings
  9569. if ( typeof selector === "string" ) {
  9570. if ( selector[ 0 ] === "<" &&
  9571. selector[ selector.length - 1 ] === ">" &&
  9572. selector.length >= 3 ) {
  9573. // Assume that strings that start and end with <> are HTML and skip the regex check
  9574. match = [ null, selector, null ];
  9575. } else {
  9576. match = rquickExpr.exec( selector );
  9577. }
  9578. // Match html or make sure no context is specified for #id
  9579. if ( match && ( match[ 1 ] || !context ) ) {
  9580. // HANDLE: $(html) -> $(array)
  9581. if ( match[ 1 ] ) {
  9582. context = context instanceof jQuery ? context[ 0 ] : context;
  9583. // Option to run scripts is true for back-compat
  9584. // Intentionally let the error be thrown if parseHTML is not present
  9585. jQuery.merge( this, jQuery.parseHTML(
  9586. match[ 1 ],
  9587. context && context.nodeType ? context.ownerDocument || context : document,
  9588. true
  9589. ) );
  9590. // HANDLE: $(html, props)
  9591. if ( rsingleTag.test( match[ 1 ] ) && jQuery.isPlainObject( context ) ) {
  9592. for ( match in context ) {
  9593. // Properties of context are called as methods if possible
  9594. if ( isFunction( this[ match ] ) ) {
  9595. this[ match ]( context[ match ] );
  9596. // ...and otherwise set as attributes
  9597. } else {
  9598. this.attr( match, context[ match ] );
  9599. }
  9600. }
  9601. }
  9602. return this;
  9603. // HANDLE: $(#id)
  9604. } else {
  9605. elem = document.getElementById( match[ 2 ] );
  9606. if ( elem ) {
  9607. // Inject the element directly into the jQuery object
  9608. this[ 0 ] = elem;
  9609. this.length = 1;
  9610. }
  9611. return this;
  9612. }
  9613. // HANDLE: $(expr, $(...))
  9614. } else if ( !context || context.jquery ) {
  9615. return ( context || root ).find( selector );
  9616. // HANDLE: $(expr, context)
  9617. // (which is just equivalent to: $(context).find(expr)
  9618. } else {
  9619. return this.constructor( context ).find( selector );
  9620. }
  9621. // HANDLE: $(DOMElement)
  9622. } else if ( selector.nodeType ) {
  9623. this[ 0 ] = selector;
  9624. this.length = 1;
  9625. return this;
  9626. // HANDLE: $(function)
  9627. // Shortcut for document ready
  9628. } else if ( isFunction( selector ) ) {
  9629. return root.ready !== undefined ?
  9630. root.ready( selector ) :
  9631. // Execute immediately if ready is not present
  9632. selector( jQuery );
  9633. }
  9634. return jQuery.makeArray( selector, this );
  9635. };
  9636. // Give the init function the jQuery prototype for later instantiation
  9637. init.prototype = jQuery.fn;
  9638. // Initialize central reference
  9639. rootjQuery = jQuery( document );
  9640. var rparentsprev = /^(?:parents|prev(?:Until|All))/,
  9641. // Methods guaranteed to produce a unique set when starting from a unique set
  9642. guaranteedUnique = {
  9643. children: true,
  9644. contents: true,
  9645. next: true,
  9646. prev: true
  9647. };
  9648. jQuery.fn.extend( {
  9649. has: function( target ) {
  9650. var targets = jQuery( target, this ),
  9651. l = targets.length;
  9652. return this.filter( function() {
  9653. var i = 0;
  9654. for ( ; i < l; i++ ) {
  9655. if ( jQuery.contains( this, targets[ i ] ) ) {
  9656. return true;
  9657. }
  9658. }
  9659. } );
  9660. },
  9661. closest: function( selectors, context ) {
  9662. var cur,
  9663. i = 0,
  9664. l = this.length,
  9665. matched = [],
  9666. targets = typeof selectors !== "string" && jQuery( selectors );
  9667. // Positional selectors never match, since there's no _selection_ context
  9668. if ( !rneedsContext.test( selectors ) ) {
  9669. for ( ; i < l; i++ ) {
  9670. for ( cur = this[ i ]; cur && cur !== context; cur = cur.parentNode ) {
  9671. // Always skip document fragments
  9672. if ( cur.nodeType < 11 && ( targets ?
  9673. targets.index( cur ) > -1 :
  9674. // Don't pass non-elements to Sizzle
  9675. cur.nodeType === 1 &&
  9676. jQuery.find.matchesSelector( cur, selectors ) ) ) {
  9677. matched.push( cur );
  9678. break;
  9679. }
  9680. }
  9681. }
  9682. }
  9683. return this.pushStack( matched.length > 1 ? jQuery.uniqueSort( matched ) : matched );
  9684. },
  9685. // Determine the position of an element within the set
  9686. index: function( elem ) {
  9687. // No argument, return index in parent
  9688. if ( !elem ) {
  9689. return ( this[ 0 ] && this[ 0 ].parentNode ) ? this.first().prevAll().length : -1;
  9690. }
  9691. // Index in selector
  9692. if ( typeof elem === "string" ) {
  9693. return indexOf.call( jQuery( elem ), this[ 0 ] );
  9694. }
  9695. // Locate the position of the desired element
  9696. return indexOf.call( this,
  9697. // If it receives a jQuery object, the first element is used
  9698. elem.jquery ? elem[ 0 ] : elem
  9699. );
  9700. },
  9701. add: function( selector, context ) {
  9702. return this.pushStack(
  9703. jQuery.uniqueSort(
  9704. jQuery.merge( this.get(), jQuery( selector, context ) )
  9705. )
  9706. );
  9707. },
  9708. addBack: function( selector ) {
  9709. return this.add( selector == null ?
  9710. this.prevObject : this.prevObject.filter( selector )
  9711. );
  9712. }
  9713. } );
  9714. function sibling( cur, dir ) {
  9715. while ( ( cur = cur[ dir ] ) && cur.nodeType !== 1 ) {}
  9716. return cur;
  9717. }
  9718. jQuery.each( {
  9719. parent: function( elem ) {
  9720. var parent = elem.parentNode;
  9721. return parent && parent.nodeType !== 11 ? parent : null;
  9722. },
  9723. parents: function( elem ) {
  9724. return dir( elem, "parentNode" );
  9725. },
  9726. parentsUntil: function( elem, i, until ) {
  9727. return dir( elem, "parentNode", until );
  9728. },
  9729. next: function( elem ) {
  9730. return sibling( elem, "nextSibling" );
  9731. },
  9732. prev: function( elem ) {
  9733. return sibling( elem, "previousSibling" );
  9734. },
  9735. nextAll: function( elem ) {
  9736. return dir( elem, "nextSibling" );
  9737. },
  9738. prevAll: function( elem ) {
  9739. return dir( elem, "previousSibling" );
  9740. },
  9741. nextUntil: function( elem, i, until ) {
  9742. return dir( elem, "nextSibling", until );
  9743. },
  9744. prevUntil: function( elem, i, until ) {
  9745. return dir( elem, "previousSibling", until );
  9746. },
  9747. siblings: function( elem ) {
  9748. return siblings( ( elem.parentNode || {} ).firstChild, elem );
  9749. },
  9750. children: function( elem ) {
  9751. return siblings( elem.firstChild );
  9752. },
  9753. contents: function( elem ) {
  9754. if ( typeof elem.contentDocument !== "undefined" ) {
  9755. return elem.contentDocument;
  9756. }
  9757. // Support: IE 9 - 11 only, iOS 7 only, Android Browser <=4.3 only
  9758. // Treat the template element as a regular one in browsers that
  9759. // don't support it.
  9760. if ( nodeName( elem, "template" ) ) {
  9761. elem = elem.content || elem;
  9762. }
  9763. return jQuery.merge( [], elem.childNodes );
  9764. }
  9765. }, function( name, fn ) {
  9766. jQuery.fn[ name ] = function( until, selector ) {
  9767. var matched = jQuery.map( this, fn, until );
  9768. if ( name.slice( -5 ) !== "Until" ) {
  9769. selector = until;
  9770. }
  9771. if ( selector && typeof selector === "string" ) {
  9772. matched = jQuery.filter( selector, matched );
  9773. }
  9774. if ( this.length > 1 ) {
  9775. // Remove duplicates
  9776. if ( !guaranteedUnique[ name ] ) {
  9777. jQuery.uniqueSort( matched );
  9778. }
  9779. // Reverse order for parents* and prev-derivatives
  9780. if ( rparentsprev.test( name ) ) {
  9781. matched.reverse();
  9782. }
  9783. }
  9784. return this.pushStack( matched );
  9785. };
  9786. } );
  9787. var rnothtmlwhite = ( /[^\x20\t\r\n\f]+/g );
  9788. // Convert String-formatted options into Object-formatted ones
  9789. function createOptions( options ) {
  9790. var object = {};
  9791. jQuery.each( options.match( rnothtmlwhite ) || [], function( _, flag ) {
  9792. object[ flag ] = true;
  9793. } );
  9794. return object;
  9795. }
  9796. /*
  9797. * Create a callback list using the following parameters:
  9798. *
  9799. * options: an optional list of space-separated options that will change how
  9800. * the callback list behaves or a more traditional option object
  9801. *
  9802. * By default a callback list will act like an event callback list and can be
  9803. * "fired" multiple times.
  9804. *
  9805. * Possible options:
  9806. *
  9807. * once: will ensure the callback list can only be fired once (like a Deferred)
  9808. *
  9809. * memory: will keep track of previous values and will call any callback added
  9810. * after the list has been fired right away with the latest "memorized"
  9811. * values (like a Deferred)
  9812. *
  9813. * unique: will ensure a callback can only be added once (no duplicate in the list)
  9814. *
  9815. * stopOnFalse: interrupt callings when a callback returns false
  9816. *
  9817. */
  9818. jQuery.Callbacks = function( options ) {
  9819. // Convert options from String-formatted to Object-formatted if needed
  9820. // (we check in cache first)
  9821. options = typeof options === "string" ?
  9822. createOptions( options ) :
  9823. jQuery.extend( {}, options );
  9824. var // Flag to know if list is currently firing
  9825. firing,
  9826. // Last fire value for non-forgettable lists
  9827. memory,
  9828. // Flag to know if list was already fired
  9829. fired,
  9830. // Flag to prevent firing
  9831. locked,
  9832. // Actual callback list
  9833. list = [],
  9834. // Queue of execution data for repeatable lists
  9835. queue = [],
  9836. // Index of currently firing callback (modified by add/remove as needed)
  9837. firingIndex = -1,
  9838. // Fire callbacks
  9839. fire = function() {
  9840. // Enforce single-firing
  9841. locked = locked || options.once;
  9842. // Execute callbacks for all pending executions,
  9843. // respecting firingIndex overrides and runtime changes
  9844. fired = firing = true;
  9845. for ( ; queue.length; firingIndex = -1 ) {
  9846. memory = queue.shift();
  9847. while ( ++firingIndex < list.length ) {
  9848. // Run callback and check for early termination
  9849. if ( list[ firingIndex ].apply( memory[ 0 ], memory[ 1 ] ) === false &&
  9850. options.stopOnFalse ) {
  9851. // Jump to end and forget the data so .add doesn't re-fire
  9852. firingIndex = list.length;
  9853. memory = false;
  9854. }
  9855. }
  9856. }
  9857. // Forget the data if we're done with it
  9858. if ( !options.memory ) {
  9859. memory = false;
  9860. }
  9861. firing = false;
  9862. // Clean up if we're done firing for good
  9863. if ( locked ) {
  9864. // Keep an empty list if we have data for future add calls
  9865. if ( memory ) {
  9866. list = [];
  9867. // Otherwise, this object is spent
  9868. } else {
  9869. list = "";
  9870. }
  9871. }
  9872. },
  9873. // Actual Callbacks object
  9874. self = {
  9875. // Add a callback or a collection of callbacks to the list
  9876. add: function() {
  9877. if ( list ) {
  9878. // If we have memory from a past run, we should fire after adding
  9879. if ( memory && !firing ) {
  9880. firingIndex = list.length - 1;
  9881. queue.push( memory );
  9882. }
  9883. ( function add( args ) {
  9884. jQuery.each( args, function( _, arg ) {
  9885. if ( isFunction( arg ) ) {
  9886. if ( !options.unique || !self.has( arg ) ) {
  9887. list.push( arg );
  9888. }
  9889. } else if ( arg && arg.length && toType( arg ) !== "string" ) {
  9890. // Inspect recursively
  9891. add( arg );
  9892. }
  9893. } );
  9894. } )( arguments );
  9895. if ( memory && !firing ) {
  9896. fire();
  9897. }
  9898. }
  9899. return this;
  9900. },
  9901. // Remove a callback from the list
  9902. remove: function() {
  9903. jQuery.each( arguments, function( _, arg ) {
  9904. var index;
  9905. while ( ( index = jQuery.inArray( arg, list, index ) ) > -1 ) {
  9906. list.splice( index, 1 );
  9907. // Handle firing indexes
  9908. if ( index <= firingIndex ) {
  9909. firingIndex--;
  9910. }
  9911. }
  9912. } );
  9913. return this;
  9914. },
  9915. // Check if a given callback is in the list.
  9916. // If no argument is given, return whether or not list has callbacks attached.
  9917. has: function( fn ) {
  9918. return fn ?
  9919. jQuery.inArray( fn, list ) > -1 :
  9920. list.length > 0;
  9921. },
  9922. // Remove all callbacks from the list
  9923. empty: function() {
  9924. if ( list ) {
  9925. list = [];
  9926. }
  9927. return this;
  9928. },
  9929. // Disable .fire and .add
  9930. // Abort any current/pending executions
  9931. // Clear all callbacks and values
  9932. disable: function() {
  9933. locked = queue = [];
  9934. list = memory = "";
  9935. return this;
  9936. },
  9937. disabled: function() {
  9938. return !list;
  9939. },
  9940. // Disable .fire
  9941. // Also disable .add unless we have memory (since it would have no effect)
  9942. // Abort any pending executions
  9943. lock: function() {
  9944. locked = queue = [];
  9945. if ( !memory && !firing ) {
  9946. list = memory = "";
  9947. }
  9948. return this;
  9949. },
  9950. locked: function() {
  9951. return !!locked;
  9952. },
  9953. // Call all callbacks with the given context and arguments
  9954. fireWith: function( context, args ) {
  9955. if ( !locked ) {
  9956. args = args || [];
  9957. args = [ context, args.slice ? args.slice() : args ];
  9958. queue.push( args );
  9959. if ( !firing ) {
  9960. fire();
  9961. }
  9962. }
  9963. return this;
  9964. },
  9965. // Call all the callbacks with the given arguments
  9966. fire: function() {
  9967. self.fireWith( this, arguments );
  9968. return this;
  9969. },
  9970. // To know if the callbacks have already been called at least once
  9971. fired: function() {
  9972. return !!fired;
  9973. }
  9974. };
  9975. return self;
  9976. };
  9977. function Identity( v ) {
  9978. return v;
  9979. }
  9980. function Thrower( ex ) {
  9981. throw ex;
  9982. }
  9983. function adoptValue( value, resolve, reject, noValue ) {
  9984. var method;
  9985. try {
  9986. // Check for promise aspect first to privilege synchronous behavior
  9987. if ( value && isFunction( ( method = value.promise ) ) ) {
  9988. method.call( value ).done( resolve ).fail( reject );
  9989. // Other thenables
  9990. } else if ( value && isFunction( ( method = value.then ) ) ) {
  9991. method.call( value, resolve, reject );
  9992. // Other non-thenables
  9993. } else {
  9994. // Control `resolve` arguments by letting Array#slice cast boolean `noValue` to integer:
  9995. // * false: [ value ].slice( 0 ) => resolve( value )
  9996. // * true: [ value ].slice( 1 ) => resolve()
  9997. resolve.apply( undefined, [ value ].slice( noValue ) );
  9998. }
  9999. // For Promises/A+, convert exceptions into rejections
  10000. // Since jQuery.when doesn't unwrap thenables, we can skip the extra checks appearing in
  10001. // Deferred#then to conditionally suppress rejection.
  10002. } catch ( value ) {
  10003. // Support: Android 4.0 only
  10004. // Strict mode functions invoked without .call/.apply get global-object context
  10005. reject.apply( undefined, [ value ] );
  10006. }
  10007. }
  10008. jQuery.extend( {
  10009. Deferred: function( func ) {
  10010. var tuples = [
  10011. // action, add listener, callbacks,
  10012. // ... .then handlers, argument index, [final state]
  10013. [ "notify", "progress", jQuery.Callbacks( "memory" ),
  10014. jQuery.Callbacks( "memory" ), 2 ],
  10015. [ "resolve", "done", jQuery.Callbacks( "once memory" ),
  10016. jQuery.Callbacks( "once memory" ), 0, "resolved" ],
  10017. [ "reject", "fail", jQuery.Callbacks( "once memory" ),
  10018. jQuery.Callbacks( "once memory" ), 1, "rejected" ]
  10019. ],
  10020. state = "pending",
  10021. promise = {
  10022. state: function() {
  10023. return state;
  10024. },
  10025. always: function() {
  10026. deferred.done( arguments ).fail( arguments );
  10027. return this;
  10028. },
  10029. "catch": function( fn ) {
  10030. return promise.then( null, fn );
  10031. },
  10032. // Keep pipe for back-compat
  10033. pipe: function( /* fnDone, fnFail, fnProgress */ ) {
  10034. var fns = arguments;
  10035. return jQuery.Deferred( function( newDefer ) {
  10036. jQuery.each( tuples, function( i, tuple ) {
  10037. // Map tuples (progress, done, fail) to arguments (done, fail, progress)
  10038. var fn = isFunction( fns[ tuple[ 4 ] ] ) && fns[ tuple[ 4 ] ];
  10039. // deferred.progress(function() { bind to newDefer or newDefer.notify })
  10040. // deferred.done(function() { bind to newDefer or newDefer.resolve })
  10041. // deferred.fail(function() { bind to newDefer or newDefer.reject })
  10042. deferred[ tuple[ 1 ] ]( function() {
  10043. var returned = fn && fn.apply( this, arguments );
  10044. if ( returned && isFunction( returned.promise ) ) {
  10045. returned.promise()
  10046. .progress( newDefer.notify )
  10047. .done( newDefer.resolve )
  10048. .fail( newDefer.reject );
  10049. } else {
  10050. newDefer[ tuple[ 0 ] + "With" ](
  10051. this,
  10052. fn ? [ returned ] : arguments
  10053. );
  10054. }
  10055. } );
  10056. } );
  10057. fns = null;
  10058. } ).promise();
  10059. },
  10060. then: function( onFulfilled, onRejected, onProgress ) {
  10061. var maxDepth = 0;
  10062. function resolve( depth, deferred, handler, special ) {
  10063. return function() {
  10064. var that = this,
  10065. args = arguments,
  10066. mightThrow = function() {
  10067. var returned, then;
  10068. // Support: Promises/A+ section 2.3.3.3.3
  10069. // https://promisesaplus.com/#point-59
  10070. // Ignore double-resolution attempts
  10071. if ( depth < maxDepth ) {
  10072. return;
  10073. }
  10074. returned = handler.apply( that, args );
  10075. // Support: Promises/A+ section 2.3.1
  10076. // https://promisesaplus.com/#point-48
  10077. if ( returned === deferred.promise() ) {
  10078. throw new TypeError( "Thenable self-resolution" );
  10079. }
  10080. // Support: Promises/A+ sections 2.3.3.1, 3.5
  10081. // https://promisesaplus.com/#point-54
  10082. // https://promisesaplus.com/#point-75
  10083. // Retrieve `then` only once
  10084. then = returned &&
  10085. // Support: Promises/A+ section 2.3.4
  10086. // https://promisesaplus.com/#point-64
  10087. // Only check objects and functions for thenability
  10088. ( typeof returned === "object" ||
  10089. typeof returned === "function" ) &&
  10090. returned.then;
  10091. // Handle a returned thenable
  10092. if ( isFunction( then ) ) {
  10093. // Special processors (notify) just wait for resolution
  10094. if ( special ) {
  10095. then.call(
  10096. returned,
  10097. resolve( maxDepth, deferred, Identity, special ),
  10098. resolve( maxDepth, deferred, Thrower, special )
  10099. );
  10100. // Normal processors (resolve) also hook into progress
  10101. } else {
  10102. // ...and disregard older resolution values
  10103. maxDepth++;
  10104. then.call(
  10105. returned,
  10106. resolve( maxDepth, deferred, Identity, special ),
  10107. resolve( maxDepth, deferred, Thrower, special ),
  10108. resolve( maxDepth, deferred, Identity,
  10109. deferred.notifyWith )
  10110. );
  10111. }
  10112. // Handle all other returned values
  10113. } else {
  10114. // Only substitute handlers pass on context
  10115. // and multiple values (non-spec behavior)
  10116. if ( handler !== Identity ) {
  10117. that = undefined;
  10118. args = [ returned ];
  10119. }
  10120. // Process the value(s)
  10121. // Default process is resolve
  10122. ( special || deferred.resolveWith )( that, args );
  10123. }
  10124. },
  10125. // Only normal processors (resolve) catch and reject exceptions
  10126. process = special ?
  10127. mightThrow :
  10128. function() {
  10129. try {
  10130. mightThrow();
  10131. } catch ( e ) {
  10132. if ( jQuery.Deferred.exceptionHook ) {
  10133. jQuery.Deferred.exceptionHook( e,
  10134. process.stackTrace );
  10135. }
  10136. // Support: Promises/A+ section 2.3.3.3.4.1
  10137. // https://promisesaplus.com/#point-61
  10138. // Ignore post-resolution exceptions
  10139. if ( depth + 1 >= maxDepth ) {
  10140. // Only substitute handlers pass on context
  10141. // and multiple values (non-spec behavior)
  10142. if ( handler !== Thrower ) {
  10143. that = undefined;
  10144. args = [ e ];
  10145. }
  10146. deferred.rejectWith( that, args );
  10147. }
  10148. }
  10149. };
  10150. // Support: Promises/A+ section 2.3.3.3.1
  10151. // https://promisesaplus.com/#point-57
  10152. // Re-resolve promises immediately to dodge false rejection from
  10153. // subsequent errors
  10154. if ( depth ) {
  10155. process();
  10156. } else {
  10157. // Call an optional hook to record the stack, in case of exception
  10158. // since it's otherwise lost when execution goes async
  10159. if ( jQuery.Deferred.getStackHook ) {
  10160. process.stackTrace = jQuery.Deferred.getStackHook();
  10161. }
  10162. window.setTimeout( process );
  10163. }
  10164. };
  10165. }
  10166. return jQuery.Deferred( function( newDefer ) {
  10167. // progress_handlers.add( ... )
  10168. tuples[ 0 ][ 3 ].add(
  10169. resolve(
  10170. 0,
  10171. newDefer,
  10172. isFunction( onProgress ) ?
  10173. onProgress :
  10174. Identity,
  10175. newDefer.notifyWith
  10176. )
  10177. );
  10178. // fulfilled_handlers.add( ... )
  10179. tuples[ 1 ][ 3 ].add(
  10180. resolve(
  10181. 0,
  10182. newDefer,
  10183. isFunction( onFulfilled ) ?
  10184. onFulfilled :
  10185. Identity
  10186. )
  10187. );
  10188. // rejected_handlers.add( ... )
  10189. tuples[ 2 ][ 3 ].add(
  10190. resolve(
  10191. 0,
  10192. newDefer,
  10193. isFunction( onRejected ) ?
  10194. onRejected :
  10195. Thrower
  10196. )
  10197. );
  10198. } ).promise();
  10199. },
  10200. // Get a promise for this deferred
  10201. // If obj is provided, the promise aspect is added to the object
  10202. promise: function( obj ) {
  10203. return obj != null ? jQuery.extend( obj, promise ) : promise;
  10204. }
  10205. },
  10206. deferred = {};
  10207. // Add list-specific methods
  10208. jQuery.each( tuples, function( i, tuple ) {
  10209. var list = tuple[ 2 ],
  10210. stateString = tuple[ 5 ];
  10211. // promise.progress = list.add
  10212. // promise.done = list.add
  10213. // promise.fail = list.add
  10214. promise[ tuple[ 1 ] ] = list.add;
  10215. // Handle state
  10216. if ( stateString ) {
  10217. list.add(
  10218. function() {
  10219. // state = "resolved" (i.e., fulfilled)
  10220. // state = "rejected"
  10221. state = stateString;
  10222. },
  10223. // rejected_callbacks.disable
  10224. // fulfilled_callbacks.disable
  10225. tuples[ 3 - i ][ 2 ].disable,
  10226. // rejected_handlers.disable
  10227. // fulfilled_handlers.disable
  10228. tuples[ 3 - i ][ 3 ].disable,
  10229. // progress_callbacks.lock
  10230. tuples[ 0 ][ 2 ].lock,
  10231. // progress_handlers.lock
  10232. tuples[ 0 ][ 3 ].lock
  10233. );
  10234. }
  10235. // progress_handlers.fire
  10236. // fulfilled_handlers.fire
  10237. // rejected_handlers.fire
  10238. list.add( tuple[ 3 ].fire );
  10239. // deferred.notify = function() { deferred.notifyWith(...) }
  10240. // deferred.resolve = function() { deferred.resolveWith(...) }
  10241. // deferred.reject = function() { deferred.rejectWith(...) }
  10242. deferred[ tuple[ 0 ] ] = function() {
  10243. deferred[ tuple[ 0 ] + "With" ]( this === deferred ? undefined : this, arguments );
  10244. return this;
  10245. };
  10246. // deferred.notifyWith = list.fireWith
  10247. // deferred.resolveWith = list.fireWith
  10248. // deferred.rejectWith = list.fireWith
  10249. deferred[ tuple[ 0 ] + "With" ] = list.fireWith;
  10250. } );
  10251. // Make the deferred a promise
  10252. promise.promise( deferred );
  10253. // Call given func if any
  10254. if ( func ) {
  10255. func.call( deferred, deferred );
  10256. }
  10257. // All done!
  10258. return deferred;
  10259. },
  10260. // Deferred helper
  10261. when: function( singleValue ) {
  10262. var
  10263. // count of uncompleted subordinates
  10264. remaining = arguments.length,
  10265. // count of unprocessed arguments
  10266. i = remaining,
  10267. // subordinate fulfillment data
  10268. resolveContexts = Array( i ),
  10269. resolveValues = slice.call( arguments ),
  10270. // the master Deferred
  10271. master = jQuery.Deferred(),
  10272. // subordinate callback factory
  10273. updateFunc = function( i ) {
  10274. return function( value ) {
  10275. resolveContexts[ i ] = this;
  10276. resolveValues[ i ] = arguments.length > 1 ? slice.call( arguments ) : value;
  10277. if ( !( --remaining ) ) {
  10278. master.resolveWith( resolveContexts, resolveValues );
  10279. }
  10280. };
  10281. };
  10282. // Single- and empty arguments are adopted like Promise.resolve
  10283. if ( remaining <= 1 ) {
  10284. adoptValue( singleValue, master.done( updateFunc( i ) ).resolve, master.reject,
  10285. !remaining );
  10286. // Use .then() to unwrap secondary thenables (cf. gh-3000)
  10287. if ( master.state() === "pending" ||
  10288. isFunction( resolveValues[ i ] && resolveValues[ i ].then ) ) {
  10289. return master.then();
  10290. }
  10291. }
  10292. // Multiple arguments are aggregated like Promise.all array elements
  10293. while ( i-- ) {
  10294. adoptValue( resolveValues[ i ], updateFunc( i ), master.reject );
  10295. }
  10296. return master.promise();
  10297. }
  10298. } );
  10299. // These usually indicate a programmer mistake during development,
  10300. // warn about them ASAP rather than swallowing them by default.
  10301. var rerrorNames = /^(Eval|Internal|Range|Reference|Syntax|Type|URI)Error$/;
  10302. jQuery.Deferred.exceptionHook = function( error, stack ) {
  10303. // Support: IE 8 - 9 only
  10304. // Console exists when dev tools are open, which can happen at any time
  10305. if ( window.console && window.console.warn && error && rerrorNames.test( error.name ) ) {
  10306. window.console.warn( "jQuery.Deferred exception: " + error.message, error.stack, stack );
  10307. }
  10308. };
  10309. jQuery.readyException = function( error ) {
  10310. window.setTimeout( function() {
  10311. throw error;
  10312. } );
  10313. };
  10314. // The deferred used on DOM ready
  10315. var readyList = jQuery.Deferred();
  10316. jQuery.fn.ready = function( fn ) {
  10317. readyList
  10318. .then( fn )
  10319. // Wrap jQuery.readyException in a function so that the lookup
  10320. // happens at the time of error handling instead of callback
  10321. // registration.
  10322. .catch( function( error ) {
  10323. jQuery.readyException( error );
  10324. } );
  10325. return this;
  10326. };
  10327. jQuery.extend( {
  10328. // Is the DOM ready to be used? Set to true once it occurs.
  10329. isReady: false,
  10330. // A counter to track how many items to wait for before
  10331. // the ready event fires. See #6781
  10332. readyWait: 1,
  10333. // Handle when the DOM is ready
  10334. ready: function( wait ) {
  10335. // Abort if there are pending holds or we're already ready
  10336. if ( wait === true ? --jQuery.readyWait : jQuery.isReady ) {
  10337. return;
  10338. }
  10339. // Remember that the DOM is ready
  10340. jQuery.isReady = true;
  10341. // If a normal DOM Ready event fired, decrement, and wait if need be
  10342. if ( wait !== true && --jQuery.readyWait > 0 ) {
  10343. return;
  10344. }
  10345. // If there are functions bound, to execute
  10346. readyList.resolveWith( document, [ jQuery ] );
  10347. }
  10348. } );
  10349. jQuery.ready.then = readyList.then;
  10350. // The ready event handler and self cleanup method
  10351. function completed() {
  10352. document.removeEventListener( "DOMContentLoaded", completed );
  10353. window.removeEventListener( "load", completed );
  10354. jQuery.ready();
  10355. }
  10356. // Catch cases where $(document).ready() is called
  10357. // after the browser event has already occurred.
  10358. // Support: IE <=9 - 10 only
  10359. // Older IE sometimes signals "interactive" too soon
  10360. if ( document.readyState === "complete" ||
  10361. ( document.readyState !== "loading" && !document.documentElement.doScroll ) ) {
  10362. // Handle it asynchronously to allow scripts the opportunity to delay ready
  10363. window.setTimeout( jQuery.ready );
  10364. } else {
  10365. // Use the handy event callback
  10366. document.addEventListener( "DOMContentLoaded", completed );
  10367. // A fallback to window.onload, that will always work
  10368. window.addEventListener( "load", completed );
  10369. }
  10370. // Multifunctional method to get and set values of a collection
  10371. // The value/s can optionally be executed if it's a function
  10372. var access = function( elems, fn, key, value, chainable, emptyGet, raw ) {
  10373. var i = 0,
  10374. len = elems.length,
  10375. bulk = key == null;
  10376. // Sets many values
  10377. if ( toType( key ) === "object" ) {
  10378. chainable = true;
  10379. for ( i in key ) {
  10380. access( elems, fn, i, key[ i ], true, emptyGet, raw );
  10381. }
  10382. // Sets one value
  10383. } else if ( value !== undefined ) {
  10384. chainable = true;
  10385. if ( !isFunction( value ) ) {
  10386. raw = true;
  10387. }
  10388. if ( bulk ) {
  10389. // Bulk operations run against the entire set
  10390. if ( raw ) {
  10391. fn.call( elems, value );
  10392. fn = null;
  10393. // ...except when executing function values
  10394. } else {
  10395. bulk = fn;
  10396. fn = function( elem, key, value ) {
  10397. return bulk.call( jQuery( elem ), value );
  10398. };
  10399. }
  10400. }
  10401. if ( fn ) {
  10402. for ( ; i < len; i++ ) {
  10403. fn(
  10404. elems[ i ], key, raw ?
  10405. value :
  10406. value.call( elems[ i ], i, fn( elems[ i ], key ) )
  10407. );
  10408. }
  10409. }
  10410. }
  10411. if ( chainable ) {
  10412. return elems;
  10413. }
  10414. // Gets
  10415. if ( bulk ) {
  10416. return fn.call( elems );
  10417. }
  10418. return len ? fn( elems[ 0 ], key ) : emptyGet;
  10419. };
  10420. // Matches dashed string for camelizing
  10421. var rmsPrefix = /^-ms-/,
  10422. rdashAlpha = /-([a-z])/g;
  10423. // Used by camelCase as callback to replace()
  10424. function fcamelCase( all, letter ) {
  10425. return letter.toUpperCase();
  10426. }
  10427. // Convert dashed to camelCase; used by the css and data modules
  10428. // Support: IE <=9 - 11, Edge 12 - 15
  10429. // Microsoft forgot to hump their vendor prefix (#9572)
  10430. function camelCase( string ) {
  10431. return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase );
  10432. }
  10433. var acceptData = function( owner ) {
  10434. // Accepts only:
  10435. // - Node
  10436. // - Node.ELEMENT_NODE
  10437. // - Node.DOCUMENT_NODE
  10438. // - Object
  10439. // - Any
  10440. return owner.nodeType === 1 || owner.nodeType === 9 || !( +owner.nodeType );
  10441. };
  10442. function Data() {
  10443. this.expando = jQuery.expando + Data.uid++;
  10444. }
  10445. Data.uid = 1;
  10446. Data.prototype = {
  10447. cache: function( owner ) {
  10448. // Check if the owner object already has a cache
  10449. var value = owner[ this.expando ];
  10450. // If not, create one
  10451. if ( !value ) {
  10452. value = {};
  10453. // We can accept data for non-element nodes in modern browsers,
  10454. // but we should not, see #8335.
  10455. // Always return an empty object.
  10456. if ( acceptData( owner ) ) {
  10457. // If it is a node unlikely to be stringify-ed or looped over
  10458. // use plain assignment
  10459. if ( owner.nodeType ) {
  10460. owner[ this.expando ] = value;
  10461. // Otherwise secure it in a non-enumerable property
  10462. // configurable must be true to allow the property to be
  10463. // deleted when data is removed
  10464. } else {
  10465. Object.defineProperty( owner, this.expando, {
  10466. value: value,
  10467. configurable: true
  10468. } );
  10469. }
  10470. }
  10471. }
  10472. return value;
  10473. },
  10474. set: function( owner, data, value ) {
  10475. var prop,
  10476. cache = this.cache( owner );
  10477. // Handle: [ owner, key, value ] args
  10478. // Always use camelCase key (gh-2257)
  10479. if ( typeof data === "string" ) {
  10480. cache[ camelCase( data ) ] = value;
  10481. // Handle: [ owner, { properties } ] args
  10482. } else {
  10483. // Copy the properties one-by-one to the cache object
  10484. for ( prop in data ) {
  10485. cache[ camelCase( prop ) ] = data[ prop ];
  10486. }
  10487. }
  10488. return cache;
  10489. },
  10490. get: function( owner, key ) {
  10491. return key === undefined ?
  10492. this.cache( owner ) :
  10493. // Always use camelCase key (gh-2257)
  10494. owner[ this.expando ] && owner[ this.expando ][ camelCase( key ) ];
  10495. },
  10496. access: function( owner, key, value ) {
  10497. // In cases where either:
  10498. //
  10499. // 1. No key was specified
  10500. // 2. A string key was specified, but no value provided
  10501. //
  10502. // Take the "read" path and allow the get method to determine
  10503. // which value to return, respectively either:
  10504. //
  10505. // 1. The entire cache object
  10506. // 2. The data stored at the key
  10507. //
  10508. if ( key === undefined ||
  10509. ( ( key && typeof key === "string" ) && value === undefined ) ) {
  10510. return this.get( owner, key );
  10511. }
  10512. // When the key is not a string, or both a key and value
  10513. // are specified, set or extend (existing objects) with either:
  10514. //
  10515. // 1. An object of properties
  10516. // 2. A key and value
  10517. //
  10518. this.set( owner, key, value );
  10519. // Since the "set" path can have two possible entry points
  10520. // return the expected data based on which path was taken[*]
  10521. return value !== undefined ? value : key;
  10522. },
  10523. remove: function( owner, key ) {
  10524. var i,
  10525. cache = owner[ this.expando ];
  10526. if ( cache === undefined ) {
  10527. return;
  10528. }
  10529. if ( key !== undefined ) {
  10530. // Support array or space separated string of keys
  10531. if ( Array.isArray( key ) ) {
  10532. // If key is an array of keys...
  10533. // We always set camelCase keys, so remove that.
  10534. key = key.map( camelCase );
  10535. } else {
  10536. key = camelCase( key );
  10537. // If a key with the spaces exists, use it.
  10538. // Otherwise, create an array by matching non-whitespace
  10539. key = key in cache ?
  10540. [ key ] :
  10541. ( key.match( rnothtmlwhite ) || [] );
  10542. }
  10543. i = key.length;
  10544. while ( i-- ) {
  10545. delete cache[ key[ i ] ];
  10546. }
  10547. }
  10548. // Remove the expando if there's no more data
  10549. if ( key === undefined || jQuery.isEmptyObject( cache ) ) {
  10550. // Support: Chrome <=35 - 45
  10551. // Webkit & Blink performance suffers when deleting properties
  10552. // from DOM nodes, so set to undefined instead
  10553. // https://bugs.chromium.org/p/chromium/issues/detail?id=378607 (bug restricted)
  10554. if ( owner.nodeType ) {
  10555. owner[ this.expando ] = undefined;
  10556. } else {
  10557. delete owner[ this.expando ];
  10558. }
  10559. }
  10560. },
  10561. hasData: function( owner ) {
  10562. var cache = owner[ this.expando ];
  10563. return cache !== undefined && !jQuery.isEmptyObject( cache );
  10564. }
  10565. };
  10566. var dataPriv = new Data();
  10567. var dataUser = new Data();
  10568. // Implementation Summary
  10569. //
  10570. // 1. Enforce API surface and semantic compatibility with 1.9.x branch
  10571. // 2. Improve the module's maintainability by reducing the storage
  10572. // paths to a single mechanism.
  10573. // 3. Use the same single mechanism to support "private" and "user" data.
  10574. // 4. _Never_ expose "private" data to user code (TODO: Drop _data, _removeData)
  10575. // 5. Avoid exposing implementation details on user objects (eg. expando properties)
  10576. // 6. Provide a clear path for implementation upgrade to WeakMap in 2014
  10577. var rbrace = /^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,
  10578. rmultiDash = /[A-Z]/g;
  10579. function getData( data ) {
  10580. if ( data === "true" ) {
  10581. return true;
  10582. }
  10583. if ( data === "false" ) {
  10584. return false;
  10585. }
  10586. if ( data === "null" ) {
  10587. return null;
  10588. }
  10589. // Only convert to a number if it doesn't change the string
  10590. if ( data === +data + "" ) {
  10591. return +data;
  10592. }
  10593. if ( rbrace.test( data ) ) {
  10594. return JSON.parse( data );
  10595. }
  10596. return data;
  10597. }
  10598. function dataAttr( elem, key, data ) {
  10599. var name;
  10600. // If nothing was found internally, try to fetch any
  10601. // data from the HTML5 data-* attribute
  10602. if ( data === undefined && elem.nodeType === 1 ) {
  10603. name = "data-" + key.replace( rmultiDash, "-$&" ).toLowerCase();
  10604. data = elem.getAttribute( name );
  10605. if ( typeof data === "string" ) {
  10606. try {
  10607. data = getData( data );
  10608. } catch ( e ) {}
  10609. // Make sure we set the data so it isn't changed later
  10610. dataUser.set( elem, key, data );
  10611. } else {
  10612. data = undefined;
  10613. }
  10614. }
  10615. return data;
  10616. }
  10617. jQuery.extend( {
  10618. hasData: function( elem ) {
  10619. return dataUser.hasData( elem ) || dataPriv.hasData( elem );
  10620. },
  10621. data: function( elem, name, data ) {
  10622. return dataUser.access( elem, name, data );
  10623. },
  10624. removeData: function( elem, name ) {
  10625. dataUser.remove( elem, name );
  10626. },
  10627. // TODO: Now that all calls to _data and _removeData have been replaced
  10628. // with direct calls to dataPriv methods, these can be deprecated.
  10629. _data: function( elem, name, data ) {
  10630. return dataPriv.access( elem, name, data );
  10631. },
  10632. _removeData: function( elem, name ) {
  10633. dataPriv.remove( elem, name );
  10634. }
  10635. } );
  10636. jQuery.fn.extend( {
  10637. data: function( key, value ) {
  10638. var i, name, data,
  10639. elem = this[ 0 ],
  10640. attrs = elem && elem.attributes;
  10641. // Gets all values
  10642. if ( key === undefined ) {
  10643. if ( this.length ) {
  10644. data = dataUser.get( elem );
  10645. if ( elem.nodeType === 1 && !dataPriv.get( elem, "hasDataAttrs" ) ) {
  10646. i = attrs.length;
  10647. while ( i-- ) {
  10648. // Support: IE 11 only
  10649. // The attrs elements can be null (#14894)
  10650. if ( attrs[ i ] ) {
  10651. name = attrs[ i ].name;
  10652. if ( name.indexOf( "data-" ) === 0 ) {
  10653. name = camelCase( name.slice( 5 ) );
  10654. dataAttr( elem, name, data[ name ] );
  10655. }
  10656. }
  10657. }
  10658. dataPriv.set( elem, "hasDataAttrs", true );
  10659. }
  10660. }
  10661. return data;
  10662. }
  10663. // Sets multiple values
  10664. if ( typeof key === "object" ) {
  10665. return this.each( function() {
  10666. dataUser.set( this, key );
  10667. } );
  10668. }
  10669. return access( this, function( value ) {
  10670. var data;
  10671. // The calling jQuery object (element matches) is not empty
  10672. // (and therefore has an element appears at this[ 0 ]) and the
  10673. // `value` parameter was not undefined. An empty jQuery object
  10674. // will result in `undefined` for elem = this[ 0 ] which will
  10675. // throw an exception if an attempt to read a data cache is made.
  10676. if ( elem && value === undefined ) {
  10677. // Attempt to get data from the cache
  10678. // The key will always be camelCased in Data
  10679. data = dataUser.get( elem, key );
  10680. if ( data !== undefined ) {
  10681. return data;
  10682. }
  10683. // Attempt to "discover" the data in
  10684. // HTML5 custom data-* attrs
  10685. data = dataAttr( elem, key );
  10686. if ( data !== undefined ) {
  10687. return data;
  10688. }
  10689. // We tried really hard, but the data doesn't exist.
  10690. return;
  10691. }
  10692. // Set the data...
  10693. this.each( function() {
  10694. // We always store the camelCased key
  10695. dataUser.set( this, key, value );
  10696. } );
  10697. }, null, value, arguments.length > 1, null, true );
  10698. },
  10699. removeData: function( key ) {
  10700. return this.each( function() {
  10701. dataUser.remove( this, key );
  10702. } );
  10703. }
  10704. } );
  10705. jQuery.extend( {
  10706. queue: function( elem, type, data ) {
  10707. var queue;
  10708. if ( elem ) {
  10709. type = ( type || "fx" ) + "queue";
  10710. queue = dataPriv.get( elem, type );
  10711. // Speed up dequeue by getting out quickly if this is just a lookup
  10712. if ( data ) {
  10713. if ( !queue || Array.isArray( data ) ) {
  10714. queue = dataPriv.access( elem, type, jQuery.makeArray( data ) );
  10715. } else {
  10716. queue.push( data );
  10717. }
  10718. }
  10719. return queue || [];
  10720. }
  10721. },
  10722. dequeue: function( elem, type ) {
  10723. type = type || "fx";
  10724. var queue = jQuery.queue( elem, type ),
  10725. startLength = queue.length,
  10726. fn = queue.shift(),
  10727. hooks = jQuery._queueHooks( elem, type ),
  10728. next = function() {
  10729. jQuery.dequeue( elem, type );
  10730. };
  10731. // If the fx queue is dequeued, always remove the progress sentinel
  10732. if ( fn === "inprogress" ) {
  10733. fn = queue.shift();
  10734. startLength--;
  10735. }
  10736. if ( fn ) {
  10737. // Add a progress sentinel to prevent the fx queue from being
  10738. // automatically dequeued
  10739. if ( type === "fx" ) {
  10740. queue.unshift( "inprogress" );
  10741. }
  10742. // Clear up the last queue stop function
  10743. delete hooks.stop;
  10744. fn.call( elem, next, hooks );
  10745. }
  10746. if ( !startLength && hooks ) {
  10747. hooks.empty.fire();
  10748. }
  10749. },
  10750. // Not public - generate a queueHooks object, or return the current one
  10751. _queueHooks: function( elem, type ) {
  10752. var key = type + "queueHooks";
  10753. return dataPriv.get( elem, key ) || dataPriv.access( elem, key, {
  10754. empty: jQuery.Callbacks( "once memory" ).add( function() {
  10755. dataPriv.remove( elem, [ type + "queue", key ] );
  10756. } )
  10757. } );
  10758. }
  10759. } );
  10760. jQuery.fn.extend( {
  10761. queue: function( type, data ) {
  10762. var setter = 2;
  10763. if ( typeof type !== "string" ) {
  10764. data = type;
  10765. type = "fx";
  10766. setter--;
  10767. }
  10768. if ( arguments.length < setter ) {
  10769. return jQuery.queue( this[ 0 ], type );
  10770. }
  10771. return data === undefined ?
  10772. this :
  10773. this.each( function() {
  10774. var queue = jQuery.queue( this, type, data );
  10775. // Ensure a hooks for this queue
  10776. jQuery._queueHooks( this, type );
  10777. if ( type === "fx" && queue[ 0 ] !== "inprogress" ) {
  10778. jQuery.dequeue( this, type );
  10779. }
  10780. } );
  10781. },
  10782. dequeue: function( type ) {
  10783. return this.each( function() {
  10784. jQuery.dequeue( this, type );
  10785. } );
  10786. },
  10787. clearQueue: function( type ) {
  10788. return this.queue( type || "fx", [] );
  10789. },
  10790. // Get a promise resolved when queues of a certain type
  10791. // are emptied (fx is the type by default)
  10792. promise: function( type, obj ) {
  10793. var tmp,
  10794. count = 1,
  10795. defer = jQuery.Deferred(),
  10796. elements = this,
  10797. i = this.length,
  10798. resolve = function() {
  10799. if ( !( --count ) ) {
  10800. defer.resolveWith( elements, [ elements ] );
  10801. }
  10802. };
  10803. if ( typeof type !== "string" ) {
  10804. obj = type;
  10805. type = undefined;
  10806. }
  10807. type = type || "fx";
  10808. while ( i-- ) {
  10809. tmp = dataPriv.get( elements[ i ], type + "queueHooks" );
  10810. if ( tmp && tmp.empty ) {
  10811. count++;
  10812. tmp.empty.add( resolve );
  10813. }
  10814. }
  10815. resolve();
  10816. return defer.promise( obj );
  10817. }
  10818. } );
  10819. var pnum = ( /[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/ ).source;
  10820. var rcssNum = new RegExp( "^(?:([+-])=|)(" + pnum + ")([a-z%]*)$", "i" );
  10821. var cssExpand = [ "Top", "Right", "Bottom", "Left" ];
  10822. var documentElement = document.documentElement;
  10823. var isAttached = function( elem ) {
  10824. return jQuery.contains( elem.ownerDocument, elem );
  10825. },
  10826. composed = { composed: true };
  10827. // Support: IE 9 - 11+, Edge 12 - 18+, iOS 10.0 - 10.2 only
  10828. // Check attachment across shadow DOM boundaries when possible (gh-3504)
  10829. // Support: iOS 10.0-10.2 only
  10830. // Early iOS 10 versions support `attachShadow` but not `getRootNode`,
  10831. // leading to errors. We need to check for `getRootNode`.
  10832. if ( documentElement.getRootNode ) {
  10833. isAttached = function( elem ) {
  10834. return jQuery.contains( elem.ownerDocument, elem ) ||
  10835. elem.getRootNode( composed ) === elem.ownerDocument;
  10836. };
  10837. }
  10838. var isHiddenWithinTree = function( elem, el ) {
  10839. // isHiddenWithinTree might be called from jQuery#filter function;
  10840. // in that case, element will be second argument
  10841. elem = el || elem;
  10842. // Inline style trumps all
  10843. return elem.style.display === "none" ||
  10844. elem.style.display === "" &&
  10845. // Otherwise, check computed style
  10846. // Support: Firefox <=43 - 45
  10847. // Disconnected elements can have computed display: none, so first confirm that elem is
  10848. // in the document.
  10849. isAttached( elem ) &&
  10850. jQuery.css( elem, "display" ) === "none";
  10851. };
  10852. var swap = function( elem, options, callback, args ) {
  10853. var ret, name,
  10854. old = {};
  10855. // Remember the old values, and insert the new ones
  10856. for ( name in options ) {
  10857. old[ name ] = elem.style[ name ];
  10858. elem.style[ name ] = options[ name ];
  10859. }
  10860. ret = callback.apply( elem, args || [] );
  10861. // Revert the old values
  10862. for ( name in options ) {
  10863. elem.style[ name ] = old[ name ];
  10864. }
  10865. return ret;
  10866. };
  10867. function adjustCSS( elem, prop, valueParts, tween ) {
  10868. var adjusted, scale,
  10869. maxIterations = 20,
  10870. currentValue = tween ?
  10871. function() {
  10872. return tween.cur();
  10873. } :
  10874. function() {
  10875. return jQuery.css( elem, prop, "" );
  10876. },
  10877. initial = currentValue(),
  10878. unit = valueParts && valueParts[ 3 ] || ( jQuery.cssNumber[ prop ] ? "" : "px" ),
  10879. // Starting value computation is required for potential unit mismatches
  10880. initialInUnit = elem.nodeType &&
  10881. ( jQuery.cssNumber[ prop ] || unit !== "px" && +initial ) &&
  10882. rcssNum.exec( jQuery.css( elem, prop ) );
  10883. if ( initialInUnit && initialInUnit[ 3 ] !== unit ) {
  10884. // Support: Firefox <=54
  10885. // Halve the iteration target value to prevent interference from CSS upper bounds (gh-2144)
  10886. initial = initial / 2;
  10887. // Trust units reported by jQuery.css
  10888. unit = unit || initialInUnit[ 3 ];
  10889. // Iteratively approximate from a nonzero starting point
  10890. initialInUnit = +initial || 1;
  10891. while ( maxIterations-- ) {
  10892. // Evaluate and update our best guess (doubling guesses that zero out).
  10893. // Finish if the scale equals or crosses 1 (making the old*new product non-positive).
  10894. jQuery.style( elem, prop, initialInUnit + unit );
  10895. if ( ( 1 - scale ) * ( 1 - ( scale = currentValue() / initial || 0.5 ) ) <= 0 ) {
  10896. maxIterations = 0;
  10897. }
  10898. initialInUnit = initialInUnit / scale;
  10899. }
  10900. initialInUnit = initialInUnit * 2;
  10901. jQuery.style( elem, prop, initialInUnit + unit );
  10902. // Make sure we update the tween properties later on
  10903. valueParts = valueParts || [];
  10904. }
  10905. if ( valueParts ) {
  10906. initialInUnit = +initialInUnit || +initial || 0;
  10907. // Apply relative offset (+=/-=) if specified
  10908. adjusted = valueParts[ 1 ] ?
  10909. initialInUnit + ( valueParts[ 1 ] + 1 ) * valueParts[ 2 ] :
  10910. +valueParts[ 2 ];
  10911. if ( tween ) {
  10912. tween.unit = unit;
  10913. tween.start = initialInUnit;
  10914. tween.end = adjusted;
  10915. }
  10916. }
  10917. return adjusted;
  10918. }
  10919. var defaultDisplayMap = {};
  10920. function getDefaultDisplay( elem ) {
  10921. var temp,
  10922. doc = elem.ownerDocument,
  10923. nodeName = elem.nodeName,
  10924. display = defaultDisplayMap[ nodeName ];
  10925. if ( display ) {
  10926. return display;
  10927. }
  10928. temp = doc.body.appendChild( doc.createElement( nodeName ) );
  10929. display = jQuery.css( temp, "display" );
  10930. temp.parentNode.removeChild( temp );
  10931. if ( display === "none" ) {
  10932. display = "block";
  10933. }
  10934. defaultDisplayMap[ nodeName ] = display;
  10935. return display;
  10936. }
  10937. function showHide( elements, show ) {
  10938. var display, elem,
  10939. values = [],
  10940. index = 0,
  10941. length = elements.length;
  10942. // Determine new display value for elements that need to change
  10943. for ( ; index < length; index++ ) {
  10944. elem = elements[ index ];
  10945. if ( !elem.style ) {
  10946. continue;
  10947. }
  10948. display = elem.style.display;
  10949. if ( show ) {
  10950. // Since we force visibility upon cascade-hidden elements, an immediate (and slow)
  10951. // check is required in this first loop unless we have a nonempty display value (either
  10952. // inline or about-to-be-restored)
  10953. if ( display === "none" ) {
  10954. values[ index ] = dataPriv.get( elem, "display" ) || null;
  10955. if ( !values[ index ] ) {
  10956. elem.style.display = "";
  10957. }
  10958. }
  10959. if ( elem.style.display === "" && isHiddenWithinTree( elem ) ) {
  10960. values[ index ] = getDefaultDisplay( elem );
  10961. }
  10962. } else {
  10963. if ( display !== "none" ) {
  10964. values[ index ] = "none";
  10965. // Remember what we're overwriting
  10966. dataPriv.set( elem, "display", display );
  10967. }
  10968. }
  10969. }
  10970. // Set the display of the elements in a second loop to avoid constant reflow
  10971. for ( index = 0; index < length; index++ ) {
  10972. if ( values[ index ] != null ) {
  10973. elements[ index ].style.display = values[ index ];
  10974. }
  10975. }
  10976. return elements;
  10977. }
  10978. jQuery.fn.extend( {
  10979. show: function() {
  10980. return showHide( this, true );
  10981. },
  10982. hide: function() {
  10983. return showHide( this );
  10984. },
  10985. toggle: function( state ) {
  10986. if ( typeof state === "boolean" ) {
  10987. return state ? this.show() : this.hide();
  10988. }
  10989. return this.each( function() {
  10990. if ( isHiddenWithinTree( this ) ) {
  10991. jQuery( this ).show();
  10992. } else {
  10993. jQuery( this ).hide();
  10994. }
  10995. } );
  10996. }
  10997. } );
  10998. var rcheckableType = ( /^(?:checkbox|radio)$/i );
  10999. var rtagName = ( /<([a-z][^\/\0>\x20\t\r\n\f]*)/i );
  11000. var rscriptType = ( /^$|^module$|\/(?:java|ecma)script/i );
  11001. // We have to close these tags to support XHTML (#13200)
  11002. var wrapMap = {
  11003. // Support: IE <=9 only
  11004. option: [ 1, "<select multiple='multiple'>", "</select>" ],
  11005. // XHTML parsers do not magically insert elements in the
  11006. // same way that tag soup parsers do. So we cannot shorten
  11007. // this by omitting <tbody> or other required elements.
  11008. thead: [ 1, "<table>", "</table>" ],
  11009. col: [ 2, "<table><colgroup>", "</colgroup></table>" ],
  11010. tr: [ 2, "<table><tbody>", "</tbody></table>" ],
  11011. td: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ],
  11012. _default: [ 0, "", "" ]
  11013. };
  11014. // Support: IE <=9 only
  11015. wrapMap.optgroup = wrapMap.option;
  11016. wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead;
  11017. wrapMap.th = wrapMap.td;
  11018. function getAll( context, tag ) {
  11019. // Support: IE <=9 - 11 only
  11020. // Use typeof to avoid zero-argument method invocation on host objects (#15151)
  11021. var ret;
  11022. if ( typeof context.getElementsByTagName !== "undefined" ) {
  11023. ret = context.getElementsByTagName( tag || "*" );
  11024. } else if ( typeof context.querySelectorAll !== "undefined" ) {
  11025. ret = context.querySelectorAll( tag || "*" );
  11026. } else {
  11027. ret = [];
  11028. }
  11029. if ( tag === undefined || tag && nodeName( context, tag ) ) {
  11030. return jQuery.merge( [ context ], ret );
  11031. }
  11032. return ret;
  11033. }
  11034. // Mark scripts as having already been evaluated
  11035. function setGlobalEval( elems, refElements ) {
  11036. var i = 0,
  11037. l = elems.length;
  11038. for ( ; i < l; i++ ) {
  11039. dataPriv.set(
  11040. elems[ i ],
  11041. "globalEval",
  11042. !refElements || dataPriv.get( refElements[ i ], "globalEval" )
  11043. );
  11044. }
  11045. }
  11046. var rhtml = /<|&#?\w+;/;
  11047. function buildFragment( elems, context, scripts, selection, ignored ) {
  11048. var elem, tmp, tag, wrap, attached, j,
  11049. fragment = context.createDocumentFragment(),
  11050. nodes = [],
  11051. i = 0,
  11052. l = elems.length;
  11053. for ( ; i < l; i++ ) {
  11054. elem = elems[ i ];
  11055. if ( elem || elem === 0 ) {
  11056. // Add nodes directly
  11057. if ( toType( elem ) === "object" ) {
  11058. // Support: Android <=4.0 only, PhantomJS 1 only
  11059. // push.apply(_, arraylike) throws on ancient WebKit
  11060. jQuery.merge( nodes, elem.nodeType ? [ elem ] : elem );
  11061. // Convert non-html into a text node
  11062. } else if ( !rhtml.test( elem ) ) {
  11063. nodes.push( context.createTextNode( elem ) );
  11064. // Convert html into DOM nodes
  11065. } else {
  11066. tmp = tmp || fragment.appendChild( context.createElement( "div" ) );
  11067. // Deserialize a standard representation
  11068. tag = ( rtagName.exec( elem ) || [ "", "" ] )[ 1 ].toLowerCase();
  11069. wrap = wrapMap[ tag ] || wrapMap._default;
  11070. tmp.innerHTML = wrap[ 1 ] + jQuery.htmlPrefilter( elem ) + wrap[ 2 ];
  11071. // Descend through wrappers to the right content
  11072. j = wrap[ 0 ];
  11073. while ( j-- ) {
  11074. tmp = tmp.lastChild;
  11075. }
  11076. // Support: Android <=4.0 only, PhantomJS 1 only
  11077. // push.apply(_, arraylike) throws on ancient WebKit
  11078. jQuery.merge( nodes, tmp.childNodes );
  11079. // Remember the top-level container
  11080. tmp = fragment.firstChild;
  11081. // Ensure the created nodes are orphaned (#12392)
  11082. tmp.textContent = "";
  11083. }
  11084. }
  11085. }
  11086. // Remove wrapper from fragment
  11087. fragment.textContent = "";
  11088. i = 0;
  11089. while ( ( elem = nodes[ i++ ] ) ) {
  11090. // Skip elements already in the context collection (trac-4087)
  11091. if ( selection && jQuery.inArray( elem, selection ) > -1 ) {
  11092. if ( ignored ) {
  11093. ignored.push( elem );
  11094. }
  11095. continue;
  11096. }
  11097. attached = isAttached( elem );
  11098. // Append to fragment
  11099. tmp = getAll( fragment.appendChild( elem ), "script" );
  11100. // Preserve script evaluation history
  11101. if ( attached ) {
  11102. setGlobalEval( tmp );
  11103. }
  11104. // Capture executables
  11105. if ( scripts ) {
  11106. j = 0;
  11107. while ( ( elem = tmp[ j++ ] ) ) {
  11108. if ( rscriptType.test( elem.type || "" ) ) {
  11109. scripts.push( elem );
  11110. }
  11111. }
  11112. }
  11113. }
  11114. return fragment;
  11115. }
  11116. ( function() {
  11117. var fragment = document.createDocumentFragment(),
  11118. div = fragment.appendChild( document.createElement( "div" ) ),
  11119. input = document.createElement( "input" );
  11120. // Support: Android 4.0 - 4.3 only
  11121. // Check state lost if the name is set (#11217)
  11122. // Support: Windows Web Apps (WWA)
  11123. // `name` and `type` must use .setAttribute for WWA (#14901)
  11124. input.setAttribute( "type", "radio" );
  11125. input.setAttribute( "checked", "checked" );
  11126. input.setAttribute( "name", "t" );
  11127. div.appendChild( input );
  11128. // Support: Android <=4.1 only
  11129. // Older WebKit doesn't clone checked state correctly in fragments
  11130. support.checkClone = div.cloneNode( true ).cloneNode( true ).lastChild.checked;
  11131. // Support: IE <=11 only
  11132. // Make sure textarea (and checkbox) defaultValue is properly cloned
  11133. div.innerHTML = "<textarea>x</textarea>";
  11134. support.noCloneChecked = !!div.cloneNode( true ).lastChild.defaultValue;
  11135. } )();
  11136. var
  11137. rkeyEvent = /^key/,
  11138. rmouseEvent = /^(?:mouse|pointer|contextmenu|drag|drop)|click/,
  11139. rtypenamespace = /^([^.]*)(?:\.(.+)|)/;
  11140. function returnTrue() {
  11141. return true;
  11142. }
  11143. function returnFalse() {
  11144. return false;
  11145. }
  11146. // Support: IE <=9 - 11+
  11147. // focus() and blur() are asynchronous, except when they are no-op.
  11148. // So expect focus to be synchronous when the element is already active,
  11149. // and blur to be synchronous when the element is not already active.
  11150. // (focus and blur are always synchronous in other supported browsers,
  11151. // this just defines when we can count on it).
  11152. function expectSync( elem, type ) {
  11153. return ( elem === safeActiveElement() ) === ( type === "focus" );
  11154. }
  11155. // Support: IE <=9 only
  11156. // Accessing document.activeElement can throw unexpectedly
  11157. // https://bugs.jquery.com/ticket/13393
  11158. function safeActiveElement() {
  11159. try {
  11160. return document.activeElement;
  11161. } catch ( err ) { }
  11162. }
  11163. function on( elem, types, selector, data, fn, one ) {
  11164. var origFn, type;
  11165. // Types can be a map of types/handlers
  11166. if ( typeof types === "object" ) {
  11167. // ( types-Object, selector, data )
  11168. if ( typeof selector !== "string" ) {
  11169. // ( types-Object, data )
  11170. data = data || selector;
  11171. selector = undefined;
  11172. }
  11173. for ( type in types ) {
  11174. on( elem, type, selector, data, types[ type ], one );
  11175. }
  11176. return elem;
  11177. }
  11178. if ( data == null && fn == null ) {
  11179. // ( types, fn )
  11180. fn = selector;
  11181. data = selector = undefined;
  11182. } else if ( fn == null ) {
  11183. if ( typeof selector === "string" ) {
  11184. // ( types, selector, fn )
  11185. fn = data;
  11186. data = undefined;
  11187. } else {
  11188. // ( types, data, fn )
  11189. fn = data;
  11190. data = selector;
  11191. selector = undefined;
  11192. }
  11193. }
  11194. if ( fn === false ) {
  11195. fn = returnFalse;
  11196. } else if ( !fn ) {
  11197. return elem;
  11198. }
  11199. if ( one === 1 ) {
  11200. origFn = fn;
  11201. fn = function( event ) {
  11202. // Can use an empty set, since event contains the info
  11203. jQuery().off( event );
  11204. return origFn.apply( this, arguments );
  11205. };
  11206. // Use same guid so caller can remove using origFn
  11207. fn.guid = origFn.guid || ( origFn.guid = jQuery.guid++ );
  11208. }
  11209. return elem.each( function() {
  11210. jQuery.event.add( this, types, fn, data, selector );
  11211. } );
  11212. }
  11213. /*
  11214. * Helper functions for managing events -- not part of the public interface.
  11215. * Props to Dean Edwards' addEvent library for many of the ideas.
  11216. */
  11217. jQuery.event = {
  11218. global: {},
  11219. add: function( elem, types, handler, data, selector ) {
  11220. var handleObjIn, eventHandle, tmp,
  11221. events, t, handleObj,
  11222. special, handlers, type, namespaces, origType,
  11223. elemData = dataPriv.get( elem );
  11224. // Don't attach events to noData or text/comment nodes (but allow plain objects)
  11225. if ( !elemData ) {
  11226. return;
  11227. }
  11228. // Caller can pass in an object of custom data in lieu of the handler
  11229. if ( handler.handler ) {
  11230. handleObjIn = handler;
  11231. handler = handleObjIn.handler;
  11232. selector = handleObjIn.selector;
  11233. }
  11234. // Ensure that invalid selectors throw exceptions at attach time
  11235. // Evaluate against documentElement in case elem is a non-element node (e.g., document)
  11236. if ( selector ) {
  11237. jQuery.find.matchesSelector( documentElement, selector );
  11238. }
  11239. // Make sure that the handler has a unique ID, used to find/remove it later
  11240. if ( !handler.guid ) {
  11241. handler.guid = jQuery.guid++;
  11242. }
  11243. // Init the element's event structure and main handler, if this is the first
  11244. if ( !( events = elemData.events ) ) {
  11245. events = elemData.events = {};
  11246. }
  11247. if ( !( eventHandle = elemData.handle ) ) {
  11248. eventHandle = elemData.handle = function( e ) {
  11249. // Discard the second event of a jQuery.event.trigger() and
  11250. // when an event is called after a page has unloaded
  11251. return typeof jQuery !== "undefined" && jQuery.event.triggered !== e.type ?
  11252. jQuery.event.dispatch.apply( elem, arguments ) : undefined;
  11253. };
  11254. }
  11255. // Handle multiple events separated by a space
  11256. types = ( types || "" ).match( rnothtmlwhite ) || [ "" ];
  11257. t = types.length;
  11258. while ( t-- ) {
  11259. tmp = rtypenamespace.exec( types[ t ] ) || [];
  11260. type = origType = tmp[ 1 ];
  11261. namespaces = ( tmp[ 2 ] || "" ).split( "." ).sort();
  11262. // There *must* be a type, no attaching namespace-only handlers
  11263. if ( !type ) {
  11264. continue;
  11265. }
  11266. // If event changes its type, use the special event handlers for the changed type
  11267. special = jQuery.event.special[ type ] || {};
  11268. // If selector defined, determine special event api type, otherwise given type
  11269. type = ( selector ? special.delegateType : special.bindType ) || type;
  11270. // Update special based on newly reset type
  11271. special = jQuery.event.special[ type ] || {};
  11272. // handleObj is passed to all event handlers
  11273. handleObj = jQuery.extend( {
  11274. type: type,
  11275. origType: origType,
  11276. data: data,
  11277. handler: handler,
  11278. guid: handler.guid,
  11279. selector: selector,
  11280. needsContext: selector && jQuery.expr.match.needsContext.test( selector ),
  11281. namespace: namespaces.join( "." )
  11282. }, handleObjIn );
  11283. // Init the event handler queue if we're the first
  11284. if ( !( handlers = events[ type ] ) ) {
  11285. handlers = events[ type ] = [];
  11286. handlers.delegateCount = 0;
  11287. // Only use addEventListener if the special events handler returns false
  11288. if ( !special.setup ||
  11289. special.setup.call( elem, data, namespaces, eventHandle ) === false ) {
  11290. if ( elem.addEventListener ) {
  11291. elem.addEventListener( type, eventHandle );
  11292. }
  11293. }
  11294. }
  11295. if ( special.add ) {
  11296. special.add.call( elem, handleObj );
  11297. if ( !handleObj.handler.guid ) {
  11298. handleObj.handler.guid = handler.guid;
  11299. }
  11300. }
  11301. // Add to the element's handler list, delegates in front
  11302. if ( selector ) {
  11303. handlers.splice( handlers.delegateCount++, 0, handleObj );
  11304. } else {
  11305. handlers.push( handleObj );
  11306. }
  11307. // Keep track of which events have ever been used, for event optimization
  11308. jQuery.event.global[ type ] = true;
  11309. }
  11310. },
  11311. // Detach an event or set of events from an element
  11312. remove: function( elem, types, handler, selector, mappedTypes ) {
  11313. var j, origCount, tmp,
  11314. events, t, handleObj,
  11315. special, handlers, type, namespaces, origType,
  11316. elemData = dataPriv.hasData( elem ) && dataPriv.get( elem );
  11317. if ( !elemData || !( events = elemData.events ) ) {
  11318. return;
  11319. }
  11320. // Once for each type.namespace in types; type may be omitted
  11321. types = ( types || "" ).match( rnothtmlwhite ) || [ "" ];
  11322. t = types.length;
  11323. while ( t-- ) {
  11324. tmp = rtypenamespace.exec( types[ t ] ) || [];
  11325. type = origType = tmp[ 1 ];
  11326. namespaces = ( tmp[ 2 ] || "" ).split( "." ).sort();
  11327. // Unbind all events (on this namespace, if provided) for the element
  11328. if ( !type ) {
  11329. for ( type in events ) {
  11330. jQuery.event.remove( elem, type + types[ t ], handler, selector, true );
  11331. }
  11332. continue;
  11333. }
  11334. special = jQuery.event.special[ type ] || {};
  11335. type = ( selector ? special.delegateType : special.bindType ) || type;
  11336. handlers = events[ type ] || [];
  11337. tmp = tmp[ 2 ] &&
  11338. new RegExp( "(^|\\.)" + namespaces.join( "\\.(?:.*\\.|)" ) + "(\\.|$)" );
  11339. // Remove matching events
  11340. origCount = j = handlers.length;
  11341. while ( j-- ) {
  11342. handleObj = handlers[ j ];
  11343. if ( ( mappedTypes || origType === handleObj.origType ) &&
  11344. ( !handler || handler.guid === handleObj.guid ) &&
  11345. ( !tmp || tmp.test( handleObj.namespace ) ) &&
  11346. ( !selector || selector === handleObj.selector ||
  11347. selector === "**" && handleObj.selector ) ) {
  11348. handlers.splice( j, 1 );
  11349. if ( handleObj.selector ) {
  11350. handlers.delegateCount--;
  11351. }
  11352. if ( special.remove ) {
  11353. special.remove.call( elem, handleObj );
  11354. }
  11355. }
  11356. }
  11357. // Remove generic event handler if we removed something and no more handlers exist
  11358. // (avoids potential for endless recursion during removal of special event handlers)
  11359. if ( origCount && !handlers.length ) {
  11360. if ( !special.teardown ||
  11361. special.teardown.call( elem, namespaces, elemData.handle ) === false ) {
  11362. jQuery.removeEvent( elem, type, elemData.handle );
  11363. }
  11364. delete events[ type ];
  11365. }
  11366. }
  11367. // Remove data and the expando if it's no longer used
  11368. if ( jQuery.isEmptyObject( events ) ) {
  11369. dataPriv.remove( elem, "handle events" );
  11370. }
  11371. },
  11372. dispatch: function( nativeEvent ) {
  11373. // Make a writable jQuery.Event from the native event object
  11374. var event = jQuery.event.fix( nativeEvent );
  11375. var i, j, ret, matched, handleObj, handlerQueue,
  11376. args = new Array( arguments.length ),
  11377. handlers = ( dataPriv.get( this, "events" ) || {} )[ event.type ] || [],
  11378. special = jQuery.event.special[ event.type ] || {};
  11379. // Use the fix-ed jQuery.Event rather than the (read-only) native event
  11380. args[ 0 ] = event;
  11381. for ( i = 1; i < arguments.length; i++ ) {
  11382. args[ i ] = arguments[ i ];
  11383. }
  11384. event.delegateTarget = this;
  11385. // Call the preDispatch hook for the mapped type, and let it bail if desired
  11386. if ( special.preDispatch && special.preDispatch.call( this, event ) === false ) {
  11387. return;
  11388. }
  11389. // Determine handlers
  11390. handlerQueue = jQuery.event.handlers.call( this, event, handlers );
  11391. // Run delegates first; they may want to stop propagation beneath us
  11392. i = 0;
  11393. while ( ( matched = handlerQueue[ i++ ] ) && !event.isPropagationStopped() ) {
  11394. event.currentTarget = matched.elem;
  11395. j = 0;
  11396. while ( ( handleObj = matched.handlers[ j++ ] ) &&
  11397. !event.isImmediatePropagationStopped() ) {
  11398. // If the event is namespaced, then each handler is only invoked if it is
  11399. // specially universal or its namespaces are a superset of the event's.
  11400. if ( !event.rnamespace || handleObj.namespace === false ||
  11401. event.rnamespace.test( handleObj.namespace ) ) {
  11402. event.handleObj = handleObj;
  11403. event.data = handleObj.data;
  11404. ret = ( ( jQuery.event.special[ handleObj.origType ] || {} ).handle ||
  11405. handleObj.handler ).apply( matched.elem, args );
  11406. if ( ret !== undefined ) {
  11407. if ( ( event.result = ret ) === false ) {
  11408. event.preventDefault();
  11409. event.stopPropagation();
  11410. }
  11411. }
  11412. }
  11413. }
  11414. }
  11415. // Call the postDispatch hook for the mapped type
  11416. if ( special.postDispatch ) {
  11417. special.postDispatch.call( this, event );
  11418. }
  11419. return event.result;
  11420. },
  11421. handlers: function( event, handlers ) {
  11422. var i, handleObj, sel, matchedHandlers, matchedSelectors,
  11423. handlerQueue = [],
  11424. delegateCount = handlers.delegateCount,
  11425. cur = event.target;
  11426. // Find delegate handlers
  11427. if ( delegateCount &&
  11428. // Support: IE <=9
  11429. // Black-hole SVG <use> instance trees (trac-13180)
  11430. cur.nodeType &&
  11431. // Support: Firefox <=42
  11432. // Suppress spec-violating clicks indicating a non-primary pointer button (trac-3861)
  11433. // https://www.w3.org/TR/DOM-Level-3-Events/#event-type-click
  11434. // Support: IE 11 only
  11435. // ...but not arrow key "clicks" of radio inputs, which can have `button` -1 (gh-2343)
  11436. !( event.type === "click" && event.button >= 1 ) ) {
  11437. for ( ; cur !== this; cur = cur.parentNode || this ) {
  11438. // Don't check non-elements (#13208)
  11439. // Don't process clicks on disabled elements (#6911, #8165, #11382, #11764)
  11440. if ( cur.nodeType === 1 && !( event.type === "click" && cur.disabled === true ) ) {
  11441. matchedHandlers = [];
  11442. matchedSelectors = {};
  11443. for ( i = 0; i < delegateCount; i++ ) {
  11444. handleObj = handlers[ i ];
  11445. // Don't conflict with Object.prototype properties (#13203)
  11446. sel = handleObj.selector + " ";
  11447. if ( matchedSelectors[ sel ] === undefined ) {
  11448. matchedSelectors[ sel ] = handleObj.needsContext ?
  11449. jQuery( sel, this ).index( cur ) > -1 :
  11450. jQuery.find( sel, this, null, [ cur ] ).length;
  11451. }
  11452. if ( matchedSelectors[ sel ] ) {
  11453. matchedHandlers.push( handleObj );
  11454. }
  11455. }
  11456. if ( matchedHandlers.length ) {
  11457. handlerQueue.push( { elem: cur, handlers: matchedHandlers } );
  11458. }
  11459. }
  11460. }
  11461. }
  11462. // Add the remaining (directly-bound) handlers
  11463. cur = this;
  11464. if ( delegateCount < handlers.length ) {
  11465. handlerQueue.push( { elem: cur, handlers: handlers.slice( delegateCount ) } );
  11466. }
  11467. return handlerQueue;
  11468. },
  11469. addProp: function( name, hook ) {
  11470. Object.defineProperty( jQuery.Event.prototype, name, {
  11471. enumerable: true,
  11472. configurable: true,
  11473. get: isFunction( hook ) ?
  11474. function() {
  11475. if ( this.originalEvent ) {
  11476. return hook( this.originalEvent );
  11477. }
  11478. } :
  11479. function() {
  11480. if ( this.originalEvent ) {
  11481. return this.originalEvent[ name ];
  11482. }
  11483. },
  11484. set: function( value ) {
  11485. Object.defineProperty( this, name, {
  11486. enumerable: true,
  11487. configurable: true,
  11488. writable: true,
  11489. value: value
  11490. } );
  11491. }
  11492. } );
  11493. },
  11494. fix: function( originalEvent ) {
  11495. return originalEvent[ jQuery.expando ] ?
  11496. originalEvent :
  11497. new jQuery.Event( originalEvent );
  11498. },
  11499. special: {
  11500. load: {
  11501. // Prevent triggered image.load events from bubbling to window.load
  11502. noBubble: true
  11503. },
  11504. click: {
  11505. // Utilize native event to ensure correct state for checkable inputs
  11506. setup: function( data ) {
  11507. // For mutual compressibility with _default, replace `this` access with a local var.
  11508. // `|| data` is dead code meant only to preserve the variable through minification.
  11509. var el = this || data;
  11510. // Claim the first handler
  11511. if ( rcheckableType.test( el.type ) &&
  11512. el.click && nodeName( el, "input" ) ) {
  11513. // dataPriv.set( el, "click", ... )
  11514. leverageNative( el, "click", returnTrue );
  11515. }
  11516. // Return false to allow normal processing in the caller
  11517. return false;
  11518. },
  11519. trigger: function( data ) {
  11520. // For mutual compressibility with _default, replace `this` access with a local var.
  11521. // `|| data` is dead code meant only to preserve the variable through minification.
  11522. var el = this || data;
  11523. // Force setup before triggering a click
  11524. if ( rcheckableType.test( el.type ) &&
  11525. el.click && nodeName( el, "input" ) ) {
  11526. leverageNative( el, "click" );
  11527. }
  11528. // Return non-false to allow normal event-path propagation
  11529. return true;
  11530. },
  11531. // For cross-browser consistency, suppress native .click() on links
  11532. // Also prevent it if we're currently inside a leveraged native-event stack
  11533. _default: function( event ) {
  11534. var target = event.target;
  11535. return rcheckableType.test( target.type ) &&
  11536. target.click && nodeName( target, "input" ) &&
  11537. dataPriv.get( target, "click" ) ||
  11538. nodeName( target, "a" );
  11539. }
  11540. },
  11541. beforeunload: {
  11542. postDispatch: function( event ) {
  11543. // Support: Firefox 20+
  11544. // Firefox doesn't alert if the returnValue field is not set.
  11545. if ( event.result !== undefined && event.originalEvent ) {
  11546. event.originalEvent.returnValue = event.result;
  11547. }
  11548. }
  11549. }
  11550. }
  11551. };
  11552. // Ensure the presence of an event listener that handles manually-triggered
  11553. // synthetic events by interrupting progress until reinvoked in response to
  11554. // *native* events that it fires directly, ensuring that state changes have
  11555. // already occurred before other listeners are invoked.
  11556. function leverageNative( el, type, expectSync ) {
  11557. // Missing expectSync indicates a trigger call, which must force setup through jQuery.event.add
  11558. if ( !expectSync ) {
  11559. if ( dataPriv.get( el, type ) === undefined ) {
  11560. jQuery.event.add( el, type, returnTrue );
  11561. }
  11562. return;
  11563. }
  11564. // Register the controller as a special universal handler for all event namespaces
  11565. dataPriv.set( el, type, false );
  11566. jQuery.event.add( el, type, {
  11567. namespace: false,
  11568. handler: function( event ) {
  11569. var notAsync, result,
  11570. saved = dataPriv.get( this, type );
  11571. if ( ( event.isTrigger & 1 ) && this[ type ] ) {
  11572. // Interrupt processing of the outer synthetic .trigger()ed event
  11573. // Saved data should be false in such cases, but might be a leftover capture object
  11574. // from an async native handler (gh-4350)
  11575. if ( !saved.length ) {
  11576. // Store arguments for use when handling the inner native event
  11577. // There will always be at least one argument (an event object), so this array
  11578. // will not be confused with a leftover capture object.
  11579. saved = slice.call( arguments );
  11580. dataPriv.set( this, type, saved );
  11581. // Trigger the native event and capture its result
  11582. // Support: IE <=9 - 11+
  11583. // focus() and blur() are asynchronous
  11584. notAsync = expectSync( this, type );
  11585. this[ type ]();
  11586. result = dataPriv.get( this, type );
  11587. if ( saved !== result || notAsync ) {
  11588. dataPriv.set( this, type, false );
  11589. } else {
  11590. result = {};
  11591. }
  11592. if ( saved !== result ) {
  11593. // Cancel the outer synthetic event
  11594. event.stopImmediatePropagation();
  11595. event.preventDefault();
  11596. return result.value;
  11597. }
  11598. // If this is an inner synthetic event for an event with a bubbling surrogate
  11599. // (focus or blur), assume that the surrogate already propagated from triggering the
  11600. // native event and prevent that from happening again here.
  11601. // This technically gets the ordering wrong w.r.t. to `.trigger()` (in which the
  11602. // bubbling surrogate propagates *after* the non-bubbling base), but that seems
  11603. // less bad than duplication.
  11604. } else if ( ( jQuery.event.special[ type ] || {} ).delegateType ) {
  11605. event.stopPropagation();
  11606. }
  11607. // If this is a native event triggered above, everything is now in order
  11608. // Fire an inner synthetic event with the original arguments
  11609. } else if ( saved.length ) {
  11610. // ...and capture the result
  11611. dataPriv.set( this, type, {
  11612. value: jQuery.event.trigger(
  11613. // Support: IE <=9 - 11+
  11614. // Extend with the prototype to reset the above stopImmediatePropagation()
  11615. jQuery.extend( saved[ 0 ], jQuery.Event.prototype ),
  11616. saved.slice( 1 ),
  11617. this
  11618. )
  11619. } );
  11620. // Abort handling of the native event
  11621. event.stopImmediatePropagation();
  11622. }
  11623. }
  11624. } );
  11625. }
  11626. jQuery.removeEvent = function( elem, type, handle ) {
  11627. // This "if" is needed for plain objects
  11628. if ( elem.removeEventListener ) {
  11629. elem.removeEventListener( type, handle );
  11630. }
  11631. };
  11632. jQuery.Event = function( src, props ) {
  11633. // Allow instantiation without the 'new' keyword
  11634. if ( !( this instanceof jQuery.Event ) ) {
  11635. return new jQuery.Event( src, props );
  11636. }
  11637. // Event object
  11638. if ( src && src.type ) {
  11639. this.originalEvent = src;
  11640. this.type = src.type;
  11641. // Events bubbling up the document may have been marked as prevented
  11642. // by a handler lower down the tree; reflect the correct value.
  11643. this.isDefaultPrevented = src.defaultPrevented ||
  11644. src.defaultPrevented === undefined &&
  11645. // Support: Android <=2.3 only
  11646. src.returnValue === false ?
  11647. returnTrue :
  11648. returnFalse;
  11649. // Create target properties
  11650. // Support: Safari <=6 - 7 only
  11651. // Target should not be a text node (#504, #13143)
  11652. this.target = ( src.target && src.target.nodeType === 3 ) ?
  11653. src.target.parentNode :
  11654. src.target;
  11655. this.currentTarget = src.currentTarget;
  11656. this.relatedTarget = src.relatedTarget;
  11657. // Event type
  11658. } else {
  11659. this.type = src;
  11660. }
  11661. // Put explicitly provided properties onto the event object
  11662. if ( props ) {
  11663. jQuery.extend( this, props );
  11664. }
  11665. // Create a timestamp if incoming event doesn't have one
  11666. this.timeStamp = src && src.timeStamp || Date.now();
  11667. // Mark it as fixed
  11668. this[ jQuery.expando ] = true;
  11669. };
  11670. // jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding
  11671. // https://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html
  11672. jQuery.Event.prototype = {
  11673. constructor: jQuery.Event,
  11674. isDefaultPrevented: returnFalse,
  11675. isPropagationStopped: returnFalse,
  11676. isImmediatePropagationStopped: returnFalse,
  11677. isSimulated: false,
  11678. preventDefault: function() {
  11679. var e = this.originalEvent;
  11680. this.isDefaultPrevented = returnTrue;
  11681. if ( e && !this.isSimulated ) {
  11682. e.preventDefault();
  11683. }
  11684. },
  11685. stopPropagation: function() {
  11686. var e = this.originalEvent;
  11687. this.isPropagationStopped = returnTrue;
  11688. if ( e && !this.isSimulated ) {
  11689. e.stopPropagation();
  11690. }
  11691. },
  11692. stopImmediatePropagation: function() {
  11693. var e = this.originalEvent;
  11694. this.isImmediatePropagationStopped = returnTrue;
  11695. if ( e && !this.isSimulated ) {
  11696. e.stopImmediatePropagation();
  11697. }
  11698. this.stopPropagation();
  11699. }
  11700. };
  11701. // Includes all common event props including KeyEvent and MouseEvent specific props
  11702. jQuery.each( {
  11703. altKey: true,
  11704. bubbles: true,
  11705. cancelable: true,
  11706. changedTouches: true,
  11707. ctrlKey: true,
  11708. detail: true,
  11709. eventPhase: true,
  11710. metaKey: true,
  11711. pageX: true,
  11712. pageY: true,
  11713. shiftKey: true,
  11714. view: true,
  11715. "char": true,
  11716. code: true,
  11717. charCode: true,
  11718. key: true,
  11719. keyCode: true,
  11720. button: true,
  11721. buttons: true,
  11722. clientX: true,
  11723. clientY: true,
  11724. offsetX: true,
  11725. offsetY: true,
  11726. pointerId: true,
  11727. pointerType: true,
  11728. screenX: true,
  11729. screenY: true,
  11730. targetTouches: true,
  11731. toElement: true,
  11732. touches: true,
  11733. which: function( event ) {
  11734. var button = event.button;
  11735. // Add which for key events
  11736. if ( event.which == null && rkeyEvent.test( event.type ) ) {
  11737. return event.charCode != null ? event.charCode : event.keyCode;
  11738. }
  11739. // Add which for click: 1 === left; 2 === middle; 3 === right
  11740. if ( !event.which && button !== undefined && rmouseEvent.test( event.type ) ) {
  11741. if ( button & 1 ) {
  11742. return 1;
  11743. }
  11744. if ( button & 2 ) {
  11745. return 3;
  11746. }
  11747. if ( button & 4 ) {
  11748. return 2;
  11749. }
  11750. return 0;
  11751. }
  11752. return event.which;
  11753. }
  11754. }, jQuery.event.addProp );
  11755. jQuery.each( { focus: "focusin", blur: "focusout" }, function( type, delegateType ) {
  11756. jQuery.event.special[ type ] = {
  11757. // Utilize native event if possible so blur/focus sequence is correct
  11758. setup: function() {
  11759. // Claim the first handler
  11760. // dataPriv.set( this, "focus", ... )
  11761. // dataPriv.set( this, "blur", ... )
  11762. leverageNative( this, type, expectSync );
  11763. // Return false to allow normal processing in the caller
  11764. return false;
  11765. },
  11766. trigger: function() {
  11767. // Force setup before trigger
  11768. leverageNative( this, type );
  11769. // Return non-false to allow normal event-path propagation
  11770. return true;
  11771. },
  11772. delegateType: delegateType
  11773. };
  11774. } );
  11775. // Create mouseenter/leave events using mouseover/out and event-time checks
  11776. // so that event delegation works in jQuery.
  11777. // Do the same for pointerenter/pointerleave and pointerover/pointerout
  11778. //
  11779. // Support: Safari 7 only
  11780. // Safari sends mouseenter too often; see:
  11781. // https://bugs.chromium.org/p/chromium/issues/detail?id=470258
  11782. // for the description of the bug (it existed in older Chrome versions as well).
  11783. jQuery.each( {
  11784. mouseenter: "mouseover",
  11785. mouseleave: "mouseout",
  11786. pointerenter: "pointerover",
  11787. pointerleave: "pointerout"
  11788. }, function( orig, fix ) {
  11789. jQuery.event.special[ orig ] = {
  11790. delegateType: fix,
  11791. bindType: fix,
  11792. handle: function( event ) {
  11793. var ret,
  11794. target = this,
  11795. related = event.relatedTarget,
  11796. handleObj = event.handleObj;
  11797. // For mouseenter/leave call the handler if related is outside the target.
  11798. // NB: No relatedTarget if the mouse left/entered the browser window
  11799. if ( !related || ( related !== target && !jQuery.contains( target, related ) ) ) {
  11800. event.type = handleObj.origType;
  11801. ret = handleObj.handler.apply( this, arguments );
  11802. event.type = fix;
  11803. }
  11804. return ret;
  11805. }
  11806. };
  11807. } );
  11808. jQuery.fn.extend( {
  11809. on: function( types, selector, data, fn ) {
  11810. return on( this, types, selector, data, fn );
  11811. },
  11812. one: function( types, selector, data, fn ) {
  11813. return on( this, types, selector, data, fn, 1 );
  11814. },
  11815. off: function( types, selector, fn ) {
  11816. var handleObj, type;
  11817. if ( types && types.preventDefault && types.handleObj ) {
  11818. // ( event ) dispatched jQuery.Event
  11819. handleObj = types.handleObj;
  11820. jQuery( types.delegateTarget ).off(
  11821. handleObj.namespace ?
  11822. handleObj.origType + "." + handleObj.namespace :
  11823. handleObj.origType,
  11824. handleObj.selector,
  11825. handleObj.handler
  11826. );
  11827. return this;
  11828. }
  11829. if ( typeof types === "object" ) {
  11830. // ( types-object [, selector] )
  11831. for ( type in types ) {
  11832. this.off( type, selector, types[ type ] );
  11833. }
  11834. return this;
  11835. }
  11836. if ( selector === false || typeof selector === "function" ) {
  11837. // ( types [, fn] )
  11838. fn = selector;
  11839. selector = undefined;
  11840. }
  11841. if ( fn === false ) {
  11842. fn = returnFalse;
  11843. }
  11844. return this.each( function() {
  11845. jQuery.event.remove( this, types, fn, selector );
  11846. } );
  11847. }
  11848. } );
  11849. var
  11850. /* eslint-disable max-len */
  11851. // See https://github.com/eslint/eslint/issues/3229
  11852. rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([a-z][^\/\0>\x20\t\r\n\f]*)[^>]*)\/>/gi,
  11853. /* eslint-enable */
  11854. // Support: IE <=10 - 11, Edge 12 - 13 only
  11855. // In IE/Edge using regex groups here causes severe slowdowns.
  11856. // See https://connect.microsoft.com/IE/feedback/details/1736512/
  11857. rnoInnerhtml = /<script|<style|<link/i,
  11858. // checked="checked" or checked
  11859. rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i,
  11860. rcleanScript = /^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g;
  11861. // Prefer a tbody over its parent table for containing new rows
  11862. function manipulationTarget( elem, content ) {
  11863. if ( nodeName( elem, "table" ) &&
  11864. nodeName( content.nodeType !== 11 ? content : content.firstChild, "tr" ) ) {
  11865. return jQuery( elem ).children( "tbody" )[ 0 ] || elem;
  11866. }
  11867. return elem;
  11868. }
  11869. // Replace/restore the type attribute of script elements for safe DOM manipulation
  11870. function disableScript( elem ) {
  11871. elem.type = ( elem.getAttribute( "type" ) !== null ) + "/" + elem.type;
  11872. return elem;
  11873. }
  11874. function restoreScript( elem ) {
  11875. if ( ( elem.type || "" ).slice( 0, 5 ) === "true/" ) {
  11876. elem.type = elem.type.slice( 5 );
  11877. } else {
  11878. elem.removeAttribute( "type" );
  11879. }
  11880. return elem;
  11881. }
  11882. function cloneCopyEvent( src, dest ) {
  11883. var i, l, type, pdataOld, pdataCur, udataOld, udataCur, events;
  11884. if ( dest.nodeType !== 1 ) {
  11885. return;
  11886. }
  11887. // 1. Copy private data: events, handlers, etc.
  11888. if ( dataPriv.hasData( src ) ) {
  11889. pdataOld = dataPriv.access( src );
  11890. pdataCur = dataPriv.set( dest, pdataOld );
  11891. events = pdataOld.events;
  11892. if ( events ) {
  11893. delete pdataCur.handle;
  11894. pdataCur.events = {};
  11895. for ( type in events ) {
  11896. for ( i = 0, l = events[ type ].length; i < l; i++ ) {
  11897. jQuery.event.add( dest, type, events[ type ][ i ] );
  11898. }
  11899. }
  11900. }
  11901. }
  11902. // 2. Copy user data
  11903. if ( dataUser.hasData( src ) ) {
  11904. udataOld = dataUser.access( src );
  11905. udataCur = jQuery.extend( {}, udataOld );
  11906. dataUser.set( dest, udataCur );
  11907. }
  11908. }
  11909. // Fix IE bugs, see support tests
  11910. function fixInput( src, dest ) {
  11911. var nodeName = dest.nodeName.toLowerCase();
  11912. // Fails to persist the checked state of a cloned checkbox or radio button.
  11913. if ( nodeName === "input" && rcheckableType.test( src.type ) ) {
  11914. dest.checked = src.checked;
  11915. // Fails to return the selected option to the default selected state when cloning options
  11916. } else if ( nodeName === "input" || nodeName === "textarea" ) {
  11917. dest.defaultValue = src.defaultValue;
  11918. }
  11919. }
  11920. function domManip( collection, args, callback, ignored ) {
  11921. // Flatten any nested arrays
  11922. args = concat.apply( [], args );
  11923. var fragment, first, scripts, hasScripts, node, doc,
  11924. i = 0,
  11925. l = collection.length,
  11926. iNoClone = l - 1,
  11927. value = args[ 0 ],
  11928. valueIsFunction = isFunction( value );
  11929. // We can't cloneNode fragments that contain checked, in WebKit
  11930. if ( valueIsFunction ||
  11931. ( l > 1 && typeof value === "string" &&
  11932. !support.checkClone && rchecked.test( value ) ) ) {
  11933. return collection.each( function( index ) {
  11934. var self = collection.eq( index );
  11935. if ( valueIsFunction ) {
  11936. args[ 0 ] = value.call( this, index, self.html() );
  11937. }
  11938. domManip( self, args, callback, ignored );
  11939. } );
  11940. }
  11941. if ( l ) {
  11942. fragment = buildFragment( args, collection[ 0 ].ownerDocument, false, collection, ignored );
  11943. first = fragment.firstChild;
  11944. if ( fragment.childNodes.length === 1 ) {
  11945. fragment = first;
  11946. }
  11947. // Require either new content or an interest in ignored elements to invoke the callback
  11948. if ( first || ignored ) {
  11949. scripts = jQuery.map( getAll( fragment, "script" ), disableScript );
  11950. hasScripts = scripts.length;
  11951. // Use the original fragment for the last item
  11952. // instead of the first because it can end up
  11953. // being emptied incorrectly in certain situations (#8070).
  11954. for ( ; i < l; i++ ) {
  11955. node = fragment;
  11956. if ( i !== iNoClone ) {
  11957. node = jQuery.clone( node, true, true );
  11958. // Keep references to cloned scripts for later restoration
  11959. if ( hasScripts ) {
  11960. // Support: Android <=4.0 only, PhantomJS 1 only
  11961. // push.apply(_, arraylike) throws on ancient WebKit
  11962. jQuery.merge( scripts, getAll( node, "script" ) );
  11963. }
  11964. }
  11965. callback.call( collection[ i ], node, i );
  11966. }
  11967. if ( hasScripts ) {
  11968. doc = scripts[ scripts.length - 1 ].ownerDocument;
  11969. // Reenable scripts
  11970. jQuery.map( scripts, restoreScript );
  11971. // Evaluate executable scripts on first document insertion
  11972. for ( i = 0; i < hasScripts; i++ ) {
  11973. node = scripts[ i ];
  11974. if ( rscriptType.test( node.type || "" ) &&
  11975. !dataPriv.access( node, "globalEval" ) &&
  11976. jQuery.contains( doc, node ) ) {
  11977. if ( node.src && ( node.type || "" ).toLowerCase() !== "module" ) {
  11978. // Optional AJAX dependency, but won't run scripts if not present
  11979. if ( jQuery._evalUrl && !node.noModule ) {
  11980. jQuery._evalUrl( node.src, {
  11981. nonce: node.nonce || node.getAttribute( "nonce" )
  11982. } );
  11983. }
  11984. } else {
  11985. DOMEval( node.textContent.replace( rcleanScript, "" ), node, doc );
  11986. }
  11987. }
  11988. }
  11989. }
  11990. }
  11991. }
  11992. return collection;
  11993. }
  11994. function remove( elem, selector, keepData ) {
  11995. var node,
  11996. nodes = selector ? jQuery.filter( selector, elem ) : elem,
  11997. i = 0;
  11998. for ( ; ( node = nodes[ i ] ) != null; i++ ) {
  11999. if ( !keepData && node.nodeType === 1 ) {
  12000. jQuery.cleanData( getAll( node ) );
  12001. }
  12002. if ( node.parentNode ) {
  12003. if ( keepData && isAttached( node ) ) {
  12004. setGlobalEval( getAll( node, "script" ) );
  12005. }
  12006. node.parentNode.removeChild( node );
  12007. }
  12008. }
  12009. return elem;
  12010. }
  12011. jQuery.extend( {
  12012. htmlPrefilter: function( html ) {
  12013. return html.replace( rxhtmlTag, "<$1></$2>" );
  12014. },
  12015. clone: function( elem, dataAndEvents, deepDataAndEvents ) {
  12016. var i, l, srcElements, destElements,
  12017. clone = elem.cloneNode( true ),
  12018. inPage = isAttached( elem );
  12019. // Fix IE cloning issues
  12020. if ( !support.noCloneChecked && ( elem.nodeType === 1 || elem.nodeType === 11 ) &&
  12021. !jQuery.isXMLDoc( elem ) ) {
  12022. // We eschew Sizzle here for performance reasons: https://jsperf.com/getall-vs-sizzle/2
  12023. destElements = getAll( clone );
  12024. srcElements = getAll( elem );
  12025. for ( i = 0, l = srcElements.length; i < l; i++ ) {
  12026. fixInput( srcElements[ i ], destElements[ i ] );
  12027. }
  12028. }
  12029. // Copy the events from the original to the clone
  12030. if ( dataAndEvents ) {
  12031. if ( deepDataAndEvents ) {
  12032. srcElements = srcElements || getAll( elem );
  12033. destElements = destElements || getAll( clone );
  12034. for ( i = 0, l = srcElements.length; i < l; i++ ) {
  12035. cloneCopyEvent( srcElements[ i ], destElements[ i ] );
  12036. }
  12037. } else {
  12038. cloneCopyEvent( elem, clone );
  12039. }
  12040. }
  12041. // Preserve script evaluation history
  12042. destElements = getAll( clone, "script" );
  12043. if ( destElements.length > 0 ) {
  12044. setGlobalEval( destElements, !inPage && getAll( elem, "script" ) );
  12045. }
  12046. // Return the cloned set
  12047. return clone;
  12048. },
  12049. cleanData: function( elems ) {
  12050. var data, elem, type,
  12051. special = jQuery.event.special,
  12052. i = 0;
  12053. for ( ; ( elem = elems[ i ] ) !== undefined; i++ ) {
  12054. if ( acceptData( elem ) ) {
  12055. if ( ( data = elem[ dataPriv.expando ] ) ) {
  12056. if ( data.events ) {
  12057. for ( type in data.events ) {
  12058. if ( special[ type ] ) {
  12059. jQuery.event.remove( elem, type );
  12060. // This is a shortcut to avoid jQuery.event.remove's overhead
  12061. } else {
  12062. jQuery.removeEvent( elem, type, data.handle );
  12063. }
  12064. }
  12065. }
  12066. // Support: Chrome <=35 - 45+
  12067. // Assign undefined instead of using delete, see Data#remove
  12068. elem[ dataPriv.expando ] = undefined;
  12069. }
  12070. if ( elem[ dataUser.expando ] ) {
  12071. // Support: Chrome <=35 - 45+
  12072. // Assign undefined instead of using delete, see Data#remove
  12073. elem[ dataUser.expando ] = undefined;
  12074. }
  12075. }
  12076. }
  12077. }
  12078. } );
  12079. jQuery.fn.extend( {
  12080. detach: function( selector ) {
  12081. return remove( this, selector, true );
  12082. },
  12083. remove: function( selector ) {
  12084. return remove( this, selector );
  12085. },
  12086. text: function( value ) {
  12087. return access( this, function( value ) {
  12088. return value === undefined ?
  12089. jQuery.text( this ) :
  12090. this.empty().each( function() {
  12091. if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
  12092. this.textContent = value;
  12093. }
  12094. } );
  12095. }, null, value, arguments.length );
  12096. },
  12097. append: function() {
  12098. return domManip( this, arguments, function( elem ) {
  12099. if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
  12100. var target = manipulationTarget( this, elem );
  12101. target.appendChild( elem );
  12102. }
  12103. } );
  12104. },
  12105. prepend: function() {
  12106. return domManip( this, arguments, function( elem ) {
  12107. if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
  12108. var target = manipulationTarget( this, elem );
  12109. target.insertBefore( elem, target.firstChild );
  12110. }
  12111. } );
  12112. },
  12113. before: function() {
  12114. return domManip( this, arguments, function( elem ) {
  12115. if ( this.parentNode ) {
  12116. this.parentNode.insertBefore( elem, this );
  12117. }
  12118. } );
  12119. },
  12120. after: function() {
  12121. return domManip( this, arguments, function( elem ) {
  12122. if ( this.parentNode ) {
  12123. this.parentNode.insertBefore( elem, this.nextSibling );
  12124. }
  12125. } );
  12126. },
  12127. empty: function() {
  12128. var elem,
  12129. i = 0;
  12130. for ( ; ( elem = this[ i ] ) != null; i++ ) {
  12131. if ( elem.nodeType === 1 ) {
  12132. // Prevent memory leaks
  12133. jQuery.cleanData( getAll( elem, false ) );
  12134. // Remove any remaining nodes
  12135. elem.textContent = "";
  12136. }
  12137. }
  12138. return this;
  12139. },
  12140. clone: function( dataAndEvents, deepDataAndEvents ) {
  12141. dataAndEvents = dataAndEvents == null ? false : dataAndEvents;
  12142. deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents;
  12143. return this.map( function() {
  12144. return jQuery.clone( this, dataAndEvents, deepDataAndEvents );
  12145. } );
  12146. },
  12147. html: function( value ) {
  12148. return access( this, function( value ) {
  12149. var elem = this[ 0 ] || {},
  12150. i = 0,
  12151. l = this.length;
  12152. if ( value === undefined && elem.nodeType === 1 ) {
  12153. return elem.innerHTML;
  12154. }
  12155. // See if we can take a shortcut and just use innerHTML
  12156. if ( typeof value === "string" && !rnoInnerhtml.test( value ) &&
  12157. !wrapMap[ ( rtagName.exec( value ) || [ "", "" ] )[ 1 ].toLowerCase() ] ) {
  12158. value = jQuery.htmlPrefilter( value );
  12159. try {
  12160. for ( ; i < l; i++ ) {
  12161. elem = this[ i ] || {};
  12162. // Remove element nodes and prevent memory leaks
  12163. if ( elem.nodeType === 1 ) {
  12164. jQuery.cleanData( getAll( elem, false ) );
  12165. elem.innerHTML = value;
  12166. }
  12167. }
  12168. elem = 0;
  12169. // If using innerHTML throws an exception, use the fallback method
  12170. } catch ( e ) {}
  12171. }
  12172. if ( elem ) {
  12173. this.empty().append( value );
  12174. }
  12175. }, null, value, arguments.length );
  12176. },
  12177. replaceWith: function() {
  12178. var ignored = [];
  12179. // Make the changes, replacing each non-ignored context element with the new content
  12180. return domManip( this, arguments, function( elem ) {
  12181. var parent = this.parentNode;
  12182. if ( jQuery.inArray( this, ignored ) < 0 ) {
  12183. jQuery.cleanData( getAll( this ) );
  12184. if ( parent ) {
  12185. parent.replaceChild( elem, this );
  12186. }
  12187. }
  12188. // Force callback invocation
  12189. }, ignored );
  12190. }
  12191. } );
  12192. jQuery.each( {
  12193. appendTo: "append",
  12194. prependTo: "prepend",
  12195. insertBefore: "before",
  12196. insertAfter: "after",
  12197. replaceAll: "replaceWith"
  12198. }, function( name, original ) {
  12199. jQuery.fn[ name ] = function( selector ) {
  12200. var elems,
  12201. ret = [],
  12202. insert = jQuery( selector ),
  12203. last = insert.length - 1,
  12204. i = 0;
  12205. for ( ; i <= last; i++ ) {
  12206. elems = i === last ? this : this.clone( true );
  12207. jQuery( insert[ i ] )[ original ]( elems );
  12208. // Support: Android <=4.0 only, PhantomJS 1 only
  12209. // .get() because push.apply(_, arraylike) throws on ancient WebKit
  12210. push.apply( ret, elems.get() );
  12211. }
  12212. return this.pushStack( ret );
  12213. };
  12214. } );
  12215. var rnumnonpx = new RegExp( "^(" + pnum + ")(?!px)[a-z%]+$", "i" );
  12216. var getStyles = function( elem ) {
  12217. // Support: IE <=11 only, Firefox <=30 (#15098, #14150)
  12218. // IE throws on elements created in popups
  12219. // FF meanwhile throws on frame elements through "defaultView.getComputedStyle"
  12220. var view = elem.ownerDocument.defaultView;
  12221. if ( !view || !view.opener ) {
  12222. view = window;
  12223. }
  12224. return view.getComputedStyle( elem );
  12225. };
  12226. var rboxStyle = new RegExp( cssExpand.join( "|" ), "i" );
  12227. ( function() {
  12228. // Executing both pixelPosition & boxSizingReliable tests require only one layout
  12229. // so they're executed at the same time to save the second computation.
  12230. function computeStyleTests() {
  12231. // This is a singleton, we need to execute it only once
  12232. if ( !div ) {
  12233. return;
  12234. }
  12235. container.style.cssText = "position:absolute;left:-11111px;width:60px;" +
  12236. "margin-top:1px;padding:0;border:0";
  12237. div.style.cssText =
  12238. "position:relative;display:block;box-sizing:border-box;overflow:scroll;" +
  12239. "margin:auto;border:1px;padding:1px;" +
  12240. "width:60%;top:1%";
  12241. documentElement.appendChild( container ).appendChild( div );
  12242. var divStyle = window.getComputedStyle( div );
  12243. pixelPositionVal = divStyle.top !== "1%";
  12244. // Support: Android 4.0 - 4.3 only, Firefox <=3 - 44
  12245. reliableMarginLeftVal = roundPixelMeasures( divStyle.marginLeft ) === 12;
  12246. // Support: Android 4.0 - 4.3 only, Safari <=9.1 - 10.1, iOS <=7.0 - 9.3
  12247. // Some styles come back with percentage values, even though they shouldn't
  12248. div.style.right = "60%";
  12249. pixelBoxStylesVal = roundPixelMeasures( divStyle.right ) === 36;
  12250. // Support: IE 9 - 11 only
  12251. // Detect misreporting of content dimensions for box-sizing:border-box elements
  12252. boxSizingReliableVal = roundPixelMeasures( divStyle.width ) === 36;
  12253. // Support: IE 9 only
  12254. // Detect overflow:scroll screwiness (gh-3699)
  12255. // Support: Chrome <=64
  12256. // Don't get tricked when zoom affects offsetWidth (gh-4029)
  12257. div.style.position = "absolute";
  12258. scrollboxSizeVal = roundPixelMeasures( div.offsetWidth / 3 ) === 12;
  12259. documentElement.removeChild( container );
  12260. // Nullify the div so it wouldn't be stored in the memory and
  12261. // it will also be a sign that checks already performed
  12262. div = null;
  12263. }
  12264. function roundPixelMeasures( measure ) {
  12265. return Math.round( parseFloat( measure ) );
  12266. }
  12267. var pixelPositionVal, boxSizingReliableVal, scrollboxSizeVal, pixelBoxStylesVal,
  12268. reliableMarginLeftVal,
  12269. container = document.createElement( "div" ),
  12270. div = document.createElement( "div" );
  12271. // Finish early in limited (non-browser) environments
  12272. if ( !div.style ) {
  12273. return;
  12274. }
  12275. // Support: IE <=9 - 11 only
  12276. // Style of cloned element affects source element cloned (#8908)
  12277. div.style.backgroundClip = "content-box";
  12278. div.cloneNode( true ).style.backgroundClip = "";
  12279. support.clearCloneStyle = div.style.backgroundClip === "content-box";
  12280. jQuery.extend( support, {
  12281. boxSizingReliable: function() {
  12282. computeStyleTests();
  12283. return boxSizingReliableVal;
  12284. },
  12285. pixelBoxStyles: function() {
  12286. computeStyleTests();
  12287. return pixelBoxStylesVal;
  12288. },
  12289. pixelPosition: function() {
  12290. computeStyleTests();
  12291. return pixelPositionVal;
  12292. },
  12293. reliableMarginLeft: function() {
  12294. computeStyleTests();
  12295. return reliableMarginLeftVal;
  12296. },
  12297. scrollboxSize: function() {
  12298. computeStyleTests();
  12299. return scrollboxSizeVal;
  12300. }
  12301. } );
  12302. } )();
  12303. function curCSS( elem, name, computed ) {
  12304. var width, minWidth, maxWidth, ret,
  12305. // Support: Firefox 51+
  12306. // Retrieving style before computed somehow
  12307. // fixes an issue with getting wrong values
  12308. // on detached elements
  12309. style = elem.style;
  12310. computed = computed || getStyles( elem );
  12311. // getPropertyValue is needed for:
  12312. // .css('filter') (IE 9 only, #12537)
  12313. // .css('--customProperty) (#3144)
  12314. if ( computed ) {
  12315. ret = computed.getPropertyValue( name ) || computed[ name ];
  12316. if ( ret === "" && !isAttached( elem ) ) {
  12317. ret = jQuery.style( elem, name );
  12318. }
  12319. // A tribute to the "awesome hack by Dean Edwards"
  12320. // Android Browser returns percentage for some values,
  12321. // but width seems to be reliably pixels.
  12322. // This is against the CSSOM draft spec:
  12323. // https://drafts.csswg.org/cssom/#resolved-values
  12324. if ( !support.pixelBoxStyles() && rnumnonpx.test( ret ) && rboxStyle.test( name ) ) {
  12325. // Remember the original values
  12326. width = style.width;
  12327. minWidth = style.minWidth;
  12328. maxWidth = style.maxWidth;
  12329. // Put in the new values to get a computed value out
  12330. style.minWidth = style.maxWidth = style.width = ret;
  12331. ret = computed.width;
  12332. // Revert the changed values
  12333. style.width = width;
  12334. style.minWidth = minWidth;
  12335. style.maxWidth = maxWidth;
  12336. }
  12337. }
  12338. return ret !== undefined ?
  12339. // Support: IE <=9 - 11 only
  12340. // IE returns zIndex value as an integer.
  12341. ret + "" :
  12342. ret;
  12343. }
  12344. function addGetHookIf( conditionFn, hookFn ) {
  12345. // Define the hook, we'll check on the first run if it's really needed.
  12346. return {
  12347. get: function() {
  12348. if ( conditionFn() ) {
  12349. // Hook not needed (or it's not possible to use it due
  12350. // to missing dependency), remove it.
  12351. delete this.get;
  12352. return;
  12353. }
  12354. // Hook needed; redefine it so that the support test is not executed again.
  12355. return ( this.get = hookFn ).apply( this, arguments );
  12356. }
  12357. };
  12358. }
  12359. var cssPrefixes = [ "Webkit", "Moz", "ms" ],
  12360. emptyStyle = document.createElement( "div" ).style,
  12361. vendorProps = {};
  12362. // Return a vendor-prefixed property or undefined
  12363. function vendorPropName( name ) {
  12364. // Check for vendor prefixed names
  12365. var capName = name[ 0 ].toUpperCase() + name.slice( 1 ),
  12366. i = cssPrefixes.length;
  12367. while ( i-- ) {
  12368. name = cssPrefixes[ i ] + capName;
  12369. if ( name in emptyStyle ) {
  12370. return name;
  12371. }
  12372. }
  12373. }
  12374. // Return a potentially-mapped jQuery.cssProps or vendor prefixed property
  12375. function finalPropName( name ) {
  12376. var final = jQuery.cssProps[ name ] || vendorProps[ name ];
  12377. if ( final ) {
  12378. return final;
  12379. }
  12380. if ( name in emptyStyle ) {
  12381. return name;
  12382. }
  12383. return vendorProps[ name ] = vendorPropName( name ) || name;
  12384. }
  12385. var
  12386. // Swappable if display is none or starts with table
  12387. // except "table", "table-cell", or "table-caption"
  12388. // See here for display values: https://developer.mozilla.org/en-US/docs/CSS/display
  12389. rdisplayswap = /^(none|table(?!-c[ea]).+)/,
  12390. rcustomProp = /^--/,
  12391. cssShow = { position: "absolute", visibility: "hidden", display: "block" },
  12392. cssNormalTransform = {
  12393. letterSpacing: "0",
  12394. fontWeight: "400"
  12395. };
  12396. function setPositiveNumber( elem, value, subtract ) {
  12397. // Any relative (+/-) values have already been
  12398. // normalized at this point
  12399. var matches = rcssNum.exec( value );
  12400. return matches ?
  12401. // Guard against undefined "subtract", e.g., when used as in cssHooks
  12402. Math.max( 0, matches[ 2 ] - ( subtract || 0 ) ) + ( matches[ 3 ] || "px" ) :
  12403. value;
  12404. }
  12405. function boxModelAdjustment( elem, dimension, box, isBorderBox, styles, computedVal ) {
  12406. var i = dimension === "width" ? 1 : 0,
  12407. extra = 0,
  12408. delta = 0;
  12409. // Adjustment may not be necessary
  12410. if ( box === ( isBorderBox ? "border" : "content" ) ) {
  12411. return 0;
  12412. }
  12413. for ( ; i < 4; i += 2 ) {
  12414. // Both box models exclude margin
  12415. if ( box === "margin" ) {
  12416. delta += jQuery.css( elem, box + cssExpand[ i ], true, styles );
  12417. }
  12418. // If we get here with a content-box, we're seeking "padding" or "border" or "margin"
  12419. if ( !isBorderBox ) {
  12420. // Add padding
  12421. delta += jQuery.css( elem, "padding" + cssExpand[ i ], true, styles );
  12422. // For "border" or "margin", add border
  12423. if ( box !== "padding" ) {
  12424. delta += jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
  12425. // But still keep track of it otherwise
  12426. } else {
  12427. extra += jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
  12428. }
  12429. // If we get here with a border-box (content + padding + border), we're seeking "content" or
  12430. // "padding" or "margin"
  12431. } else {
  12432. // For "content", subtract padding
  12433. if ( box === "content" ) {
  12434. delta -= jQuery.css( elem, "padding" + cssExpand[ i ], true, styles );
  12435. }
  12436. // For "content" or "padding", subtract border
  12437. if ( box !== "margin" ) {
  12438. delta -= jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
  12439. }
  12440. }
  12441. }
  12442. // Account for positive content-box scroll gutter when requested by providing computedVal
  12443. if ( !isBorderBox && computedVal >= 0 ) {
  12444. // offsetWidth/offsetHeight is a rounded sum of content, padding, scroll gutter, and border
  12445. // Assuming integer scroll gutter, subtract the rest and round down
  12446. delta += Math.max( 0, Math.ceil(
  12447. elem[ "offset" + dimension[ 0 ].toUpperCase() + dimension.slice( 1 ) ] -
  12448. computedVal -
  12449. delta -
  12450. extra -
  12451. 0.5
  12452. // If offsetWidth/offsetHeight is unknown, then we can't determine content-box scroll gutter
  12453. // Use an explicit zero to avoid NaN (gh-3964)
  12454. ) ) || 0;
  12455. }
  12456. return delta;
  12457. }
  12458. function getWidthOrHeight( elem, dimension, extra ) {
  12459. // Start with computed style
  12460. var styles = getStyles( elem ),
  12461. // To avoid forcing a reflow, only fetch boxSizing if we need it (gh-4322).
  12462. // Fake content-box until we know it's needed to know the true value.
  12463. boxSizingNeeded = !support.boxSizingReliable() || extra,
  12464. isBorderBox = boxSizingNeeded &&
  12465. jQuery.css( elem, "boxSizing", false, styles ) === "border-box",
  12466. valueIsBorderBox = isBorderBox,
  12467. val = curCSS( elem, dimension, styles ),
  12468. offsetProp = "offset" + dimension[ 0 ].toUpperCase() + dimension.slice( 1 );
  12469. // Support: Firefox <=54
  12470. // Return a confounding non-pixel value or feign ignorance, as appropriate.
  12471. if ( rnumnonpx.test( val ) ) {
  12472. if ( !extra ) {
  12473. return val;
  12474. }
  12475. val = "auto";
  12476. }
  12477. // Fall back to offsetWidth/offsetHeight when value is "auto"
  12478. // This happens for inline elements with no explicit setting (gh-3571)
  12479. // Support: Android <=4.1 - 4.3 only
  12480. // Also use offsetWidth/offsetHeight for misreported inline dimensions (gh-3602)
  12481. // Support: IE 9-11 only
  12482. // Also use offsetWidth/offsetHeight for when box sizing is unreliable
  12483. // We use getClientRects() to check for hidden/disconnected.
  12484. // In those cases, the computed value can be trusted to be border-box
  12485. if ( ( !support.boxSizingReliable() && isBorderBox ||
  12486. val === "auto" ||
  12487. !parseFloat( val ) && jQuery.css( elem, "display", false, styles ) === "inline" ) &&
  12488. elem.getClientRects().length ) {
  12489. isBorderBox = jQuery.css( elem, "boxSizing", false, styles ) === "border-box";
  12490. // Where available, offsetWidth/offsetHeight approximate border box dimensions.
  12491. // Where not available (e.g., SVG), assume unreliable box-sizing and interpret the
  12492. // retrieved value as a content box dimension.
  12493. valueIsBorderBox = offsetProp in elem;
  12494. if ( valueIsBorderBox ) {
  12495. val = elem[ offsetProp ];
  12496. }
  12497. }
  12498. // Normalize "" and auto
  12499. val = parseFloat( val ) || 0;
  12500. // Adjust for the element's box model
  12501. return ( val +
  12502. boxModelAdjustment(
  12503. elem,
  12504. dimension,
  12505. extra || ( isBorderBox ? "border" : "content" ),
  12506. valueIsBorderBox,
  12507. styles,
  12508. // Provide the current computed size to request scroll gutter calculation (gh-3589)
  12509. val
  12510. )
  12511. ) + "px";
  12512. }
  12513. jQuery.extend( {
  12514. // Add in style property hooks for overriding the default
  12515. // behavior of getting and setting a style property
  12516. cssHooks: {
  12517. opacity: {
  12518. get: function( elem, computed ) {
  12519. if ( computed ) {
  12520. // We should always get a number back from opacity
  12521. var ret = curCSS( elem, "opacity" );
  12522. return ret === "" ? "1" : ret;
  12523. }
  12524. }
  12525. }
  12526. },
  12527. // Don't automatically add "px" to these possibly-unitless properties
  12528. cssNumber: {
  12529. "animationIterationCount": true,
  12530. "columnCount": true,
  12531. "fillOpacity": true,
  12532. "flexGrow": true,
  12533. "flexShrink": true,
  12534. "fontWeight": true,
  12535. "gridArea": true,
  12536. "gridColumn": true,
  12537. "gridColumnEnd": true,
  12538. "gridColumnStart": true,
  12539. "gridRow": true,
  12540. "gridRowEnd": true,
  12541. "gridRowStart": true,
  12542. "lineHeight": true,
  12543. "opacity": true,
  12544. "order": true,
  12545. "orphans": true,
  12546. "widows": true,
  12547. "zIndex": true,
  12548. "zoom": true
  12549. },
  12550. // Add in properties whose names you wish to fix before
  12551. // setting or getting the value
  12552. cssProps: {},
  12553. // Get and set the style property on a DOM Node
  12554. style: function( elem, name, value, extra ) {
  12555. // Don't set styles on text and comment nodes
  12556. if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 || !elem.style ) {
  12557. return;
  12558. }
  12559. // Make sure that we're working with the right name
  12560. var ret, type, hooks,
  12561. origName = camelCase( name ),
  12562. isCustomProp = rcustomProp.test( name ),
  12563. style = elem.style;
  12564. // Make sure that we're working with the right name. We don't
  12565. // want to query the value if it is a CSS custom property
  12566. // since they are user-defined.
  12567. if ( !isCustomProp ) {
  12568. name = finalPropName( origName );
  12569. }
  12570. // Gets hook for the prefixed version, then unprefixed version
  12571. hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
  12572. // Check if we're setting a value
  12573. if ( value !== undefined ) {
  12574. type = typeof value;
  12575. // Convert "+=" or "-=" to relative numbers (#7345)
  12576. if ( type === "string" && ( ret = rcssNum.exec( value ) ) && ret[ 1 ] ) {
  12577. value = adjustCSS( elem, name, ret );
  12578. // Fixes bug #9237
  12579. type = "number";
  12580. }
  12581. // Make sure that null and NaN values aren't set (#7116)
  12582. if ( value == null || value !== value ) {
  12583. return;
  12584. }
  12585. // If a number was passed in, add the unit (except for certain CSS properties)
  12586. // The isCustomProp check can be removed in jQuery 4.0 when we only auto-append
  12587. // "px" to a few hardcoded values.
  12588. if ( type === "number" && !isCustomProp ) {
  12589. value += ret && ret[ 3 ] || ( jQuery.cssNumber[ origName ] ? "" : "px" );
  12590. }
  12591. // background-* props affect original clone's values
  12592. if ( !support.clearCloneStyle && value === "" && name.indexOf( "background" ) === 0 ) {
  12593. style[ name ] = "inherit";
  12594. }
  12595. // If a hook was provided, use that value, otherwise just set the specified value
  12596. if ( !hooks || !( "set" in hooks ) ||
  12597. ( value = hooks.set( elem, value, extra ) ) !== undefined ) {
  12598. if ( isCustomProp ) {
  12599. style.setProperty( name, value );
  12600. } else {
  12601. style[ name ] = value;
  12602. }
  12603. }
  12604. } else {
  12605. // If a hook was provided get the non-computed value from there
  12606. if ( hooks && "get" in hooks &&
  12607. ( ret = hooks.get( elem, false, extra ) ) !== undefined ) {
  12608. return ret;
  12609. }
  12610. // Otherwise just get the value from the style object
  12611. return style[ name ];
  12612. }
  12613. },
  12614. css: function( elem, name, extra, styles ) {
  12615. var val, num, hooks,
  12616. origName = camelCase( name ),
  12617. isCustomProp = rcustomProp.test( name );
  12618. // Make sure that we're working with the right name. We don't
  12619. // want to modify the value if it is a CSS custom property
  12620. // since they are user-defined.
  12621. if ( !isCustomProp ) {
  12622. name = finalPropName( origName );
  12623. }
  12624. // Try prefixed name followed by the unprefixed name
  12625. hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
  12626. // If a hook was provided get the computed value from there
  12627. if ( hooks && "get" in hooks ) {
  12628. val = hooks.get( elem, true, extra );
  12629. }
  12630. // Otherwise, if a way to get the computed value exists, use that
  12631. if ( val === undefined ) {
  12632. val = curCSS( elem, name, styles );
  12633. }
  12634. // Convert "normal" to computed value
  12635. if ( val === "normal" && name in cssNormalTransform ) {
  12636. val = cssNormalTransform[ name ];
  12637. }
  12638. // Make numeric if forced or a qualifier was provided and val looks numeric
  12639. if ( extra === "" || extra ) {
  12640. num = parseFloat( val );
  12641. return extra === true || isFinite( num ) ? num || 0 : val;
  12642. }
  12643. return val;
  12644. }
  12645. } );
  12646. jQuery.each( [ "height", "width" ], function( i, dimension ) {
  12647. jQuery.cssHooks[ dimension ] = {
  12648. get: function( elem, computed, extra ) {
  12649. if ( computed ) {
  12650. // Certain elements can have dimension info if we invisibly show them
  12651. // but it must have a current display style that would benefit
  12652. return rdisplayswap.test( jQuery.css( elem, "display" ) ) &&
  12653. // Support: Safari 8+
  12654. // Table columns in Safari have non-zero offsetWidth & zero
  12655. // getBoundingClientRect().width unless display is changed.
  12656. // Support: IE <=11 only
  12657. // Running getBoundingClientRect on a disconnected node
  12658. // in IE throws an error.
  12659. ( !elem.getClientRects().length || !elem.getBoundingClientRect().width ) ?
  12660. swap( elem, cssShow, function() {
  12661. return getWidthOrHeight( elem, dimension, extra );
  12662. } ) :
  12663. getWidthOrHeight( elem, dimension, extra );
  12664. }
  12665. },
  12666. set: function( elem, value, extra ) {
  12667. var matches,
  12668. styles = getStyles( elem ),
  12669. // Only read styles.position if the test has a chance to fail
  12670. // to avoid forcing a reflow.
  12671. scrollboxSizeBuggy = !support.scrollboxSize() &&
  12672. styles.position === "absolute",
  12673. // To avoid forcing a reflow, only fetch boxSizing if we need it (gh-3991)
  12674. boxSizingNeeded = scrollboxSizeBuggy || extra,
  12675. isBorderBox = boxSizingNeeded &&
  12676. jQuery.css( elem, "boxSizing", false, styles ) === "border-box",
  12677. subtract = extra ?
  12678. boxModelAdjustment(
  12679. elem,
  12680. dimension,
  12681. extra,
  12682. isBorderBox,
  12683. styles
  12684. ) :
  12685. 0;
  12686. // Account for unreliable border-box dimensions by comparing offset* to computed and
  12687. // faking a content-box to get border and padding (gh-3699)
  12688. if ( isBorderBox && scrollboxSizeBuggy ) {
  12689. subtract -= Math.ceil(
  12690. elem[ "offset" + dimension[ 0 ].toUpperCase() + dimension.slice( 1 ) ] -
  12691. parseFloat( styles[ dimension ] ) -
  12692. boxModelAdjustment( elem, dimension, "border", false, styles ) -
  12693. 0.5
  12694. );
  12695. }
  12696. // Convert to pixels if value adjustment is needed
  12697. if ( subtract && ( matches = rcssNum.exec( value ) ) &&
  12698. ( matches[ 3 ] || "px" ) !== "px" ) {
  12699. elem.style[ dimension ] = value;
  12700. value = jQuery.css( elem, dimension );
  12701. }
  12702. return setPositiveNumber( elem, value, subtract );
  12703. }
  12704. };
  12705. } );
  12706. jQuery.cssHooks.marginLeft = addGetHookIf( support.reliableMarginLeft,
  12707. function( elem, computed ) {
  12708. if ( computed ) {
  12709. return ( parseFloat( curCSS( elem, "marginLeft" ) ) ||
  12710. elem.getBoundingClientRect().left -
  12711. swap( elem, { marginLeft: 0 }, function() {
  12712. return elem.getBoundingClientRect().left;
  12713. } )
  12714. ) + "px";
  12715. }
  12716. }
  12717. );
  12718. // These hooks are used by animate to expand properties
  12719. jQuery.each( {
  12720. margin: "",
  12721. padding: "",
  12722. border: "Width"
  12723. }, function( prefix, suffix ) {
  12724. jQuery.cssHooks[ prefix + suffix ] = {
  12725. expand: function( value ) {
  12726. var i = 0,
  12727. expanded = {},
  12728. // Assumes a single number if not a string
  12729. parts = typeof value === "string" ? value.split( " " ) : [ value ];
  12730. for ( ; i < 4; i++ ) {
  12731. expanded[ prefix + cssExpand[ i ] + suffix ] =
  12732. parts[ i ] || parts[ i - 2 ] || parts[ 0 ];
  12733. }
  12734. return expanded;
  12735. }
  12736. };
  12737. if ( prefix !== "margin" ) {
  12738. jQuery.cssHooks[ prefix + suffix ].set = setPositiveNumber;
  12739. }
  12740. } );
  12741. jQuery.fn.extend( {
  12742. css: function( name, value ) {
  12743. return access( this, function( elem, name, value ) {
  12744. var styles, len,
  12745. map = {},
  12746. i = 0;
  12747. if ( Array.isArray( name ) ) {
  12748. styles = getStyles( elem );
  12749. len = name.length;
  12750. for ( ; i < len; i++ ) {
  12751. map[ name[ i ] ] = jQuery.css( elem, name[ i ], false, styles );
  12752. }
  12753. return map;
  12754. }
  12755. return value !== undefined ?
  12756. jQuery.style( elem, name, value ) :
  12757. jQuery.css( elem, name );
  12758. }, name, value, arguments.length > 1 );
  12759. }
  12760. } );
  12761. function Tween( elem, options, prop, end, easing ) {
  12762. return new Tween.prototype.init( elem, options, prop, end, easing );
  12763. }
  12764. jQuery.Tween = Tween;
  12765. Tween.prototype = {
  12766. constructor: Tween,
  12767. init: function( elem, options, prop, end, easing, unit ) {
  12768. this.elem = elem;
  12769. this.prop = prop;
  12770. this.easing = easing || jQuery.easing._default;
  12771. this.options = options;
  12772. this.start = this.now = this.cur();
  12773. this.end = end;
  12774. this.unit = unit || ( jQuery.cssNumber[ prop ] ? "" : "px" );
  12775. },
  12776. cur: function() {
  12777. var hooks = Tween.propHooks[ this.prop ];
  12778. return hooks && hooks.get ?
  12779. hooks.get( this ) :
  12780. Tween.propHooks._default.get( this );
  12781. },
  12782. run: function( percent ) {
  12783. var eased,
  12784. hooks = Tween.propHooks[ this.prop ];
  12785. if ( this.options.duration ) {
  12786. this.pos = eased = jQuery.easing[ this.easing ](
  12787. percent, this.options.duration * percent, 0, 1, this.options.duration
  12788. );
  12789. } else {
  12790. this.pos = eased = percent;
  12791. }
  12792. this.now = ( this.end - this.start ) * eased + this.start;
  12793. if ( this.options.step ) {
  12794. this.options.step.call( this.elem, this.now, this );
  12795. }
  12796. if ( hooks && hooks.set ) {
  12797. hooks.set( this );
  12798. } else {
  12799. Tween.propHooks._default.set( this );
  12800. }
  12801. return this;
  12802. }
  12803. };
  12804. Tween.prototype.init.prototype = Tween.prototype;
  12805. Tween.propHooks = {
  12806. _default: {
  12807. get: function( tween ) {
  12808. var result;
  12809. // Use a property on the element directly when it is not a DOM element,
  12810. // or when there is no matching style property that exists.
  12811. if ( tween.elem.nodeType !== 1 ||
  12812. tween.elem[ tween.prop ] != null && tween.elem.style[ tween.prop ] == null ) {
  12813. return tween.elem[ tween.prop ];
  12814. }
  12815. // Passing an empty string as a 3rd parameter to .css will automatically
  12816. // attempt a parseFloat and fallback to a string if the parse fails.
  12817. // Simple values such as "10px" are parsed to Float;
  12818. // complex values such as "rotate(1rad)" are returned as-is.
  12819. result = jQuery.css( tween.elem, tween.prop, "" );
  12820. // Empty strings, null, undefined and "auto" are converted to 0.
  12821. return !result || result === "auto" ? 0 : result;
  12822. },
  12823. set: function( tween ) {
  12824. // Use step hook for back compat.
  12825. // Use cssHook if its there.
  12826. // Use .style if available and use plain properties where available.
  12827. if ( jQuery.fx.step[ tween.prop ] ) {
  12828. jQuery.fx.step[ tween.prop ]( tween );
  12829. } else if ( tween.elem.nodeType === 1 && (
  12830. jQuery.cssHooks[ tween.prop ] ||
  12831. tween.elem.style[ finalPropName( tween.prop ) ] != null ) ) {
  12832. jQuery.style( tween.elem, tween.prop, tween.now + tween.unit );
  12833. } else {
  12834. tween.elem[ tween.prop ] = tween.now;
  12835. }
  12836. }
  12837. }
  12838. };
  12839. // Support: IE <=9 only
  12840. // Panic based approach to setting things on disconnected nodes
  12841. Tween.propHooks.scrollTop = Tween.propHooks.scrollLeft = {
  12842. set: function( tween ) {
  12843. if ( tween.elem.nodeType && tween.elem.parentNode ) {
  12844. tween.elem[ tween.prop ] = tween.now;
  12845. }
  12846. }
  12847. };
  12848. jQuery.easing = {
  12849. linear: function( p ) {
  12850. return p;
  12851. },
  12852. swing: function( p ) {
  12853. return 0.5 - Math.cos( p * Math.PI ) / 2;
  12854. },
  12855. _default: "swing"
  12856. };
  12857. jQuery.fx = Tween.prototype.init;
  12858. // Back compat <1.8 extension point
  12859. jQuery.fx.step = {};
  12860. var
  12861. fxNow, inProgress,
  12862. rfxtypes = /^(?:toggle|show|hide)$/,
  12863. rrun = /queueHooks$/;
  12864. function schedule() {
  12865. if ( inProgress ) {
  12866. if ( document.hidden === false && window.requestAnimationFrame ) {
  12867. window.requestAnimationFrame( schedule );
  12868. } else {
  12869. window.setTimeout( schedule, jQuery.fx.interval );
  12870. }
  12871. jQuery.fx.tick();
  12872. }
  12873. }
  12874. // Animations created synchronously will run synchronously
  12875. function createFxNow() {
  12876. window.setTimeout( function() {
  12877. fxNow = undefined;
  12878. } );
  12879. return ( fxNow = Date.now() );
  12880. }
  12881. // Generate parameters to create a standard animation
  12882. function genFx( type, includeWidth ) {
  12883. var which,
  12884. i = 0,
  12885. attrs = { height: type };
  12886. // If we include width, step value is 1 to do all cssExpand values,
  12887. // otherwise step value is 2 to skip over Left and Right
  12888. includeWidth = includeWidth ? 1 : 0;
  12889. for ( ; i < 4; i += 2 - includeWidth ) {
  12890. which = cssExpand[ i ];
  12891. attrs[ "margin" + which ] = attrs[ "padding" + which ] = type;
  12892. }
  12893. if ( includeWidth ) {
  12894. attrs.opacity = attrs.width = type;
  12895. }
  12896. return attrs;
  12897. }
  12898. function createTween( value, prop, animation ) {
  12899. var tween,
  12900. collection = ( Animation.tweeners[ prop ] || [] ).concat( Animation.tweeners[ "*" ] ),
  12901. index = 0,
  12902. length = collection.length;
  12903. for ( ; index < length; index++ ) {
  12904. if ( ( tween = collection[ index ].call( animation, prop, value ) ) ) {
  12905. // We're done with this property
  12906. return tween;
  12907. }
  12908. }
  12909. }
  12910. function defaultPrefilter( elem, props, opts ) {
  12911. var prop, value, toggle, hooks, oldfire, propTween, restoreDisplay, display,
  12912. isBox = "width" in props || "height" in props,
  12913. anim = this,
  12914. orig = {},
  12915. style = elem.style,
  12916. hidden = elem.nodeType && isHiddenWithinTree( elem ),
  12917. dataShow = dataPriv.get( elem, "fxshow" );
  12918. // Queue-skipping animations hijack the fx hooks
  12919. if ( !opts.queue ) {
  12920. hooks = jQuery._queueHooks( elem, "fx" );
  12921. if ( hooks.unqueued == null ) {
  12922. hooks.unqueued = 0;
  12923. oldfire = hooks.empty.fire;
  12924. hooks.empty.fire = function() {
  12925. if ( !hooks.unqueued ) {
  12926. oldfire();
  12927. }
  12928. };
  12929. }
  12930. hooks.unqueued++;
  12931. anim.always( function() {
  12932. // Ensure the complete handler is called before this completes
  12933. anim.always( function() {
  12934. hooks.unqueued--;
  12935. if ( !jQuery.queue( elem, "fx" ).length ) {
  12936. hooks.empty.fire();
  12937. }
  12938. } );
  12939. } );
  12940. }
  12941. // Detect show/hide animations
  12942. for ( prop in props ) {
  12943. value = props[ prop ];
  12944. if ( rfxtypes.test( value ) ) {
  12945. delete props[ prop ];
  12946. toggle = toggle || value === "toggle";
  12947. if ( value === ( hidden ? "hide" : "show" ) ) {
  12948. // Pretend to be hidden if this is a "show" and
  12949. // there is still data from a stopped show/hide
  12950. if ( value === "show" && dataShow && dataShow[ prop ] !== undefined ) {
  12951. hidden = true;
  12952. // Ignore all other no-op show/hide data
  12953. } else {
  12954. continue;
  12955. }
  12956. }
  12957. orig[ prop ] = dataShow && dataShow[ prop ] || jQuery.style( elem, prop );
  12958. }
  12959. }
  12960. // Bail out if this is a no-op like .hide().hide()
  12961. propTween = !jQuery.isEmptyObject( props );
  12962. if ( !propTween && jQuery.isEmptyObject( orig ) ) {
  12963. return;
  12964. }
  12965. // Restrict "overflow" and "display" styles during box animations
  12966. if ( isBox && elem.nodeType === 1 ) {
  12967. // Support: IE <=9 - 11, Edge 12 - 15
  12968. // Record all 3 overflow attributes because IE does not infer the shorthand
  12969. // from identically-valued overflowX and overflowY and Edge just mirrors
  12970. // the overflowX value there.
  12971. opts.overflow = [ style.overflow, style.overflowX, style.overflowY ];
  12972. // Identify a display type, preferring old show/hide data over the CSS cascade
  12973. restoreDisplay = dataShow && dataShow.display;
  12974. if ( restoreDisplay == null ) {
  12975. restoreDisplay = dataPriv.get( elem, "display" );
  12976. }
  12977. display = jQuery.css( elem, "display" );
  12978. if ( display === "none" ) {
  12979. if ( restoreDisplay ) {
  12980. display = restoreDisplay;
  12981. } else {
  12982. // Get nonempty value(s) by temporarily forcing visibility
  12983. showHide( [ elem ], true );
  12984. restoreDisplay = elem.style.display || restoreDisplay;
  12985. display = jQuery.css( elem, "display" );
  12986. showHide( [ elem ] );
  12987. }
  12988. }
  12989. // Animate inline elements as inline-block
  12990. if ( display === "inline" || display === "inline-block" && restoreDisplay != null ) {
  12991. if ( jQuery.css( elem, "float" ) === "none" ) {
  12992. // Restore the original display value at the end of pure show/hide animations
  12993. if ( !propTween ) {
  12994. anim.done( function() {
  12995. style.display = restoreDisplay;
  12996. } );
  12997. if ( restoreDisplay == null ) {
  12998. display = style.display;
  12999. restoreDisplay = display === "none" ? "" : display;
  13000. }
  13001. }
  13002. style.display = "inline-block";
  13003. }
  13004. }
  13005. }
  13006. if ( opts.overflow ) {
  13007. style.overflow = "hidden";
  13008. anim.always( function() {
  13009. style.overflow = opts.overflow[ 0 ];
  13010. style.overflowX = opts.overflow[ 1 ];
  13011. style.overflowY = opts.overflow[ 2 ];
  13012. } );
  13013. }
  13014. // Implement show/hide animations
  13015. propTween = false;
  13016. for ( prop in orig ) {
  13017. // General show/hide setup for this element animation
  13018. if ( !propTween ) {
  13019. if ( dataShow ) {
  13020. if ( "hidden" in dataShow ) {
  13021. hidden = dataShow.hidden;
  13022. }
  13023. } else {
  13024. dataShow = dataPriv.access( elem, "fxshow", { display: restoreDisplay } );
  13025. }
  13026. // Store hidden/visible for toggle so `.stop().toggle()` "reverses"
  13027. if ( toggle ) {
  13028. dataShow.hidden = !hidden;
  13029. }
  13030. // Show elements before animating them
  13031. if ( hidden ) {
  13032. showHide( [ elem ], true );
  13033. }
  13034. /* eslint-disable no-loop-func */
  13035. anim.done( function() {
  13036. /* eslint-enable no-loop-func */
  13037. // The final step of a "hide" animation is actually hiding the element
  13038. if ( !hidden ) {
  13039. showHide( [ elem ] );
  13040. }
  13041. dataPriv.remove( elem, "fxshow" );
  13042. for ( prop in orig ) {
  13043. jQuery.style( elem, prop, orig[ prop ] );
  13044. }
  13045. } );
  13046. }
  13047. // Per-property setup
  13048. propTween = createTween( hidden ? dataShow[ prop ] : 0, prop, anim );
  13049. if ( !( prop in dataShow ) ) {
  13050. dataShow[ prop ] = propTween.start;
  13051. if ( hidden ) {
  13052. propTween.end = propTween.start;
  13053. propTween.start = 0;
  13054. }
  13055. }
  13056. }
  13057. }
  13058. function propFilter( props, specialEasing ) {
  13059. var index, name, easing, value, hooks;
  13060. // camelCase, specialEasing and expand cssHook pass
  13061. for ( index in props ) {
  13062. name = camelCase( index );
  13063. easing = specialEasing[ name ];
  13064. value = props[ index ];
  13065. if ( Array.isArray( value ) ) {
  13066. easing = value[ 1 ];
  13067. value = props[ index ] = value[ 0 ];
  13068. }
  13069. if ( index !== name ) {
  13070. props[ name ] = value;
  13071. delete props[ index ];
  13072. }
  13073. hooks = jQuery.cssHooks[ name ];
  13074. if ( hooks && "expand" in hooks ) {
  13075. value = hooks.expand( value );
  13076. delete props[ name ];
  13077. // Not quite $.extend, this won't overwrite existing keys.
  13078. // Reusing 'index' because we have the correct "name"
  13079. for ( index in value ) {
  13080. if ( !( index in props ) ) {
  13081. props[ index ] = value[ index ];
  13082. specialEasing[ index ] = easing;
  13083. }
  13084. }
  13085. } else {
  13086. specialEasing[ name ] = easing;
  13087. }
  13088. }
  13089. }
  13090. function Animation( elem, properties, options ) {
  13091. var result,
  13092. stopped,
  13093. index = 0,
  13094. length = Animation.prefilters.length,
  13095. deferred = jQuery.Deferred().always( function() {
  13096. // Don't match elem in the :animated selector
  13097. delete tick.elem;
  13098. } ),
  13099. tick = function() {
  13100. if ( stopped ) {
  13101. return false;
  13102. }
  13103. var currentTime = fxNow || createFxNow(),
  13104. remaining = Math.max( 0, animation.startTime + animation.duration - currentTime ),
  13105. // Support: Android 2.3 only
  13106. // Archaic crash bug won't allow us to use `1 - ( 0.5 || 0 )` (#12497)
  13107. temp = remaining / animation.duration || 0,
  13108. percent = 1 - temp,
  13109. index = 0,
  13110. length = animation.tweens.length;
  13111. for ( ; index < length; index++ ) {
  13112. animation.tweens[ index ].run( percent );
  13113. }
  13114. deferred.notifyWith( elem, [ animation, percent, remaining ] );
  13115. // If there's more to do, yield
  13116. if ( percent < 1 && length ) {
  13117. return remaining;
  13118. }
  13119. // If this was an empty animation, synthesize a final progress notification
  13120. if ( !length ) {
  13121. deferred.notifyWith( elem, [ animation, 1, 0 ] );
  13122. }
  13123. // Resolve the animation and report its conclusion
  13124. deferred.resolveWith( elem, [ animation ] );
  13125. return false;
  13126. },
  13127. animation = deferred.promise( {
  13128. elem: elem,
  13129. props: jQuery.extend( {}, properties ),
  13130. opts: jQuery.extend( true, {
  13131. specialEasing: {},
  13132. easing: jQuery.easing._default
  13133. }, options ),
  13134. originalProperties: properties,
  13135. originalOptions: options,
  13136. startTime: fxNow || createFxNow(),
  13137. duration: options.duration,
  13138. tweens: [],
  13139. createTween: function( prop, end ) {
  13140. var tween = jQuery.Tween( elem, animation.opts, prop, end,
  13141. animation.opts.specialEasing[ prop ] || animation.opts.easing );
  13142. animation.tweens.push( tween );
  13143. return tween;
  13144. },
  13145. stop: function( gotoEnd ) {
  13146. var index = 0,
  13147. // If we are going to the end, we want to run all the tweens
  13148. // otherwise we skip this part
  13149. length = gotoEnd ? animation.tweens.length : 0;
  13150. if ( stopped ) {
  13151. return this;
  13152. }
  13153. stopped = true;
  13154. for ( ; index < length; index++ ) {
  13155. animation.tweens[ index ].run( 1 );
  13156. }
  13157. // Resolve when we played the last frame; otherwise, reject
  13158. if ( gotoEnd ) {
  13159. deferred.notifyWith( elem, [ animation, 1, 0 ] );
  13160. deferred.resolveWith( elem, [ animation, gotoEnd ] );
  13161. } else {
  13162. deferred.rejectWith( elem, [ animation, gotoEnd ] );
  13163. }
  13164. return this;
  13165. }
  13166. } ),
  13167. props = animation.props;
  13168. propFilter( props, animation.opts.specialEasing );
  13169. for ( ; index < length; index++ ) {
  13170. result = Animation.prefilters[ index ].call( animation, elem, props, animation.opts );
  13171. if ( result ) {
  13172. if ( isFunction( result.stop ) ) {
  13173. jQuery._queueHooks( animation.elem, animation.opts.queue ).stop =
  13174. result.stop.bind( result );
  13175. }
  13176. return result;
  13177. }
  13178. }
  13179. jQuery.map( props, createTween, animation );
  13180. if ( isFunction( animation.opts.start ) ) {
  13181. animation.opts.start.call( elem, animation );
  13182. }
  13183. // Attach callbacks from options
  13184. animation
  13185. .progress( animation.opts.progress )
  13186. .done( animation.opts.done, animation.opts.complete )
  13187. .fail( animation.opts.fail )
  13188. .always( animation.opts.always );
  13189. jQuery.fx.timer(
  13190. jQuery.extend( tick, {
  13191. elem: elem,
  13192. anim: animation,
  13193. queue: animation.opts.queue
  13194. } )
  13195. );
  13196. return animation;
  13197. }
  13198. jQuery.Animation = jQuery.extend( Animation, {
  13199. tweeners: {
  13200. "*": [ function( prop, value ) {
  13201. var tween = this.createTween( prop, value );
  13202. adjustCSS( tween.elem, prop, rcssNum.exec( value ), tween );
  13203. return tween;
  13204. } ]
  13205. },
  13206. tweener: function( props, callback ) {
  13207. if ( isFunction( props ) ) {
  13208. callback = props;
  13209. props = [ "*" ];
  13210. } else {
  13211. props = props.match( rnothtmlwhite );
  13212. }
  13213. var prop,
  13214. index = 0,
  13215. length = props.length;
  13216. for ( ; index < length; index++ ) {
  13217. prop = props[ index ];
  13218. Animation.tweeners[ prop ] = Animation.tweeners[ prop ] || [];
  13219. Animation.tweeners[ prop ].unshift( callback );
  13220. }
  13221. },
  13222. prefilters: [ defaultPrefilter ],
  13223. prefilter: function( callback, prepend ) {
  13224. if ( prepend ) {
  13225. Animation.prefilters.unshift( callback );
  13226. } else {
  13227. Animation.prefilters.push( callback );
  13228. }
  13229. }
  13230. } );
  13231. jQuery.speed = function( speed, easing, fn ) {
  13232. var opt = speed && typeof speed === "object" ? jQuery.extend( {}, speed ) : {
  13233. complete: fn || !fn && easing ||
  13234. isFunction( speed ) && speed,
  13235. duration: speed,
  13236. easing: fn && easing || easing && !isFunction( easing ) && easing
  13237. };
  13238. // Go to the end state if fx are off
  13239. if ( jQuery.fx.off ) {
  13240. opt.duration = 0;
  13241. } else {
  13242. if ( typeof opt.duration !== "number" ) {
  13243. if ( opt.duration in jQuery.fx.speeds ) {
  13244. opt.duration = jQuery.fx.speeds[ opt.duration ];
  13245. } else {
  13246. opt.duration = jQuery.fx.speeds._default;
  13247. }
  13248. }
  13249. }
  13250. // Normalize opt.queue - true/undefined/null -> "fx"
  13251. if ( opt.queue == null || opt.queue === true ) {
  13252. opt.queue = "fx";
  13253. }
  13254. // Queueing
  13255. opt.old = opt.complete;
  13256. opt.complete = function() {
  13257. if ( isFunction( opt.old ) ) {
  13258. opt.old.call( this );
  13259. }
  13260. if ( opt.queue ) {
  13261. jQuery.dequeue( this, opt.queue );
  13262. }
  13263. };
  13264. return opt;
  13265. };
  13266. jQuery.fn.extend( {
  13267. fadeTo: function( speed, to, easing, callback ) {
  13268. // Show any hidden elements after setting opacity to 0
  13269. return this.filter( isHiddenWithinTree ).css( "opacity", 0 ).show()
  13270. // Animate to the value specified
  13271. .end().animate( { opacity: to }, speed, easing, callback );
  13272. },
  13273. animate: function( prop, speed, easing, callback ) {
  13274. var empty = jQuery.isEmptyObject( prop ),
  13275. optall = jQuery.speed( speed, easing, callback ),
  13276. doAnimation = function() {
  13277. // Operate on a copy of prop so per-property easing won't be lost
  13278. var anim = Animation( this, jQuery.extend( {}, prop ), optall );
  13279. // Empty animations, or finishing resolves immediately
  13280. if ( empty || dataPriv.get( this, "finish" ) ) {
  13281. anim.stop( true );
  13282. }
  13283. };
  13284. doAnimation.finish = doAnimation;
  13285. return empty || optall.queue === false ?
  13286. this.each( doAnimation ) :
  13287. this.queue( optall.queue, doAnimation );
  13288. },
  13289. stop: function( type, clearQueue, gotoEnd ) {
  13290. var stopQueue = function( hooks ) {
  13291. var stop = hooks.stop;
  13292. delete hooks.stop;
  13293. stop( gotoEnd );
  13294. };
  13295. if ( typeof type !== "string" ) {
  13296. gotoEnd = clearQueue;
  13297. clearQueue = type;
  13298. type = undefined;
  13299. }
  13300. if ( clearQueue && type !== false ) {
  13301. this.queue( type || "fx", [] );
  13302. }
  13303. return this.each( function() {
  13304. var dequeue = true,
  13305. index = type != null && type + "queueHooks",
  13306. timers = jQuery.timers,
  13307. data = dataPriv.get( this );
  13308. if ( index ) {
  13309. if ( data[ index ] && data[ index ].stop ) {
  13310. stopQueue( data[ index ] );
  13311. }
  13312. } else {
  13313. for ( index in data ) {
  13314. if ( data[ index ] && data[ index ].stop && rrun.test( index ) ) {
  13315. stopQueue( data[ index ] );
  13316. }
  13317. }
  13318. }
  13319. for ( index = timers.length; index--; ) {
  13320. if ( timers[ index ].elem === this &&
  13321. ( type == null || timers[ index ].queue === type ) ) {
  13322. timers[ index ].anim.stop( gotoEnd );
  13323. dequeue = false;
  13324. timers.splice( index, 1 );
  13325. }
  13326. }
  13327. // Start the next in the queue if the last step wasn't forced.
  13328. // Timers currently will call their complete callbacks, which
  13329. // will dequeue but only if they were gotoEnd.
  13330. if ( dequeue || !gotoEnd ) {
  13331. jQuery.dequeue( this, type );
  13332. }
  13333. } );
  13334. },
  13335. finish: function( type ) {
  13336. if ( type !== false ) {
  13337. type = type || "fx";
  13338. }
  13339. return this.each( function() {
  13340. var index,
  13341. data = dataPriv.get( this ),
  13342. queue = data[ type + "queue" ],
  13343. hooks = data[ type + "queueHooks" ],
  13344. timers = jQuery.timers,
  13345. length = queue ? queue.length : 0;
  13346. // Enable finishing flag on private data
  13347. data.finish = true;
  13348. // Empty the queue first
  13349. jQuery.queue( this, type, [] );
  13350. if ( hooks && hooks.stop ) {
  13351. hooks.stop.call( this, true );
  13352. }
  13353. // Look for any active animations, and finish them
  13354. for ( index = timers.length; index--; ) {
  13355. if ( timers[ index ].elem === this && timers[ index ].queue === type ) {
  13356. timers[ index ].anim.stop( true );
  13357. timers.splice( index, 1 );
  13358. }
  13359. }
  13360. // Look for any animations in the old queue and finish them
  13361. for ( index = 0; index < length; index++ ) {
  13362. if ( queue[ index ] && queue[ index ].finish ) {
  13363. queue[ index ].finish.call( this );
  13364. }
  13365. }
  13366. // Turn off finishing flag
  13367. delete data.finish;
  13368. } );
  13369. }
  13370. } );
  13371. jQuery.each( [ "toggle", "show", "hide" ], function( i, name ) {
  13372. var cssFn = jQuery.fn[ name ];
  13373. jQuery.fn[ name ] = function( speed, easing, callback ) {
  13374. return speed == null || typeof speed === "boolean" ?
  13375. cssFn.apply( this, arguments ) :
  13376. this.animate( genFx( name, true ), speed, easing, callback );
  13377. };
  13378. } );
  13379. // Generate shortcuts for custom animations
  13380. jQuery.each( {
  13381. slideDown: genFx( "show" ),
  13382. slideUp: genFx( "hide" ),
  13383. slideToggle: genFx( "toggle" ),
  13384. fadeIn: { opacity: "show" },
  13385. fadeOut: { opacity: "hide" },
  13386. fadeToggle: { opacity: "toggle" }
  13387. }, function( name, props ) {
  13388. jQuery.fn[ name ] = function( speed, easing, callback ) {
  13389. return this.animate( props, speed, easing, callback );
  13390. };
  13391. } );
  13392. jQuery.timers = [];
  13393. jQuery.fx.tick = function() {
  13394. var timer,
  13395. i = 0,
  13396. timers = jQuery.timers;
  13397. fxNow = Date.now();
  13398. for ( ; i < timers.length; i++ ) {
  13399. timer = timers[ i ];
  13400. // Run the timer and safely remove it when done (allowing for external removal)
  13401. if ( !timer() && timers[ i ] === timer ) {
  13402. timers.splice( i--, 1 );
  13403. }
  13404. }
  13405. if ( !timers.length ) {
  13406. jQuery.fx.stop();
  13407. }
  13408. fxNow = undefined;
  13409. };
  13410. jQuery.fx.timer = function( timer ) {
  13411. jQuery.timers.push( timer );
  13412. jQuery.fx.start();
  13413. };
  13414. jQuery.fx.interval = 13;
  13415. jQuery.fx.start = function() {
  13416. if ( inProgress ) {
  13417. return;
  13418. }
  13419. inProgress = true;
  13420. schedule();
  13421. };
  13422. jQuery.fx.stop = function() {
  13423. inProgress = null;
  13424. };
  13425. jQuery.fx.speeds = {
  13426. slow: 600,
  13427. fast: 200,
  13428. // Default speed
  13429. _default: 400
  13430. };
  13431. // Based off of the plugin by Clint Helfers, with permission.
  13432. // https://web.archive.org/web/20100324014747/http://blindsignals.com/index.php/2009/07/jquery-delay/
  13433. jQuery.fn.delay = function( time, type ) {
  13434. time = jQuery.fx ? jQuery.fx.speeds[ time ] || time : time;
  13435. type = type || "fx";
  13436. return this.queue( type, function( next, hooks ) {
  13437. var timeout = window.setTimeout( next, time );
  13438. hooks.stop = function() {
  13439. window.clearTimeout( timeout );
  13440. };
  13441. } );
  13442. };
  13443. ( function() {
  13444. var input = document.createElement( "input" ),
  13445. select = document.createElement( "select" ),
  13446. opt = select.appendChild( document.createElement( "option" ) );
  13447. input.type = "checkbox";
  13448. // Support: Android <=4.3 only
  13449. // Default value for a checkbox should be "on"
  13450. support.checkOn = input.value !== "";
  13451. // Support: IE <=11 only
  13452. // Must access selectedIndex to make default options select
  13453. support.optSelected = opt.selected;
  13454. // Support: IE <=11 only
  13455. // An input loses its value after becoming a radio
  13456. input = document.createElement( "input" );
  13457. input.value = "t";
  13458. input.type = "radio";
  13459. support.radioValue = input.value === "t";
  13460. } )();
  13461. var boolHook,
  13462. attrHandle = jQuery.expr.attrHandle;
  13463. jQuery.fn.extend( {
  13464. attr: function( name, value ) {
  13465. return access( this, jQuery.attr, name, value, arguments.length > 1 );
  13466. },
  13467. removeAttr: function( name ) {
  13468. return this.each( function() {
  13469. jQuery.removeAttr( this, name );
  13470. } );
  13471. }
  13472. } );
  13473. jQuery.extend( {
  13474. attr: function( elem, name, value ) {
  13475. var ret, hooks,
  13476. nType = elem.nodeType;
  13477. // Don't get/set attributes on text, comment and attribute nodes
  13478. if ( nType === 3 || nType === 8 || nType === 2 ) {
  13479. return;
  13480. }
  13481. // Fallback to prop when attributes are not supported
  13482. if ( typeof elem.getAttribute === "undefined" ) {
  13483. return jQuery.prop( elem, name, value );
  13484. }
  13485. // Attribute hooks are determined by the lowercase version
  13486. // Grab necessary hook if one is defined
  13487. if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) {
  13488. hooks = jQuery.attrHooks[ name.toLowerCase() ] ||
  13489. ( jQuery.expr.match.bool.test( name ) ? boolHook : undefined );
  13490. }
  13491. if ( value !== undefined ) {
  13492. if ( value === null ) {
  13493. jQuery.removeAttr( elem, name );
  13494. return;
  13495. }
  13496. if ( hooks && "set" in hooks &&
  13497. ( ret = hooks.set( elem, value, name ) ) !== undefined ) {
  13498. return ret;
  13499. }
  13500. elem.setAttribute( name, value + "" );
  13501. return value;
  13502. }
  13503. if ( hooks && "get" in hooks && ( ret = hooks.get( elem, name ) ) !== null ) {
  13504. return ret;
  13505. }
  13506. ret = jQuery.find.attr( elem, name );
  13507. // Non-existent attributes return null, we normalize to undefined
  13508. return ret == null ? undefined : ret;
  13509. },
  13510. attrHooks: {
  13511. type: {
  13512. set: function( elem, value ) {
  13513. if ( !support.radioValue && value === "radio" &&
  13514. nodeName( elem, "input" ) ) {
  13515. var val = elem.value;
  13516. elem.setAttribute( "type", value );
  13517. if ( val ) {
  13518. elem.value = val;
  13519. }
  13520. return value;
  13521. }
  13522. }
  13523. }
  13524. },
  13525. removeAttr: function( elem, value ) {
  13526. var name,
  13527. i = 0,
  13528. // Attribute names can contain non-HTML whitespace characters
  13529. // https://html.spec.whatwg.org/multipage/syntax.html#attributes-2
  13530. attrNames = value && value.match( rnothtmlwhite );
  13531. if ( attrNames && elem.nodeType === 1 ) {
  13532. while ( ( name = attrNames[ i++ ] ) ) {
  13533. elem.removeAttribute( name );
  13534. }
  13535. }
  13536. }
  13537. } );
  13538. // Hooks for boolean attributes
  13539. boolHook = {
  13540. set: function( elem, value, name ) {
  13541. if ( value === false ) {
  13542. // Remove boolean attributes when set to false
  13543. jQuery.removeAttr( elem, name );
  13544. } else {
  13545. elem.setAttribute( name, name );
  13546. }
  13547. return name;
  13548. }
  13549. };
  13550. jQuery.each( jQuery.expr.match.bool.source.match( /\w+/g ), function( i, name ) {
  13551. var getter = attrHandle[ name ] || jQuery.find.attr;
  13552. attrHandle[ name ] = function( elem, name, isXML ) {
  13553. var ret, handle,
  13554. lowercaseName = name.toLowerCase();
  13555. if ( !isXML ) {
  13556. // Avoid an infinite loop by temporarily removing this function from the getter
  13557. handle = attrHandle[ lowercaseName ];
  13558. attrHandle[ lowercaseName ] = ret;
  13559. ret = getter( elem, name, isXML ) != null ?
  13560. lowercaseName :
  13561. null;
  13562. attrHandle[ lowercaseName ] = handle;
  13563. }
  13564. return ret;
  13565. };
  13566. } );
  13567. var rfocusable = /^(?:input|select|textarea|button)$/i,
  13568. rclickable = /^(?:a|area)$/i;
  13569. jQuery.fn.extend( {
  13570. prop: function( name, value ) {
  13571. return access( this, jQuery.prop, name, value, arguments.length > 1 );
  13572. },
  13573. removeProp: function( name ) {
  13574. return this.each( function() {
  13575. delete this[ jQuery.propFix[ name ] || name ];
  13576. } );
  13577. }
  13578. } );
  13579. jQuery.extend( {
  13580. prop: function( elem, name, value ) {
  13581. var ret, hooks,
  13582. nType = elem.nodeType;
  13583. // Don't get/set properties on text, comment and attribute nodes
  13584. if ( nType === 3 || nType === 8 || nType === 2 ) {
  13585. return;
  13586. }
  13587. if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) {
  13588. // Fix name and attach hooks
  13589. name = jQuery.propFix[ name ] || name;
  13590. hooks = jQuery.propHooks[ name ];
  13591. }
  13592. if ( value !== undefined ) {
  13593. if ( hooks && "set" in hooks &&
  13594. ( ret = hooks.set( elem, value, name ) ) !== undefined ) {
  13595. return ret;
  13596. }
  13597. return ( elem[ name ] = value );
  13598. }
  13599. if ( hooks && "get" in hooks && ( ret = hooks.get( elem, name ) ) !== null ) {
  13600. return ret;
  13601. }
  13602. return elem[ name ];
  13603. },
  13604. propHooks: {
  13605. tabIndex: {
  13606. get: function( elem ) {
  13607. // Support: IE <=9 - 11 only
  13608. // elem.tabIndex doesn't always return the
  13609. // correct value when it hasn't been explicitly set
  13610. // https://web.archive.org/web/20141116233347/http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/
  13611. // Use proper attribute retrieval(#12072)
  13612. var tabindex = jQuery.find.attr( elem, "tabindex" );
  13613. if ( tabindex ) {
  13614. return parseInt( tabindex, 10 );
  13615. }
  13616. if (
  13617. rfocusable.test( elem.nodeName ) ||
  13618. rclickable.test( elem.nodeName ) &&
  13619. elem.href
  13620. ) {
  13621. return 0;
  13622. }
  13623. return -1;
  13624. }
  13625. }
  13626. },
  13627. propFix: {
  13628. "for": "htmlFor",
  13629. "class": "className"
  13630. }
  13631. } );
  13632. // Support: IE <=11 only
  13633. // Accessing the selectedIndex property
  13634. // forces the browser to respect setting selected
  13635. // on the option
  13636. // The getter ensures a default option is selected
  13637. // when in an optgroup
  13638. // eslint rule "no-unused-expressions" is disabled for this code
  13639. // since it considers such accessions noop
  13640. if ( !support.optSelected ) {
  13641. jQuery.propHooks.selected = {
  13642. get: function( elem ) {
  13643. /* eslint no-unused-expressions: "off" */
  13644. var parent = elem.parentNode;
  13645. if ( parent && parent.parentNode ) {
  13646. parent.parentNode.selectedIndex;
  13647. }
  13648. return null;
  13649. },
  13650. set: function( elem ) {
  13651. /* eslint no-unused-expressions: "off" */
  13652. var parent = elem.parentNode;
  13653. if ( parent ) {
  13654. parent.selectedIndex;
  13655. if ( parent.parentNode ) {
  13656. parent.parentNode.selectedIndex;
  13657. }
  13658. }
  13659. }
  13660. };
  13661. }
  13662. jQuery.each( [
  13663. "tabIndex",
  13664. "readOnly",
  13665. "maxLength",
  13666. "cellSpacing",
  13667. "cellPadding",
  13668. "rowSpan",
  13669. "colSpan",
  13670. "useMap",
  13671. "frameBorder",
  13672. "contentEditable"
  13673. ], function() {
  13674. jQuery.propFix[ this.toLowerCase() ] = this;
  13675. } );
  13676. // Strip and collapse whitespace according to HTML spec
  13677. // https://infra.spec.whatwg.org/#strip-and-collapse-ascii-whitespace
  13678. function stripAndCollapse( value ) {
  13679. var tokens = value.match( rnothtmlwhite ) || [];
  13680. return tokens.join( " " );
  13681. }
  13682. function getClass( elem ) {
  13683. return elem.getAttribute && elem.getAttribute( "class" ) || "";
  13684. }
  13685. function classesToArray( value ) {
  13686. if ( Array.isArray( value ) ) {
  13687. return value;
  13688. }
  13689. if ( typeof value === "string" ) {
  13690. return value.match( rnothtmlwhite ) || [];
  13691. }
  13692. return [];
  13693. }
  13694. jQuery.fn.extend( {
  13695. addClass: function( value ) {
  13696. var classes, elem, cur, curValue, clazz, j, finalValue,
  13697. i = 0;
  13698. if ( isFunction( value ) ) {
  13699. return this.each( function( j ) {
  13700. jQuery( this ).addClass( value.call( this, j, getClass( this ) ) );
  13701. } );
  13702. }
  13703. classes = classesToArray( value );
  13704. if ( classes.length ) {
  13705. while ( ( elem = this[ i++ ] ) ) {
  13706. curValue = getClass( elem );
  13707. cur = elem.nodeType === 1 && ( " " + stripAndCollapse( curValue ) + " " );
  13708. if ( cur ) {
  13709. j = 0;
  13710. while ( ( clazz = classes[ j++ ] ) ) {
  13711. if ( cur.indexOf( " " + clazz + " " ) < 0 ) {
  13712. cur += clazz + " ";
  13713. }
  13714. }
  13715. // Only assign if different to avoid unneeded rendering.
  13716. finalValue = stripAndCollapse( cur );
  13717. if ( curValue !== finalValue ) {
  13718. elem.setAttribute( "class", finalValue );
  13719. }
  13720. }
  13721. }
  13722. }
  13723. return this;
  13724. },
  13725. removeClass: function( value ) {
  13726. var classes, elem, cur, curValue, clazz, j, finalValue,
  13727. i = 0;
  13728. if ( isFunction( value ) ) {
  13729. return this.each( function( j ) {
  13730. jQuery( this ).removeClass( value.call( this, j, getClass( this ) ) );
  13731. } );
  13732. }
  13733. if ( !arguments.length ) {
  13734. return this.attr( "class", "" );
  13735. }
  13736. classes = classesToArray( value );
  13737. if ( classes.length ) {
  13738. while ( ( elem = this[ i++ ] ) ) {
  13739. curValue = getClass( elem );
  13740. // This expression is here for better compressibility (see addClass)
  13741. cur = elem.nodeType === 1 && ( " " + stripAndCollapse( curValue ) + " " );
  13742. if ( cur ) {
  13743. j = 0;
  13744. while ( ( clazz = classes[ j++ ] ) ) {
  13745. // Remove *all* instances
  13746. while ( cur.indexOf( " " + clazz + " " ) > -1 ) {
  13747. cur = cur.replace( " " + clazz + " ", " " );
  13748. }
  13749. }
  13750. // Only assign if different to avoid unneeded rendering.
  13751. finalValue = stripAndCollapse( cur );
  13752. if ( curValue !== finalValue ) {
  13753. elem.setAttribute( "class", finalValue );
  13754. }
  13755. }
  13756. }
  13757. }
  13758. return this;
  13759. },
  13760. toggleClass: function( value, stateVal ) {
  13761. var type = typeof value,
  13762. isValidValue = type === "string" || Array.isArray( value );
  13763. if ( typeof stateVal === "boolean" && isValidValue ) {
  13764. return stateVal ? this.addClass( value ) : this.removeClass( value );
  13765. }
  13766. if ( isFunction( value ) ) {
  13767. return this.each( function( i ) {
  13768. jQuery( this ).toggleClass(
  13769. value.call( this, i, getClass( this ), stateVal ),
  13770. stateVal
  13771. );
  13772. } );
  13773. }
  13774. return this.each( function() {
  13775. var className, i, self, classNames;
  13776. if ( isValidValue ) {
  13777. // Toggle individual class names
  13778. i = 0;
  13779. self = jQuery( this );
  13780. classNames = classesToArray( value );
  13781. while ( ( className = classNames[ i++ ] ) ) {
  13782. // Check each className given, space separated list
  13783. if ( self.hasClass( className ) ) {
  13784. self.removeClass( className );
  13785. } else {
  13786. self.addClass( className );
  13787. }
  13788. }
  13789. // Toggle whole class name
  13790. } else if ( value === undefined || type === "boolean" ) {
  13791. className = getClass( this );
  13792. if ( className ) {
  13793. // Store className if set
  13794. dataPriv.set( this, "__className__", className );
  13795. }
  13796. // If the element has a class name or if we're passed `false`,
  13797. // then remove the whole classname (if there was one, the above saved it).
  13798. // Otherwise bring back whatever was previously saved (if anything),
  13799. // falling back to the empty string if nothing was stored.
  13800. if ( this.setAttribute ) {
  13801. this.setAttribute( "class",
  13802. className || value === false ?
  13803. "" :
  13804. dataPriv.get( this, "__className__" ) || ""
  13805. );
  13806. }
  13807. }
  13808. } );
  13809. },
  13810. hasClass: function( selector ) {
  13811. var className, elem,
  13812. i = 0;
  13813. className = " " + selector + " ";
  13814. while ( ( elem = this[ i++ ] ) ) {
  13815. if ( elem.nodeType === 1 &&
  13816. ( " " + stripAndCollapse( getClass( elem ) ) + " " ).indexOf( className ) > -1 ) {
  13817. return true;
  13818. }
  13819. }
  13820. return false;
  13821. }
  13822. } );
  13823. var rreturn = /\r/g;
  13824. jQuery.fn.extend( {
  13825. val: function( value ) {
  13826. var hooks, ret, valueIsFunction,
  13827. elem = this[ 0 ];
  13828. if ( !arguments.length ) {
  13829. if ( elem ) {
  13830. hooks = jQuery.valHooks[ elem.type ] ||
  13831. jQuery.valHooks[ elem.nodeName.toLowerCase() ];
  13832. if ( hooks &&
  13833. "get" in hooks &&
  13834. ( ret = hooks.get( elem, "value" ) ) !== undefined
  13835. ) {
  13836. return ret;
  13837. }
  13838. ret = elem.value;
  13839. // Handle most common string cases
  13840. if ( typeof ret === "string" ) {
  13841. return ret.replace( rreturn, "" );
  13842. }
  13843. // Handle cases where value is null/undef or number
  13844. return ret == null ? "" : ret;
  13845. }
  13846. return;
  13847. }
  13848. valueIsFunction = isFunction( value );
  13849. return this.each( function( i ) {
  13850. var val;
  13851. if ( this.nodeType !== 1 ) {
  13852. return;
  13853. }
  13854. if ( valueIsFunction ) {
  13855. val = value.call( this, i, jQuery( this ).val() );
  13856. } else {
  13857. val = value;
  13858. }
  13859. // Treat null/undefined as ""; convert numbers to string
  13860. if ( val == null ) {
  13861. val = "";
  13862. } else if ( typeof val === "number" ) {
  13863. val += "";
  13864. } else if ( Array.isArray( val ) ) {
  13865. val = jQuery.map( val, function( value ) {
  13866. return value == null ? "" : value + "";
  13867. } );
  13868. }
  13869. hooks = jQuery.valHooks[ this.type ] || jQuery.valHooks[ this.nodeName.toLowerCase() ];
  13870. // If set returns undefined, fall back to normal setting
  13871. if ( !hooks || !( "set" in hooks ) || hooks.set( this, val, "value" ) === undefined ) {
  13872. this.value = val;
  13873. }
  13874. } );
  13875. }
  13876. } );
  13877. jQuery.extend( {
  13878. valHooks: {
  13879. option: {
  13880. get: function( elem ) {
  13881. var val = jQuery.find.attr( elem, "value" );
  13882. return val != null ?
  13883. val :
  13884. // Support: IE <=10 - 11 only
  13885. // option.text throws exceptions (#14686, #14858)
  13886. // Strip and collapse whitespace
  13887. // https://html.spec.whatwg.org/#strip-and-collapse-whitespace
  13888. stripAndCollapse( jQuery.text( elem ) );
  13889. }
  13890. },
  13891. select: {
  13892. get: function( elem ) {
  13893. var value, option, i,
  13894. options = elem.options,
  13895. index = elem.selectedIndex,
  13896. one = elem.type === "select-one",
  13897. values = one ? null : [],
  13898. max = one ? index + 1 : options.length;
  13899. if ( index < 0 ) {
  13900. i = max;
  13901. } else {
  13902. i = one ? index : 0;
  13903. }
  13904. // Loop through all the selected options
  13905. for ( ; i < max; i++ ) {
  13906. option = options[ i ];
  13907. // Support: IE <=9 only
  13908. // IE8-9 doesn't update selected after form reset (#2551)
  13909. if ( ( option.selected || i === index ) &&
  13910. // Don't return options that are disabled or in a disabled optgroup
  13911. !option.disabled &&
  13912. ( !option.parentNode.disabled ||
  13913. !nodeName( option.parentNode, "optgroup" ) ) ) {
  13914. // Get the specific value for the option
  13915. value = jQuery( option ).val();
  13916. // We don't need an array for one selects
  13917. if ( one ) {
  13918. return value;
  13919. }
  13920. // Multi-Selects return an array
  13921. values.push( value );
  13922. }
  13923. }
  13924. return values;
  13925. },
  13926. set: function( elem, value ) {
  13927. var optionSet, option,
  13928. options = elem.options,
  13929. values = jQuery.makeArray( value ),
  13930. i = options.length;
  13931. while ( i-- ) {
  13932. option = options[ i ];
  13933. /* eslint-disable no-cond-assign */
  13934. if ( option.selected =
  13935. jQuery.inArray( jQuery.valHooks.option.get( option ), values ) > -1
  13936. ) {
  13937. optionSet = true;
  13938. }
  13939. /* eslint-enable no-cond-assign */
  13940. }
  13941. // Force browsers to behave consistently when non-matching value is set
  13942. if ( !optionSet ) {
  13943. elem.selectedIndex = -1;
  13944. }
  13945. return values;
  13946. }
  13947. }
  13948. }
  13949. } );
  13950. // Radios and checkboxes getter/setter
  13951. jQuery.each( [ "radio", "checkbox" ], function() {
  13952. jQuery.valHooks[ this ] = {
  13953. set: function( elem, value ) {
  13954. if ( Array.isArray( value ) ) {
  13955. return ( elem.checked = jQuery.inArray( jQuery( elem ).val(), value ) > -1 );
  13956. }
  13957. }
  13958. };
  13959. if ( !support.checkOn ) {
  13960. jQuery.valHooks[ this ].get = function( elem ) {
  13961. return elem.getAttribute( "value" ) === null ? "on" : elem.value;
  13962. };
  13963. }
  13964. } );
  13965. // Return jQuery for attributes-only inclusion
  13966. support.focusin = "onfocusin" in window;
  13967. var rfocusMorph = /^(?:focusinfocus|focusoutblur)$/,
  13968. stopPropagationCallback = function( e ) {
  13969. e.stopPropagation();
  13970. };
  13971. jQuery.extend( jQuery.event, {
  13972. trigger: function( event, data, elem, onlyHandlers ) {
  13973. var i, cur, tmp, bubbleType, ontype, handle, special, lastElement,
  13974. eventPath = [ elem || document ],
  13975. type = hasOwn.call( event, "type" ) ? event.type : event,
  13976. namespaces = hasOwn.call( event, "namespace" ) ? event.namespace.split( "." ) : [];
  13977. cur = lastElement = tmp = elem = elem || document;
  13978. // Don't do events on text and comment nodes
  13979. if ( elem.nodeType === 3 || elem.nodeType === 8 ) {
  13980. return;
  13981. }
  13982. // focus/blur morphs to focusin/out; ensure we're not firing them right now
  13983. if ( rfocusMorph.test( type + jQuery.event.triggered ) ) {
  13984. return;
  13985. }
  13986. if ( type.indexOf( "." ) > -1 ) {
  13987. // Namespaced trigger; create a regexp to match event type in handle()
  13988. namespaces = type.split( "." );
  13989. type = namespaces.shift();
  13990. namespaces.sort();
  13991. }
  13992. ontype = type.indexOf( ":" ) < 0 && "on" + type;
  13993. // Caller can pass in a jQuery.Event object, Object, or just an event type string
  13994. event = event[ jQuery.expando ] ?
  13995. event :
  13996. new jQuery.Event( type, typeof event === "object" && event );
  13997. // Trigger bitmask: & 1 for native handlers; & 2 for jQuery (always true)
  13998. event.isTrigger = onlyHandlers ? 2 : 3;
  13999. event.namespace = namespaces.join( "." );
  14000. event.rnamespace = event.namespace ?
  14001. new RegExp( "(^|\\.)" + namespaces.join( "\\.(?:.*\\.|)" ) + "(\\.|$)" ) :
  14002. null;
  14003. // Clean up the event in case it is being reused
  14004. event.result = undefined;
  14005. if ( !event.target ) {
  14006. event.target = elem;
  14007. }
  14008. // Clone any incoming data and prepend the event, creating the handler arg list
  14009. data = data == null ?
  14010. [ event ] :
  14011. jQuery.makeArray( data, [ event ] );
  14012. // Allow special events to draw outside the lines
  14013. special = jQuery.event.special[ type ] || {};
  14014. if ( !onlyHandlers && special.trigger && special.trigger.apply( elem, data ) === false ) {
  14015. return;
  14016. }
  14017. // Determine event propagation path in advance, per W3C events spec (#9951)
  14018. // Bubble up to document, then to window; watch for a global ownerDocument var (#9724)
  14019. if ( !onlyHandlers && !special.noBubble && !isWindow( elem ) ) {
  14020. bubbleType = special.delegateType || type;
  14021. if ( !rfocusMorph.test( bubbleType + type ) ) {
  14022. cur = cur.parentNode;
  14023. }
  14024. for ( ; cur; cur = cur.parentNode ) {
  14025. eventPath.push( cur );
  14026. tmp = cur;
  14027. }
  14028. // Only add window if we got to document (e.g., not plain obj or detached DOM)
  14029. if ( tmp === ( elem.ownerDocument || document ) ) {
  14030. eventPath.push( tmp.defaultView || tmp.parentWindow || window );
  14031. }
  14032. }
  14033. // Fire handlers on the event path
  14034. i = 0;
  14035. while ( ( cur = eventPath[ i++ ] ) && !event.isPropagationStopped() ) {
  14036. lastElement = cur;
  14037. event.type = i > 1 ?
  14038. bubbleType :
  14039. special.bindType || type;
  14040. // jQuery handler
  14041. handle = ( dataPriv.get( cur, "events" ) || {} )[ event.type ] &&
  14042. dataPriv.get( cur, "handle" );
  14043. if ( handle ) {
  14044. handle.apply( cur, data );
  14045. }
  14046. // Native handler
  14047. handle = ontype && cur[ ontype ];
  14048. if ( handle && handle.apply && acceptData( cur ) ) {
  14049. event.result = handle.apply( cur, data );
  14050. if ( event.result === false ) {
  14051. event.preventDefault();
  14052. }
  14053. }
  14054. }
  14055. event.type = type;
  14056. // If nobody prevented the default action, do it now
  14057. if ( !onlyHandlers && !event.isDefaultPrevented() ) {
  14058. if ( ( !special._default ||
  14059. special._default.apply( eventPath.pop(), data ) === false ) &&
  14060. acceptData( elem ) ) {
  14061. // Call a native DOM method on the target with the same name as the event.
  14062. // Don't do default actions on window, that's where global variables be (#6170)
  14063. if ( ontype && isFunction( elem[ type ] ) && !isWindow( elem ) ) {
  14064. // Don't re-trigger an onFOO event when we call its FOO() method
  14065. tmp = elem[ ontype ];
  14066. if ( tmp ) {
  14067. elem[ ontype ] = null;
  14068. }
  14069. // Prevent re-triggering of the same event, since we already bubbled it above
  14070. jQuery.event.triggered = type;
  14071. if ( event.isPropagationStopped() ) {
  14072. lastElement.addEventListener( type, stopPropagationCallback );
  14073. }
  14074. elem[ type ]();
  14075. if ( event.isPropagationStopped() ) {
  14076. lastElement.removeEventListener( type, stopPropagationCallback );
  14077. }
  14078. jQuery.event.triggered = undefined;
  14079. if ( tmp ) {
  14080. elem[ ontype ] = tmp;
  14081. }
  14082. }
  14083. }
  14084. }
  14085. return event.result;
  14086. },
  14087. // Piggyback on a donor event to simulate a different one
  14088. // Used only for `focus(in | out)` events
  14089. simulate: function( type, elem, event ) {
  14090. var e = jQuery.extend(
  14091. new jQuery.Event(),
  14092. event,
  14093. {
  14094. type: type,
  14095. isSimulated: true
  14096. }
  14097. );
  14098. jQuery.event.trigger( e, null, elem );
  14099. }
  14100. } );
  14101. jQuery.fn.extend( {
  14102. trigger: function( type, data ) {
  14103. return this.each( function() {
  14104. jQuery.event.trigger( type, data, this );
  14105. } );
  14106. },
  14107. triggerHandler: function( type, data ) {
  14108. var elem = this[ 0 ];
  14109. if ( elem ) {
  14110. return jQuery.event.trigger( type, data, elem, true );
  14111. }
  14112. }
  14113. } );
  14114. // Support: Firefox <=44
  14115. // Firefox doesn't have focus(in | out) events
  14116. // Related ticket - https://bugzilla.mozilla.org/show_bug.cgi?id=687787
  14117. //
  14118. // Support: Chrome <=48 - 49, Safari <=9.0 - 9.1
  14119. // focus(in | out) events fire after focus & blur events,
  14120. // which is spec violation - http://www.w3.org/TR/DOM-Level-3-Events/#events-focusevent-event-order
  14121. // Related ticket - https://bugs.chromium.org/p/chromium/issues/detail?id=449857
  14122. if ( !support.focusin ) {
  14123. jQuery.each( { focus: "focusin", blur: "focusout" }, function( orig, fix ) {
  14124. // Attach a single capturing handler on the document while someone wants focusin/focusout
  14125. var handler = function( event ) {
  14126. jQuery.event.simulate( fix, event.target, jQuery.event.fix( event ) );
  14127. };
  14128. jQuery.event.special[ fix ] = {
  14129. setup: function() {
  14130. var doc = this.ownerDocument || this,
  14131. attaches = dataPriv.access( doc, fix );
  14132. if ( !attaches ) {
  14133. doc.addEventListener( orig, handler, true );
  14134. }
  14135. dataPriv.access( doc, fix, ( attaches || 0 ) + 1 );
  14136. },
  14137. teardown: function() {
  14138. var doc = this.ownerDocument || this,
  14139. attaches = dataPriv.access( doc, fix ) - 1;
  14140. if ( !attaches ) {
  14141. doc.removeEventListener( orig, handler, true );
  14142. dataPriv.remove( doc, fix );
  14143. } else {
  14144. dataPriv.access( doc, fix, attaches );
  14145. }
  14146. }
  14147. };
  14148. } );
  14149. }
  14150. var location = window.location;
  14151. var nonce = Date.now();
  14152. var rquery = ( /\?/ );
  14153. // Cross-browser xml parsing
  14154. jQuery.parseXML = function( data ) {
  14155. var xml;
  14156. if ( !data || typeof data !== "string" ) {
  14157. return null;
  14158. }
  14159. // Support: IE 9 - 11 only
  14160. // IE throws on parseFromString with invalid input.
  14161. try {
  14162. xml = ( new window.DOMParser() ).parseFromString( data, "text/xml" );
  14163. } catch ( e ) {
  14164. xml = undefined;
  14165. }
  14166. if ( !xml || xml.getElementsByTagName( "parsererror" ).length ) {
  14167. jQuery.error( "Invalid XML: " + data );
  14168. }
  14169. return xml;
  14170. };
  14171. var
  14172. rbracket = /\[\]$/,
  14173. rCRLF = /\r?\n/g,
  14174. rsubmitterTypes = /^(?:submit|button|image|reset|file)$/i,
  14175. rsubmittable = /^(?:input|select|textarea|keygen)/i;
  14176. function buildParams( prefix, obj, traditional, add ) {
  14177. var name;
  14178. if ( Array.isArray( obj ) ) {
  14179. // Serialize array item.
  14180. jQuery.each( obj, function( i, v ) {
  14181. if ( traditional || rbracket.test( prefix ) ) {
  14182. // Treat each array item as a scalar.
  14183. add( prefix, v );
  14184. } else {
  14185. // Item is non-scalar (array or object), encode its numeric index.
  14186. buildParams(
  14187. prefix + "[" + ( typeof v === "object" && v != null ? i : "" ) + "]",
  14188. v,
  14189. traditional,
  14190. add
  14191. );
  14192. }
  14193. } );
  14194. } else if ( !traditional && toType( obj ) === "object" ) {
  14195. // Serialize object item.
  14196. for ( name in obj ) {
  14197. buildParams( prefix + "[" + name + "]", obj[ name ], traditional, add );
  14198. }
  14199. } else {
  14200. // Serialize scalar item.
  14201. add( prefix, obj );
  14202. }
  14203. }
  14204. // Serialize an array of form elements or a set of
  14205. // key/values into a query string
  14206. jQuery.param = function( a, traditional ) {
  14207. var prefix,
  14208. s = [],
  14209. add = function( key, valueOrFunction ) {
  14210. // If value is a function, invoke it and use its return value
  14211. var value = isFunction( valueOrFunction ) ?
  14212. valueOrFunction() :
  14213. valueOrFunction;
  14214. s[ s.length ] = encodeURIComponent( key ) + "=" +
  14215. encodeURIComponent( value == null ? "" : value );
  14216. };
  14217. if ( a == null ) {
  14218. return "";
  14219. }
  14220. // If an array was passed in, assume that it is an array of form elements.
  14221. if ( Array.isArray( a ) || ( a.jquery && !jQuery.isPlainObject( a ) ) ) {
  14222. // Serialize the form elements
  14223. jQuery.each( a, function() {
  14224. add( this.name, this.value );
  14225. } );
  14226. } else {
  14227. // If traditional, encode the "old" way (the way 1.3.2 or older
  14228. // did it), otherwise encode params recursively.
  14229. for ( prefix in a ) {
  14230. buildParams( prefix, a[ prefix ], traditional, add );
  14231. }
  14232. }
  14233. // Return the resulting serialization
  14234. return s.join( "&" );
  14235. };
  14236. jQuery.fn.extend( {
  14237. serialize: function() {
  14238. return jQuery.param( this.serializeArray() );
  14239. },
  14240. serializeArray: function() {
  14241. return this.map( function() {
  14242. // Can add propHook for "elements" to filter or add form elements
  14243. var elements = jQuery.prop( this, "elements" );
  14244. return elements ? jQuery.makeArray( elements ) : this;
  14245. } )
  14246. .filter( function() {
  14247. var type = this.type;
  14248. // Use .is( ":disabled" ) so that fieldset[disabled] works
  14249. return this.name && !jQuery( this ).is( ":disabled" ) &&
  14250. rsubmittable.test( this.nodeName ) && !rsubmitterTypes.test( type ) &&
  14251. ( this.checked || !rcheckableType.test( type ) );
  14252. } )
  14253. .map( function( i, elem ) {
  14254. var val = jQuery( this ).val();
  14255. if ( val == null ) {
  14256. return null;
  14257. }
  14258. if ( Array.isArray( val ) ) {
  14259. return jQuery.map( val, function( val ) {
  14260. return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
  14261. } );
  14262. }
  14263. return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
  14264. } ).get();
  14265. }
  14266. } );
  14267. var
  14268. r20 = /%20/g,
  14269. rhash = /#.*$/,
  14270. rantiCache = /([?&])_=[^&]*/,
  14271. rheaders = /^(.*?):[ \t]*([^\r\n]*)$/mg,
  14272. // #7653, #8125, #8152: local protocol detection
  14273. rlocalProtocol = /^(?:about|app|app-storage|.+-extension|file|res|widget):$/,
  14274. rnoContent = /^(?:GET|HEAD)$/,
  14275. rprotocol = /^\/\//,
  14276. /* Prefilters
  14277. * 1) They are useful to introduce custom dataTypes (see ajax/jsonp.js for an example)
  14278. * 2) These are called:
  14279. * - BEFORE asking for a transport
  14280. * - AFTER param serialization (s.data is a string if s.processData is true)
  14281. * 3) key is the dataType
  14282. * 4) the catchall symbol "*" can be used
  14283. * 5) execution will start with transport dataType and THEN continue down to "*" if needed
  14284. */
  14285. prefilters = {},
  14286. /* Transports bindings
  14287. * 1) key is the dataType
  14288. * 2) the catchall symbol "*" can be used
  14289. * 3) selection will start with transport dataType and THEN go to "*" if needed
  14290. */
  14291. transports = {},
  14292. // Avoid comment-prolog char sequence (#10098); must appease lint and evade compression
  14293. allTypes = "*/".concat( "*" ),
  14294. // Anchor tag for parsing the document origin
  14295. originAnchor = document.createElement( "a" );
  14296. originAnchor.href = location.href;
  14297. // Base "constructor" for jQuery.ajaxPrefilter and jQuery.ajaxTransport
  14298. function addToPrefiltersOrTransports( structure ) {
  14299. // dataTypeExpression is optional and defaults to "*"
  14300. return function( dataTypeExpression, func ) {
  14301. if ( typeof dataTypeExpression !== "string" ) {
  14302. func = dataTypeExpression;
  14303. dataTypeExpression = "*";
  14304. }
  14305. var dataType,
  14306. i = 0,
  14307. dataTypes = dataTypeExpression.toLowerCase().match( rnothtmlwhite ) || [];
  14308. if ( isFunction( func ) ) {
  14309. // For each dataType in the dataTypeExpression
  14310. while ( ( dataType = dataTypes[ i++ ] ) ) {
  14311. // Prepend if requested
  14312. if ( dataType[ 0 ] === "+" ) {
  14313. dataType = dataType.slice( 1 ) || "*";
  14314. ( structure[ dataType ] = structure[ dataType ] || [] ).unshift( func );
  14315. // Otherwise append
  14316. } else {
  14317. ( structure[ dataType ] = structure[ dataType ] || [] ).push( func );
  14318. }
  14319. }
  14320. }
  14321. };
  14322. }
  14323. // Base inspection function for prefilters and transports
  14324. function inspectPrefiltersOrTransports( structure, options, originalOptions, jqXHR ) {
  14325. var inspected = {},
  14326. seekingTransport = ( structure === transports );
  14327. function inspect( dataType ) {
  14328. var selected;
  14329. inspected[ dataType ] = true;
  14330. jQuery.each( structure[ dataType ] || [], function( _, prefilterOrFactory ) {
  14331. var dataTypeOrTransport = prefilterOrFactory( options, originalOptions, jqXHR );
  14332. if ( typeof dataTypeOrTransport === "string" &&
  14333. !seekingTransport && !inspected[ dataTypeOrTransport ] ) {
  14334. options.dataTypes.unshift( dataTypeOrTransport );
  14335. inspect( dataTypeOrTransport );
  14336. return false;
  14337. } else if ( seekingTransport ) {
  14338. return !( selected = dataTypeOrTransport );
  14339. }
  14340. } );
  14341. return selected;
  14342. }
  14343. return inspect( options.dataTypes[ 0 ] ) || !inspected[ "*" ] && inspect( "*" );
  14344. }
  14345. // A special extend for ajax options
  14346. // that takes "flat" options (not to be deep extended)
  14347. // Fixes #9887
  14348. function ajaxExtend( target, src ) {
  14349. var key, deep,
  14350. flatOptions = jQuery.ajaxSettings.flatOptions || {};
  14351. for ( key in src ) {
  14352. if ( src[ key ] !== undefined ) {
  14353. ( flatOptions[ key ] ? target : ( deep || ( deep = {} ) ) )[ key ] = src[ key ];
  14354. }
  14355. }
  14356. if ( deep ) {
  14357. jQuery.extend( true, target, deep );
  14358. }
  14359. return target;
  14360. }
  14361. /* Handles responses to an ajax request:
  14362. * - finds the right dataType (mediates between content-type and expected dataType)
  14363. * - returns the corresponding response
  14364. */
  14365. function ajaxHandleResponses( s, jqXHR, responses ) {
  14366. var ct, type, finalDataType, firstDataType,
  14367. contents = s.contents,
  14368. dataTypes = s.dataTypes;
  14369. // Remove auto dataType and get content-type in the process
  14370. while ( dataTypes[ 0 ] === "*" ) {
  14371. dataTypes.shift();
  14372. if ( ct === undefined ) {
  14373. ct = s.mimeType || jqXHR.getResponseHeader( "Content-Type" );
  14374. }
  14375. }
  14376. // Check if we're dealing with a known content-type
  14377. if ( ct ) {
  14378. for ( type in contents ) {
  14379. if ( contents[ type ] && contents[ type ].test( ct ) ) {
  14380. dataTypes.unshift( type );
  14381. break;
  14382. }
  14383. }
  14384. }
  14385. // Check to see if we have a response for the expected dataType
  14386. if ( dataTypes[ 0 ] in responses ) {
  14387. finalDataType = dataTypes[ 0 ];
  14388. } else {
  14389. // Try convertible dataTypes
  14390. for ( type in responses ) {
  14391. if ( !dataTypes[ 0 ] || s.converters[ type + " " + dataTypes[ 0 ] ] ) {
  14392. finalDataType = type;
  14393. break;
  14394. }
  14395. if ( !firstDataType ) {
  14396. firstDataType = type;
  14397. }
  14398. }
  14399. // Or just use first one
  14400. finalDataType = finalDataType || firstDataType;
  14401. }
  14402. // If we found a dataType
  14403. // We add the dataType to the list if needed
  14404. // and return the corresponding response
  14405. if ( finalDataType ) {
  14406. if ( finalDataType !== dataTypes[ 0 ] ) {
  14407. dataTypes.unshift( finalDataType );
  14408. }
  14409. return responses[ finalDataType ];
  14410. }
  14411. }
  14412. /* Chain conversions given the request and the original response
  14413. * Also sets the responseXXX fields on the jqXHR instance
  14414. */
  14415. function ajaxConvert( s, response, jqXHR, isSuccess ) {
  14416. var conv2, current, conv, tmp, prev,
  14417. converters = {},
  14418. // Work with a copy of dataTypes in case we need to modify it for conversion
  14419. dataTypes = s.dataTypes.slice();
  14420. // Create converters map with lowercased keys
  14421. if ( dataTypes[ 1 ] ) {
  14422. for ( conv in s.converters ) {
  14423. converters[ conv.toLowerCase() ] = s.converters[ conv ];
  14424. }
  14425. }
  14426. current = dataTypes.shift();
  14427. // Convert to each sequential dataType
  14428. while ( current ) {
  14429. if ( s.responseFields[ current ] ) {
  14430. jqXHR[ s.responseFields[ current ] ] = response;
  14431. }
  14432. // Apply the dataFilter if provided
  14433. if ( !prev && isSuccess && s.dataFilter ) {
  14434. response = s.dataFilter( response, s.dataType );
  14435. }
  14436. prev = current;
  14437. current = dataTypes.shift();
  14438. if ( current ) {
  14439. // There's only work to do if current dataType is non-auto
  14440. if ( current === "*" ) {
  14441. current = prev;
  14442. // Convert response if prev dataType is non-auto and differs from current
  14443. } else if ( prev !== "*" && prev !== current ) {
  14444. // Seek a direct converter
  14445. conv = converters[ prev + " " + current ] || converters[ "* " + current ];
  14446. // If none found, seek a pair
  14447. if ( !conv ) {
  14448. for ( conv2 in converters ) {
  14449. // If conv2 outputs current
  14450. tmp = conv2.split( " " );
  14451. if ( tmp[ 1 ] === current ) {
  14452. // If prev can be converted to accepted input
  14453. conv = converters[ prev + " " + tmp[ 0 ] ] ||
  14454. converters[ "* " + tmp[ 0 ] ];
  14455. if ( conv ) {
  14456. // Condense equivalence converters
  14457. if ( conv === true ) {
  14458. conv = converters[ conv2 ];
  14459. // Otherwise, insert the intermediate dataType
  14460. } else if ( converters[ conv2 ] !== true ) {
  14461. current = tmp[ 0 ];
  14462. dataTypes.unshift( tmp[ 1 ] );
  14463. }
  14464. break;
  14465. }
  14466. }
  14467. }
  14468. }
  14469. // Apply converter (if not an equivalence)
  14470. if ( conv !== true ) {
  14471. // Unless errors are allowed to bubble, catch and return them
  14472. if ( conv && s.throws ) {
  14473. response = conv( response );
  14474. } else {
  14475. try {
  14476. response = conv( response );
  14477. } catch ( e ) {
  14478. return {
  14479. state: "parsererror",
  14480. error: conv ? e : "No conversion from " + prev + " to " + current
  14481. };
  14482. }
  14483. }
  14484. }
  14485. }
  14486. }
  14487. }
  14488. return { state: "success", data: response };
  14489. }
  14490. jQuery.extend( {
  14491. // Counter for holding the number of active queries
  14492. active: 0,
  14493. // Last-Modified header cache for next request
  14494. lastModified: {},
  14495. etag: {},
  14496. ajaxSettings: {
  14497. url: location.href,
  14498. type: "GET",
  14499. isLocal: rlocalProtocol.test( location.protocol ),
  14500. global: true,
  14501. processData: true,
  14502. async: true,
  14503. contentType: "application/x-www-form-urlencoded; charset=UTF-8",
  14504. /*
  14505. timeout: 0,
  14506. data: null,
  14507. dataType: null,
  14508. username: null,
  14509. password: null,
  14510. cache: null,
  14511. throws: false,
  14512. traditional: false,
  14513. headers: {},
  14514. */
  14515. accepts: {
  14516. "*": allTypes,
  14517. text: "text/plain",
  14518. html: "text/html",
  14519. xml: "application/xml, text/xml",
  14520. json: "application/json, text/javascript"
  14521. },
  14522. contents: {
  14523. xml: /\bxml\b/,
  14524. html: /\bhtml/,
  14525. json: /\bjson\b/
  14526. },
  14527. responseFields: {
  14528. xml: "responseXML",
  14529. text: "responseText",
  14530. json: "responseJSON"
  14531. },
  14532. // Data converters
  14533. // Keys separate source (or catchall "*") and destination types with a single space
  14534. converters: {
  14535. // Convert anything to text
  14536. "* text": String,
  14537. // Text to html (true = no transformation)
  14538. "text html": true,
  14539. // Evaluate text as a json expression
  14540. "text json": JSON.parse,
  14541. // Parse text as xml
  14542. "text xml": jQuery.parseXML
  14543. },
  14544. // For options that shouldn't be deep extended:
  14545. // you can add your own custom options here if
  14546. // and when you create one that shouldn't be
  14547. // deep extended (see ajaxExtend)
  14548. flatOptions: {
  14549. url: true,
  14550. context: true
  14551. }
  14552. },
  14553. // Creates a full fledged settings object into target
  14554. // with both ajaxSettings and settings fields.
  14555. // If target is omitted, writes into ajaxSettings.
  14556. ajaxSetup: function( target, settings ) {
  14557. return settings ?
  14558. // Building a settings object
  14559. ajaxExtend( ajaxExtend( target, jQuery.ajaxSettings ), settings ) :
  14560. // Extending ajaxSettings
  14561. ajaxExtend( jQuery.ajaxSettings, target );
  14562. },
  14563. ajaxPrefilter: addToPrefiltersOrTransports( prefilters ),
  14564. ajaxTransport: addToPrefiltersOrTransports( transports ),
  14565. // Main method
  14566. ajax: function( url, options ) {
  14567. // If url is an object, simulate pre-1.5 signature
  14568. if ( typeof url === "object" ) {
  14569. options = url;
  14570. url = undefined;
  14571. }
  14572. // Force options to be an object
  14573. options = options || {};
  14574. var transport,
  14575. // URL without anti-cache param
  14576. cacheURL,
  14577. // Response headers
  14578. responseHeadersString,
  14579. responseHeaders,
  14580. // timeout handle
  14581. timeoutTimer,
  14582. // Url cleanup var
  14583. urlAnchor,
  14584. // Request state (becomes false upon send and true upon completion)
  14585. completed,
  14586. // To know if global events are to be dispatched
  14587. fireGlobals,
  14588. // Loop variable
  14589. i,
  14590. // uncached part of the url
  14591. uncached,
  14592. // Create the final options object
  14593. s = jQuery.ajaxSetup( {}, options ),
  14594. // Callbacks context
  14595. callbackContext = s.context || s,
  14596. // Context for global events is callbackContext if it is a DOM node or jQuery collection
  14597. globalEventContext = s.context &&
  14598. ( callbackContext.nodeType || callbackContext.jquery ) ?
  14599. jQuery( callbackContext ) :
  14600. jQuery.event,
  14601. // Deferreds
  14602. deferred = jQuery.Deferred(),
  14603. completeDeferred = jQuery.Callbacks( "once memory" ),
  14604. // Status-dependent callbacks
  14605. statusCode = s.statusCode || {},
  14606. // Headers (they are sent all at once)
  14607. requestHeaders = {},
  14608. requestHeadersNames = {},
  14609. // Default abort message
  14610. strAbort = "canceled",
  14611. // Fake xhr
  14612. jqXHR = {
  14613. readyState: 0,
  14614. // Builds headers hashtable if needed
  14615. getResponseHeader: function( key ) {
  14616. var match;
  14617. if ( completed ) {
  14618. if ( !responseHeaders ) {
  14619. responseHeaders = {};
  14620. while ( ( match = rheaders.exec( responseHeadersString ) ) ) {
  14621. responseHeaders[ match[ 1 ].toLowerCase() + " " ] =
  14622. ( responseHeaders[ match[ 1 ].toLowerCase() + " " ] || [] )
  14623. .concat( match[ 2 ] );
  14624. }
  14625. }
  14626. match = responseHeaders[ key.toLowerCase() + " " ];
  14627. }
  14628. return match == null ? null : match.join( ", " );
  14629. },
  14630. // Raw string
  14631. getAllResponseHeaders: function() {
  14632. return completed ? responseHeadersString : null;
  14633. },
  14634. // Caches the header
  14635. setRequestHeader: function( name, value ) {
  14636. if ( completed == null ) {
  14637. name = requestHeadersNames[ name.toLowerCase() ] =
  14638. requestHeadersNames[ name.toLowerCase() ] || name;
  14639. requestHeaders[ name ] = value;
  14640. }
  14641. return this;
  14642. },
  14643. // Overrides response content-type header
  14644. overrideMimeType: function( type ) {
  14645. if ( completed == null ) {
  14646. s.mimeType = type;
  14647. }
  14648. return this;
  14649. },
  14650. // Status-dependent callbacks
  14651. statusCode: function( map ) {
  14652. var code;
  14653. if ( map ) {
  14654. if ( completed ) {
  14655. // Execute the appropriate callbacks
  14656. jqXHR.always( map[ jqXHR.status ] );
  14657. } else {
  14658. // Lazy-add the new callbacks in a way that preserves old ones
  14659. for ( code in map ) {
  14660. statusCode[ code ] = [ statusCode[ code ], map[ code ] ];
  14661. }
  14662. }
  14663. }
  14664. return this;
  14665. },
  14666. // Cancel the request
  14667. abort: function( statusText ) {
  14668. var finalText = statusText || strAbort;
  14669. if ( transport ) {
  14670. transport.abort( finalText );
  14671. }
  14672. done( 0, finalText );
  14673. return this;
  14674. }
  14675. };
  14676. // Attach deferreds
  14677. deferred.promise( jqXHR );
  14678. // Add protocol if not provided (prefilters might expect it)
  14679. // Handle falsy url in the settings object (#10093: consistency with old signature)
  14680. // We also use the url parameter if available
  14681. s.url = ( ( url || s.url || location.href ) + "" )
  14682. .replace( rprotocol, location.protocol + "//" );
  14683. // Alias method option to type as per ticket #12004
  14684. s.type = options.method || options.type || s.method || s.type;
  14685. // Extract dataTypes list
  14686. s.dataTypes = ( s.dataType || "*" ).toLowerCase().match( rnothtmlwhite ) || [ "" ];
  14687. // A cross-domain request is in order when the origin doesn't match the current origin.
  14688. if ( s.crossDomain == null ) {
  14689. urlAnchor = document.createElement( "a" );
  14690. // Support: IE <=8 - 11, Edge 12 - 15
  14691. // IE throws exception on accessing the href property if url is malformed,
  14692. // e.g. http://example.com:80x/
  14693. try {
  14694. urlAnchor.href = s.url;
  14695. // Support: IE <=8 - 11 only
  14696. // Anchor's host property isn't correctly set when s.url is relative
  14697. urlAnchor.href = urlAnchor.href;
  14698. s.crossDomain = originAnchor.protocol + "//" + originAnchor.host !==
  14699. urlAnchor.protocol + "//" + urlAnchor.host;
  14700. } catch ( e ) {
  14701. // If there is an error parsing the URL, assume it is crossDomain,
  14702. // it can be rejected by the transport if it is invalid
  14703. s.crossDomain = true;
  14704. }
  14705. }
  14706. // Convert data if not already a string
  14707. if ( s.data && s.processData && typeof s.data !== "string" ) {
  14708. s.data = jQuery.param( s.data, s.traditional );
  14709. }
  14710. // Apply prefilters
  14711. inspectPrefiltersOrTransports( prefilters, s, options, jqXHR );
  14712. // If request was aborted inside a prefilter, stop there
  14713. if ( completed ) {
  14714. return jqXHR;
  14715. }
  14716. // We can fire global events as of now if asked to
  14717. // Don't fire events if jQuery.event is undefined in an AMD-usage scenario (#15118)
  14718. fireGlobals = jQuery.event && s.global;
  14719. // Watch for a new set of requests
  14720. if ( fireGlobals && jQuery.active++ === 0 ) {
  14721. jQuery.event.trigger( "ajaxStart" );
  14722. }
  14723. // Uppercase the type
  14724. s.type = s.type.toUpperCase();
  14725. // Determine if request has content
  14726. s.hasContent = !rnoContent.test( s.type );
  14727. // Save the URL in case we're toying with the If-Modified-Since
  14728. // and/or If-None-Match header later on
  14729. // Remove hash to simplify url manipulation
  14730. cacheURL = s.url.replace( rhash, "" );
  14731. // More options handling for requests with no content
  14732. if ( !s.hasContent ) {
  14733. // Remember the hash so we can put it back
  14734. uncached = s.url.slice( cacheURL.length );
  14735. // If data is available and should be processed, append data to url
  14736. if ( s.data && ( s.processData || typeof s.data === "string" ) ) {
  14737. cacheURL += ( rquery.test( cacheURL ) ? "&" : "?" ) + s.data;
  14738. // #9682: remove data so that it's not used in an eventual retry
  14739. delete s.data;
  14740. }
  14741. // Add or update anti-cache param if needed
  14742. if ( s.cache === false ) {
  14743. cacheURL = cacheURL.replace( rantiCache, "$1" );
  14744. uncached = ( rquery.test( cacheURL ) ? "&" : "?" ) + "_=" + ( nonce++ ) + uncached;
  14745. }
  14746. // Put hash and anti-cache on the URL that will be requested (gh-1732)
  14747. s.url = cacheURL + uncached;
  14748. // Change '%20' to '+' if this is encoded form body content (gh-2658)
  14749. } else if ( s.data && s.processData &&
  14750. ( s.contentType || "" ).indexOf( "application/x-www-form-urlencoded" ) === 0 ) {
  14751. s.data = s.data.replace( r20, "+" );
  14752. }
  14753. // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
  14754. if ( s.ifModified ) {
  14755. if ( jQuery.lastModified[ cacheURL ] ) {
  14756. jqXHR.setRequestHeader( "If-Modified-Since", jQuery.lastModified[ cacheURL ] );
  14757. }
  14758. if ( jQuery.etag[ cacheURL ] ) {
  14759. jqXHR.setRequestHeader( "If-None-Match", jQuery.etag[ cacheURL ] );
  14760. }
  14761. }
  14762. // Set the correct header, if data is being sent
  14763. if ( s.data && s.hasContent && s.contentType !== false || options.contentType ) {
  14764. jqXHR.setRequestHeader( "Content-Type", s.contentType );
  14765. }
  14766. // Set the Accepts header for the server, depending on the dataType
  14767. jqXHR.setRequestHeader(
  14768. "Accept",
  14769. s.dataTypes[ 0 ] && s.accepts[ s.dataTypes[ 0 ] ] ?
  14770. s.accepts[ s.dataTypes[ 0 ] ] +
  14771. ( s.dataTypes[ 0 ] !== "*" ? ", " + allTypes + "; q=0.01" : "" ) :
  14772. s.accepts[ "*" ]
  14773. );
  14774. // Check for headers option
  14775. for ( i in s.headers ) {
  14776. jqXHR.setRequestHeader( i, s.headers[ i ] );
  14777. }
  14778. // Allow custom headers/mimetypes and early abort
  14779. if ( s.beforeSend &&
  14780. ( s.beforeSend.call( callbackContext, jqXHR, s ) === false || completed ) ) {
  14781. // Abort if not done already and return
  14782. return jqXHR.abort();
  14783. }
  14784. // Aborting is no longer a cancellation
  14785. strAbort = "abort";
  14786. // Install callbacks on deferreds
  14787. completeDeferred.add( s.complete );
  14788. jqXHR.done( s.success );
  14789. jqXHR.fail( s.error );
  14790. // Get transport
  14791. transport = inspectPrefiltersOrTransports( transports, s, options, jqXHR );
  14792. // If no transport, we auto-abort
  14793. if ( !transport ) {
  14794. done( -1, "No Transport" );
  14795. } else {
  14796. jqXHR.readyState = 1;
  14797. // Send global event
  14798. if ( fireGlobals ) {
  14799. globalEventContext.trigger( "ajaxSend", [ jqXHR, s ] );
  14800. }
  14801. // If request was aborted inside ajaxSend, stop there
  14802. if ( completed ) {
  14803. return jqXHR;
  14804. }
  14805. // Timeout
  14806. if ( s.async && s.timeout > 0 ) {
  14807. timeoutTimer = window.setTimeout( function() {
  14808. jqXHR.abort( "timeout" );
  14809. }, s.timeout );
  14810. }
  14811. try {
  14812. completed = false;
  14813. transport.send( requestHeaders, done );
  14814. } catch ( e ) {
  14815. // Rethrow post-completion exceptions
  14816. if ( completed ) {
  14817. throw e;
  14818. }
  14819. // Propagate others as results
  14820. done( -1, e );
  14821. }
  14822. }
  14823. // Callback for when everything is done
  14824. function done( status, nativeStatusText, responses, headers ) {
  14825. var isSuccess, success, error, response, modified,
  14826. statusText = nativeStatusText;
  14827. // Ignore repeat invocations
  14828. if ( completed ) {
  14829. return;
  14830. }
  14831. completed = true;
  14832. // Clear timeout if it exists
  14833. if ( timeoutTimer ) {
  14834. window.clearTimeout( timeoutTimer );
  14835. }
  14836. // Dereference transport for early garbage collection
  14837. // (no matter how long the jqXHR object will be used)
  14838. transport = undefined;
  14839. // Cache response headers
  14840. responseHeadersString = headers || "";
  14841. // Set readyState
  14842. jqXHR.readyState = status > 0 ? 4 : 0;
  14843. // Determine if successful
  14844. isSuccess = status >= 200 && status < 300 || status === 304;
  14845. // Get response data
  14846. if ( responses ) {
  14847. response = ajaxHandleResponses( s, jqXHR, responses );
  14848. }
  14849. // Convert no matter what (that way responseXXX fields are always set)
  14850. response = ajaxConvert( s, response, jqXHR, isSuccess );
  14851. // If successful, handle type chaining
  14852. if ( isSuccess ) {
  14853. // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
  14854. if ( s.ifModified ) {
  14855. modified = jqXHR.getResponseHeader( "Last-Modified" );
  14856. if ( modified ) {
  14857. jQuery.lastModified[ cacheURL ] = modified;
  14858. }
  14859. modified = jqXHR.getResponseHeader( "etag" );
  14860. if ( modified ) {
  14861. jQuery.etag[ cacheURL ] = modified;
  14862. }
  14863. }
  14864. // if no content
  14865. if ( status === 204 || s.type === "HEAD" ) {
  14866. statusText = "nocontent";
  14867. // if not modified
  14868. } else if ( status === 304 ) {
  14869. statusText = "notmodified";
  14870. // If we have data, let's convert it
  14871. } else {
  14872. statusText = response.state;
  14873. success = response.data;
  14874. error = response.error;
  14875. isSuccess = !error;
  14876. }
  14877. } else {
  14878. // Extract error from statusText and normalize for non-aborts
  14879. error = statusText;
  14880. if ( status || !statusText ) {
  14881. statusText = "error";
  14882. if ( status < 0 ) {
  14883. status = 0;
  14884. }
  14885. }
  14886. }
  14887. // Set data for the fake xhr object
  14888. jqXHR.status = status;
  14889. jqXHR.statusText = ( nativeStatusText || statusText ) + "";
  14890. // Success/Error
  14891. if ( isSuccess ) {
  14892. deferred.resolveWith( callbackContext, [ success, statusText, jqXHR ] );
  14893. } else {
  14894. deferred.rejectWith( callbackContext, [ jqXHR, statusText, error ] );
  14895. }
  14896. // Status-dependent callbacks
  14897. jqXHR.statusCode( statusCode );
  14898. statusCode = undefined;
  14899. if ( fireGlobals ) {
  14900. globalEventContext.trigger( isSuccess ? "ajaxSuccess" : "ajaxError",
  14901. [ jqXHR, s, isSuccess ? success : error ] );
  14902. }
  14903. // Complete
  14904. completeDeferred.fireWith( callbackContext, [ jqXHR, statusText ] );
  14905. if ( fireGlobals ) {
  14906. globalEventContext.trigger( "ajaxComplete", [ jqXHR, s ] );
  14907. // Handle the global AJAX counter
  14908. if ( !( --jQuery.active ) ) {
  14909. jQuery.event.trigger( "ajaxStop" );
  14910. }
  14911. }
  14912. }
  14913. return jqXHR;
  14914. },
  14915. getJSON: function( url, data, callback ) {
  14916. return jQuery.get( url, data, callback, "json" );
  14917. },
  14918. getScript: function( url, callback ) {
  14919. return jQuery.get( url, undefined, callback, "script" );
  14920. }
  14921. } );
  14922. jQuery.each( [ "get", "post" ], function( i, method ) {
  14923. jQuery[ method ] = function( url, data, callback, type ) {
  14924. // Shift arguments if data argument was omitted
  14925. if ( isFunction( data ) ) {
  14926. type = type || callback;
  14927. callback = data;
  14928. data = undefined;
  14929. }
  14930. // The url can be an options object (which then must have .url)
  14931. return jQuery.ajax( jQuery.extend( {
  14932. url: url,
  14933. type: method,
  14934. dataType: type,
  14935. data: data,
  14936. success: callback
  14937. }, jQuery.isPlainObject( url ) && url ) );
  14938. };
  14939. } );
  14940. jQuery._evalUrl = function( url, options ) {
  14941. return jQuery.ajax( {
  14942. url: url,
  14943. // Make this explicit, since user can override this through ajaxSetup (#11264)
  14944. type: "GET",
  14945. dataType: "script",
  14946. cache: true,
  14947. async: false,
  14948. global: false,
  14949. // Only evaluate the response if it is successful (gh-4126)
  14950. // dataFilter is not invoked for failure responses, so using it instead
  14951. // of the default converter is kludgy but it works.
  14952. converters: {
  14953. "text script": function() {}
  14954. },
  14955. dataFilter: function( response ) {
  14956. jQuery.globalEval( response, options );
  14957. }
  14958. } );
  14959. };
  14960. jQuery.fn.extend( {
  14961. wrapAll: function( html ) {
  14962. var wrap;
  14963. if ( this[ 0 ] ) {
  14964. if ( isFunction( html ) ) {
  14965. html = html.call( this[ 0 ] );
  14966. }
  14967. // The elements to wrap the target around
  14968. wrap = jQuery( html, this[ 0 ].ownerDocument ).eq( 0 ).clone( true );
  14969. if ( this[ 0 ].parentNode ) {
  14970. wrap.insertBefore( this[ 0 ] );
  14971. }
  14972. wrap.map( function() {
  14973. var elem = this;
  14974. while ( elem.firstElementChild ) {
  14975. elem = elem.firstElementChild;
  14976. }
  14977. return elem;
  14978. } ).append( this );
  14979. }
  14980. return this;
  14981. },
  14982. wrapInner: function( html ) {
  14983. if ( isFunction( html ) ) {
  14984. return this.each( function( i ) {
  14985. jQuery( this ).wrapInner( html.call( this, i ) );
  14986. } );
  14987. }
  14988. return this.each( function() {
  14989. var self = jQuery( this ),
  14990. contents = self.contents();
  14991. if ( contents.length ) {
  14992. contents.wrapAll( html );
  14993. } else {
  14994. self.append( html );
  14995. }
  14996. } );
  14997. },
  14998. wrap: function( html ) {
  14999. var htmlIsFunction = isFunction( html );
  15000. return this.each( function( i ) {
  15001. jQuery( this ).wrapAll( htmlIsFunction ? html.call( this, i ) : html );
  15002. } );
  15003. },
  15004. unwrap: function( selector ) {
  15005. this.parent( selector ).not( "body" ).each( function() {
  15006. jQuery( this ).replaceWith( this.childNodes );
  15007. } );
  15008. return this;
  15009. }
  15010. } );
  15011. jQuery.expr.pseudos.hidden = function( elem ) {
  15012. return !jQuery.expr.pseudos.visible( elem );
  15013. };
  15014. jQuery.expr.pseudos.visible = function( elem ) {
  15015. return !!( elem.offsetWidth || elem.offsetHeight || elem.getClientRects().length );
  15016. };
  15017. jQuery.ajaxSettings.xhr = function() {
  15018. try {
  15019. return new window.XMLHttpRequest();
  15020. } catch ( e ) {}
  15021. };
  15022. var xhrSuccessStatus = {
  15023. // File protocol always yields status code 0, assume 200
  15024. 0: 200,
  15025. // Support: IE <=9 only
  15026. // #1450: sometimes IE returns 1223 when it should be 204
  15027. 1223: 204
  15028. },
  15029. xhrSupported = jQuery.ajaxSettings.xhr();
  15030. support.cors = !!xhrSupported && ( "withCredentials" in xhrSupported );
  15031. support.ajax = xhrSupported = !!xhrSupported;
  15032. jQuery.ajaxTransport( function( options ) {
  15033. var callback, errorCallback;
  15034. // Cross domain only allowed if supported through XMLHttpRequest
  15035. if ( support.cors || xhrSupported && !options.crossDomain ) {
  15036. return {
  15037. send: function( headers, complete ) {
  15038. var i,
  15039. xhr = options.xhr();
  15040. xhr.open(
  15041. options.type,
  15042. options.url,
  15043. options.async,
  15044. options.username,
  15045. options.password
  15046. );
  15047. // Apply custom fields if provided
  15048. if ( options.xhrFields ) {
  15049. for ( i in options.xhrFields ) {
  15050. xhr[ i ] = options.xhrFields[ i ];
  15051. }
  15052. }
  15053. // Override mime type if needed
  15054. if ( options.mimeType && xhr.overrideMimeType ) {
  15055. xhr.overrideMimeType( options.mimeType );
  15056. }
  15057. // X-Requested-With header
  15058. // For cross-domain requests, seeing as conditions for a preflight are
  15059. // akin to a jigsaw puzzle, we simply never set it to be sure.
  15060. // (it can always be set on a per-request basis or even using ajaxSetup)
  15061. // For same-domain requests, won't change header if already provided.
  15062. if ( !options.crossDomain && !headers[ "X-Requested-With" ] ) {
  15063. headers[ "X-Requested-With" ] = "XMLHttpRequest";
  15064. }
  15065. // Set headers
  15066. for ( i in headers ) {
  15067. xhr.setRequestHeader( i, headers[ i ] );
  15068. }
  15069. // Callback
  15070. callback = function( type ) {
  15071. return function() {
  15072. if ( callback ) {
  15073. callback = errorCallback = xhr.onload =
  15074. xhr.onerror = xhr.onabort = xhr.ontimeout =
  15075. xhr.onreadystatechange = null;
  15076. if ( type === "abort" ) {
  15077. xhr.abort();
  15078. } else if ( type === "error" ) {
  15079. // Support: IE <=9 only
  15080. // On a manual native abort, IE9 throws
  15081. // errors on any property access that is not readyState
  15082. if ( typeof xhr.status !== "number" ) {
  15083. complete( 0, "error" );
  15084. } else {
  15085. complete(
  15086. // File: protocol always yields status 0; see #8605, #14207
  15087. xhr.status,
  15088. xhr.statusText
  15089. );
  15090. }
  15091. } else {
  15092. complete(
  15093. xhrSuccessStatus[ xhr.status ] || xhr.status,
  15094. xhr.statusText,
  15095. // Support: IE <=9 only
  15096. // IE9 has no XHR2 but throws on binary (trac-11426)
  15097. // For XHR2 non-text, let the caller handle it (gh-2498)
  15098. ( xhr.responseType || "text" ) !== "text" ||
  15099. typeof xhr.responseText !== "string" ?
  15100. { binary: xhr.response } :
  15101. { text: xhr.responseText },
  15102. xhr.getAllResponseHeaders()
  15103. );
  15104. }
  15105. }
  15106. };
  15107. };
  15108. // Listen to events
  15109. xhr.onload = callback();
  15110. errorCallback = xhr.onerror = xhr.ontimeout = callback( "error" );
  15111. // Support: IE 9 only
  15112. // Use onreadystatechange to replace onabort
  15113. // to handle uncaught aborts
  15114. if ( xhr.onabort !== undefined ) {
  15115. xhr.onabort = errorCallback;
  15116. } else {
  15117. xhr.onreadystatechange = function() {
  15118. // Check readyState before timeout as it changes
  15119. if ( xhr.readyState === 4 ) {
  15120. // Allow onerror to be called first,
  15121. // but that will not handle a native abort
  15122. // Also, save errorCallback to a variable
  15123. // as xhr.onerror cannot be accessed
  15124. window.setTimeout( function() {
  15125. if ( callback ) {
  15126. errorCallback();
  15127. }
  15128. } );
  15129. }
  15130. };
  15131. }
  15132. // Create the abort callback
  15133. callback = callback( "abort" );
  15134. try {
  15135. // Do send the request (this may raise an exception)
  15136. xhr.send( options.hasContent && options.data || null );
  15137. } catch ( e ) {
  15138. // #14683: Only rethrow if this hasn't been notified as an error yet
  15139. if ( callback ) {
  15140. throw e;
  15141. }
  15142. }
  15143. },
  15144. abort: function() {
  15145. if ( callback ) {
  15146. callback();
  15147. }
  15148. }
  15149. };
  15150. }
  15151. } );
  15152. // Prevent auto-execution of scripts when no explicit dataType was provided (See gh-2432)
  15153. jQuery.ajaxPrefilter( function( s ) {
  15154. if ( s.crossDomain ) {
  15155. s.contents.script = false;
  15156. }
  15157. } );
  15158. // Install script dataType
  15159. jQuery.ajaxSetup( {
  15160. accepts: {
  15161. script: "text/javascript, application/javascript, " +
  15162. "application/ecmascript, application/x-ecmascript"
  15163. },
  15164. contents: {
  15165. script: /\b(?:java|ecma)script\b/
  15166. },
  15167. converters: {
  15168. "text script": function( text ) {
  15169. jQuery.globalEval( text );
  15170. return text;
  15171. }
  15172. }
  15173. } );
  15174. // Handle cache's special case and crossDomain
  15175. jQuery.ajaxPrefilter( "script", function( s ) {
  15176. if ( s.cache === undefined ) {
  15177. s.cache = false;
  15178. }
  15179. if ( s.crossDomain ) {
  15180. s.type = "GET";
  15181. }
  15182. } );
  15183. // Bind script tag hack transport
  15184. jQuery.ajaxTransport( "script", function( s ) {
  15185. // This transport only deals with cross domain or forced-by-attrs requests
  15186. if ( s.crossDomain || s.scriptAttrs ) {
  15187. var script, callback;
  15188. return {
  15189. send: function( _, complete ) {
  15190. script = jQuery( "<script>" )
  15191. .attr( s.scriptAttrs || {} )
  15192. .prop( { charset: s.scriptCharset, src: s.url } )
  15193. .on( "load error", callback = function( evt ) {
  15194. script.remove();
  15195. callback = null;
  15196. if ( evt ) {
  15197. complete( evt.type === "error" ? 404 : 200, evt.type );
  15198. }
  15199. } );
  15200. // Use native DOM manipulation to avoid our domManip AJAX trickery
  15201. document.head.appendChild( script[ 0 ] );
  15202. },
  15203. abort: function() {
  15204. if ( callback ) {
  15205. callback();
  15206. }
  15207. }
  15208. };
  15209. }
  15210. } );
  15211. var oldCallbacks = [],
  15212. rjsonp = /(=)\?(?=&|$)|\?\?/;
  15213. // Default jsonp settings
  15214. jQuery.ajaxSetup( {
  15215. jsonp: "callback",
  15216. jsonpCallback: function() {
  15217. var callback = oldCallbacks.pop() || ( jQuery.expando + "_" + ( nonce++ ) );
  15218. this[ callback ] = true;
  15219. return callback;
  15220. }
  15221. } );
  15222. // Detect, normalize options and install callbacks for jsonp requests
  15223. jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) {
  15224. var callbackName, overwritten, responseContainer,
  15225. jsonProp = s.jsonp !== false && ( rjsonp.test( s.url ) ?
  15226. "url" :
  15227. typeof s.data === "string" &&
  15228. ( s.contentType || "" )
  15229. .indexOf( "application/x-www-form-urlencoded" ) === 0 &&
  15230. rjsonp.test( s.data ) && "data"
  15231. );
  15232. // Handle iff the expected data type is "jsonp" or we have a parameter to set
  15233. if ( jsonProp || s.dataTypes[ 0 ] === "jsonp" ) {
  15234. // Get callback name, remembering preexisting value associated with it
  15235. callbackName = s.jsonpCallback = isFunction( s.jsonpCallback ) ?
  15236. s.jsonpCallback() :
  15237. s.jsonpCallback;
  15238. // Insert callback into url or form data
  15239. if ( jsonProp ) {
  15240. s[ jsonProp ] = s[ jsonProp ].replace( rjsonp, "$1" + callbackName );
  15241. } else if ( s.jsonp !== false ) {
  15242. s.url += ( rquery.test( s.url ) ? "&" : "?" ) + s.jsonp + "=" + callbackName;
  15243. }
  15244. // Use data converter to retrieve json after script execution
  15245. s.converters[ "script json" ] = function() {
  15246. if ( !responseContainer ) {
  15247. jQuery.error( callbackName + " was not called" );
  15248. }
  15249. return responseContainer[ 0 ];
  15250. };
  15251. // Force json dataType
  15252. s.dataTypes[ 0 ] = "json";
  15253. // Install callback
  15254. overwritten = window[ callbackName ];
  15255. window[ callbackName ] = function() {
  15256. responseContainer = arguments;
  15257. };
  15258. // Clean-up function (fires after converters)
  15259. jqXHR.always( function() {
  15260. // If previous value didn't exist - remove it
  15261. if ( overwritten === undefined ) {
  15262. jQuery( window ).removeProp( callbackName );
  15263. // Otherwise restore preexisting value
  15264. } else {
  15265. window[ callbackName ] = overwritten;
  15266. }
  15267. // Save back as free
  15268. if ( s[ callbackName ] ) {
  15269. // Make sure that re-using the options doesn't screw things around
  15270. s.jsonpCallback = originalSettings.jsonpCallback;
  15271. // Save the callback name for future use
  15272. oldCallbacks.push( callbackName );
  15273. }
  15274. // Call if it was a function and we have a response
  15275. if ( responseContainer && isFunction( overwritten ) ) {
  15276. overwritten( responseContainer[ 0 ] );
  15277. }
  15278. responseContainer = overwritten = undefined;
  15279. } );
  15280. // Delegate to script
  15281. return "script";
  15282. }
  15283. } );
  15284. // Support: Safari 8 only
  15285. // In Safari 8 documents created via document.implementation.createHTMLDocument
  15286. // collapse sibling forms: the second one becomes a child of the first one.
  15287. // Because of that, this security measure has to be disabled in Safari 8.
  15288. // https://bugs.webkit.org/show_bug.cgi?id=137337
  15289. support.createHTMLDocument = ( function() {
  15290. var body = document.implementation.createHTMLDocument( "" ).body;
  15291. body.innerHTML = "<form></form><form></form>";
  15292. return body.childNodes.length === 2;
  15293. } )();
  15294. // Argument "data" should be string of html
  15295. // context (optional): If specified, the fragment will be created in this context,
  15296. // defaults to document
  15297. // keepScripts (optional): If true, will include scripts passed in the html string
  15298. jQuery.parseHTML = function( data, context, keepScripts ) {
  15299. if ( typeof data !== "string" ) {
  15300. return [];
  15301. }
  15302. if ( typeof context === "boolean" ) {
  15303. keepScripts = context;
  15304. context = false;
  15305. }
  15306. var base, parsed, scripts;
  15307. if ( !context ) {
  15308. // Stop scripts or inline event handlers from being executed immediately
  15309. // by using document.implementation
  15310. if ( support.createHTMLDocument ) {
  15311. context = document.implementation.createHTMLDocument( "" );
  15312. // Set the base href for the created document
  15313. // so any parsed elements with URLs
  15314. // are based on the document's URL (gh-2965)
  15315. base = context.createElement( "base" );
  15316. base.href = document.location.href;
  15317. context.head.appendChild( base );
  15318. } else {
  15319. context = document;
  15320. }
  15321. }
  15322. parsed = rsingleTag.exec( data );
  15323. scripts = !keepScripts && [];
  15324. // Single tag
  15325. if ( parsed ) {
  15326. return [ context.createElement( parsed[ 1 ] ) ];
  15327. }
  15328. parsed = buildFragment( [ data ], context, scripts );
  15329. if ( scripts && scripts.length ) {
  15330. jQuery( scripts ).remove();
  15331. }
  15332. return jQuery.merge( [], parsed.childNodes );
  15333. };
  15334. /**
  15335. * Load a url into a page
  15336. */
  15337. jQuery.fn.load = function( url, params, callback ) {
  15338. var selector, type, response,
  15339. self = this,
  15340. off = url.indexOf( " " );
  15341. if ( off > -1 ) {
  15342. selector = stripAndCollapse( url.slice( off ) );
  15343. url = url.slice( 0, off );
  15344. }
  15345. // If it's a function
  15346. if ( isFunction( params ) ) {
  15347. // We assume that it's the callback
  15348. callback = params;
  15349. params = undefined;
  15350. // Otherwise, build a param string
  15351. } else if ( params && typeof params === "object" ) {
  15352. type = "POST";
  15353. }
  15354. // If we have elements to modify, make the request
  15355. if ( self.length > 0 ) {
  15356. jQuery.ajax( {
  15357. url: url,
  15358. // If "type" variable is undefined, then "GET" method will be used.
  15359. // Make value of this field explicit since
  15360. // user can override it through ajaxSetup method
  15361. type: type || "GET",
  15362. dataType: "html",
  15363. data: params
  15364. } ).done( function( responseText ) {
  15365. // Save response for use in complete callback
  15366. response = arguments;
  15367. self.html( selector ?
  15368. // If a selector was specified, locate the right elements in a dummy div
  15369. // Exclude scripts to avoid IE 'Permission Denied' errors
  15370. jQuery( "<div>" ).append( jQuery.parseHTML( responseText ) ).find( selector ) :
  15371. // Otherwise use the full result
  15372. responseText );
  15373. // If the request succeeds, this function gets "data", "status", "jqXHR"
  15374. // but they are ignored because response was set above.
  15375. // If it fails, this function gets "jqXHR", "status", "error"
  15376. } ).always( callback && function( jqXHR, status ) {
  15377. self.each( function() {
  15378. callback.apply( this, response || [ jqXHR.responseText, status, jqXHR ] );
  15379. } );
  15380. } );
  15381. }
  15382. return this;
  15383. };
  15384. // Attach a bunch of functions for handling common AJAX events
  15385. jQuery.each( [
  15386. "ajaxStart",
  15387. "ajaxStop",
  15388. "ajaxComplete",
  15389. "ajaxError",
  15390. "ajaxSuccess",
  15391. "ajaxSend"
  15392. ], function( i, type ) {
  15393. jQuery.fn[ type ] = function( fn ) {
  15394. return this.on( type, fn );
  15395. };
  15396. } );
  15397. jQuery.expr.pseudos.animated = function( elem ) {
  15398. return jQuery.grep( jQuery.timers, function( fn ) {
  15399. return elem === fn.elem;
  15400. } ).length;
  15401. };
  15402. jQuery.offset = {
  15403. setOffset: function( elem, options, i ) {
  15404. var curPosition, curLeft, curCSSTop, curTop, curOffset, curCSSLeft, calculatePosition,
  15405. position = jQuery.css( elem, "position" ),
  15406. curElem = jQuery( elem ),
  15407. props = {};
  15408. // Set position first, in-case top/left are set even on static elem
  15409. if ( position === "static" ) {
  15410. elem.style.position = "relative";
  15411. }
  15412. curOffset = curElem.offset();
  15413. curCSSTop = jQuery.css( elem, "top" );
  15414. curCSSLeft = jQuery.css( elem, "left" );
  15415. calculatePosition = ( position === "absolute" || position === "fixed" ) &&
  15416. ( curCSSTop + curCSSLeft ).indexOf( "auto" ) > -1;
  15417. // Need to be able to calculate position if either
  15418. // top or left is auto and position is either absolute or fixed
  15419. if ( calculatePosition ) {
  15420. curPosition = curElem.position();
  15421. curTop = curPosition.top;
  15422. curLeft = curPosition.left;
  15423. } else {
  15424. curTop = parseFloat( curCSSTop ) || 0;
  15425. curLeft = parseFloat( curCSSLeft ) || 0;
  15426. }
  15427. if ( isFunction( options ) ) {
  15428. // Use jQuery.extend here to allow modification of coordinates argument (gh-1848)
  15429. options = options.call( elem, i, jQuery.extend( {}, curOffset ) );
  15430. }
  15431. if ( options.top != null ) {
  15432. props.top = ( options.top - curOffset.top ) + curTop;
  15433. }
  15434. if ( options.left != null ) {
  15435. props.left = ( options.left - curOffset.left ) + curLeft;
  15436. }
  15437. if ( "using" in options ) {
  15438. options.using.call( elem, props );
  15439. } else {
  15440. curElem.css( props );
  15441. }
  15442. }
  15443. };
  15444. jQuery.fn.extend( {
  15445. // offset() relates an element's border box to the document origin
  15446. offset: function( options ) {
  15447. // Preserve chaining for setter
  15448. if ( arguments.length ) {
  15449. return options === undefined ?
  15450. this :
  15451. this.each( function( i ) {
  15452. jQuery.offset.setOffset( this, options, i );
  15453. } );
  15454. }
  15455. var rect, win,
  15456. elem = this[ 0 ];
  15457. if ( !elem ) {
  15458. return;
  15459. }
  15460. // Return zeros for disconnected and hidden (display: none) elements (gh-2310)
  15461. // Support: IE <=11 only
  15462. // Running getBoundingClientRect on a
  15463. // disconnected node in IE throws an error
  15464. if ( !elem.getClientRects().length ) {
  15465. return { top: 0, left: 0 };
  15466. }
  15467. // Get document-relative position by adding viewport scroll to viewport-relative gBCR
  15468. rect = elem.getBoundingClientRect();
  15469. win = elem.ownerDocument.defaultView;
  15470. return {
  15471. top: rect.top + win.pageYOffset,
  15472. left: rect.left + win.pageXOffset
  15473. };
  15474. },
  15475. // position() relates an element's margin box to its offset parent's padding box
  15476. // This corresponds to the behavior of CSS absolute positioning
  15477. position: function() {
  15478. if ( !this[ 0 ] ) {
  15479. return;
  15480. }
  15481. var offsetParent, offset, doc,
  15482. elem = this[ 0 ],
  15483. parentOffset = { top: 0, left: 0 };
  15484. // position:fixed elements are offset from the viewport, which itself always has zero offset
  15485. if ( jQuery.css( elem, "position" ) === "fixed" ) {
  15486. // Assume position:fixed implies availability of getBoundingClientRect
  15487. offset = elem.getBoundingClientRect();
  15488. } else {
  15489. offset = this.offset();
  15490. // Account for the *real* offset parent, which can be the document or its root element
  15491. // when a statically positioned element is identified
  15492. doc = elem.ownerDocument;
  15493. offsetParent = elem.offsetParent || doc.documentElement;
  15494. while ( offsetParent &&
  15495. ( offsetParent === doc.body || offsetParent === doc.documentElement ) &&
  15496. jQuery.css( offsetParent, "position" ) === "static" ) {
  15497. offsetParent = offsetParent.parentNode;
  15498. }
  15499. if ( offsetParent && offsetParent !== elem && offsetParent.nodeType === 1 ) {
  15500. // Incorporate borders into its offset, since they are outside its content origin
  15501. parentOffset = jQuery( offsetParent ).offset();
  15502. parentOffset.top += jQuery.css( offsetParent, "borderTopWidth", true );
  15503. parentOffset.left += jQuery.css( offsetParent, "borderLeftWidth", true );
  15504. }
  15505. }
  15506. // Subtract parent offsets and element margins
  15507. return {
  15508. top: offset.top - parentOffset.top - jQuery.css( elem, "marginTop", true ),
  15509. left: offset.left - parentOffset.left - jQuery.css( elem, "marginLeft", true )
  15510. };
  15511. },
  15512. // This method will return documentElement in the following cases:
  15513. // 1) For the element inside the iframe without offsetParent, this method will return
  15514. // documentElement of the parent window
  15515. // 2) For the hidden or detached element
  15516. // 3) For body or html element, i.e. in case of the html node - it will return itself
  15517. //
  15518. // but those exceptions were never presented as a real life use-cases
  15519. // and might be considered as more preferable results.
  15520. //
  15521. // This logic, however, is not guaranteed and can change at any point in the future
  15522. offsetParent: function() {
  15523. return this.map( function() {
  15524. var offsetParent = this.offsetParent;
  15525. while ( offsetParent && jQuery.css( offsetParent, "position" ) === "static" ) {
  15526. offsetParent = offsetParent.offsetParent;
  15527. }
  15528. return offsetParent || documentElement;
  15529. } );
  15530. }
  15531. } );
  15532. // Create scrollLeft and scrollTop methods
  15533. jQuery.each( { scrollLeft: "pageXOffset", scrollTop: "pageYOffset" }, function( method, prop ) {
  15534. var top = "pageYOffset" === prop;
  15535. jQuery.fn[ method ] = function( val ) {
  15536. return access( this, function( elem, method, val ) {
  15537. // Coalesce documents and windows
  15538. var win;
  15539. if ( isWindow( elem ) ) {
  15540. win = elem;
  15541. } else if ( elem.nodeType === 9 ) {
  15542. win = elem.defaultView;
  15543. }
  15544. if ( val === undefined ) {
  15545. return win ? win[ prop ] : elem[ method ];
  15546. }
  15547. if ( win ) {
  15548. win.scrollTo(
  15549. !top ? val : win.pageXOffset,
  15550. top ? val : win.pageYOffset
  15551. );
  15552. } else {
  15553. elem[ method ] = val;
  15554. }
  15555. }, method, val, arguments.length );
  15556. };
  15557. } );
  15558. // Support: Safari <=7 - 9.1, Chrome <=37 - 49
  15559. // Add the top/left cssHooks using jQuery.fn.position
  15560. // Webkit bug: https://bugs.webkit.org/show_bug.cgi?id=29084
  15561. // Blink bug: https://bugs.chromium.org/p/chromium/issues/detail?id=589347
  15562. // getComputedStyle returns percent when specified for top/left/bottom/right;
  15563. // rather than make the css module depend on the offset module, just check for it here
  15564. jQuery.each( [ "top", "left" ], function( i, prop ) {
  15565. jQuery.cssHooks[ prop ] = addGetHookIf( support.pixelPosition,
  15566. function( elem, computed ) {
  15567. if ( computed ) {
  15568. computed = curCSS( elem, prop );
  15569. // If curCSS returns percentage, fallback to offset
  15570. return rnumnonpx.test( computed ) ?
  15571. jQuery( elem ).position()[ prop ] + "px" :
  15572. computed;
  15573. }
  15574. }
  15575. );
  15576. } );
  15577. // Create innerHeight, innerWidth, height, width, outerHeight and outerWidth methods
  15578. jQuery.each( { Height: "height", Width: "width" }, function( name, type ) {
  15579. jQuery.each( { padding: "inner" + name, content: type, "": "outer" + name },
  15580. function( defaultExtra, funcName ) {
  15581. // Margin is only for outerHeight, outerWidth
  15582. jQuery.fn[ funcName ] = function( margin, value ) {
  15583. var chainable = arguments.length && ( defaultExtra || typeof margin !== "boolean" ),
  15584. extra = defaultExtra || ( margin === true || value === true ? "margin" : "border" );
  15585. return access( this, function( elem, type, value ) {
  15586. var doc;
  15587. if ( isWindow( elem ) ) {
  15588. // $( window ).outerWidth/Height return w/h including scrollbars (gh-1729)
  15589. return funcName.indexOf( "outer" ) === 0 ?
  15590. elem[ "inner" + name ] :
  15591. elem.document.documentElement[ "client" + name ];
  15592. }
  15593. // Get document width or height
  15594. if ( elem.nodeType === 9 ) {
  15595. doc = elem.documentElement;
  15596. // Either scroll[Width/Height] or offset[Width/Height] or client[Width/Height],
  15597. // whichever is greatest
  15598. return Math.max(
  15599. elem.body[ "scroll" + name ], doc[ "scroll" + name ],
  15600. elem.body[ "offset" + name ], doc[ "offset" + name ],
  15601. doc[ "client" + name ]
  15602. );
  15603. }
  15604. return value === undefined ?
  15605. // Get width or height on the element, requesting but not forcing parseFloat
  15606. jQuery.css( elem, type, extra ) :
  15607. // Set width or height on the element
  15608. jQuery.style( elem, type, value, extra );
  15609. }, type, chainable ? margin : undefined, chainable );
  15610. };
  15611. } );
  15612. } );
  15613. jQuery.each( ( "blur focus focusin focusout resize scroll click dblclick " +
  15614. "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " +
  15615. "change select submit keydown keypress keyup contextmenu" ).split( " " ),
  15616. function( i, name ) {
  15617. // Handle event binding
  15618. jQuery.fn[ name ] = function( data, fn ) {
  15619. return arguments.length > 0 ?
  15620. this.on( name, null, data, fn ) :
  15621. this.trigger( name );
  15622. };
  15623. } );
  15624. jQuery.fn.extend( {
  15625. hover: function( fnOver, fnOut ) {
  15626. return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver );
  15627. }
  15628. } );
  15629. jQuery.fn.extend( {
  15630. bind: function( types, data, fn ) {
  15631. return this.on( types, null, data, fn );
  15632. },
  15633. unbind: function( types, fn ) {
  15634. return this.off( types, null, fn );
  15635. },
  15636. delegate: function( selector, types, data, fn ) {
  15637. return this.on( types, selector, data, fn );
  15638. },
  15639. undelegate: function( selector, types, fn ) {
  15640. // ( namespace ) or ( selector, types [, fn] )
  15641. return arguments.length === 1 ?
  15642. this.off( selector, "**" ) :
  15643. this.off( types, selector || "**", fn );
  15644. }
  15645. } );
  15646. // Bind a function to a context, optionally partially applying any
  15647. // arguments.
  15648. // jQuery.proxy is deprecated to promote standards (specifically Function#bind)
  15649. // However, it is not slated for removal any time soon
  15650. jQuery.proxy = function( fn, context ) {
  15651. var tmp, args, proxy;
  15652. if ( typeof context === "string" ) {
  15653. tmp = fn[ context ];
  15654. context = fn;
  15655. fn = tmp;
  15656. }
  15657. // Quick check to determine if target is callable, in the spec
  15658. // this throws a TypeError, but we will just return undefined.
  15659. if ( !isFunction( fn ) ) {
  15660. return undefined;
  15661. }
  15662. // Simulated bind
  15663. args = slice.call( arguments, 2 );
  15664. proxy = function() {
  15665. return fn.apply( context || this, args.concat( slice.call( arguments ) ) );
  15666. };
  15667. // Set the guid of unique handler to the same of original handler, so it can be removed
  15668. proxy.guid = fn.guid = fn.guid || jQuery.guid++;
  15669. return proxy;
  15670. };
  15671. jQuery.holdReady = function( hold ) {
  15672. if ( hold ) {
  15673. jQuery.readyWait++;
  15674. } else {
  15675. jQuery.ready( true );
  15676. }
  15677. };
  15678. jQuery.isArray = Array.isArray;
  15679. jQuery.parseJSON = JSON.parse;
  15680. jQuery.nodeName = nodeName;
  15681. jQuery.isFunction = isFunction;
  15682. jQuery.isWindow = isWindow;
  15683. jQuery.camelCase = camelCase;
  15684. jQuery.type = toType;
  15685. jQuery.now = Date.now;
  15686. jQuery.isNumeric = function( obj ) {
  15687. // As of jQuery 3.0, isNumeric is limited to
  15688. // strings and numbers (primitives or objects)
  15689. // that can be coerced to finite numbers (gh-2662)
  15690. var type = jQuery.type( obj );
  15691. return ( type === "number" || type === "string" ) &&
  15692. // parseFloat NaNs numeric-cast false positives ("")
  15693. // ...but misinterprets leading-number strings, particularly hex literals ("0x...")
  15694. // subtraction forces infinities to NaN
  15695. !isNaN( obj - parseFloat( obj ) );
  15696. };
  15697. // Register as a named AMD module, since jQuery can be concatenated with other
  15698. // files that may use define, but not via a proper concatenation script that
  15699. // understands anonymous AMD modules. A named AMD is safest and most robust
  15700. // way to register. Lowercase jquery is used because AMD module names are
  15701. // derived from file names, and jQuery is normally delivered in a lowercase
  15702. // file name. Do this after creating the global so that if an AMD module wants
  15703. // to call noConflict to hide this version of jQuery, it will work.
  15704. // Note that for maximum portability, libraries that are not jQuery should
  15705. // declare themselves as anonymous modules, and avoid setting a global if an
  15706. // AMD loader is present. jQuery is a special case. For more information, see
  15707. // https://github.com/jrburke/requirejs/wiki/Updating-existing-libraries#wiki-anon
  15708. if ( true ) {
  15709. !(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_RESULT__ = (function() {
  15710. return jQuery;
  15711. }).apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__),
  15712. __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
  15713. }
  15714. var
  15715. // Map over jQuery in case of overwrite
  15716. _jQuery = window.jQuery,
  15717. // Map over the $ in case of overwrite
  15718. _$ = window.$;
  15719. jQuery.noConflict = function( deep ) {
  15720. if ( window.$ === jQuery ) {
  15721. window.$ = _$;
  15722. }
  15723. if ( deep && window.jQuery === jQuery ) {
  15724. window.jQuery = _jQuery;
  15725. }
  15726. return jQuery;
  15727. };
  15728. // Expose jQuery and $ identifiers, even in AMD
  15729. // (#7102#comment:10, https://github.com/jquery/jquery/pull/557)
  15730. // and CommonJS for browser emulators (#13566)
  15731. if ( !noGlobal ) {
  15732. window.jQuery = window.$ = jQuery;
  15733. }
  15734. return jQuery;
  15735. } );
  15736. /***/ }),
  15737. /***/ "./node_modules/laravel-echo/dist/echo.js":
  15738. /*!************************************************!*\
  15739. !*** ./node_modules/laravel-echo/dist/echo.js ***!
  15740. \************************************************/
  15741. /*! exports provided: default */
  15742. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15743. "use strict";
  15744. __webpack_require__.r(__webpack_exports__);
  15745. var classCallCheck = function (instance, Constructor) {
  15746. if (!(instance instanceof Constructor)) {
  15747. throw new TypeError("Cannot call a class as a function");
  15748. }
  15749. };
  15750. var createClass = function () {
  15751. function defineProperties(target, props) {
  15752. for (var i = 0; i < props.length; i++) {
  15753. var descriptor = props[i];
  15754. descriptor.enumerable = descriptor.enumerable || false;
  15755. descriptor.configurable = true;
  15756. if ("value" in descriptor) descriptor.writable = true;
  15757. Object.defineProperty(target, descriptor.key, descriptor);
  15758. }
  15759. }
  15760. return function (Constructor, protoProps, staticProps) {
  15761. if (protoProps) defineProperties(Constructor.prototype, protoProps);
  15762. if (staticProps) defineProperties(Constructor, staticProps);
  15763. return Constructor;
  15764. };
  15765. }();
  15766. var _extends = Object.assign || function (target) {
  15767. for (var i = 1; i < arguments.length; i++) {
  15768. var source = arguments[i];
  15769. for (var key in source) {
  15770. if (Object.prototype.hasOwnProperty.call(source, key)) {
  15771. target[key] = source[key];
  15772. }
  15773. }
  15774. }
  15775. return target;
  15776. };
  15777. var inherits = function (subClass, superClass) {
  15778. if (typeof superClass !== "function" && superClass !== null) {
  15779. throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
  15780. }
  15781. subClass.prototype = Object.create(superClass && superClass.prototype, {
  15782. constructor: {
  15783. value: subClass,
  15784. enumerable: false,
  15785. writable: true,
  15786. configurable: true
  15787. }
  15788. });
  15789. if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass;
  15790. };
  15791. var possibleConstructorReturn = function (self, call) {
  15792. if (!self) {
  15793. throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
  15794. }
  15795. return call && (typeof call === "object" || typeof call === "function") ? call : self;
  15796. };
  15797. var Connector = function () {
  15798. /**
  15799. * Create a new class instance.
  15800. */
  15801. function Connector(options) {
  15802. classCallCheck(this, Connector);
  15803. /**
  15804. * Default connector options.
  15805. */
  15806. this._defaultOptions = {
  15807. auth: {
  15808. headers: {}
  15809. },
  15810. authEndpoint: '/broadcasting/auth',
  15811. broadcaster: 'pusher',
  15812. csrfToken: null,
  15813. host: null,
  15814. key: null,
  15815. namespace: 'App.Events'
  15816. };
  15817. this.setOptions(options);
  15818. this.connect();
  15819. }
  15820. /**
  15821. * Merge the custom options with the defaults.
  15822. */
  15823. createClass(Connector, [{
  15824. key: 'setOptions',
  15825. value: function setOptions(options) {
  15826. this.options = _extends(this._defaultOptions, options);
  15827. if (this.csrfToken()) {
  15828. this.options.auth.headers['X-CSRF-TOKEN'] = this.csrfToken();
  15829. }
  15830. return options;
  15831. }
  15832. /**
  15833. * Extract the CSRF token from the page.
  15834. */
  15835. }, {
  15836. key: 'csrfToken',
  15837. value: function csrfToken() {
  15838. var selector = void 0;
  15839. if (typeof window !== 'undefined' && window['Laravel'] && window['Laravel'].csrfToken) {
  15840. return window['Laravel'].csrfToken;
  15841. } else if (this.options.csrfToken) {
  15842. return this.options.csrfToken;
  15843. } else if (typeof document !== 'undefined' && typeof document.querySelector === 'function' && (selector = document.querySelector('meta[name="csrf-token"]'))) {
  15844. return selector.getAttribute('content');
  15845. }
  15846. return null;
  15847. }
  15848. }]);
  15849. return Connector;
  15850. }();
  15851. /**
  15852. * This class represents a basic channel.
  15853. */
  15854. var Channel = function () {
  15855. function Channel() {
  15856. classCallCheck(this, Channel);
  15857. }
  15858. createClass(Channel, [{
  15859. key: 'listenForWhisper',
  15860. /**
  15861. * Listen for a whisper event on the channel instance.
  15862. */
  15863. value: function listenForWhisper(event, callback) {
  15864. return this.listen('.client-' + event, callback);
  15865. }
  15866. /**
  15867. * Listen for an event on the channel instance.
  15868. */
  15869. }, {
  15870. key: 'notification',
  15871. value: function notification(callback) {
  15872. return this.listen('.Illuminate\\Notifications\\Events\\BroadcastNotificationCreated', callback);
  15873. }
  15874. /**
  15875. * Stop listening for a whispser event on the channel instance.
  15876. */
  15877. }, {
  15878. key: 'stopListeningForWhisper',
  15879. value: function stopListeningForWhisper(event) {
  15880. return this.stopListening('.client-' + event);
  15881. }
  15882. }]);
  15883. return Channel;
  15884. }();
  15885. /**
  15886. * Event name formatter
  15887. */
  15888. var EventFormatter = function () {
  15889. /**
  15890. * Create a new class instance.
  15891. */
  15892. function EventFormatter(namespace) {
  15893. classCallCheck(this, EventFormatter);
  15894. this.setNamespace(namespace);
  15895. }
  15896. /**
  15897. * Format the given event name.
  15898. */
  15899. createClass(EventFormatter, [{
  15900. key: 'format',
  15901. value: function format(event) {
  15902. if (event.charAt(0) === '.' || event.charAt(0) === '\\') {
  15903. return event.substr(1);
  15904. } else if (this.namespace) {
  15905. event = this.namespace + '.' + event;
  15906. }
  15907. return event.replace(/\./g, '\\');
  15908. }
  15909. /**
  15910. * Set the event namespace.
  15911. */
  15912. }, {
  15913. key: 'setNamespace',
  15914. value: function setNamespace(value) {
  15915. this.namespace = value;
  15916. }
  15917. }]);
  15918. return EventFormatter;
  15919. }();
  15920. /**
  15921. * This class represents a Pusher channel.
  15922. */
  15923. var PusherChannel = function (_Channel) {
  15924. inherits(PusherChannel, _Channel);
  15925. /**
  15926. * Create a new class instance.
  15927. */
  15928. function PusherChannel(pusher, name, options) {
  15929. classCallCheck(this, PusherChannel);
  15930. var _this = possibleConstructorReturn(this, (PusherChannel.__proto__ || Object.getPrototypeOf(PusherChannel)).call(this));
  15931. _this.name = name;
  15932. _this.pusher = pusher;
  15933. _this.options = options;
  15934. _this.eventFormatter = new EventFormatter(_this.options.namespace);
  15935. _this.subscribe();
  15936. return _this;
  15937. }
  15938. /**
  15939. * Subscribe to a Pusher channel.
  15940. */
  15941. createClass(PusherChannel, [{
  15942. key: 'subscribe',
  15943. value: function subscribe() {
  15944. this.subscription = this.pusher.subscribe(this.name);
  15945. }
  15946. /**
  15947. * Unsubscribe from a Pusher channel.
  15948. */
  15949. }, {
  15950. key: 'unsubscribe',
  15951. value: function unsubscribe() {
  15952. this.pusher.unsubscribe(this.name);
  15953. }
  15954. /**
  15955. * Listen for an event on the channel instance.
  15956. */
  15957. }, {
  15958. key: 'listen',
  15959. value: function listen(event, callback) {
  15960. this.on(this.eventFormatter.format(event), callback);
  15961. return this;
  15962. }
  15963. /**
  15964. * Stop listening for an event on the channel instance.
  15965. */
  15966. }, {
  15967. key: 'stopListening',
  15968. value: function stopListening(event) {
  15969. this.subscription.unbind(this.eventFormatter.format(event));
  15970. return this;
  15971. }
  15972. /**
  15973. * Bind a channel to an event.
  15974. */
  15975. }, {
  15976. key: 'on',
  15977. value: function on(event, callback) {
  15978. this.subscription.bind(event, callback);
  15979. return this;
  15980. }
  15981. }]);
  15982. return PusherChannel;
  15983. }(Channel);
  15984. /**
  15985. * This class represents a Pusher private channel.
  15986. */
  15987. var PusherPrivateChannel = function (_PusherChannel) {
  15988. inherits(PusherPrivateChannel, _PusherChannel);
  15989. function PusherPrivateChannel() {
  15990. classCallCheck(this, PusherPrivateChannel);
  15991. return possibleConstructorReturn(this, (PusherPrivateChannel.__proto__ || Object.getPrototypeOf(PusherPrivateChannel)).apply(this, arguments));
  15992. }
  15993. createClass(PusherPrivateChannel, [{
  15994. key: 'whisper',
  15995. /**
  15996. * Trigger client event on the channel.
  15997. */
  15998. value: function whisper(eventName, data) {
  15999. this.pusher.channels.channels[this.name].trigger('client-' + eventName, data);
  16000. return this;
  16001. }
  16002. }]);
  16003. return PusherPrivateChannel;
  16004. }(PusherChannel);
  16005. /**
  16006. * This class represents a Pusher presence channel.
  16007. */
  16008. var PusherPresenceChannel = function (_PusherChannel) {
  16009. inherits(PusherPresenceChannel, _PusherChannel);
  16010. function PusherPresenceChannel() {
  16011. classCallCheck(this, PusherPresenceChannel);
  16012. return possibleConstructorReturn(this, (PusherPresenceChannel.__proto__ || Object.getPrototypeOf(PusherPresenceChannel)).apply(this, arguments));
  16013. }
  16014. createClass(PusherPresenceChannel, [{
  16015. key: 'here',
  16016. /**
  16017. * Register a callback to be called anytime the member list changes.
  16018. */
  16019. value: function here(callback) {
  16020. this.on('pusher:subscription_succeeded', function (data) {
  16021. callback(Object.keys(data.members).map(function (k) {
  16022. return data.members[k];
  16023. }));
  16024. });
  16025. return this;
  16026. }
  16027. /**
  16028. * Listen for someone joining the channel.
  16029. */
  16030. }, {
  16031. key: 'joining',
  16032. value: function joining(callback) {
  16033. this.on('pusher:member_added', function (member) {
  16034. callback(member.info);
  16035. });
  16036. return this;
  16037. }
  16038. /**
  16039. * Listen for someone leaving the channel.
  16040. */
  16041. }, {
  16042. key: 'leaving',
  16043. value: function leaving(callback) {
  16044. this.on('pusher:member_removed', function (member) {
  16045. callback(member.info);
  16046. });
  16047. return this;
  16048. }
  16049. /**
  16050. * Trigger client event on the channel.
  16051. */
  16052. }, {
  16053. key: 'whisper',
  16054. value: function whisper(eventName, data) {
  16055. this.pusher.channels.channels[this.name].trigger('client-' + eventName, data);
  16056. return this;
  16057. }
  16058. }]);
  16059. return PusherPresenceChannel;
  16060. }(PusherChannel);
  16061. /**
  16062. * This class represents a Socket.io channel.
  16063. */
  16064. var SocketIoChannel = function (_Channel) {
  16065. inherits(SocketIoChannel, _Channel);
  16066. /**
  16067. * Create a new class instance.
  16068. */
  16069. function SocketIoChannel(socket, name, options) {
  16070. classCallCheck(this, SocketIoChannel);
  16071. /**
  16072. * The event callbacks applied to the channel.
  16073. */
  16074. var _this = possibleConstructorReturn(this, (SocketIoChannel.__proto__ || Object.getPrototypeOf(SocketIoChannel)).call(this));
  16075. _this.events = {};
  16076. _this.name = name;
  16077. _this.socket = socket;
  16078. _this.options = options;
  16079. _this.eventFormatter = new EventFormatter(_this.options.namespace);
  16080. _this.subscribe();
  16081. _this.configureReconnector();
  16082. return _this;
  16083. }
  16084. /**
  16085. * Subscribe to a Socket.io channel.
  16086. */
  16087. createClass(SocketIoChannel, [{
  16088. key: 'subscribe',
  16089. value: function subscribe() {
  16090. this.socket.emit('subscribe', {
  16091. channel: this.name,
  16092. auth: this.options.auth || {}
  16093. });
  16094. }
  16095. /**
  16096. * Unsubscribe from channel and ubind event callbacks.
  16097. */
  16098. }, {
  16099. key: 'unsubscribe',
  16100. value: function unsubscribe() {
  16101. this.unbind();
  16102. this.socket.emit('unsubscribe', {
  16103. channel: this.name,
  16104. auth: this.options.auth || {}
  16105. });
  16106. }
  16107. /**
  16108. * Listen for an event on the channel instance.
  16109. */
  16110. }, {
  16111. key: 'listen',
  16112. value: function listen(event, callback) {
  16113. this.on(this.eventFormatter.format(event), callback);
  16114. return this;
  16115. }
  16116. /**
  16117. * Stop listening for an event on the channel instance.
  16118. */
  16119. }, {
  16120. key: 'stopListening',
  16121. value: function stopListening(event) {
  16122. var name = this.eventFormatter.format(event);
  16123. this.socket.removeListener(name);
  16124. delete this.events[name];
  16125. return this;
  16126. }
  16127. /**
  16128. * Bind the channel's socket to an event and store the callback.
  16129. */
  16130. }, {
  16131. key: 'on',
  16132. value: function on(event, callback) {
  16133. var _this2 = this;
  16134. var listener = function listener(channel, data) {
  16135. if (_this2.name == channel) {
  16136. callback(data);
  16137. }
  16138. };
  16139. this.socket.on(event, listener);
  16140. this.bind(event, listener);
  16141. }
  16142. /**
  16143. * Attach a 'reconnect' listener and bind the event.
  16144. */
  16145. }, {
  16146. key: 'configureReconnector',
  16147. value: function configureReconnector() {
  16148. var _this3 = this;
  16149. var listener = function listener() {
  16150. _this3.subscribe();
  16151. };
  16152. this.socket.on('reconnect', listener);
  16153. this.bind('reconnect', listener);
  16154. }
  16155. /**
  16156. * Bind the channel's socket to an event and store the callback.
  16157. */
  16158. }, {
  16159. key: 'bind',
  16160. value: function bind(event, callback) {
  16161. this.events[event] = this.events[event] || [];
  16162. this.events[event].push(callback);
  16163. }
  16164. /**
  16165. * Unbind the channel's socket from all stored event callbacks.
  16166. */
  16167. }, {
  16168. key: 'unbind',
  16169. value: function unbind() {
  16170. var _this4 = this;
  16171. Object.keys(this.events).forEach(function (event) {
  16172. _this4.events[event].forEach(function (callback) {
  16173. _this4.socket.removeListener(event, callback);
  16174. });
  16175. delete _this4.events[event];
  16176. });
  16177. }
  16178. }]);
  16179. return SocketIoChannel;
  16180. }(Channel);
  16181. /**
  16182. * This class represents a Socket.io presence channel.
  16183. */
  16184. var SocketIoPrivateChannel = function (_SocketIoChannel) {
  16185. inherits(SocketIoPrivateChannel, _SocketIoChannel);
  16186. function SocketIoPrivateChannel() {
  16187. classCallCheck(this, SocketIoPrivateChannel);
  16188. return possibleConstructorReturn(this, (SocketIoPrivateChannel.__proto__ || Object.getPrototypeOf(SocketIoPrivateChannel)).apply(this, arguments));
  16189. }
  16190. createClass(SocketIoPrivateChannel, [{
  16191. key: 'whisper',
  16192. /**
  16193. * Trigger client event on the channel.
  16194. */
  16195. value: function whisper(eventName, data) {
  16196. this.socket.emit('client event', {
  16197. channel: this.name,
  16198. event: 'client-' + eventName,
  16199. data: data
  16200. });
  16201. return this;
  16202. }
  16203. }]);
  16204. return SocketIoPrivateChannel;
  16205. }(SocketIoChannel);
  16206. /**
  16207. * This class represents a Socket.io presence channel.
  16208. */
  16209. var SocketIoPresenceChannel = function (_SocketIoPrivateChann) {
  16210. inherits(SocketIoPresenceChannel, _SocketIoPrivateChann);
  16211. function SocketIoPresenceChannel() {
  16212. classCallCheck(this, SocketIoPresenceChannel);
  16213. return possibleConstructorReturn(this, (SocketIoPresenceChannel.__proto__ || Object.getPrototypeOf(SocketIoPresenceChannel)).apply(this, arguments));
  16214. }
  16215. createClass(SocketIoPresenceChannel, [{
  16216. key: 'here',
  16217. /**
  16218. * Register a callback to be called anytime the member list changes.
  16219. */
  16220. value: function here(callback) {
  16221. this.on('presence:subscribed', function (members) {
  16222. callback(members.map(function (m) {
  16223. return m.user_info;
  16224. }));
  16225. });
  16226. return this;
  16227. }
  16228. /**
  16229. * Listen for someone joining the channel.
  16230. */
  16231. }, {
  16232. key: 'joining',
  16233. value: function joining(callback) {
  16234. this.on('presence:joining', function (member) {
  16235. return callback(member.user_info);
  16236. });
  16237. return this;
  16238. }
  16239. /**
  16240. * Listen for someone leaving the channel.
  16241. */
  16242. }, {
  16243. key: 'leaving',
  16244. value: function leaving(callback) {
  16245. this.on('presence:leaving', function (member) {
  16246. return callback(member.user_info);
  16247. });
  16248. return this;
  16249. }
  16250. }]);
  16251. return SocketIoPresenceChannel;
  16252. }(SocketIoPrivateChannel);
  16253. /**
  16254. * This class represents a null channel.
  16255. */
  16256. var NullChannel = function (_Channel) {
  16257. inherits(NullChannel, _Channel);
  16258. function NullChannel() {
  16259. classCallCheck(this, NullChannel);
  16260. return possibleConstructorReturn(this, (NullChannel.__proto__ || Object.getPrototypeOf(NullChannel)).apply(this, arguments));
  16261. }
  16262. createClass(NullChannel, [{
  16263. key: 'subscribe',
  16264. /**
  16265. * Subscribe to a channel.
  16266. */
  16267. value: function subscribe() {}
  16268. //
  16269. /**
  16270. * Unsubscribe from a channel.
  16271. */
  16272. }, {
  16273. key: 'unsubscribe',
  16274. value: function unsubscribe() {}
  16275. //
  16276. /**
  16277. * Listen for an event on the channel instance.
  16278. */
  16279. }, {
  16280. key: 'listen',
  16281. value: function listen(event, callback) {
  16282. return this;
  16283. }
  16284. /**
  16285. * Stop listening for an event on the channel instance.
  16286. */
  16287. }, {
  16288. key: 'stopListening',
  16289. value: function stopListening(event) {
  16290. return this;
  16291. }
  16292. /**
  16293. * Bind a channel to an event.
  16294. */
  16295. }, {
  16296. key: 'on',
  16297. value: function on(event, callback) {
  16298. return this;
  16299. }
  16300. }]);
  16301. return NullChannel;
  16302. }(Channel);
  16303. /**
  16304. * This class represents a null private channel.
  16305. */
  16306. var NullPrivateChannel = function (_NullChannel) {
  16307. inherits(NullPrivateChannel, _NullChannel);
  16308. function NullPrivateChannel() {
  16309. classCallCheck(this, NullPrivateChannel);
  16310. return possibleConstructorReturn(this, (NullPrivateChannel.__proto__ || Object.getPrototypeOf(NullPrivateChannel)).apply(this, arguments));
  16311. }
  16312. createClass(NullPrivateChannel, [{
  16313. key: 'whisper',
  16314. /**
  16315. * Trigger client event on the channel.
  16316. */
  16317. value: function whisper(eventName, data) {
  16318. return this;
  16319. }
  16320. }]);
  16321. return NullPrivateChannel;
  16322. }(NullChannel);
  16323. /**
  16324. * This class represents a null presence channel.
  16325. */
  16326. var NullPresenceChannel = function (_NullChannel) {
  16327. inherits(NullPresenceChannel, _NullChannel);
  16328. function NullPresenceChannel() {
  16329. classCallCheck(this, NullPresenceChannel);
  16330. return possibleConstructorReturn(this, (NullPresenceChannel.__proto__ || Object.getPrototypeOf(NullPresenceChannel)).apply(this, arguments));
  16331. }
  16332. createClass(NullPresenceChannel, [{
  16333. key: 'here',
  16334. /**
  16335. * Register a callback to be called anytime the member list changes.
  16336. */
  16337. value: function here(callback) {
  16338. return this;
  16339. }
  16340. /**
  16341. * Listen for someone joining the channel.
  16342. */
  16343. }, {
  16344. key: 'joining',
  16345. value: function joining(callback) {
  16346. return this;
  16347. }
  16348. /**
  16349. * Listen for someone leaving the channel.
  16350. */
  16351. }, {
  16352. key: 'leaving',
  16353. value: function leaving(callback) {
  16354. return this;
  16355. }
  16356. /**
  16357. * Trigger client event on the channel.
  16358. */
  16359. }, {
  16360. key: 'whisper',
  16361. value: function whisper(eventName, data) {
  16362. return this;
  16363. }
  16364. }]);
  16365. return NullPresenceChannel;
  16366. }(NullChannel);
  16367. /**
  16368. * This class creates a connector to Pusher.
  16369. */
  16370. var PusherConnector = function (_Connector) {
  16371. inherits(PusherConnector, _Connector);
  16372. function PusherConnector() {
  16373. classCallCheck(this, PusherConnector);
  16374. /**
  16375. * All of the subscribed channel names.
  16376. */
  16377. var _this = possibleConstructorReturn(this, (PusherConnector.__proto__ || Object.getPrototypeOf(PusherConnector)).apply(this, arguments));
  16378. _this.channels = {};
  16379. return _this;
  16380. }
  16381. /**
  16382. * Create a fresh Pusher connection.
  16383. */
  16384. createClass(PusherConnector, [{
  16385. key: 'connect',
  16386. value: function connect() {
  16387. if (typeof this.options.client !== 'undefined') {
  16388. this.pusher = this.options.client;
  16389. } else {
  16390. this.pusher = new Pusher(this.options.key, this.options);
  16391. }
  16392. }
  16393. /**
  16394. * Listen for an event on a channel instance.
  16395. */
  16396. }, {
  16397. key: 'listen',
  16398. value: function listen(name, event, callback) {
  16399. return this.channel(name).listen(event, callback);
  16400. }
  16401. /**
  16402. * Get a channel instance by name.
  16403. */
  16404. }, {
  16405. key: 'channel',
  16406. value: function channel(name) {
  16407. if (!this.channels[name]) {
  16408. this.channels[name] = new PusherChannel(this.pusher, name, this.options);
  16409. }
  16410. return this.channels[name];
  16411. }
  16412. /**
  16413. * Get a private channel instance by name.
  16414. */
  16415. }, {
  16416. key: 'privateChannel',
  16417. value: function privateChannel(name) {
  16418. if (!this.channels['private-' + name]) {
  16419. this.channels['private-' + name] = new PusherPrivateChannel(this.pusher, 'private-' + name, this.options);
  16420. }
  16421. return this.channels['private-' + name];
  16422. }
  16423. /**
  16424. * Get a presence channel instance by name.
  16425. */
  16426. }, {
  16427. key: 'presenceChannel',
  16428. value: function presenceChannel(name) {
  16429. if (!this.channels['presence-' + name]) {
  16430. this.channels['presence-' + name] = new PusherPresenceChannel(this.pusher, 'presence-' + name, this.options);
  16431. }
  16432. return this.channels['presence-' + name];
  16433. }
  16434. /**
  16435. * Leave the given channel, as well as its private and presence variants.
  16436. */
  16437. }, {
  16438. key: 'leave',
  16439. value: function leave(name) {
  16440. var _this2 = this;
  16441. var channels = [name, 'private-' + name, 'presence-' + name];
  16442. channels.forEach(function (name, index) {
  16443. _this2.leaveChannel(name);
  16444. });
  16445. }
  16446. /**
  16447. * Leave the given channel.
  16448. */
  16449. }, {
  16450. key: 'leaveChannel',
  16451. value: function leaveChannel(name) {
  16452. if (this.channels[name]) {
  16453. this.channels[name].unsubscribe();
  16454. delete this.channels[name];
  16455. }
  16456. }
  16457. /**
  16458. * Get the socket ID for the connection.
  16459. */
  16460. }, {
  16461. key: 'socketId',
  16462. value: function socketId() {
  16463. return this.pusher.connection.socket_id;
  16464. }
  16465. /**
  16466. * Disconnect Pusher connection.
  16467. */
  16468. }, {
  16469. key: 'disconnect',
  16470. value: function disconnect() {
  16471. this.pusher.disconnect();
  16472. }
  16473. }]);
  16474. return PusherConnector;
  16475. }(Connector);
  16476. /**
  16477. * This class creates a connnector to a Socket.io server.
  16478. */
  16479. var SocketIoConnector = function (_Connector) {
  16480. inherits(SocketIoConnector, _Connector);
  16481. function SocketIoConnector() {
  16482. classCallCheck(this, SocketIoConnector);
  16483. /**
  16484. * All of the subscribed channel names.
  16485. */
  16486. var _this = possibleConstructorReturn(this, (SocketIoConnector.__proto__ || Object.getPrototypeOf(SocketIoConnector)).apply(this, arguments));
  16487. _this.channels = {};
  16488. return _this;
  16489. }
  16490. /**
  16491. * Create a fresh Socket.io connection.
  16492. */
  16493. createClass(SocketIoConnector, [{
  16494. key: 'connect',
  16495. value: function connect() {
  16496. var io = this.getSocketIO();
  16497. this.socket = io(this.options.host, this.options);
  16498. return this.socket;
  16499. }
  16500. /**
  16501. * Get socket.io module from global scope or options.
  16502. */
  16503. }, {
  16504. key: 'getSocketIO',
  16505. value: function getSocketIO() {
  16506. if (typeof this.options.client !== 'undefined') {
  16507. return this.options.client;
  16508. }
  16509. if (typeof io !== 'undefined') {
  16510. return io;
  16511. }
  16512. throw new Error('Socket.io client not found. Should be globally available or passed via options.client');
  16513. }
  16514. /**
  16515. * Listen for an event on a channel instance.
  16516. */
  16517. }, {
  16518. key: 'listen',
  16519. value: function listen(name, event, callback) {
  16520. return this.channel(name).listen(event, callback);
  16521. }
  16522. /**
  16523. * Get a channel instance by name.
  16524. */
  16525. }, {
  16526. key: 'channel',
  16527. value: function channel(name) {
  16528. if (!this.channels[name]) {
  16529. this.channels[name] = new SocketIoChannel(this.socket, name, this.options);
  16530. }
  16531. return this.channels[name];
  16532. }
  16533. /**
  16534. * Get a private channel instance by name.
  16535. */
  16536. }, {
  16537. key: 'privateChannel',
  16538. value: function privateChannel(name) {
  16539. if (!this.channels['private-' + name]) {
  16540. this.channels['private-' + name] = new SocketIoPrivateChannel(this.socket, 'private-' + name, this.options);
  16541. }
  16542. return this.channels['private-' + name];
  16543. }
  16544. /**
  16545. * Get a presence channel instance by name.
  16546. */
  16547. }, {
  16548. key: 'presenceChannel',
  16549. value: function presenceChannel(name) {
  16550. if (!this.channels['presence-' + name]) {
  16551. this.channels['presence-' + name] = new SocketIoPresenceChannel(this.socket, 'presence-' + name, this.options);
  16552. }
  16553. return this.channels['presence-' + name];
  16554. }
  16555. /**
  16556. * Leave the given channel, as well as its private and presence variants.
  16557. */
  16558. }, {
  16559. key: 'leave',
  16560. value: function leave(name) {
  16561. var _this2 = this;
  16562. var channels = [name, 'private-' + name, 'presence-' + name];
  16563. channels.forEach(function (name) {
  16564. _this2.leaveChannel(name);
  16565. });
  16566. }
  16567. /**
  16568. * Leave the given channel.
  16569. */
  16570. }, {
  16571. key: 'leaveChannel',
  16572. value: function leaveChannel(name) {
  16573. if (this.channels[name]) {
  16574. this.channels[name].unsubscribe();
  16575. delete this.channels[name];
  16576. }
  16577. }
  16578. /**
  16579. * Get the socket ID for the connection.
  16580. */
  16581. }, {
  16582. key: 'socketId',
  16583. value: function socketId() {
  16584. return this.socket.id;
  16585. }
  16586. /**
  16587. * Disconnect Socketio connection.
  16588. */
  16589. }, {
  16590. key: 'disconnect',
  16591. value: function disconnect() {
  16592. this.socket.disconnect();
  16593. }
  16594. }]);
  16595. return SocketIoConnector;
  16596. }(Connector);
  16597. /**
  16598. * This class creates a null connector.
  16599. */
  16600. var NullConnector = function (_Connector) {
  16601. inherits(NullConnector, _Connector);
  16602. function NullConnector() {
  16603. classCallCheck(this, NullConnector);
  16604. /**
  16605. * All of the subscribed channel names.
  16606. */
  16607. var _this = possibleConstructorReturn(this, (NullConnector.__proto__ || Object.getPrototypeOf(NullConnector)).apply(this, arguments));
  16608. _this.channels = {};
  16609. return _this;
  16610. }
  16611. /**
  16612. * Create a fresh connection.
  16613. */
  16614. createClass(NullConnector, [{
  16615. key: 'connect',
  16616. value: function connect() {}
  16617. //
  16618. /**
  16619. * Listen for an event on a channel instance.
  16620. */
  16621. }, {
  16622. key: 'listen',
  16623. value: function listen(name, event, callback) {
  16624. return new NullChannel();
  16625. }
  16626. /**
  16627. * Get a channel instance by name.
  16628. */
  16629. }, {
  16630. key: 'channel',
  16631. value: function channel(name) {
  16632. return new NullChannel();
  16633. }
  16634. /**
  16635. * Get a private channel instance by name.
  16636. */
  16637. }, {
  16638. key: 'privateChannel',
  16639. value: function privateChannel(name) {
  16640. return new NullPrivateChannel();
  16641. }
  16642. /**
  16643. * Get a presence channel instance by name.
  16644. */
  16645. }, {
  16646. key: 'presenceChannel',
  16647. value: function presenceChannel(name) {
  16648. return new NullPresenceChannel();
  16649. }
  16650. /**
  16651. * Leave the given channel, as well as its private and presence variants.
  16652. */
  16653. }, {
  16654. key: 'leave',
  16655. value: function leave(name) {}
  16656. //
  16657. /**
  16658. * Leave the given channel.
  16659. */
  16660. }, {
  16661. key: 'leaveChannel',
  16662. value: function leaveChannel(name) {}
  16663. //
  16664. /**
  16665. * Get the socket ID for the connection.
  16666. */
  16667. }, {
  16668. key: 'socketId',
  16669. value: function socketId() {
  16670. return 'fake-socket-id';
  16671. }
  16672. /**
  16673. * Disconnect the connection.
  16674. */
  16675. }, {
  16676. key: 'disconnect',
  16677. value: function disconnect() {
  16678. //
  16679. }
  16680. }]);
  16681. return NullConnector;
  16682. }(Connector);
  16683. /**
  16684. * This class is the primary API for interacting with broadcasting.
  16685. */
  16686. var Echo = function () {
  16687. /**
  16688. * Create a new class instance.
  16689. */
  16690. function Echo(options) {
  16691. classCallCheck(this, Echo);
  16692. this.options = options;
  16693. this.connect();
  16694. if (!this.options.withoutInterceptors) {
  16695. this.registerInterceptors();
  16696. }
  16697. }
  16698. /**
  16699. * Get a channel instance by name.
  16700. */
  16701. createClass(Echo, [{
  16702. key: 'channel',
  16703. value: function channel(_channel) {
  16704. return this.connector.channel(_channel);
  16705. }
  16706. /**
  16707. * Create a new connection.
  16708. */
  16709. }, {
  16710. key: 'connect',
  16711. value: function connect() {
  16712. if (this.options.broadcaster == 'pusher') {
  16713. this.connector = new PusherConnector(this.options);
  16714. } else if (this.options.broadcaster == 'socket.io') {
  16715. this.connector = new SocketIoConnector(this.options);
  16716. } else if (this.options.broadcaster == 'null') {
  16717. this.connector = new NullConnector(this.options);
  16718. } else if (typeof this.options.broadcaster == 'function') {
  16719. this.connector = new this.options.broadcaster(this.options);
  16720. }
  16721. }
  16722. /**
  16723. * Disconnect from the Echo server.
  16724. */
  16725. }, {
  16726. key: 'disconnect',
  16727. value: function disconnect() {
  16728. this.connector.disconnect();
  16729. }
  16730. /**
  16731. * Get a presence channel instance by name.
  16732. */
  16733. }, {
  16734. key: 'join',
  16735. value: function join(channel) {
  16736. return this.connector.presenceChannel(channel);
  16737. }
  16738. /**
  16739. * Leave the given channel, as well as its private and presence variants.
  16740. */
  16741. }, {
  16742. key: 'leave',
  16743. value: function leave(channel) {
  16744. this.connector.leave(channel);
  16745. }
  16746. /**
  16747. * Leave the given channel.
  16748. */
  16749. }, {
  16750. key: 'leaveChannel',
  16751. value: function leaveChannel(channel) {
  16752. this.connector.leaveChannel(channel);
  16753. }
  16754. /**
  16755. * Listen for an event on a channel instance.
  16756. */
  16757. }, {
  16758. key: 'listen',
  16759. value: function listen(channel, event, callback) {
  16760. return this.connector.listen(channel, event, callback);
  16761. }
  16762. /**
  16763. * Get a private channel instance by name.
  16764. */
  16765. }, {
  16766. key: 'private',
  16767. value: function _private(channel) {
  16768. return this.connector.privateChannel(channel);
  16769. }
  16770. /**
  16771. * Get the Socket ID for the connection.
  16772. */
  16773. }, {
  16774. key: 'socketId',
  16775. value: function socketId() {
  16776. return this.connector.socketId();
  16777. }
  16778. /**
  16779. * Register 3rd party request interceptiors. These are used to automatically
  16780. * send a connections socket id to a Laravel app with a X-Socket-Id header.
  16781. */
  16782. }, {
  16783. key: 'registerInterceptors',
  16784. value: function registerInterceptors() {
  16785. if (typeof Vue === 'function' && Vue.http) {
  16786. this.registerVueRequestInterceptor();
  16787. }
  16788. if (typeof axios === 'function') {
  16789. this.registerAxiosRequestInterceptor();
  16790. }
  16791. if (typeof jQuery === 'function') {
  16792. this.registerjQueryAjaxSetup();
  16793. }
  16794. }
  16795. /**
  16796. * Register a Vue HTTP interceptor to add the X-Socket-ID header.
  16797. */
  16798. }, {
  16799. key: 'registerVueRequestInterceptor',
  16800. value: function registerVueRequestInterceptor() {
  16801. var _this = this;
  16802. Vue.http.interceptors.push(function (request, next) {
  16803. if (_this.socketId()) {
  16804. request.headers.set('X-Socket-ID', _this.socketId());
  16805. }
  16806. next();
  16807. });
  16808. }
  16809. /**
  16810. * Register an Axios HTTP interceptor to add the X-Socket-ID header.
  16811. */
  16812. }, {
  16813. key: 'registerAxiosRequestInterceptor',
  16814. value: function registerAxiosRequestInterceptor() {
  16815. var _this2 = this;
  16816. axios.interceptors.request.use(function (config) {
  16817. if (_this2.socketId()) {
  16818. config.headers['X-Socket-Id'] = _this2.socketId();
  16819. }
  16820. return config;
  16821. });
  16822. }
  16823. /**
  16824. * Register jQuery AjaxPrefilter to add the X-Socket-ID header.
  16825. */
  16826. }, {
  16827. key: 'registerjQueryAjaxSetup',
  16828. value: function registerjQueryAjaxSetup() {
  16829. var _this3 = this;
  16830. if (typeof jQuery.ajax != 'undefined') {
  16831. jQuery.ajaxPrefilter(function (options, originalOptions, xhr) {
  16832. if (_this3.socketId()) {
  16833. xhr.setRequestHeader('X-Socket-Id', _this3.socketId());
  16834. }
  16835. });
  16836. }
  16837. }
  16838. }]);
  16839. return Echo;
  16840. }();
  16841. /* harmony default export */ __webpack_exports__["default"] = (Echo);
  16842. /***/ }),
  16843. /***/ "./node_modules/lodash/lodash.js":
  16844. /*!***************************************!*\
  16845. !*** ./node_modules/lodash/lodash.js ***!
  16846. \***************************************/
  16847. /*! no static exports found */
  16848. /***/ (function(module, exports, __webpack_require__) {
  16849. /* WEBPACK VAR INJECTION */(function(global, module) {var __WEBPACK_AMD_DEFINE_RESULT__;/**
  16850. * @license
  16851. * Lodash <https://lodash.com/>
  16852. * Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
  16853. * Released under MIT license <https://lodash.com/license>
  16854. * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
  16855. * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
  16856. */
  16857. ;(function() {
  16858. /** Used as a safe reference for `undefined` in pre-ES5 environments. */
  16859. var undefined;
  16860. /** Used as the semantic version number. */
  16861. var VERSION = '4.17.15';
  16862. /** Used as the size to enable large array optimizations. */
  16863. var LARGE_ARRAY_SIZE = 200;
  16864. /** Error message constants. */
  16865. var CORE_ERROR_TEXT = 'Unsupported core-js use. Try https://npms.io/search?q=ponyfill.',
  16866. FUNC_ERROR_TEXT = 'Expected a function';
  16867. /** Used to stand-in for `undefined` hash values. */
  16868. var HASH_UNDEFINED = '__lodash_hash_undefined__';
  16869. /** Used as the maximum memoize cache size. */
  16870. var MAX_MEMOIZE_SIZE = 500;
  16871. /** Used as the internal argument placeholder. */
  16872. var PLACEHOLDER = '__lodash_placeholder__';
  16873. /** Used to compose bitmasks for cloning. */
  16874. var CLONE_DEEP_FLAG = 1,
  16875. CLONE_FLAT_FLAG = 2,
  16876. CLONE_SYMBOLS_FLAG = 4;
  16877. /** Used to compose bitmasks for value comparisons. */
  16878. var COMPARE_PARTIAL_FLAG = 1,
  16879. COMPARE_UNORDERED_FLAG = 2;
  16880. /** Used to compose bitmasks for function metadata. */
  16881. var WRAP_BIND_FLAG = 1,
  16882. WRAP_BIND_KEY_FLAG = 2,
  16883. WRAP_CURRY_BOUND_FLAG = 4,
  16884. WRAP_CURRY_FLAG = 8,
  16885. WRAP_CURRY_RIGHT_FLAG = 16,
  16886. WRAP_PARTIAL_FLAG = 32,
  16887. WRAP_PARTIAL_RIGHT_FLAG = 64,
  16888. WRAP_ARY_FLAG = 128,
  16889. WRAP_REARG_FLAG = 256,
  16890. WRAP_FLIP_FLAG = 512;
  16891. /** Used as default options for `_.truncate`. */
  16892. var DEFAULT_TRUNC_LENGTH = 30,
  16893. DEFAULT_TRUNC_OMISSION = '...';
  16894. /** Used to detect hot functions by number of calls within a span of milliseconds. */
  16895. var HOT_COUNT = 800,
  16896. HOT_SPAN = 16;
  16897. /** Used to indicate the type of lazy iteratees. */
  16898. var LAZY_FILTER_FLAG = 1,
  16899. LAZY_MAP_FLAG = 2,
  16900. LAZY_WHILE_FLAG = 3;
  16901. /** Used as references for various `Number` constants. */
  16902. var INFINITY = 1 / 0,
  16903. MAX_SAFE_INTEGER = 9007199254740991,
  16904. MAX_INTEGER = 1.7976931348623157e+308,
  16905. NAN = 0 / 0;
  16906. /** Used as references for the maximum length and index of an array. */
  16907. var MAX_ARRAY_LENGTH = 4294967295,
  16908. MAX_ARRAY_INDEX = MAX_ARRAY_LENGTH - 1,
  16909. HALF_MAX_ARRAY_LENGTH = MAX_ARRAY_LENGTH >>> 1;
  16910. /** Used to associate wrap methods with their bit flags. */
  16911. var wrapFlags = [
  16912. ['ary', WRAP_ARY_FLAG],
  16913. ['bind', WRAP_BIND_FLAG],
  16914. ['bindKey', WRAP_BIND_KEY_FLAG],
  16915. ['curry', WRAP_CURRY_FLAG],
  16916. ['curryRight', WRAP_CURRY_RIGHT_FLAG],
  16917. ['flip', WRAP_FLIP_FLAG],
  16918. ['partial', WRAP_PARTIAL_FLAG],
  16919. ['partialRight', WRAP_PARTIAL_RIGHT_FLAG],
  16920. ['rearg', WRAP_REARG_FLAG]
  16921. ];
  16922. /** `Object#toString` result references. */
  16923. var argsTag = '[object Arguments]',
  16924. arrayTag = '[object Array]',
  16925. asyncTag = '[object AsyncFunction]',
  16926. boolTag = '[object Boolean]',
  16927. dateTag = '[object Date]',
  16928. domExcTag = '[object DOMException]',
  16929. errorTag = '[object Error]',
  16930. funcTag = '[object Function]',
  16931. genTag = '[object GeneratorFunction]',
  16932. mapTag = '[object Map]',
  16933. numberTag = '[object Number]',
  16934. nullTag = '[object Null]',
  16935. objectTag = '[object Object]',
  16936. promiseTag = '[object Promise]',
  16937. proxyTag = '[object Proxy]',
  16938. regexpTag = '[object RegExp]',
  16939. setTag = '[object Set]',
  16940. stringTag = '[object String]',
  16941. symbolTag = '[object Symbol]',
  16942. undefinedTag = '[object Undefined]',
  16943. weakMapTag = '[object WeakMap]',
  16944. weakSetTag = '[object WeakSet]';
  16945. var arrayBufferTag = '[object ArrayBuffer]',
  16946. dataViewTag = '[object DataView]',
  16947. float32Tag = '[object Float32Array]',
  16948. float64Tag = '[object Float64Array]',
  16949. int8Tag = '[object Int8Array]',
  16950. int16Tag = '[object Int16Array]',
  16951. int32Tag = '[object Int32Array]',
  16952. uint8Tag = '[object Uint8Array]',
  16953. uint8ClampedTag = '[object Uint8ClampedArray]',
  16954. uint16Tag = '[object Uint16Array]',
  16955. uint32Tag = '[object Uint32Array]';
  16956. /** Used to match empty string literals in compiled template source. */
  16957. var reEmptyStringLeading = /\b__p \+= '';/g,
  16958. reEmptyStringMiddle = /\b(__p \+=) '' \+/g,
  16959. reEmptyStringTrailing = /(__e\(.*?\)|\b__t\)) \+\n'';/g;
  16960. /** Used to match HTML entities and HTML characters. */
  16961. var reEscapedHtml = /&(?:amp|lt|gt|quot|#39);/g,
  16962. reUnescapedHtml = /[&<>"']/g,
  16963. reHasEscapedHtml = RegExp(reEscapedHtml.source),
  16964. reHasUnescapedHtml = RegExp(reUnescapedHtml.source);
  16965. /** Used to match template delimiters. */
  16966. var reEscape = /<%-([\s\S]+?)%>/g,
  16967. reEvaluate = /<%([\s\S]+?)%>/g,
  16968. reInterpolate = /<%=([\s\S]+?)%>/g;
  16969. /** Used to match property names within property paths. */
  16970. var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,
  16971. reIsPlainProp = /^\w*$/,
  16972. rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;
  16973. /**
  16974. * Used to match `RegExp`
  16975. * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
  16976. */
  16977. var reRegExpChar = /[\\^$.*+?()[\]{}|]/g,
  16978. reHasRegExpChar = RegExp(reRegExpChar.source);
  16979. /** Used to match leading and trailing whitespace. */
  16980. var reTrim = /^\s+|\s+$/g,
  16981. reTrimStart = /^\s+/,
  16982. reTrimEnd = /\s+$/;
  16983. /** Used to match wrap detail comments. */
  16984. var reWrapComment = /\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,
  16985. reWrapDetails = /\{\n\/\* \[wrapped with (.+)\] \*/,
  16986. reSplitDetails = /,? & /;
  16987. /** Used to match words composed of alphanumeric characters. */
  16988. var reAsciiWord = /[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;
  16989. /** Used to match backslashes in property paths. */
  16990. var reEscapeChar = /\\(\\)?/g;
  16991. /**
  16992. * Used to match
  16993. * [ES template delimiters](http://ecma-international.org/ecma-262/7.0/#sec-template-literal-lexical-components).
  16994. */
  16995. var reEsTemplate = /\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g;
  16996. /** Used to match `RegExp` flags from their coerced string values. */
  16997. var reFlags = /\w*$/;
  16998. /** Used to detect bad signed hexadecimal string values. */
  16999. var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
  17000. /** Used to detect binary string values. */
  17001. var reIsBinary = /^0b[01]+$/i;
  17002. /** Used to detect host constructors (Safari). */
  17003. var reIsHostCtor = /^\[object .+?Constructor\]$/;
  17004. /** Used to detect octal string values. */
  17005. var reIsOctal = /^0o[0-7]+$/i;
  17006. /** Used to detect unsigned integer values. */
  17007. var reIsUint = /^(?:0|[1-9]\d*)$/;
  17008. /** Used to match Latin Unicode letters (excluding mathematical operators). */
  17009. var reLatin = /[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g;
  17010. /** Used to ensure capturing order of template delimiters. */
  17011. var reNoMatch = /($^)/;
  17012. /** Used to match unescaped characters in compiled string literals. */
  17013. var reUnescapedString = /['\n\r\u2028\u2029\\]/g;
  17014. /** Used to compose unicode character classes. */
  17015. var rsAstralRange = '\\ud800-\\udfff',
  17016. rsComboMarksRange = '\\u0300-\\u036f',
  17017. reComboHalfMarksRange = '\\ufe20-\\ufe2f',
  17018. rsComboSymbolsRange = '\\u20d0-\\u20ff',
  17019. rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange,
  17020. rsDingbatRange = '\\u2700-\\u27bf',
  17021. rsLowerRange = 'a-z\\xdf-\\xf6\\xf8-\\xff',
  17022. rsMathOpRange = '\\xac\\xb1\\xd7\\xf7',
  17023. rsNonCharRange = '\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf',
  17024. rsPunctuationRange = '\\u2000-\\u206f',
  17025. 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',
  17026. rsUpperRange = 'A-Z\\xc0-\\xd6\\xd8-\\xde',
  17027. rsVarRange = '\\ufe0e\\ufe0f',
  17028. rsBreakRange = rsMathOpRange + rsNonCharRange + rsPunctuationRange + rsSpaceRange;
  17029. /** Used to compose unicode capture groups. */
  17030. var rsApos = "['\u2019]",
  17031. rsAstral = '[' + rsAstralRange + ']',
  17032. rsBreak = '[' + rsBreakRange + ']',
  17033. rsCombo = '[' + rsComboRange + ']',
  17034. rsDigits = '\\d+',
  17035. rsDingbat = '[' + rsDingbatRange + ']',
  17036. rsLower = '[' + rsLowerRange + ']',
  17037. rsMisc = '[^' + rsAstralRange + rsBreakRange + rsDigits + rsDingbatRange + rsLowerRange + rsUpperRange + ']',
  17038. rsFitz = '\\ud83c[\\udffb-\\udfff]',
  17039. rsModifier = '(?:' + rsCombo + '|' + rsFitz + ')',
  17040. rsNonAstral = '[^' + rsAstralRange + ']',
  17041. rsRegional = '(?:\\ud83c[\\udde6-\\uddff]){2}',
  17042. rsSurrPair = '[\\ud800-\\udbff][\\udc00-\\udfff]',
  17043. rsUpper = '[' + rsUpperRange + ']',
  17044. rsZWJ = '\\u200d';
  17045. /** Used to compose unicode regexes. */
  17046. var rsMiscLower = '(?:' + rsLower + '|' + rsMisc + ')',
  17047. rsMiscUpper = '(?:' + rsUpper + '|' + rsMisc + ')',
  17048. rsOptContrLower = '(?:' + rsApos + '(?:d|ll|m|re|s|t|ve))?',
  17049. rsOptContrUpper = '(?:' + rsApos + '(?:D|LL|M|RE|S|T|VE))?',
  17050. reOptMod = rsModifier + '?',
  17051. rsOptVar = '[' + rsVarRange + ']?',
  17052. rsOptJoin = '(?:' + rsZWJ + '(?:' + [rsNonAstral, rsRegional, rsSurrPair].join('|') + ')' + rsOptVar + reOptMod + ')*',
  17053. rsOrdLower = '\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])',
  17054. rsOrdUpper = '\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])',
  17055. rsSeq = rsOptVar + reOptMod + rsOptJoin,
  17056. rsEmoji = '(?:' + [rsDingbat, rsRegional, rsSurrPair].join('|') + ')' + rsSeq,
  17057. rsSymbol = '(?:' + [rsNonAstral + rsCombo + '?', rsCombo, rsRegional, rsSurrPair, rsAstral].join('|') + ')';
  17058. /** Used to match apostrophes. */
  17059. var reApos = RegExp(rsApos, 'g');
  17060. /**
  17061. * Used to match [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks) and
  17062. * [combining diacritical marks for symbols](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks_for_Symbols).
  17063. */
  17064. var reComboMark = RegExp(rsCombo, 'g');
  17065. /** Used to match [string symbols](https://mathiasbynens.be/notes/javascript-unicode). */
  17066. var reUnicode = RegExp(rsFitz + '(?=' + rsFitz + ')|' + rsSymbol + rsSeq, 'g');
  17067. /** Used to match complex or compound words. */
  17068. var reUnicodeWord = RegExp([
  17069. rsUpper + '?' + rsLower + '+' + rsOptContrLower + '(?=' + [rsBreak, rsUpper, '$'].join('|') + ')',
  17070. rsMiscUpper + '+' + rsOptContrUpper + '(?=' + [rsBreak, rsUpper + rsMiscLower, '$'].join('|') + ')',
  17071. rsUpper + '?' + rsMiscLower + '+' + rsOptContrLower,
  17072. rsUpper + '+' + rsOptContrUpper,
  17073. rsOrdUpper,
  17074. rsOrdLower,
  17075. rsDigits,
  17076. rsEmoji
  17077. ].join('|'), 'g');
  17078. /** 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/). */
  17079. var reHasUnicode = RegExp('[' + rsZWJ + rsAstralRange + rsComboRange + rsVarRange + ']');
  17080. /** Used to detect strings that need a more robust regexp to match words. */
  17081. 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 ]/;
  17082. /** Used to assign default `context` object properties. */
  17083. var contextProps = [
  17084. 'Array', 'Buffer', 'DataView', 'Date', 'Error', 'Float32Array', 'Float64Array',
  17085. 'Function', 'Int8Array', 'Int16Array', 'Int32Array', 'Map', 'Math', 'Object',
  17086. 'Promise', 'RegExp', 'Set', 'String', 'Symbol', 'TypeError', 'Uint8Array',
  17087. 'Uint8ClampedArray', 'Uint16Array', 'Uint32Array', 'WeakMap',
  17088. '_', 'clearTimeout', 'isFinite', 'parseInt', 'setTimeout'
  17089. ];
  17090. /** Used to make template sourceURLs easier to identify. */
  17091. var templateCounter = -1;
  17092. /** Used to identify `toStringTag` values of typed arrays. */
  17093. var typedArrayTags = {};
  17094. typedArrayTags[float32Tag] = typedArrayTags[float64Tag] =
  17095. typedArrayTags[int8Tag] = typedArrayTags[int16Tag] =
  17096. typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =
  17097. typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =
  17098. typedArrayTags[uint32Tag] = true;
  17099. typedArrayTags[argsTag] = typedArrayTags[arrayTag] =
  17100. typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] =
  17101. typedArrayTags[dataViewTag] = typedArrayTags[dateTag] =
  17102. typedArrayTags[errorTag] = typedArrayTags[funcTag] =
  17103. typedArrayTags[mapTag] = typedArrayTags[numberTag] =
  17104. typedArrayTags[objectTag] = typedArrayTags[regexpTag] =
  17105. typedArrayTags[setTag] = typedArrayTags[stringTag] =
  17106. typedArrayTags[weakMapTag] = false;
  17107. /** Used to identify `toStringTag` values supported by `_.clone`. */
  17108. var cloneableTags = {};
  17109. cloneableTags[argsTag] = cloneableTags[arrayTag] =
  17110. cloneableTags[arrayBufferTag] = cloneableTags[dataViewTag] =
  17111. cloneableTags[boolTag] = cloneableTags[dateTag] =
  17112. cloneableTags[float32Tag] = cloneableTags[float64Tag] =
  17113. cloneableTags[int8Tag] = cloneableTags[int16Tag] =
  17114. cloneableTags[int32Tag] = cloneableTags[mapTag] =
  17115. cloneableTags[numberTag] = cloneableTags[objectTag] =
  17116. cloneableTags[regexpTag] = cloneableTags[setTag] =
  17117. cloneableTags[stringTag] = cloneableTags[symbolTag] =
  17118. cloneableTags[uint8Tag] = cloneableTags[uint8ClampedTag] =
  17119. cloneableTags[uint16Tag] = cloneableTags[uint32Tag] = true;
  17120. cloneableTags[errorTag] = cloneableTags[funcTag] =
  17121. cloneableTags[weakMapTag] = false;
  17122. /** Used to map Latin Unicode letters to basic Latin letters. */
  17123. var deburredLetters = {
  17124. // Latin-1 Supplement block.
  17125. '\xc0': 'A', '\xc1': 'A', '\xc2': 'A', '\xc3': 'A', '\xc4': 'A', '\xc5': 'A',
  17126. '\xe0': 'a', '\xe1': 'a', '\xe2': 'a', '\xe3': 'a', '\xe4': 'a', '\xe5': 'a',
  17127. '\xc7': 'C', '\xe7': 'c',
  17128. '\xd0': 'D', '\xf0': 'd',
  17129. '\xc8': 'E', '\xc9': 'E', '\xca': 'E', '\xcb': 'E',
  17130. '\xe8': 'e', '\xe9': 'e', '\xea': 'e', '\xeb': 'e',
  17131. '\xcc': 'I', '\xcd': 'I', '\xce': 'I', '\xcf': 'I',
  17132. '\xec': 'i', '\xed': 'i', '\xee': 'i', '\xef': 'i',
  17133. '\xd1': 'N', '\xf1': 'n',
  17134. '\xd2': 'O', '\xd3': 'O', '\xd4': 'O', '\xd5': 'O', '\xd6': 'O', '\xd8': 'O',
  17135. '\xf2': 'o', '\xf3': 'o', '\xf4': 'o', '\xf5': 'o', '\xf6': 'o', '\xf8': 'o',
  17136. '\xd9': 'U', '\xda': 'U', '\xdb': 'U', '\xdc': 'U',
  17137. '\xf9': 'u', '\xfa': 'u', '\xfb': 'u', '\xfc': 'u',
  17138. '\xdd': 'Y', '\xfd': 'y', '\xff': 'y',
  17139. '\xc6': 'Ae', '\xe6': 'ae',
  17140. '\xde': 'Th', '\xfe': 'th',
  17141. '\xdf': 'ss',
  17142. // Latin Extended-A block.
  17143. '\u0100': 'A', '\u0102': 'A', '\u0104': 'A',
  17144. '\u0101': 'a', '\u0103': 'a', '\u0105': 'a',
  17145. '\u0106': 'C', '\u0108': 'C', '\u010a': 'C', '\u010c': 'C',
  17146. '\u0107': 'c', '\u0109': 'c', '\u010b': 'c', '\u010d': 'c',
  17147. '\u010e': 'D', '\u0110': 'D', '\u010f': 'd', '\u0111': 'd',
  17148. '\u0112': 'E', '\u0114': 'E', '\u0116': 'E', '\u0118': 'E', '\u011a': 'E',
  17149. '\u0113': 'e', '\u0115': 'e', '\u0117': 'e', '\u0119': 'e', '\u011b': 'e',
  17150. '\u011c': 'G', '\u011e': 'G', '\u0120': 'G', '\u0122': 'G',
  17151. '\u011d': 'g', '\u011f': 'g', '\u0121': 'g', '\u0123': 'g',
  17152. '\u0124': 'H', '\u0126': 'H', '\u0125': 'h', '\u0127': 'h',
  17153. '\u0128': 'I', '\u012a': 'I', '\u012c': 'I', '\u012e': 'I', '\u0130': 'I',
  17154. '\u0129': 'i', '\u012b': 'i', '\u012d': 'i', '\u012f': 'i', '\u0131': 'i',
  17155. '\u0134': 'J', '\u0135': 'j',
  17156. '\u0136': 'K', '\u0137': 'k', '\u0138': 'k',
  17157. '\u0139': 'L', '\u013b': 'L', '\u013d': 'L', '\u013f': 'L', '\u0141': 'L',
  17158. '\u013a': 'l', '\u013c': 'l', '\u013e': 'l', '\u0140': 'l', '\u0142': 'l',
  17159. '\u0143': 'N', '\u0145': 'N', '\u0147': 'N', '\u014a': 'N',
  17160. '\u0144': 'n', '\u0146': 'n', '\u0148': 'n', '\u014b': 'n',
  17161. '\u014c': 'O', '\u014e': 'O', '\u0150': 'O',
  17162. '\u014d': 'o', '\u014f': 'o', '\u0151': 'o',
  17163. '\u0154': 'R', '\u0156': 'R', '\u0158': 'R',
  17164. '\u0155': 'r', '\u0157': 'r', '\u0159': 'r',
  17165. '\u015a': 'S', '\u015c': 'S', '\u015e': 'S', '\u0160': 'S',
  17166. '\u015b': 's', '\u015d': 's', '\u015f': 's', '\u0161': 's',
  17167. '\u0162': 'T', '\u0164': 'T', '\u0166': 'T',
  17168. '\u0163': 't', '\u0165': 't', '\u0167': 't',
  17169. '\u0168': 'U', '\u016a': 'U', '\u016c': 'U', '\u016e': 'U', '\u0170': 'U', '\u0172': 'U',
  17170. '\u0169': 'u', '\u016b': 'u', '\u016d': 'u', '\u016f': 'u', '\u0171': 'u', '\u0173': 'u',
  17171. '\u0174': 'W', '\u0175': 'w',
  17172. '\u0176': 'Y', '\u0177': 'y', '\u0178': 'Y',
  17173. '\u0179': 'Z', '\u017b': 'Z', '\u017d': 'Z',
  17174. '\u017a': 'z', '\u017c': 'z', '\u017e': 'z',
  17175. '\u0132': 'IJ', '\u0133': 'ij',
  17176. '\u0152': 'Oe', '\u0153': 'oe',
  17177. '\u0149': "'n", '\u017f': 's'
  17178. };
  17179. /** Used to map characters to HTML entities. */
  17180. var htmlEscapes = {
  17181. '&': '&amp;',
  17182. '<': '&lt;',
  17183. '>': '&gt;',
  17184. '"': '&quot;',
  17185. "'": '&#39;'
  17186. };
  17187. /** Used to map HTML entities to characters. */
  17188. var htmlUnescapes = {
  17189. '&amp;': '&',
  17190. '&lt;': '<',
  17191. '&gt;': '>',
  17192. '&quot;': '"',
  17193. '&#39;': "'"
  17194. };
  17195. /** Used to escape characters for inclusion in compiled string literals. */
  17196. var stringEscapes = {
  17197. '\\': '\\',
  17198. "'": "'",
  17199. '\n': 'n',
  17200. '\r': 'r',
  17201. '\u2028': 'u2028',
  17202. '\u2029': 'u2029'
  17203. };
  17204. /** Built-in method references without a dependency on `root`. */
  17205. var freeParseFloat = parseFloat,
  17206. freeParseInt = parseInt;
  17207. /** Detect free variable `global` from Node.js. */
  17208. var freeGlobal = typeof global == 'object' && global && global.Object === Object && global;
  17209. /** Detect free variable `self`. */
  17210. var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
  17211. /** Used as a reference to the global object. */
  17212. var root = freeGlobal || freeSelf || Function('return this')();
  17213. /** Detect free variable `exports`. */
  17214. var freeExports = true && exports && !exports.nodeType && exports;
  17215. /** Detect free variable `module`. */
  17216. var freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module;
  17217. /** Detect the popular CommonJS extension `module.exports`. */
  17218. var moduleExports = freeModule && freeModule.exports === freeExports;
  17219. /** Detect free variable `process` from Node.js. */
  17220. var freeProcess = moduleExports && freeGlobal.process;
  17221. /** Used to access faster Node.js helpers. */
  17222. var nodeUtil = (function() {
  17223. try {
  17224. // Use `util.types` for Node.js 10+.
  17225. var types = freeModule && freeModule.require && freeModule.require('util').types;
  17226. if (types) {
  17227. return types;
  17228. }
  17229. // Legacy `process.binding('util')` for Node.js < 10.
  17230. return freeProcess && freeProcess.binding && freeProcess.binding('util');
  17231. } catch (e) {}
  17232. }());
  17233. /* Node.js helper references. */
  17234. var nodeIsArrayBuffer = nodeUtil && nodeUtil.isArrayBuffer,
  17235. nodeIsDate = nodeUtil && nodeUtil.isDate,
  17236. nodeIsMap = nodeUtil && nodeUtil.isMap,
  17237. nodeIsRegExp = nodeUtil && nodeUtil.isRegExp,
  17238. nodeIsSet = nodeUtil && nodeUtil.isSet,
  17239. nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray;
  17240. /*--------------------------------------------------------------------------*/
  17241. /**
  17242. * A faster alternative to `Function#apply`, this function invokes `func`
  17243. * with the `this` binding of `thisArg` and the arguments of `args`.
  17244. *
  17245. * @private
  17246. * @param {Function} func The function to invoke.
  17247. * @param {*} thisArg The `this` binding of `func`.
  17248. * @param {Array} args The arguments to invoke `func` with.
  17249. * @returns {*} Returns the result of `func`.
  17250. */
  17251. function apply(func, thisArg, args) {
  17252. switch (args.length) {
  17253. case 0: return func.call(thisArg);
  17254. case 1: return func.call(thisArg, args[0]);
  17255. case 2: return func.call(thisArg, args[0], args[1]);
  17256. case 3: return func.call(thisArg, args[0], args[1], args[2]);
  17257. }
  17258. return func.apply(thisArg, args);
  17259. }
  17260. /**
  17261. * A specialized version of `baseAggregator` for arrays.
  17262. *
  17263. * @private
  17264. * @param {Array} [array] The array to iterate over.
  17265. * @param {Function} setter The function to set `accumulator` values.
  17266. * @param {Function} iteratee The iteratee to transform keys.
  17267. * @param {Object} accumulator The initial aggregated object.
  17268. * @returns {Function} Returns `accumulator`.
  17269. */
  17270. function arrayAggregator(array, setter, iteratee, accumulator) {
  17271. var index = -1,
  17272. length = array == null ? 0 : array.length;
  17273. while (++index < length) {
  17274. var value = array[index];
  17275. setter(accumulator, value, iteratee(value), array);
  17276. }
  17277. return accumulator;
  17278. }
  17279. /**
  17280. * A specialized version of `_.forEach` for arrays without support for
  17281. * iteratee shorthands.
  17282. *
  17283. * @private
  17284. * @param {Array} [array] The array to iterate over.
  17285. * @param {Function} iteratee The function invoked per iteration.
  17286. * @returns {Array} Returns `array`.
  17287. */
  17288. function arrayEach(array, iteratee) {
  17289. var index = -1,
  17290. length = array == null ? 0 : array.length;
  17291. while (++index < length) {
  17292. if (iteratee(array[index], index, array) === false) {
  17293. break;
  17294. }
  17295. }
  17296. return array;
  17297. }
  17298. /**
  17299. * A specialized version of `_.forEachRight` for arrays without support for
  17300. * iteratee shorthands.
  17301. *
  17302. * @private
  17303. * @param {Array} [array] The array to iterate over.
  17304. * @param {Function} iteratee The function invoked per iteration.
  17305. * @returns {Array} Returns `array`.
  17306. */
  17307. function arrayEachRight(array, iteratee) {
  17308. var length = array == null ? 0 : array.length;
  17309. while (length--) {
  17310. if (iteratee(array[length], length, array) === false) {
  17311. break;
  17312. }
  17313. }
  17314. return array;
  17315. }
  17316. /**
  17317. * A specialized version of `_.every` for arrays without support for
  17318. * iteratee shorthands.
  17319. *
  17320. * @private
  17321. * @param {Array} [array] The array to iterate over.
  17322. * @param {Function} predicate The function invoked per iteration.
  17323. * @returns {boolean} Returns `true` if all elements pass the predicate check,
  17324. * else `false`.
  17325. */
  17326. function arrayEvery(array, predicate) {
  17327. var index = -1,
  17328. length = array == null ? 0 : array.length;
  17329. while (++index < length) {
  17330. if (!predicate(array[index], index, array)) {
  17331. return false;
  17332. }
  17333. }
  17334. return true;
  17335. }
  17336. /**
  17337. * A specialized version of `_.filter` for arrays without support for
  17338. * iteratee shorthands.
  17339. *
  17340. * @private
  17341. * @param {Array} [array] The array to iterate over.
  17342. * @param {Function} predicate The function invoked per iteration.
  17343. * @returns {Array} Returns the new filtered array.
  17344. */
  17345. function arrayFilter(array, predicate) {
  17346. var index = -1,
  17347. length = array == null ? 0 : array.length,
  17348. resIndex = 0,
  17349. result = [];
  17350. while (++index < length) {
  17351. var value = array[index];
  17352. if (predicate(value, index, array)) {
  17353. result[resIndex++] = value;
  17354. }
  17355. }
  17356. return result;
  17357. }
  17358. /**
  17359. * A specialized version of `_.includes` for arrays without support for
  17360. * specifying an index to search from.
  17361. *
  17362. * @private
  17363. * @param {Array} [array] The array to inspect.
  17364. * @param {*} target The value to search for.
  17365. * @returns {boolean} Returns `true` if `target` is found, else `false`.
  17366. */
  17367. function arrayIncludes(array, value) {
  17368. var length = array == null ? 0 : array.length;
  17369. return !!length && baseIndexOf(array, value, 0) > -1;
  17370. }
  17371. /**
  17372. * This function is like `arrayIncludes` except that it accepts a comparator.
  17373. *
  17374. * @private
  17375. * @param {Array} [array] The array to inspect.
  17376. * @param {*} target The value to search for.
  17377. * @param {Function} comparator The comparator invoked per element.
  17378. * @returns {boolean} Returns `true` if `target` is found, else `false`.
  17379. */
  17380. function arrayIncludesWith(array, value, comparator) {
  17381. var index = -1,
  17382. length = array == null ? 0 : array.length;
  17383. while (++index < length) {
  17384. if (comparator(value, array[index])) {
  17385. return true;
  17386. }
  17387. }
  17388. return false;
  17389. }
  17390. /**
  17391. * A specialized version of `_.map` for arrays without support for iteratee
  17392. * shorthands.
  17393. *
  17394. * @private
  17395. * @param {Array} [array] The array to iterate over.
  17396. * @param {Function} iteratee The function invoked per iteration.
  17397. * @returns {Array} Returns the new mapped array.
  17398. */
  17399. function arrayMap(array, iteratee) {
  17400. var index = -1,
  17401. length = array == null ? 0 : array.length,
  17402. result = Array(length);
  17403. while (++index < length) {
  17404. result[index] = iteratee(array[index], index, array);
  17405. }
  17406. return result;
  17407. }
  17408. /**
  17409. * Appends the elements of `values` to `array`.
  17410. *
  17411. * @private
  17412. * @param {Array} array The array to modify.
  17413. * @param {Array} values The values to append.
  17414. * @returns {Array} Returns `array`.
  17415. */
  17416. function arrayPush(array, values) {
  17417. var index = -1,
  17418. length = values.length,
  17419. offset = array.length;
  17420. while (++index < length) {
  17421. array[offset + index] = values[index];
  17422. }
  17423. return array;
  17424. }
  17425. /**
  17426. * A specialized version of `_.reduce` for arrays without support for
  17427. * iteratee shorthands.
  17428. *
  17429. * @private
  17430. * @param {Array} [array] The array to iterate over.
  17431. * @param {Function} iteratee The function invoked per iteration.
  17432. * @param {*} [accumulator] The initial value.
  17433. * @param {boolean} [initAccum] Specify using the first element of `array` as
  17434. * the initial value.
  17435. * @returns {*} Returns the accumulated value.
  17436. */
  17437. function arrayReduce(array, iteratee, accumulator, initAccum) {
  17438. var index = -1,
  17439. length = array == null ? 0 : array.length;
  17440. if (initAccum && length) {
  17441. accumulator = array[++index];
  17442. }
  17443. while (++index < length) {
  17444. accumulator = iteratee(accumulator, array[index], index, array);
  17445. }
  17446. return accumulator;
  17447. }
  17448. /**
  17449. * A specialized version of `_.reduceRight` for arrays without support for
  17450. * iteratee shorthands.
  17451. *
  17452. * @private
  17453. * @param {Array} [array] The array to iterate over.
  17454. * @param {Function} iteratee The function invoked per iteration.
  17455. * @param {*} [accumulator] The initial value.
  17456. * @param {boolean} [initAccum] Specify using the last element of `array` as
  17457. * the initial value.
  17458. * @returns {*} Returns the accumulated value.
  17459. */
  17460. function arrayReduceRight(array, iteratee, accumulator, initAccum) {
  17461. var length = array == null ? 0 : array.length;
  17462. if (initAccum && length) {
  17463. accumulator = array[--length];
  17464. }
  17465. while (length--) {
  17466. accumulator = iteratee(accumulator, array[length], length, array);
  17467. }
  17468. return accumulator;
  17469. }
  17470. /**
  17471. * A specialized version of `_.some` for arrays without support for iteratee
  17472. * shorthands.
  17473. *
  17474. * @private
  17475. * @param {Array} [array] The array to iterate over.
  17476. * @param {Function} predicate The function invoked per iteration.
  17477. * @returns {boolean} Returns `true` if any element passes the predicate check,
  17478. * else `false`.
  17479. */
  17480. function arraySome(array, predicate) {
  17481. var index = -1,
  17482. length = array == null ? 0 : array.length;
  17483. while (++index < length) {
  17484. if (predicate(array[index], index, array)) {
  17485. return true;
  17486. }
  17487. }
  17488. return false;
  17489. }
  17490. /**
  17491. * Gets the size of an ASCII `string`.
  17492. *
  17493. * @private
  17494. * @param {string} string The string inspect.
  17495. * @returns {number} Returns the string size.
  17496. */
  17497. var asciiSize = baseProperty('length');
  17498. /**
  17499. * Converts an ASCII `string` to an array.
  17500. *
  17501. * @private
  17502. * @param {string} string The string to convert.
  17503. * @returns {Array} Returns the converted array.
  17504. */
  17505. function asciiToArray(string) {
  17506. return string.split('');
  17507. }
  17508. /**
  17509. * Splits an ASCII `string` into an array of its words.
  17510. *
  17511. * @private
  17512. * @param {string} The string to inspect.
  17513. * @returns {Array} Returns the words of `string`.
  17514. */
  17515. function asciiWords(string) {
  17516. return string.match(reAsciiWord) || [];
  17517. }
  17518. /**
  17519. * The base implementation of methods like `_.findKey` and `_.findLastKey`,
  17520. * without support for iteratee shorthands, which iterates over `collection`
  17521. * using `eachFunc`.
  17522. *
  17523. * @private
  17524. * @param {Array|Object} collection The collection to inspect.
  17525. * @param {Function} predicate The function invoked per iteration.
  17526. * @param {Function} eachFunc The function to iterate over `collection`.
  17527. * @returns {*} Returns the found element or its key, else `undefined`.
  17528. */
  17529. function baseFindKey(collection, predicate, eachFunc) {
  17530. var result;
  17531. eachFunc(collection, function(value, key, collection) {
  17532. if (predicate(value, key, collection)) {
  17533. result = key;
  17534. return false;
  17535. }
  17536. });
  17537. return result;
  17538. }
  17539. /**
  17540. * The base implementation of `_.findIndex` and `_.findLastIndex` without
  17541. * support for iteratee shorthands.
  17542. *
  17543. * @private
  17544. * @param {Array} array The array to inspect.
  17545. * @param {Function} predicate The function invoked per iteration.
  17546. * @param {number} fromIndex The index to search from.
  17547. * @param {boolean} [fromRight] Specify iterating from right to left.
  17548. * @returns {number} Returns the index of the matched value, else `-1`.
  17549. */
  17550. function baseFindIndex(array, predicate, fromIndex, fromRight) {
  17551. var length = array.length,
  17552. index = fromIndex + (fromRight ? 1 : -1);
  17553. while ((fromRight ? index-- : ++index < length)) {
  17554. if (predicate(array[index], index, array)) {
  17555. return index;
  17556. }
  17557. }
  17558. return -1;
  17559. }
  17560. /**
  17561. * The base implementation of `_.indexOf` without `fromIndex` bounds checks.
  17562. *
  17563. * @private
  17564. * @param {Array} array The array to inspect.
  17565. * @param {*} value The value to search for.
  17566. * @param {number} fromIndex The index to search from.
  17567. * @returns {number} Returns the index of the matched value, else `-1`.
  17568. */
  17569. function baseIndexOf(array, value, fromIndex) {
  17570. return value === value
  17571. ? strictIndexOf(array, value, fromIndex)
  17572. : baseFindIndex(array, baseIsNaN, fromIndex);
  17573. }
  17574. /**
  17575. * This function is like `baseIndexOf` except that it accepts a comparator.
  17576. *
  17577. * @private
  17578. * @param {Array} array The array to inspect.
  17579. * @param {*} value The value to search for.
  17580. * @param {number} fromIndex The index to search from.
  17581. * @param {Function} comparator The comparator invoked per element.
  17582. * @returns {number} Returns the index of the matched value, else `-1`.
  17583. */
  17584. function baseIndexOfWith(array, value, fromIndex, comparator) {
  17585. var index = fromIndex - 1,
  17586. length = array.length;
  17587. while (++index < length) {
  17588. if (comparator(array[index], value)) {
  17589. return index;
  17590. }
  17591. }
  17592. return -1;
  17593. }
  17594. /**
  17595. * The base implementation of `_.isNaN` without support for number objects.
  17596. *
  17597. * @private
  17598. * @param {*} value The value to check.
  17599. * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`.
  17600. */
  17601. function baseIsNaN(value) {
  17602. return value !== value;
  17603. }
  17604. /**
  17605. * The base implementation of `_.mean` and `_.meanBy` without support for
  17606. * iteratee shorthands.
  17607. *
  17608. * @private
  17609. * @param {Array} array The array to iterate over.
  17610. * @param {Function} iteratee The function invoked per iteration.
  17611. * @returns {number} Returns the mean.
  17612. */
  17613. function baseMean(array, iteratee) {
  17614. var length = array == null ? 0 : array.length;
  17615. return length ? (baseSum(array, iteratee) / length) : NAN;
  17616. }
  17617. /**
  17618. * The base implementation of `_.property` without support for deep paths.
  17619. *
  17620. * @private
  17621. * @param {string} key The key of the property to get.
  17622. * @returns {Function} Returns the new accessor function.
  17623. */
  17624. function baseProperty(key) {
  17625. return function(object) {
  17626. return object == null ? undefined : object[key];
  17627. };
  17628. }
  17629. /**
  17630. * The base implementation of `_.propertyOf` without support for deep paths.
  17631. *
  17632. * @private
  17633. * @param {Object} object The object to query.
  17634. * @returns {Function} Returns the new accessor function.
  17635. */
  17636. function basePropertyOf(object) {
  17637. return function(key) {
  17638. return object == null ? undefined : object[key];
  17639. };
  17640. }
  17641. /**
  17642. * The base implementation of `_.reduce` and `_.reduceRight`, without support
  17643. * for iteratee shorthands, which iterates over `collection` using `eachFunc`.
  17644. *
  17645. * @private
  17646. * @param {Array|Object} collection The collection to iterate over.
  17647. * @param {Function} iteratee The function invoked per iteration.
  17648. * @param {*} accumulator The initial value.
  17649. * @param {boolean} initAccum Specify using the first or last element of
  17650. * `collection` as the initial value.
  17651. * @param {Function} eachFunc The function to iterate over `collection`.
  17652. * @returns {*} Returns the accumulated value.
  17653. */
  17654. function baseReduce(collection, iteratee, accumulator, initAccum, eachFunc) {
  17655. eachFunc(collection, function(value, index, collection) {
  17656. accumulator = initAccum
  17657. ? (initAccum = false, value)
  17658. : iteratee(accumulator, value, index, collection);
  17659. });
  17660. return accumulator;
  17661. }
  17662. /**
  17663. * The base implementation of `_.sortBy` which uses `comparer` to define the
  17664. * sort order of `array` and replaces criteria objects with their corresponding
  17665. * values.
  17666. *
  17667. * @private
  17668. * @param {Array} array The array to sort.
  17669. * @param {Function} comparer The function to define sort order.
  17670. * @returns {Array} Returns `array`.
  17671. */
  17672. function baseSortBy(array, comparer) {
  17673. var length = array.length;
  17674. array.sort(comparer);
  17675. while (length--) {
  17676. array[length] = array[length].value;
  17677. }
  17678. return array;
  17679. }
  17680. /**
  17681. * The base implementation of `_.sum` and `_.sumBy` without support for
  17682. * iteratee shorthands.
  17683. *
  17684. * @private
  17685. * @param {Array} array The array to iterate over.
  17686. * @param {Function} iteratee The function invoked per iteration.
  17687. * @returns {number} Returns the sum.
  17688. */
  17689. function baseSum(array, iteratee) {
  17690. var result,
  17691. index = -1,
  17692. length = array.length;
  17693. while (++index < length) {
  17694. var current = iteratee(array[index]);
  17695. if (current !== undefined) {
  17696. result = result === undefined ? current : (result + current);
  17697. }
  17698. }
  17699. return result;
  17700. }
  17701. /**
  17702. * The base implementation of `_.times` without support for iteratee shorthands
  17703. * or max array length checks.
  17704. *
  17705. * @private
  17706. * @param {number} n The number of times to invoke `iteratee`.
  17707. * @param {Function} iteratee The function invoked per iteration.
  17708. * @returns {Array} Returns the array of results.
  17709. */
  17710. function baseTimes(n, iteratee) {
  17711. var index = -1,
  17712. result = Array(n);
  17713. while (++index < n) {
  17714. result[index] = iteratee(index);
  17715. }
  17716. return result;
  17717. }
  17718. /**
  17719. * The base implementation of `_.toPairs` and `_.toPairsIn` which creates an array
  17720. * of key-value pairs for `object` corresponding to the property names of `props`.
  17721. *
  17722. * @private
  17723. * @param {Object} object The object to query.
  17724. * @param {Array} props The property names to get values for.
  17725. * @returns {Object} Returns the key-value pairs.
  17726. */
  17727. function baseToPairs(object, props) {
  17728. return arrayMap(props, function(key) {
  17729. return [key, object[key]];
  17730. });
  17731. }
  17732. /**
  17733. * The base implementation of `_.unary` without support for storing metadata.
  17734. *
  17735. * @private
  17736. * @param {Function} func The function to cap arguments for.
  17737. * @returns {Function} Returns the new capped function.
  17738. */
  17739. function baseUnary(func) {
  17740. return function(value) {
  17741. return func(value);
  17742. };
  17743. }
  17744. /**
  17745. * The base implementation of `_.values` and `_.valuesIn` which creates an
  17746. * array of `object` property values corresponding to the property names
  17747. * of `props`.
  17748. *
  17749. * @private
  17750. * @param {Object} object The object to query.
  17751. * @param {Array} props The property names to get values for.
  17752. * @returns {Object} Returns the array of property values.
  17753. */
  17754. function baseValues(object, props) {
  17755. return arrayMap(props, function(key) {
  17756. return object[key];
  17757. });
  17758. }
  17759. /**
  17760. * Checks if a `cache` value for `key` exists.
  17761. *
  17762. * @private
  17763. * @param {Object} cache The cache to query.
  17764. * @param {string} key The key of the entry to check.
  17765. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  17766. */
  17767. function cacheHas(cache, key) {
  17768. return cache.has(key);
  17769. }
  17770. /**
  17771. * Used by `_.trim` and `_.trimStart` to get the index of the first string symbol
  17772. * that is not found in the character symbols.
  17773. *
  17774. * @private
  17775. * @param {Array} strSymbols The string symbols to inspect.
  17776. * @param {Array} chrSymbols The character symbols to find.
  17777. * @returns {number} Returns the index of the first unmatched string symbol.
  17778. */
  17779. function charsStartIndex(strSymbols, chrSymbols) {
  17780. var index = -1,
  17781. length = strSymbols.length;
  17782. while (++index < length && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {}
  17783. return index;
  17784. }
  17785. /**
  17786. * Used by `_.trim` and `_.trimEnd` to get the index of the last string symbol
  17787. * that is not found in the character symbols.
  17788. *
  17789. * @private
  17790. * @param {Array} strSymbols The string symbols to inspect.
  17791. * @param {Array} chrSymbols The character symbols to find.
  17792. * @returns {number} Returns the index of the last unmatched string symbol.
  17793. */
  17794. function charsEndIndex(strSymbols, chrSymbols) {
  17795. var index = strSymbols.length;
  17796. while (index-- && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {}
  17797. return index;
  17798. }
  17799. /**
  17800. * Gets the number of `placeholder` occurrences in `array`.
  17801. *
  17802. * @private
  17803. * @param {Array} array The array to inspect.
  17804. * @param {*} placeholder The placeholder to search for.
  17805. * @returns {number} Returns the placeholder count.
  17806. */
  17807. function countHolders(array, placeholder) {
  17808. var length = array.length,
  17809. result = 0;
  17810. while (length--) {
  17811. if (array[length] === placeholder) {
  17812. ++result;
  17813. }
  17814. }
  17815. return result;
  17816. }
  17817. /**
  17818. * Used by `_.deburr` to convert Latin-1 Supplement and Latin Extended-A
  17819. * letters to basic Latin letters.
  17820. *
  17821. * @private
  17822. * @param {string} letter The matched letter to deburr.
  17823. * @returns {string} Returns the deburred letter.
  17824. */
  17825. var deburrLetter = basePropertyOf(deburredLetters);
  17826. /**
  17827. * Used by `_.escape` to convert characters to HTML entities.
  17828. *
  17829. * @private
  17830. * @param {string} chr The matched character to escape.
  17831. * @returns {string} Returns the escaped character.
  17832. */
  17833. var escapeHtmlChar = basePropertyOf(htmlEscapes);
  17834. /**
  17835. * Used by `_.template` to escape characters for inclusion in compiled string literals.
  17836. *
  17837. * @private
  17838. * @param {string} chr The matched character to escape.
  17839. * @returns {string} Returns the escaped character.
  17840. */
  17841. function escapeStringChar(chr) {
  17842. return '\\' + stringEscapes[chr];
  17843. }
  17844. /**
  17845. * Gets the value at `key` of `object`.
  17846. *
  17847. * @private
  17848. * @param {Object} [object] The object to query.
  17849. * @param {string} key The key of the property to get.
  17850. * @returns {*} Returns the property value.
  17851. */
  17852. function getValue(object, key) {
  17853. return object == null ? undefined : object[key];
  17854. }
  17855. /**
  17856. * Checks if `string` contains Unicode symbols.
  17857. *
  17858. * @private
  17859. * @param {string} string The string to inspect.
  17860. * @returns {boolean} Returns `true` if a symbol is found, else `false`.
  17861. */
  17862. function hasUnicode(string) {
  17863. return reHasUnicode.test(string);
  17864. }
  17865. /**
  17866. * Checks if `string` contains a word composed of Unicode symbols.
  17867. *
  17868. * @private
  17869. * @param {string} string The string to inspect.
  17870. * @returns {boolean} Returns `true` if a word is found, else `false`.
  17871. */
  17872. function hasUnicodeWord(string) {
  17873. return reHasUnicodeWord.test(string);
  17874. }
  17875. /**
  17876. * Converts `iterator` to an array.
  17877. *
  17878. * @private
  17879. * @param {Object} iterator The iterator to convert.
  17880. * @returns {Array} Returns the converted array.
  17881. */
  17882. function iteratorToArray(iterator) {
  17883. var data,
  17884. result = [];
  17885. while (!(data = iterator.next()).done) {
  17886. result.push(data.value);
  17887. }
  17888. return result;
  17889. }
  17890. /**
  17891. * Converts `map` to its key-value pairs.
  17892. *
  17893. * @private
  17894. * @param {Object} map The map to convert.
  17895. * @returns {Array} Returns the key-value pairs.
  17896. */
  17897. function mapToArray(map) {
  17898. var index = -1,
  17899. result = Array(map.size);
  17900. map.forEach(function(value, key) {
  17901. result[++index] = [key, value];
  17902. });
  17903. return result;
  17904. }
  17905. /**
  17906. * Creates a unary function that invokes `func` with its argument transformed.
  17907. *
  17908. * @private
  17909. * @param {Function} func The function to wrap.
  17910. * @param {Function} transform The argument transform.
  17911. * @returns {Function} Returns the new function.
  17912. */
  17913. function overArg(func, transform) {
  17914. return function(arg) {
  17915. return func(transform(arg));
  17916. };
  17917. }
  17918. /**
  17919. * Replaces all `placeholder` elements in `array` with an internal placeholder
  17920. * and returns an array of their indexes.
  17921. *
  17922. * @private
  17923. * @param {Array} array The array to modify.
  17924. * @param {*} placeholder The placeholder to replace.
  17925. * @returns {Array} Returns the new array of placeholder indexes.
  17926. */
  17927. function replaceHolders(array, placeholder) {
  17928. var index = -1,
  17929. length = array.length,
  17930. resIndex = 0,
  17931. result = [];
  17932. while (++index < length) {
  17933. var value = array[index];
  17934. if (value === placeholder || value === PLACEHOLDER) {
  17935. array[index] = PLACEHOLDER;
  17936. result[resIndex++] = index;
  17937. }
  17938. }
  17939. return result;
  17940. }
  17941. /**
  17942. * Converts `set` to an array of its values.
  17943. *
  17944. * @private
  17945. * @param {Object} set The set to convert.
  17946. * @returns {Array} Returns the values.
  17947. */
  17948. function setToArray(set) {
  17949. var index = -1,
  17950. result = Array(set.size);
  17951. set.forEach(function(value) {
  17952. result[++index] = value;
  17953. });
  17954. return result;
  17955. }
  17956. /**
  17957. * Converts `set` to its value-value pairs.
  17958. *
  17959. * @private
  17960. * @param {Object} set The set to convert.
  17961. * @returns {Array} Returns the value-value pairs.
  17962. */
  17963. function setToPairs(set) {
  17964. var index = -1,
  17965. result = Array(set.size);
  17966. set.forEach(function(value) {
  17967. result[++index] = [value, value];
  17968. });
  17969. return result;
  17970. }
  17971. /**
  17972. * A specialized version of `_.indexOf` which performs strict equality
  17973. * comparisons of values, i.e. `===`.
  17974. *
  17975. * @private
  17976. * @param {Array} array The array to inspect.
  17977. * @param {*} value The value to search for.
  17978. * @param {number} fromIndex The index to search from.
  17979. * @returns {number} Returns the index of the matched value, else `-1`.
  17980. */
  17981. function strictIndexOf(array, value, fromIndex) {
  17982. var index = fromIndex - 1,
  17983. length = array.length;
  17984. while (++index < length) {
  17985. if (array[index] === value) {
  17986. return index;
  17987. }
  17988. }
  17989. return -1;
  17990. }
  17991. /**
  17992. * A specialized version of `_.lastIndexOf` which performs strict equality
  17993. * comparisons of values, i.e. `===`.
  17994. *
  17995. * @private
  17996. * @param {Array} array The array to inspect.
  17997. * @param {*} value The value to search for.
  17998. * @param {number} fromIndex The index to search from.
  17999. * @returns {number} Returns the index of the matched value, else `-1`.
  18000. */
  18001. function strictLastIndexOf(array, value, fromIndex) {
  18002. var index = fromIndex + 1;
  18003. while (index--) {
  18004. if (array[index] === value) {
  18005. return index;
  18006. }
  18007. }
  18008. return index;
  18009. }
  18010. /**
  18011. * Gets the number of symbols in `string`.
  18012. *
  18013. * @private
  18014. * @param {string} string The string to inspect.
  18015. * @returns {number} Returns the string size.
  18016. */
  18017. function stringSize(string) {
  18018. return hasUnicode(string)
  18019. ? unicodeSize(string)
  18020. : asciiSize(string);
  18021. }
  18022. /**
  18023. * Converts `string` to an array.
  18024. *
  18025. * @private
  18026. * @param {string} string The string to convert.
  18027. * @returns {Array} Returns the converted array.
  18028. */
  18029. function stringToArray(string) {
  18030. return hasUnicode(string)
  18031. ? unicodeToArray(string)
  18032. : asciiToArray(string);
  18033. }
  18034. /**
  18035. * Used by `_.unescape` to convert HTML entities to characters.
  18036. *
  18037. * @private
  18038. * @param {string} chr The matched character to unescape.
  18039. * @returns {string} Returns the unescaped character.
  18040. */
  18041. var unescapeHtmlChar = basePropertyOf(htmlUnescapes);
  18042. /**
  18043. * Gets the size of a Unicode `string`.
  18044. *
  18045. * @private
  18046. * @param {string} string The string inspect.
  18047. * @returns {number} Returns the string size.
  18048. */
  18049. function unicodeSize(string) {
  18050. var result = reUnicode.lastIndex = 0;
  18051. while (reUnicode.test(string)) {
  18052. ++result;
  18053. }
  18054. return result;
  18055. }
  18056. /**
  18057. * Converts a Unicode `string` to an array.
  18058. *
  18059. * @private
  18060. * @param {string} string The string to convert.
  18061. * @returns {Array} Returns the converted array.
  18062. */
  18063. function unicodeToArray(string) {
  18064. return string.match(reUnicode) || [];
  18065. }
  18066. /**
  18067. * Splits a Unicode `string` into an array of its words.
  18068. *
  18069. * @private
  18070. * @param {string} The string to inspect.
  18071. * @returns {Array} Returns the words of `string`.
  18072. */
  18073. function unicodeWords(string) {
  18074. return string.match(reUnicodeWord) || [];
  18075. }
  18076. /*--------------------------------------------------------------------------*/
  18077. /**
  18078. * Create a new pristine `lodash` function using the `context` object.
  18079. *
  18080. * @static
  18081. * @memberOf _
  18082. * @since 1.1.0
  18083. * @category Util
  18084. * @param {Object} [context=root] The context object.
  18085. * @returns {Function} Returns a new `lodash` function.
  18086. * @example
  18087. *
  18088. * _.mixin({ 'foo': _.constant('foo') });
  18089. *
  18090. * var lodash = _.runInContext();
  18091. * lodash.mixin({ 'bar': lodash.constant('bar') });
  18092. *
  18093. * _.isFunction(_.foo);
  18094. * // => true
  18095. * _.isFunction(_.bar);
  18096. * // => false
  18097. *
  18098. * lodash.isFunction(lodash.foo);
  18099. * // => false
  18100. * lodash.isFunction(lodash.bar);
  18101. * // => true
  18102. *
  18103. * // Create a suped-up `defer` in Node.js.
  18104. * var defer = _.runInContext({ 'setTimeout': setImmediate }).defer;
  18105. */
  18106. var runInContext = (function runInContext(context) {
  18107. context = context == null ? root : _.defaults(root.Object(), context, _.pick(root, contextProps));
  18108. /** Built-in constructor references. */
  18109. var Array = context.Array,
  18110. Date = context.Date,
  18111. Error = context.Error,
  18112. Function = context.Function,
  18113. Math = context.Math,
  18114. Object = context.Object,
  18115. RegExp = context.RegExp,
  18116. String = context.String,
  18117. TypeError = context.TypeError;
  18118. /** Used for built-in method references. */
  18119. var arrayProto = Array.prototype,
  18120. funcProto = Function.prototype,
  18121. objectProto = Object.prototype;
  18122. /** Used to detect overreaching core-js shims. */
  18123. var coreJsData = context['__core-js_shared__'];
  18124. /** Used to resolve the decompiled source of functions. */
  18125. var funcToString = funcProto.toString;
  18126. /** Used to check objects for own properties. */
  18127. var hasOwnProperty = objectProto.hasOwnProperty;
  18128. /** Used to generate unique IDs. */
  18129. var idCounter = 0;
  18130. /** Used to detect methods masquerading as native. */
  18131. var maskSrcKey = (function() {
  18132. var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
  18133. return uid ? ('Symbol(src)_1.' + uid) : '';
  18134. }());
  18135. /**
  18136. * Used to resolve the
  18137. * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
  18138. * of values.
  18139. */
  18140. var nativeObjectToString = objectProto.toString;
  18141. /** Used to infer the `Object` constructor. */
  18142. var objectCtorString = funcToString.call(Object);
  18143. /** Used to restore the original `_` reference in `_.noConflict`. */
  18144. var oldDash = root._;
  18145. /** Used to detect if a method is native. */
  18146. var reIsNative = RegExp('^' +
  18147. funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&')
  18148. .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
  18149. );
  18150. /** Built-in value references. */
  18151. var Buffer = moduleExports ? context.Buffer : undefined,
  18152. Symbol = context.Symbol,
  18153. Uint8Array = context.Uint8Array,
  18154. allocUnsafe = Buffer ? Buffer.allocUnsafe : undefined,
  18155. getPrototype = overArg(Object.getPrototypeOf, Object),
  18156. objectCreate = Object.create,
  18157. propertyIsEnumerable = objectProto.propertyIsEnumerable,
  18158. splice = arrayProto.splice,
  18159. spreadableSymbol = Symbol ? Symbol.isConcatSpreadable : undefined,
  18160. symIterator = Symbol ? Symbol.iterator : undefined,
  18161. symToStringTag = Symbol ? Symbol.toStringTag : undefined;
  18162. var defineProperty = (function() {
  18163. try {
  18164. var func = getNative(Object, 'defineProperty');
  18165. func({}, '', {});
  18166. return func;
  18167. } catch (e) {}
  18168. }());
  18169. /** Mocked built-ins. */
  18170. var ctxClearTimeout = context.clearTimeout !== root.clearTimeout && context.clearTimeout,
  18171. ctxNow = Date && Date.now !== root.Date.now && Date.now,
  18172. ctxSetTimeout = context.setTimeout !== root.setTimeout && context.setTimeout;
  18173. /* Built-in method references for those with the same name as other `lodash` methods. */
  18174. var nativeCeil = Math.ceil,
  18175. nativeFloor = Math.floor,
  18176. nativeGetSymbols = Object.getOwnPropertySymbols,
  18177. nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined,
  18178. nativeIsFinite = context.isFinite,
  18179. nativeJoin = arrayProto.join,
  18180. nativeKeys = overArg(Object.keys, Object),
  18181. nativeMax = Math.max,
  18182. nativeMin = Math.min,
  18183. nativeNow = Date.now,
  18184. nativeParseInt = context.parseInt,
  18185. nativeRandom = Math.random,
  18186. nativeReverse = arrayProto.reverse;
  18187. /* Built-in method references that are verified to be native. */
  18188. var DataView = getNative(context, 'DataView'),
  18189. Map = getNative(context, 'Map'),
  18190. Promise = getNative(context, 'Promise'),
  18191. Set = getNative(context, 'Set'),
  18192. WeakMap = getNative(context, 'WeakMap'),
  18193. nativeCreate = getNative(Object, 'create');
  18194. /** Used to store function metadata. */
  18195. var metaMap = WeakMap && new WeakMap;
  18196. /** Used to lookup unminified function names. */
  18197. var realNames = {};
  18198. /** Used to detect maps, sets, and weakmaps. */
  18199. var dataViewCtorString = toSource(DataView),
  18200. mapCtorString = toSource(Map),
  18201. promiseCtorString = toSource(Promise),
  18202. setCtorString = toSource(Set),
  18203. weakMapCtorString = toSource(WeakMap);
  18204. /** Used to convert symbols to primitives and strings. */
  18205. var symbolProto = Symbol ? Symbol.prototype : undefined,
  18206. symbolValueOf = symbolProto ? symbolProto.valueOf : undefined,
  18207. symbolToString = symbolProto ? symbolProto.toString : undefined;
  18208. /*------------------------------------------------------------------------*/
  18209. /**
  18210. * Creates a `lodash` object which wraps `value` to enable implicit method
  18211. * chain sequences. Methods that operate on and return arrays, collections,
  18212. * and functions can be chained together. Methods that retrieve a single value
  18213. * or may return a primitive value will automatically end the chain sequence
  18214. * and return the unwrapped value. Otherwise, the value must be unwrapped
  18215. * with `_#value`.
  18216. *
  18217. * Explicit chain sequences, which must be unwrapped with `_#value`, may be
  18218. * enabled using `_.chain`.
  18219. *
  18220. * The execution of chained methods is lazy, that is, it's deferred until
  18221. * `_#value` is implicitly or explicitly called.
  18222. *
  18223. * Lazy evaluation allows several methods to support shortcut fusion.
  18224. * Shortcut fusion is an optimization to merge iteratee calls; this avoids
  18225. * the creation of intermediate arrays and can greatly reduce the number of
  18226. * iteratee executions. Sections of a chain sequence qualify for shortcut
  18227. * fusion if the section is applied to an array and iteratees accept only
  18228. * one argument. The heuristic for whether a section qualifies for shortcut
  18229. * fusion is subject to change.
  18230. *
  18231. * Chaining is supported in custom builds as long as the `_#value` method is
  18232. * directly or indirectly included in the build.
  18233. *
  18234. * In addition to lodash methods, wrappers have `Array` and `String` methods.
  18235. *
  18236. * The wrapper `Array` methods are:
  18237. * `concat`, `join`, `pop`, `push`, `shift`, `sort`, `splice`, and `unshift`
  18238. *
  18239. * The wrapper `String` methods are:
  18240. * `replace` and `split`
  18241. *
  18242. * The wrapper methods that support shortcut fusion are:
  18243. * `at`, `compact`, `drop`, `dropRight`, `dropWhile`, `filter`, `find`,
  18244. * `findLast`, `head`, `initial`, `last`, `map`, `reject`, `reverse`, `slice`,
  18245. * `tail`, `take`, `takeRight`, `takeRightWhile`, `takeWhile`, and `toArray`
  18246. *
  18247. * The chainable wrapper methods are:
  18248. * `after`, `ary`, `assign`, `assignIn`, `assignInWith`, `assignWith`, `at`,
  18249. * `before`, `bind`, `bindAll`, `bindKey`, `castArray`, `chain`, `chunk`,
  18250. * `commit`, `compact`, `concat`, `conforms`, `constant`, `countBy`, `create`,
  18251. * `curry`, `debounce`, `defaults`, `defaultsDeep`, `defer`, `delay`,
  18252. * `difference`, `differenceBy`, `differenceWith`, `drop`, `dropRight`,
  18253. * `dropRightWhile`, `dropWhile`, `extend`, `extendWith`, `fill`, `filter`,
  18254. * `flatMap`, `flatMapDeep`, `flatMapDepth`, `flatten`, `flattenDeep`,
  18255. * `flattenDepth`, `flip`, `flow`, `flowRight`, `fromPairs`, `functions`,
  18256. * `functionsIn`, `groupBy`, `initial`, `intersection`, `intersectionBy`,
  18257. * `intersectionWith`, `invert`, `invertBy`, `invokeMap`, `iteratee`, `keyBy`,
  18258. * `keys`, `keysIn`, `map`, `mapKeys`, `mapValues`, `matches`, `matchesProperty`,
  18259. * `memoize`, `merge`, `mergeWith`, `method`, `methodOf`, `mixin`, `negate`,
  18260. * `nthArg`, `omit`, `omitBy`, `once`, `orderBy`, `over`, `overArgs`,
  18261. * `overEvery`, `overSome`, `partial`, `partialRight`, `partition`, `pick`,
  18262. * `pickBy`, `plant`, `property`, `propertyOf`, `pull`, `pullAll`, `pullAllBy`,
  18263. * `pullAllWith`, `pullAt`, `push`, `range`, `rangeRight`, `rearg`, `reject`,
  18264. * `remove`, `rest`, `reverse`, `sampleSize`, `set`, `setWith`, `shuffle`,
  18265. * `slice`, `sort`, `sortBy`, `splice`, `spread`, `tail`, `take`, `takeRight`,
  18266. * `takeRightWhile`, `takeWhile`, `tap`, `throttle`, `thru`, `toArray`,
  18267. * `toPairs`, `toPairsIn`, `toPath`, `toPlainObject`, `transform`, `unary`,
  18268. * `union`, `unionBy`, `unionWith`, `uniq`, `uniqBy`, `uniqWith`, `unset`,
  18269. * `unshift`, `unzip`, `unzipWith`, `update`, `updateWith`, `values`,
  18270. * `valuesIn`, `without`, `wrap`, `xor`, `xorBy`, `xorWith`, `zip`,
  18271. * `zipObject`, `zipObjectDeep`, and `zipWith`
  18272. *
  18273. * The wrapper methods that are **not** chainable by default are:
  18274. * `add`, `attempt`, `camelCase`, `capitalize`, `ceil`, `clamp`, `clone`,
  18275. * `cloneDeep`, `cloneDeepWith`, `cloneWith`, `conformsTo`, `deburr`,
  18276. * `defaultTo`, `divide`, `each`, `eachRight`, `endsWith`, `eq`, `escape`,
  18277. * `escapeRegExp`, `every`, `find`, `findIndex`, `findKey`, `findLast`,
  18278. * `findLastIndex`, `findLastKey`, `first`, `floor`, `forEach`, `forEachRight`,
  18279. * `forIn`, `forInRight`, `forOwn`, `forOwnRight`, `get`, `gt`, `gte`, `has`,
  18280. * `hasIn`, `head`, `identity`, `includes`, `indexOf`, `inRange`, `invoke`,
  18281. * `isArguments`, `isArray`, `isArrayBuffer`, `isArrayLike`, `isArrayLikeObject`,
  18282. * `isBoolean`, `isBuffer`, `isDate`, `isElement`, `isEmpty`, `isEqual`,
  18283. * `isEqualWith`, `isError`, `isFinite`, `isFunction`, `isInteger`, `isLength`,
  18284. * `isMap`, `isMatch`, `isMatchWith`, `isNaN`, `isNative`, `isNil`, `isNull`,
  18285. * `isNumber`, `isObject`, `isObjectLike`, `isPlainObject`, `isRegExp`,
  18286. * `isSafeInteger`, `isSet`, `isString`, `isUndefined`, `isTypedArray`,
  18287. * `isWeakMap`, `isWeakSet`, `join`, `kebabCase`, `last`, `lastIndexOf`,
  18288. * `lowerCase`, `lowerFirst`, `lt`, `lte`, `max`, `maxBy`, `mean`, `meanBy`,
  18289. * `min`, `minBy`, `multiply`, `noConflict`, `noop`, `now`, `nth`, `pad`,
  18290. * `padEnd`, `padStart`, `parseInt`, `pop`, `random`, `reduce`, `reduceRight`,
  18291. * `repeat`, `result`, `round`, `runInContext`, `sample`, `shift`, `size`,
  18292. * `snakeCase`, `some`, `sortedIndex`, `sortedIndexBy`, `sortedLastIndex`,
  18293. * `sortedLastIndexBy`, `startCase`, `startsWith`, `stubArray`, `stubFalse`,
  18294. * `stubObject`, `stubString`, `stubTrue`, `subtract`, `sum`, `sumBy`,
  18295. * `template`, `times`, `toFinite`, `toInteger`, `toJSON`, `toLength`,
  18296. * `toLower`, `toNumber`, `toSafeInteger`, `toString`, `toUpper`, `trim`,
  18297. * `trimEnd`, `trimStart`, `truncate`, `unescape`, `uniqueId`, `upperCase`,
  18298. * `upperFirst`, `value`, and `words`
  18299. *
  18300. * @name _
  18301. * @constructor
  18302. * @category Seq
  18303. * @param {*} value The value to wrap in a `lodash` instance.
  18304. * @returns {Object} Returns the new `lodash` wrapper instance.
  18305. * @example
  18306. *
  18307. * function square(n) {
  18308. * return n * n;
  18309. * }
  18310. *
  18311. * var wrapped = _([1, 2, 3]);
  18312. *
  18313. * // Returns an unwrapped value.
  18314. * wrapped.reduce(_.add);
  18315. * // => 6
  18316. *
  18317. * // Returns a wrapped value.
  18318. * var squares = wrapped.map(square);
  18319. *
  18320. * _.isArray(squares);
  18321. * // => false
  18322. *
  18323. * _.isArray(squares.value());
  18324. * // => true
  18325. */
  18326. function lodash(value) {
  18327. if (isObjectLike(value) && !isArray(value) && !(value instanceof LazyWrapper)) {
  18328. if (value instanceof LodashWrapper) {
  18329. return value;
  18330. }
  18331. if (hasOwnProperty.call(value, '__wrapped__')) {
  18332. return wrapperClone(value);
  18333. }
  18334. }
  18335. return new LodashWrapper(value);
  18336. }
  18337. /**
  18338. * The base implementation of `_.create` without support for assigning
  18339. * properties to the created object.
  18340. *
  18341. * @private
  18342. * @param {Object} proto The object to inherit from.
  18343. * @returns {Object} Returns the new object.
  18344. */
  18345. var baseCreate = (function() {
  18346. function object() {}
  18347. return function(proto) {
  18348. if (!isObject(proto)) {
  18349. return {};
  18350. }
  18351. if (objectCreate) {
  18352. return objectCreate(proto);
  18353. }
  18354. object.prototype = proto;
  18355. var result = new object;
  18356. object.prototype = undefined;
  18357. return result;
  18358. };
  18359. }());
  18360. /**
  18361. * The function whose prototype chain sequence wrappers inherit from.
  18362. *
  18363. * @private
  18364. */
  18365. function baseLodash() {
  18366. // No operation performed.
  18367. }
  18368. /**
  18369. * The base constructor for creating `lodash` wrapper objects.
  18370. *
  18371. * @private
  18372. * @param {*} value The value to wrap.
  18373. * @param {boolean} [chainAll] Enable explicit method chain sequences.
  18374. */
  18375. function LodashWrapper(value, chainAll) {
  18376. this.__wrapped__ = value;
  18377. this.__actions__ = [];
  18378. this.__chain__ = !!chainAll;
  18379. this.__index__ = 0;
  18380. this.__values__ = undefined;
  18381. }
  18382. /**
  18383. * By default, the template delimiters used by lodash are like those in
  18384. * embedded Ruby (ERB) as well as ES2015 template strings. Change the
  18385. * following template settings to use alternative delimiters.
  18386. *
  18387. * @static
  18388. * @memberOf _
  18389. * @type {Object}
  18390. */
  18391. lodash.templateSettings = {
  18392. /**
  18393. * Used to detect `data` property values to be HTML-escaped.
  18394. *
  18395. * @memberOf _.templateSettings
  18396. * @type {RegExp}
  18397. */
  18398. 'escape': reEscape,
  18399. /**
  18400. * Used to detect code to be evaluated.
  18401. *
  18402. * @memberOf _.templateSettings
  18403. * @type {RegExp}
  18404. */
  18405. 'evaluate': reEvaluate,
  18406. /**
  18407. * Used to detect `data` property values to inject.
  18408. *
  18409. * @memberOf _.templateSettings
  18410. * @type {RegExp}
  18411. */
  18412. 'interpolate': reInterpolate,
  18413. /**
  18414. * Used to reference the data object in the template text.
  18415. *
  18416. * @memberOf _.templateSettings
  18417. * @type {string}
  18418. */
  18419. 'variable': '',
  18420. /**
  18421. * Used to import variables into the compiled template.
  18422. *
  18423. * @memberOf _.templateSettings
  18424. * @type {Object}
  18425. */
  18426. 'imports': {
  18427. /**
  18428. * A reference to the `lodash` function.
  18429. *
  18430. * @memberOf _.templateSettings.imports
  18431. * @type {Function}
  18432. */
  18433. '_': lodash
  18434. }
  18435. };
  18436. // Ensure wrappers are instances of `baseLodash`.
  18437. lodash.prototype = baseLodash.prototype;
  18438. lodash.prototype.constructor = lodash;
  18439. LodashWrapper.prototype = baseCreate(baseLodash.prototype);
  18440. LodashWrapper.prototype.constructor = LodashWrapper;
  18441. /*------------------------------------------------------------------------*/
  18442. /**
  18443. * Creates a lazy wrapper object which wraps `value` to enable lazy evaluation.
  18444. *
  18445. * @private
  18446. * @constructor
  18447. * @param {*} value The value to wrap.
  18448. */
  18449. function LazyWrapper(value) {
  18450. this.__wrapped__ = value;
  18451. this.__actions__ = [];
  18452. this.__dir__ = 1;
  18453. this.__filtered__ = false;
  18454. this.__iteratees__ = [];
  18455. this.__takeCount__ = MAX_ARRAY_LENGTH;
  18456. this.__views__ = [];
  18457. }
  18458. /**
  18459. * Creates a clone of the lazy wrapper object.
  18460. *
  18461. * @private
  18462. * @name clone
  18463. * @memberOf LazyWrapper
  18464. * @returns {Object} Returns the cloned `LazyWrapper` object.
  18465. */
  18466. function lazyClone() {
  18467. var result = new LazyWrapper(this.__wrapped__);
  18468. result.__actions__ = copyArray(this.__actions__);
  18469. result.__dir__ = this.__dir__;
  18470. result.__filtered__ = this.__filtered__;
  18471. result.__iteratees__ = copyArray(this.__iteratees__);
  18472. result.__takeCount__ = this.__takeCount__;
  18473. result.__views__ = copyArray(this.__views__);
  18474. return result;
  18475. }
  18476. /**
  18477. * Reverses the direction of lazy iteration.
  18478. *
  18479. * @private
  18480. * @name reverse
  18481. * @memberOf LazyWrapper
  18482. * @returns {Object} Returns the new reversed `LazyWrapper` object.
  18483. */
  18484. function lazyReverse() {
  18485. if (this.__filtered__) {
  18486. var result = new LazyWrapper(this);
  18487. result.__dir__ = -1;
  18488. result.__filtered__ = true;
  18489. } else {
  18490. result = this.clone();
  18491. result.__dir__ *= -1;
  18492. }
  18493. return result;
  18494. }
  18495. /**
  18496. * Extracts the unwrapped value from its lazy wrapper.
  18497. *
  18498. * @private
  18499. * @name value
  18500. * @memberOf LazyWrapper
  18501. * @returns {*} Returns the unwrapped value.
  18502. */
  18503. function lazyValue() {
  18504. var array = this.__wrapped__.value(),
  18505. dir = this.__dir__,
  18506. isArr = isArray(array),
  18507. isRight = dir < 0,
  18508. arrLength = isArr ? array.length : 0,
  18509. view = getView(0, arrLength, this.__views__),
  18510. start = view.start,
  18511. end = view.end,
  18512. length = end - start,
  18513. index = isRight ? end : (start - 1),
  18514. iteratees = this.__iteratees__,
  18515. iterLength = iteratees.length,
  18516. resIndex = 0,
  18517. takeCount = nativeMin(length, this.__takeCount__);
  18518. if (!isArr || (!isRight && arrLength == length && takeCount == length)) {
  18519. return baseWrapperValue(array, this.__actions__);
  18520. }
  18521. var result = [];
  18522. outer:
  18523. while (length-- && resIndex < takeCount) {
  18524. index += dir;
  18525. var iterIndex = -1,
  18526. value = array[index];
  18527. while (++iterIndex < iterLength) {
  18528. var data = iteratees[iterIndex],
  18529. iteratee = data.iteratee,
  18530. type = data.type,
  18531. computed = iteratee(value);
  18532. if (type == LAZY_MAP_FLAG) {
  18533. value = computed;
  18534. } else if (!computed) {
  18535. if (type == LAZY_FILTER_FLAG) {
  18536. continue outer;
  18537. } else {
  18538. break outer;
  18539. }
  18540. }
  18541. }
  18542. result[resIndex++] = value;
  18543. }
  18544. return result;
  18545. }
  18546. // Ensure `LazyWrapper` is an instance of `baseLodash`.
  18547. LazyWrapper.prototype = baseCreate(baseLodash.prototype);
  18548. LazyWrapper.prototype.constructor = LazyWrapper;
  18549. /*------------------------------------------------------------------------*/
  18550. /**
  18551. * Creates a hash object.
  18552. *
  18553. * @private
  18554. * @constructor
  18555. * @param {Array} [entries] The key-value pairs to cache.
  18556. */
  18557. function Hash(entries) {
  18558. var index = -1,
  18559. length = entries == null ? 0 : entries.length;
  18560. this.clear();
  18561. while (++index < length) {
  18562. var entry = entries[index];
  18563. this.set(entry[0], entry[1]);
  18564. }
  18565. }
  18566. /**
  18567. * Removes all key-value entries from the hash.
  18568. *
  18569. * @private
  18570. * @name clear
  18571. * @memberOf Hash
  18572. */
  18573. function hashClear() {
  18574. this.__data__ = nativeCreate ? nativeCreate(null) : {};
  18575. this.size = 0;
  18576. }
  18577. /**
  18578. * Removes `key` and its value from the hash.
  18579. *
  18580. * @private
  18581. * @name delete
  18582. * @memberOf Hash
  18583. * @param {Object} hash The hash to modify.
  18584. * @param {string} key The key of the value to remove.
  18585. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  18586. */
  18587. function hashDelete(key) {
  18588. var result = this.has(key) && delete this.__data__[key];
  18589. this.size -= result ? 1 : 0;
  18590. return result;
  18591. }
  18592. /**
  18593. * Gets the hash value for `key`.
  18594. *
  18595. * @private
  18596. * @name get
  18597. * @memberOf Hash
  18598. * @param {string} key The key of the value to get.
  18599. * @returns {*} Returns the entry value.
  18600. */
  18601. function hashGet(key) {
  18602. var data = this.__data__;
  18603. if (nativeCreate) {
  18604. var result = data[key];
  18605. return result === HASH_UNDEFINED ? undefined : result;
  18606. }
  18607. return hasOwnProperty.call(data, key) ? data[key] : undefined;
  18608. }
  18609. /**
  18610. * Checks if a hash value for `key` exists.
  18611. *
  18612. * @private
  18613. * @name has
  18614. * @memberOf Hash
  18615. * @param {string} key The key of the entry to check.
  18616. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  18617. */
  18618. function hashHas(key) {
  18619. var data = this.__data__;
  18620. return nativeCreate ? (data[key] !== undefined) : hasOwnProperty.call(data, key);
  18621. }
  18622. /**
  18623. * Sets the hash `key` to `value`.
  18624. *
  18625. * @private
  18626. * @name set
  18627. * @memberOf Hash
  18628. * @param {string} key The key of the value to set.
  18629. * @param {*} value The value to set.
  18630. * @returns {Object} Returns the hash instance.
  18631. */
  18632. function hashSet(key, value) {
  18633. var data = this.__data__;
  18634. this.size += this.has(key) ? 0 : 1;
  18635. data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value;
  18636. return this;
  18637. }
  18638. // Add methods to `Hash`.
  18639. Hash.prototype.clear = hashClear;
  18640. Hash.prototype['delete'] = hashDelete;
  18641. Hash.prototype.get = hashGet;
  18642. Hash.prototype.has = hashHas;
  18643. Hash.prototype.set = hashSet;
  18644. /*------------------------------------------------------------------------*/
  18645. /**
  18646. * Creates an list cache object.
  18647. *
  18648. * @private
  18649. * @constructor
  18650. * @param {Array} [entries] The key-value pairs to cache.
  18651. */
  18652. function ListCache(entries) {
  18653. var index = -1,
  18654. length = entries == null ? 0 : entries.length;
  18655. this.clear();
  18656. while (++index < length) {
  18657. var entry = entries[index];
  18658. this.set(entry[0], entry[1]);
  18659. }
  18660. }
  18661. /**
  18662. * Removes all key-value entries from the list cache.
  18663. *
  18664. * @private
  18665. * @name clear
  18666. * @memberOf ListCache
  18667. */
  18668. function listCacheClear() {
  18669. this.__data__ = [];
  18670. this.size = 0;
  18671. }
  18672. /**
  18673. * Removes `key` and its value from the list cache.
  18674. *
  18675. * @private
  18676. * @name delete
  18677. * @memberOf ListCache
  18678. * @param {string} key The key of the value to remove.
  18679. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  18680. */
  18681. function listCacheDelete(key) {
  18682. var data = this.__data__,
  18683. index = assocIndexOf(data, key);
  18684. if (index < 0) {
  18685. return false;
  18686. }
  18687. var lastIndex = data.length - 1;
  18688. if (index == lastIndex) {
  18689. data.pop();
  18690. } else {
  18691. splice.call(data, index, 1);
  18692. }
  18693. --this.size;
  18694. return true;
  18695. }
  18696. /**
  18697. * Gets the list cache value for `key`.
  18698. *
  18699. * @private
  18700. * @name get
  18701. * @memberOf ListCache
  18702. * @param {string} key The key of the value to get.
  18703. * @returns {*} Returns the entry value.
  18704. */
  18705. function listCacheGet(key) {
  18706. var data = this.__data__,
  18707. index = assocIndexOf(data, key);
  18708. return index < 0 ? undefined : data[index][1];
  18709. }
  18710. /**
  18711. * Checks if a list cache value for `key` exists.
  18712. *
  18713. * @private
  18714. * @name has
  18715. * @memberOf ListCache
  18716. * @param {string} key The key of the entry to check.
  18717. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  18718. */
  18719. function listCacheHas(key) {
  18720. return assocIndexOf(this.__data__, key) > -1;
  18721. }
  18722. /**
  18723. * Sets the list cache `key` to `value`.
  18724. *
  18725. * @private
  18726. * @name set
  18727. * @memberOf ListCache
  18728. * @param {string} key The key of the value to set.
  18729. * @param {*} value The value to set.
  18730. * @returns {Object} Returns the list cache instance.
  18731. */
  18732. function listCacheSet(key, value) {
  18733. var data = this.__data__,
  18734. index = assocIndexOf(data, key);
  18735. if (index < 0) {
  18736. ++this.size;
  18737. data.push([key, value]);
  18738. } else {
  18739. data[index][1] = value;
  18740. }
  18741. return this;
  18742. }
  18743. // Add methods to `ListCache`.
  18744. ListCache.prototype.clear = listCacheClear;
  18745. ListCache.prototype['delete'] = listCacheDelete;
  18746. ListCache.prototype.get = listCacheGet;
  18747. ListCache.prototype.has = listCacheHas;
  18748. ListCache.prototype.set = listCacheSet;
  18749. /*------------------------------------------------------------------------*/
  18750. /**
  18751. * Creates a map cache object to store key-value pairs.
  18752. *
  18753. * @private
  18754. * @constructor
  18755. * @param {Array} [entries] The key-value pairs to cache.
  18756. */
  18757. function MapCache(entries) {
  18758. var index = -1,
  18759. length = entries == null ? 0 : entries.length;
  18760. this.clear();
  18761. while (++index < length) {
  18762. var entry = entries[index];
  18763. this.set(entry[0], entry[1]);
  18764. }
  18765. }
  18766. /**
  18767. * Removes all key-value entries from the map.
  18768. *
  18769. * @private
  18770. * @name clear
  18771. * @memberOf MapCache
  18772. */
  18773. function mapCacheClear() {
  18774. this.size = 0;
  18775. this.__data__ = {
  18776. 'hash': new Hash,
  18777. 'map': new (Map || ListCache),
  18778. 'string': new Hash
  18779. };
  18780. }
  18781. /**
  18782. * Removes `key` and its value from the map.
  18783. *
  18784. * @private
  18785. * @name delete
  18786. * @memberOf MapCache
  18787. * @param {string} key The key of the value to remove.
  18788. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  18789. */
  18790. function mapCacheDelete(key) {
  18791. var result = getMapData(this, key)['delete'](key);
  18792. this.size -= result ? 1 : 0;
  18793. return result;
  18794. }
  18795. /**
  18796. * Gets the map value for `key`.
  18797. *
  18798. * @private
  18799. * @name get
  18800. * @memberOf MapCache
  18801. * @param {string} key The key of the value to get.
  18802. * @returns {*} Returns the entry value.
  18803. */
  18804. function mapCacheGet(key) {
  18805. return getMapData(this, key).get(key);
  18806. }
  18807. /**
  18808. * Checks if a map value for `key` exists.
  18809. *
  18810. * @private
  18811. * @name has
  18812. * @memberOf MapCache
  18813. * @param {string} key The key of the entry to check.
  18814. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  18815. */
  18816. function mapCacheHas(key) {
  18817. return getMapData(this, key).has(key);
  18818. }
  18819. /**
  18820. * Sets the map `key` to `value`.
  18821. *
  18822. * @private
  18823. * @name set
  18824. * @memberOf MapCache
  18825. * @param {string} key The key of the value to set.
  18826. * @param {*} value The value to set.
  18827. * @returns {Object} Returns the map cache instance.
  18828. */
  18829. function mapCacheSet(key, value) {
  18830. var data = getMapData(this, key),
  18831. size = data.size;
  18832. data.set(key, value);
  18833. this.size += data.size == size ? 0 : 1;
  18834. return this;
  18835. }
  18836. // Add methods to `MapCache`.
  18837. MapCache.prototype.clear = mapCacheClear;
  18838. MapCache.prototype['delete'] = mapCacheDelete;
  18839. MapCache.prototype.get = mapCacheGet;
  18840. MapCache.prototype.has = mapCacheHas;
  18841. MapCache.prototype.set = mapCacheSet;
  18842. /*------------------------------------------------------------------------*/
  18843. /**
  18844. *
  18845. * Creates an array cache object to store unique values.
  18846. *
  18847. * @private
  18848. * @constructor
  18849. * @param {Array} [values] The values to cache.
  18850. */
  18851. function SetCache(values) {
  18852. var index = -1,
  18853. length = values == null ? 0 : values.length;
  18854. this.__data__ = new MapCache;
  18855. while (++index < length) {
  18856. this.add(values[index]);
  18857. }
  18858. }
  18859. /**
  18860. * Adds `value` to the array cache.
  18861. *
  18862. * @private
  18863. * @name add
  18864. * @memberOf SetCache
  18865. * @alias push
  18866. * @param {*} value The value to cache.
  18867. * @returns {Object} Returns the cache instance.
  18868. */
  18869. function setCacheAdd(value) {
  18870. this.__data__.set(value, HASH_UNDEFINED);
  18871. return this;
  18872. }
  18873. /**
  18874. * Checks if `value` is in the array cache.
  18875. *
  18876. * @private
  18877. * @name has
  18878. * @memberOf SetCache
  18879. * @param {*} value The value to search for.
  18880. * @returns {number} Returns `true` if `value` is found, else `false`.
  18881. */
  18882. function setCacheHas(value) {
  18883. return this.__data__.has(value);
  18884. }
  18885. // Add methods to `SetCache`.
  18886. SetCache.prototype.add = SetCache.prototype.push = setCacheAdd;
  18887. SetCache.prototype.has = setCacheHas;
  18888. /*------------------------------------------------------------------------*/
  18889. /**
  18890. * Creates a stack cache object to store key-value pairs.
  18891. *
  18892. * @private
  18893. * @constructor
  18894. * @param {Array} [entries] The key-value pairs to cache.
  18895. */
  18896. function Stack(entries) {
  18897. var data = this.__data__ = new ListCache(entries);
  18898. this.size = data.size;
  18899. }
  18900. /**
  18901. * Removes all key-value entries from the stack.
  18902. *
  18903. * @private
  18904. * @name clear
  18905. * @memberOf Stack
  18906. */
  18907. function stackClear() {
  18908. this.__data__ = new ListCache;
  18909. this.size = 0;
  18910. }
  18911. /**
  18912. * Removes `key` and its value from the stack.
  18913. *
  18914. * @private
  18915. * @name delete
  18916. * @memberOf Stack
  18917. * @param {string} key The key of the value to remove.
  18918. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  18919. */
  18920. function stackDelete(key) {
  18921. var data = this.__data__,
  18922. result = data['delete'](key);
  18923. this.size = data.size;
  18924. return result;
  18925. }
  18926. /**
  18927. * Gets the stack value for `key`.
  18928. *
  18929. * @private
  18930. * @name get
  18931. * @memberOf Stack
  18932. * @param {string} key The key of the value to get.
  18933. * @returns {*} Returns the entry value.
  18934. */
  18935. function stackGet(key) {
  18936. return this.__data__.get(key);
  18937. }
  18938. /**
  18939. * Checks if a stack value for `key` exists.
  18940. *
  18941. * @private
  18942. * @name has
  18943. * @memberOf Stack
  18944. * @param {string} key The key of the entry to check.
  18945. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  18946. */
  18947. function stackHas(key) {
  18948. return this.__data__.has(key);
  18949. }
  18950. /**
  18951. * Sets the stack `key` to `value`.
  18952. *
  18953. * @private
  18954. * @name set
  18955. * @memberOf Stack
  18956. * @param {string} key The key of the value to set.
  18957. * @param {*} value The value to set.
  18958. * @returns {Object} Returns the stack cache instance.
  18959. */
  18960. function stackSet(key, value) {
  18961. var data = this.__data__;
  18962. if (data instanceof ListCache) {
  18963. var pairs = data.__data__;
  18964. if (!Map || (pairs.length < LARGE_ARRAY_SIZE - 1)) {
  18965. pairs.push([key, value]);
  18966. this.size = ++data.size;
  18967. return this;
  18968. }
  18969. data = this.__data__ = new MapCache(pairs);
  18970. }
  18971. data.set(key, value);
  18972. this.size = data.size;
  18973. return this;
  18974. }
  18975. // Add methods to `Stack`.
  18976. Stack.prototype.clear = stackClear;
  18977. Stack.prototype['delete'] = stackDelete;
  18978. Stack.prototype.get = stackGet;
  18979. Stack.prototype.has = stackHas;
  18980. Stack.prototype.set = stackSet;
  18981. /*------------------------------------------------------------------------*/
  18982. /**
  18983. * Creates an array of the enumerable property names of the array-like `value`.
  18984. *
  18985. * @private
  18986. * @param {*} value The value to query.
  18987. * @param {boolean} inherited Specify returning inherited property names.
  18988. * @returns {Array} Returns the array of property names.
  18989. */
  18990. function arrayLikeKeys(value, inherited) {
  18991. var isArr = isArray(value),
  18992. isArg = !isArr && isArguments(value),
  18993. isBuff = !isArr && !isArg && isBuffer(value),
  18994. isType = !isArr && !isArg && !isBuff && isTypedArray(value),
  18995. skipIndexes = isArr || isArg || isBuff || isType,
  18996. result = skipIndexes ? baseTimes(value.length, String) : [],
  18997. length = result.length;
  18998. for (var key in value) {
  18999. if ((inherited || hasOwnProperty.call(value, key)) &&
  19000. !(skipIndexes && (
  19001. // Safari 9 has enumerable `arguments.length` in strict mode.
  19002. key == 'length' ||
  19003. // Node.js 0.10 has enumerable non-index properties on buffers.
  19004. (isBuff && (key == 'offset' || key == 'parent')) ||
  19005. // PhantomJS 2 has enumerable non-index properties on typed arrays.
  19006. (isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) ||
  19007. // Skip index properties.
  19008. isIndex(key, length)
  19009. ))) {
  19010. result.push(key);
  19011. }
  19012. }
  19013. return result;
  19014. }
  19015. /**
  19016. * A specialized version of `_.sample` for arrays.
  19017. *
  19018. * @private
  19019. * @param {Array} array The array to sample.
  19020. * @returns {*} Returns the random element.
  19021. */
  19022. function arraySample(array) {
  19023. var length = array.length;
  19024. return length ? array[baseRandom(0, length - 1)] : undefined;
  19025. }
  19026. /**
  19027. * A specialized version of `_.sampleSize` for arrays.
  19028. *
  19029. * @private
  19030. * @param {Array} array The array to sample.
  19031. * @param {number} n The number of elements to sample.
  19032. * @returns {Array} Returns the random elements.
  19033. */
  19034. function arraySampleSize(array, n) {
  19035. return shuffleSelf(copyArray(array), baseClamp(n, 0, array.length));
  19036. }
  19037. /**
  19038. * A specialized version of `_.shuffle` for arrays.
  19039. *
  19040. * @private
  19041. * @param {Array} array The array to shuffle.
  19042. * @returns {Array} Returns the new shuffled array.
  19043. */
  19044. function arrayShuffle(array) {
  19045. return shuffleSelf(copyArray(array));
  19046. }
  19047. /**
  19048. * This function is like `assignValue` except that it doesn't assign
  19049. * `undefined` values.
  19050. *
  19051. * @private
  19052. * @param {Object} object The object to modify.
  19053. * @param {string} key The key of the property to assign.
  19054. * @param {*} value The value to assign.
  19055. */
  19056. function assignMergeValue(object, key, value) {
  19057. if ((value !== undefined && !eq(object[key], value)) ||
  19058. (value === undefined && !(key in object))) {
  19059. baseAssignValue(object, key, value);
  19060. }
  19061. }
  19062. /**
  19063. * Assigns `value` to `key` of `object` if the existing value is not equivalent
  19064. * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  19065. * for equality comparisons.
  19066. *
  19067. * @private
  19068. * @param {Object} object The object to modify.
  19069. * @param {string} key The key of the property to assign.
  19070. * @param {*} value The value to assign.
  19071. */
  19072. function assignValue(object, key, value) {
  19073. var objValue = object[key];
  19074. if (!(hasOwnProperty.call(object, key) && eq(objValue, value)) ||
  19075. (value === undefined && !(key in object))) {
  19076. baseAssignValue(object, key, value);
  19077. }
  19078. }
  19079. /**
  19080. * Gets the index at which the `key` is found in `array` of key-value pairs.
  19081. *
  19082. * @private
  19083. * @param {Array} array The array to inspect.
  19084. * @param {*} key The key to search for.
  19085. * @returns {number} Returns the index of the matched value, else `-1`.
  19086. */
  19087. function assocIndexOf(array, key) {
  19088. var length = array.length;
  19089. while (length--) {
  19090. if (eq(array[length][0], key)) {
  19091. return length;
  19092. }
  19093. }
  19094. return -1;
  19095. }
  19096. /**
  19097. * Aggregates elements of `collection` on `accumulator` with keys transformed
  19098. * by `iteratee` and values set by `setter`.
  19099. *
  19100. * @private
  19101. * @param {Array|Object} collection The collection to iterate over.
  19102. * @param {Function} setter The function to set `accumulator` values.
  19103. * @param {Function} iteratee The iteratee to transform keys.
  19104. * @param {Object} accumulator The initial aggregated object.
  19105. * @returns {Function} Returns `accumulator`.
  19106. */
  19107. function baseAggregator(collection, setter, iteratee, accumulator) {
  19108. baseEach(collection, function(value, key, collection) {
  19109. setter(accumulator, value, iteratee(value), collection);
  19110. });
  19111. return accumulator;
  19112. }
  19113. /**
  19114. * The base implementation of `_.assign` without support for multiple sources
  19115. * or `customizer` functions.
  19116. *
  19117. * @private
  19118. * @param {Object} object The destination object.
  19119. * @param {Object} source The source object.
  19120. * @returns {Object} Returns `object`.
  19121. */
  19122. function baseAssign(object, source) {
  19123. return object && copyObject(source, keys(source), object);
  19124. }
  19125. /**
  19126. * The base implementation of `_.assignIn` without support for multiple sources
  19127. * or `customizer` functions.
  19128. *
  19129. * @private
  19130. * @param {Object} object The destination object.
  19131. * @param {Object} source The source object.
  19132. * @returns {Object} Returns `object`.
  19133. */
  19134. function baseAssignIn(object, source) {
  19135. return object && copyObject(source, keysIn(source), object);
  19136. }
  19137. /**
  19138. * The base implementation of `assignValue` and `assignMergeValue` without
  19139. * value checks.
  19140. *
  19141. * @private
  19142. * @param {Object} object The object to modify.
  19143. * @param {string} key The key of the property to assign.
  19144. * @param {*} value The value to assign.
  19145. */
  19146. function baseAssignValue(object, key, value) {
  19147. if (key == '__proto__' && defineProperty) {
  19148. defineProperty(object, key, {
  19149. 'configurable': true,
  19150. 'enumerable': true,
  19151. 'value': value,
  19152. 'writable': true
  19153. });
  19154. } else {
  19155. object[key] = value;
  19156. }
  19157. }
  19158. /**
  19159. * The base implementation of `_.at` without support for individual paths.
  19160. *
  19161. * @private
  19162. * @param {Object} object The object to iterate over.
  19163. * @param {string[]} paths The property paths to pick.
  19164. * @returns {Array} Returns the picked elements.
  19165. */
  19166. function baseAt(object, paths) {
  19167. var index = -1,
  19168. length = paths.length,
  19169. result = Array(length),
  19170. skip = object == null;
  19171. while (++index < length) {
  19172. result[index] = skip ? undefined : get(object, paths[index]);
  19173. }
  19174. return result;
  19175. }
  19176. /**
  19177. * The base implementation of `_.clamp` which doesn't coerce arguments.
  19178. *
  19179. * @private
  19180. * @param {number} number The number to clamp.
  19181. * @param {number} [lower] The lower bound.
  19182. * @param {number} upper The upper bound.
  19183. * @returns {number} Returns the clamped number.
  19184. */
  19185. function baseClamp(number, lower, upper) {
  19186. if (number === number) {
  19187. if (upper !== undefined) {
  19188. number = number <= upper ? number : upper;
  19189. }
  19190. if (lower !== undefined) {
  19191. number = number >= lower ? number : lower;
  19192. }
  19193. }
  19194. return number;
  19195. }
  19196. /**
  19197. * The base implementation of `_.clone` and `_.cloneDeep` which tracks
  19198. * traversed objects.
  19199. *
  19200. * @private
  19201. * @param {*} value The value to clone.
  19202. * @param {boolean} bitmask The bitmask flags.
  19203. * 1 - Deep clone
  19204. * 2 - Flatten inherited properties
  19205. * 4 - Clone symbols
  19206. * @param {Function} [customizer] The function to customize cloning.
  19207. * @param {string} [key] The key of `value`.
  19208. * @param {Object} [object] The parent object of `value`.
  19209. * @param {Object} [stack] Tracks traversed objects and their clone counterparts.
  19210. * @returns {*} Returns the cloned value.
  19211. */
  19212. function baseClone(value, bitmask, customizer, key, object, stack) {
  19213. var result,
  19214. isDeep = bitmask & CLONE_DEEP_FLAG,
  19215. isFlat = bitmask & CLONE_FLAT_FLAG,
  19216. isFull = bitmask & CLONE_SYMBOLS_FLAG;
  19217. if (customizer) {
  19218. result = object ? customizer(value, key, object, stack) : customizer(value);
  19219. }
  19220. if (result !== undefined) {
  19221. return result;
  19222. }
  19223. if (!isObject(value)) {
  19224. return value;
  19225. }
  19226. var isArr = isArray(value);
  19227. if (isArr) {
  19228. result = initCloneArray(value);
  19229. if (!isDeep) {
  19230. return copyArray(value, result);
  19231. }
  19232. } else {
  19233. var tag = getTag(value),
  19234. isFunc = tag == funcTag || tag == genTag;
  19235. if (isBuffer(value)) {
  19236. return cloneBuffer(value, isDeep);
  19237. }
  19238. if (tag == objectTag || tag == argsTag || (isFunc && !object)) {
  19239. result = (isFlat || isFunc) ? {} : initCloneObject(value);
  19240. if (!isDeep) {
  19241. return isFlat
  19242. ? copySymbolsIn(value, baseAssignIn(result, value))
  19243. : copySymbols(value, baseAssign(result, value));
  19244. }
  19245. } else {
  19246. if (!cloneableTags[tag]) {
  19247. return object ? value : {};
  19248. }
  19249. result = initCloneByTag(value, tag, isDeep);
  19250. }
  19251. }
  19252. // Check for circular references and return its corresponding clone.
  19253. stack || (stack = new Stack);
  19254. var stacked = stack.get(value);
  19255. if (stacked) {
  19256. return stacked;
  19257. }
  19258. stack.set(value, result);
  19259. if (isSet(value)) {
  19260. value.forEach(function(subValue) {
  19261. result.add(baseClone(subValue, bitmask, customizer, subValue, value, stack));
  19262. });
  19263. } else if (isMap(value)) {
  19264. value.forEach(function(subValue, key) {
  19265. result.set(key, baseClone(subValue, bitmask, customizer, key, value, stack));
  19266. });
  19267. }
  19268. var keysFunc = isFull
  19269. ? (isFlat ? getAllKeysIn : getAllKeys)
  19270. : (isFlat ? keysIn : keys);
  19271. var props = isArr ? undefined : keysFunc(value);
  19272. arrayEach(props || value, function(subValue, key) {
  19273. if (props) {
  19274. key = subValue;
  19275. subValue = value[key];
  19276. }
  19277. // Recursively populate clone (susceptible to call stack limits).
  19278. assignValue(result, key, baseClone(subValue, bitmask, customizer, key, value, stack));
  19279. });
  19280. return result;
  19281. }
  19282. /**
  19283. * The base implementation of `_.conforms` which doesn't clone `source`.
  19284. *
  19285. * @private
  19286. * @param {Object} source The object of property predicates to conform to.
  19287. * @returns {Function} Returns the new spec function.
  19288. */
  19289. function baseConforms(source) {
  19290. var props = keys(source);
  19291. return function(object) {
  19292. return baseConformsTo(object, source, props);
  19293. };
  19294. }
  19295. /**
  19296. * The base implementation of `_.conformsTo` which accepts `props` to check.
  19297. *
  19298. * @private
  19299. * @param {Object} object The object to inspect.
  19300. * @param {Object} source The object of property predicates to conform to.
  19301. * @returns {boolean} Returns `true` if `object` conforms, else `false`.
  19302. */
  19303. function baseConformsTo(object, source, props) {
  19304. var length = props.length;
  19305. if (object == null) {
  19306. return !length;
  19307. }
  19308. object = Object(object);
  19309. while (length--) {
  19310. var key = props[length],
  19311. predicate = source[key],
  19312. value = object[key];
  19313. if ((value === undefined && !(key in object)) || !predicate(value)) {
  19314. return false;
  19315. }
  19316. }
  19317. return true;
  19318. }
  19319. /**
  19320. * The base implementation of `_.delay` and `_.defer` which accepts `args`
  19321. * to provide to `func`.
  19322. *
  19323. * @private
  19324. * @param {Function} func The function to delay.
  19325. * @param {number} wait The number of milliseconds to delay invocation.
  19326. * @param {Array} args The arguments to provide to `func`.
  19327. * @returns {number|Object} Returns the timer id or timeout object.
  19328. */
  19329. function baseDelay(func, wait, args) {
  19330. if (typeof func != 'function') {
  19331. throw new TypeError(FUNC_ERROR_TEXT);
  19332. }
  19333. return setTimeout(function() { func.apply(undefined, args); }, wait);
  19334. }
  19335. /**
  19336. * The base implementation of methods like `_.difference` without support
  19337. * for excluding multiple arrays or iteratee shorthands.
  19338. *
  19339. * @private
  19340. * @param {Array} array The array to inspect.
  19341. * @param {Array} values The values to exclude.
  19342. * @param {Function} [iteratee] The iteratee invoked per element.
  19343. * @param {Function} [comparator] The comparator invoked per element.
  19344. * @returns {Array} Returns the new array of filtered values.
  19345. */
  19346. function baseDifference(array, values, iteratee, comparator) {
  19347. var index = -1,
  19348. includes = arrayIncludes,
  19349. isCommon = true,
  19350. length = array.length,
  19351. result = [],
  19352. valuesLength = values.length;
  19353. if (!length) {
  19354. return result;
  19355. }
  19356. if (iteratee) {
  19357. values = arrayMap(values, baseUnary(iteratee));
  19358. }
  19359. if (comparator) {
  19360. includes = arrayIncludesWith;
  19361. isCommon = false;
  19362. }
  19363. else if (values.length >= LARGE_ARRAY_SIZE) {
  19364. includes = cacheHas;
  19365. isCommon = false;
  19366. values = new SetCache(values);
  19367. }
  19368. outer:
  19369. while (++index < length) {
  19370. var value = array[index],
  19371. computed = iteratee == null ? value : iteratee(value);
  19372. value = (comparator || value !== 0) ? value : 0;
  19373. if (isCommon && computed === computed) {
  19374. var valuesIndex = valuesLength;
  19375. while (valuesIndex--) {
  19376. if (values[valuesIndex] === computed) {
  19377. continue outer;
  19378. }
  19379. }
  19380. result.push(value);
  19381. }
  19382. else if (!includes(values, computed, comparator)) {
  19383. result.push(value);
  19384. }
  19385. }
  19386. return result;
  19387. }
  19388. /**
  19389. * The base implementation of `_.forEach` without support for iteratee shorthands.
  19390. *
  19391. * @private
  19392. * @param {Array|Object} collection The collection to iterate over.
  19393. * @param {Function} iteratee The function invoked per iteration.
  19394. * @returns {Array|Object} Returns `collection`.
  19395. */
  19396. var baseEach = createBaseEach(baseForOwn);
  19397. /**
  19398. * The base implementation of `_.forEachRight` without support for iteratee shorthands.
  19399. *
  19400. * @private
  19401. * @param {Array|Object} collection The collection to iterate over.
  19402. * @param {Function} iteratee The function invoked per iteration.
  19403. * @returns {Array|Object} Returns `collection`.
  19404. */
  19405. var baseEachRight = createBaseEach(baseForOwnRight, true);
  19406. /**
  19407. * The base implementation of `_.every` without support for iteratee shorthands.
  19408. *
  19409. * @private
  19410. * @param {Array|Object} collection The collection to iterate over.
  19411. * @param {Function} predicate The function invoked per iteration.
  19412. * @returns {boolean} Returns `true` if all elements pass the predicate check,
  19413. * else `false`
  19414. */
  19415. function baseEvery(collection, predicate) {
  19416. var result = true;
  19417. baseEach(collection, function(value, index, collection) {
  19418. result = !!predicate(value, index, collection);
  19419. return result;
  19420. });
  19421. return result;
  19422. }
  19423. /**
  19424. * The base implementation of methods like `_.max` and `_.min` which accepts a
  19425. * `comparator` to determine the extremum value.
  19426. *
  19427. * @private
  19428. * @param {Array} array The array to iterate over.
  19429. * @param {Function} iteratee The iteratee invoked per iteration.
  19430. * @param {Function} comparator The comparator used to compare values.
  19431. * @returns {*} Returns the extremum value.
  19432. */
  19433. function baseExtremum(array, iteratee, comparator) {
  19434. var index = -1,
  19435. length = array.length;
  19436. while (++index < length) {
  19437. var value = array[index],
  19438. current = iteratee(value);
  19439. if (current != null && (computed === undefined
  19440. ? (current === current && !isSymbol(current))
  19441. : comparator(current, computed)
  19442. )) {
  19443. var computed = current,
  19444. result = value;
  19445. }
  19446. }
  19447. return result;
  19448. }
  19449. /**
  19450. * The base implementation of `_.fill` without an iteratee call guard.
  19451. *
  19452. * @private
  19453. * @param {Array} array The array to fill.
  19454. * @param {*} value The value to fill `array` with.
  19455. * @param {number} [start=0] The start position.
  19456. * @param {number} [end=array.length] The end position.
  19457. * @returns {Array} Returns `array`.
  19458. */
  19459. function baseFill(array, value, start, end) {
  19460. var length = array.length;
  19461. start = toInteger(start);
  19462. if (start < 0) {
  19463. start = -start > length ? 0 : (length + start);
  19464. }
  19465. end = (end === undefined || end > length) ? length : toInteger(end);
  19466. if (end < 0) {
  19467. end += length;
  19468. }
  19469. end = start > end ? 0 : toLength(end);
  19470. while (start < end) {
  19471. array[start++] = value;
  19472. }
  19473. return array;
  19474. }
  19475. /**
  19476. * The base implementation of `_.filter` without support for iteratee shorthands.
  19477. *
  19478. * @private
  19479. * @param {Array|Object} collection The collection to iterate over.
  19480. * @param {Function} predicate The function invoked per iteration.
  19481. * @returns {Array} Returns the new filtered array.
  19482. */
  19483. function baseFilter(collection, predicate) {
  19484. var result = [];
  19485. baseEach(collection, function(value, index, collection) {
  19486. if (predicate(value, index, collection)) {
  19487. result.push(value);
  19488. }
  19489. });
  19490. return result;
  19491. }
  19492. /**
  19493. * The base implementation of `_.flatten` with support for restricting flattening.
  19494. *
  19495. * @private
  19496. * @param {Array} array The array to flatten.
  19497. * @param {number} depth The maximum recursion depth.
  19498. * @param {boolean} [predicate=isFlattenable] The function invoked per iteration.
  19499. * @param {boolean} [isStrict] Restrict to values that pass `predicate` checks.
  19500. * @param {Array} [result=[]] The initial result value.
  19501. * @returns {Array} Returns the new flattened array.
  19502. */
  19503. function baseFlatten(array, depth, predicate, isStrict, result) {
  19504. var index = -1,
  19505. length = array.length;
  19506. predicate || (predicate = isFlattenable);
  19507. result || (result = []);
  19508. while (++index < length) {
  19509. var value = array[index];
  19510. if (depth > 0 && predicate(value)) {
  19511. if (depth > 1) {
  19512. // Recursively flatten arrays (susceptible to call stack limits).
  19513. baseFlatten(value, depth - 1, predicate, isStrict, result);
  19514. } else {
  19515. arrayPush(result, value);
  19516. }
  19517. } else if (!isStrict) {
  19518. result[result.length] = value;
  19519. }
  19520. }
  19521. return result;
  19522. }
  19523. /**
  19524. * The base implementation of `baseForOwn` which iterates over `object`
  19525. * properties returned by `keysFunc` and invokes `iteratee` for each property.
  19526. * Iteratee functions may exit iteration early by explicitly returning `false`.
  19527. *
  19528. * @private
  19529. * @param {Object} object The object to iterate over.
  19530. * @param {Function} iteratee The function invoked per iteration.
  19531. * @param {Function} keysFunc The function to get the keys of `object`.
  19532. * @returns {Object} Returns `object`.
  19533. */
  19534. var baseFor = createBaseFor();
  19535. /**
  19536. * This function is like `baseFor` except that it iterates over properties
  19537. * in the opposite order.
  19538. *
  19539. * @private
  19540. * @param {Object} object The object to iterate over.
  19541. * @param {Function} iteratee The function invoked per iteration.
  19542. * @param {Function} keysFunc The function to get the keys of `object`.
  19543. * @returns {Object} Returns `object`.
  19544. */
  19545. var baseForRight = createBaseFor(true);
  19546. /**
  19547. * The base implementation of `_.forOwn` without support for iteratee shorthands.
  19548. *
  19549. * @private
  19550. * @param {Object} object The object to iterate over.
  19551. * @param {Function} iteratee The function invoked per iteration.
  19552. * @returns {Object} Returns `object`.
  19553. */
  19554. function baseForOwn(object, iteratee) {
  19555. return object && baseFor(object, iteratee, keys);
  19556. }
  19557. /**
  19558. * The base implementation of `_.forOwnRight` without support for iteratee shorthands.
  19559. *
  19560. * @private
  19561. * @param {Object} object The object to iterate over.
  19562. * @param {Function} iteratee The function invoked per iteration.
  19563. * @returns {Object} Returns `object`.
  19564. */
  19565. function baseForOwnRight(object, iteratee) {
  19566. return object && baseForRight(object, iteratee, keys);
  19567. }
  19568. /**
  19569. * The base implementation of `_.functions` which creates an array of
  19570. * `object` function property names filtered from `props`.
  19571. *
  19572. * @private
  19573. * @param {Object} object The object to inspect.
  19574. * @param {Array} props The property names to filter.
  19575. * @returns {Array} Returns the function names.
  19576. */
  19577. function baseFunctions(object, props) {
  19578. return arrayFilter(props, function(key) {
  19579. return isFunction(object[key]);
  19580. });
  19581. }
  19582. /**
  19583. * The base implementation of `_.get` without support for default values.
  19584. *
  19585. * @private
  19586. * @param {Object} object The object to query.
  19587. * @param {Array|string} path The path of the property to get.
  19588. * @returns {*} Returns the resolved value.
  19589. */
  19590. function baseGet(object, path) {
  19591. path = castPath(path, object);
  19592. var index = 0,
  19593. length = path.length;
  19594. while (object != null && index < length) {
  19595. object = object[toKey(path[index++])];
  19596. }
  19597. return (index && index == length) ? object : undefined;
  19598. }
  19599. /**
  19600. * The base implementation of `getAllKeys` and `getAllKeysIn` which uses
  19601. * `keysFunc` and `symbolsFunc` to get the enumerable property names and
  19602. * symbols of `object`.
  19603. *
  19604. * @private
  19605. * @param {Object} object The object to query.
  19606. * @param {Function} keysFunc The function to get the keys of `object`.
  19607. * @param {Function} symbolsFunc The function to get the symbols of `object`.
  19608. * @returns {Array} Returns the array of property names and symbols.
  19609. */
  19610. function baseGetAllKeys(object, keysFunc, symbolsFunc) {
  19611. var result = keysFunc(object);
  19612. return isArray(object) ? result : arrayPush(result, symbolsFunc(object));
  19613. }
  19614. /**
  19615. * The base implementation of `getTag` without fallbacks for buggy environments.
  19616. *
  19617. * @private
  19618. * @param {*} value The value to query.
  19619. * @returns {string} Returns the `toStringTag`.
  19620. */
  19621. function baseGetTag(value) {
  19622. if (value == null) {
  19623. return value === undefined ? undefinedTag : nullTag;
  19624. }
  19625. return (symToStringTag && symToStringTag in Object(value))
  19626. ? getRawTag(value)
  19627. : objectToString(value);
  19628. }
  19629. /**
  19630. * The base implementation of `_.gt` which doesn't coerce arguments.
  19631. *
  19632. * @private
  19633. * @param {*} value The value to compare.
  19634. * @param {*} other The other value to compare.
  19635. * @returns {boolean} Returns `true` if `value` is greater than `other`,
  19636. * else `false`.
  19637. */
  19638. function baseGt(value, other) {
  19639. return value > other;
  19640. }
  19641. /**
  19642. * The base implementation of `_.has` without support for deep paths.
  19643. *
  19644. * @private
  19645. * @param {Object} [object] The object to query.
  19646. * @param {Array|string} key The key to check.
  19647. * @returns {boolean} Returns `true` if `key` exists, else `false`.
  19648. */
  19649. function baseHas(object, key) {
  19650. return object != null && hasOwnProperty.call(object, key);
  19651. }
  19652. /**
  19653. * The base implementation of `_.hasIn` without support for deep paths.
  19654. *
  19655. * @private
  19656. * @param {Object} [object] The object to query.
  19657. * @param {Array|string} key The key to check.
  19658. * @returns {boolean} Returns `true` if `key` exists, else `false`.
  19659. */
  19660. function baseHasIn(object, key) {
  19661. return object != null && key in Object(object);
  19662. }
  19663. /**
  19664. * The base implementation of `_.inRange` which doesn't coerce arguments.
  19665. *
  19666. * @private
  19667. * @param {number} number The number to check.
  19668. * @param {number} start The start of the range.
  19669. * @param {number} end The end of the range.
  19670. * @returns {boolean} Returns `true` if `number` is in the range, else `false`.
  19671. */
  19672. function baseInRange(number, start, end) {
  19673. return number >= nativeMin(start, end) && number < nativeMax(start, end);
  19674. }
  19675. /**
  19676. * The base implementation of methods like `_.intersection`, without support
  19677. * for iteratee shorthands, that accepts an array of arrays to inspect.
  19678. *
  19679. * @private
  19680. * @param {Array} arrays The arrays to inspect.
  19681. * @param {Function} [iteratee] The iteratee invoked per element.
  19682. * @param {Function} [comparator] The comparator invoked per element.
  19683. * @returns {Array} Returns the new array of shared values.
  19684. */
  19685. function baseIntersection(arrays, iteratee, comparator) {
  19686. var includes = comparator ? arrayIncludesWith : arrayIncludes,
  19687. length = arrays[0].length,
  19688. othLength = arrays.length,
  19689. othIndex = othLength,
  19690. caches = Array(othLength),
  19691. maxLength = Infinity,
  19692. result = [];
  19693. while (othIndex--) {
  19694. var array = arrays[othIndex];
  19695. if (othIndex && iteratee) {
  19696. array = arrayMap(array, baseUnary(iteratee));
  19697. }
  19698. maxLength = nativeMin(array.length, maxLength);
  19699. caches[othIndex] = !comparator && (iteratee || (length >= 120 && array.length >= 120))
  19700. ? new SetCache(othIndex && array)
  19701. : undefined;
  19702. }
  19703. array = arrays[0];
  19704. var index = -1,
  19705. seen = caches[0];
  19706. outer:
  19707. while (++index < length && result.length < maxLength) {
  19708. var value = array[index],
  19709. computed = iteratee ? iteratee(value) : value;
  19710. value = (comparator || value !== 0) ? value : 0;
  19711. if (!(seen
  19712. ? cacheHas(seen, computed)
  19713. : includes(result, computed, comparator)
  19714. )) {
  19715. othIndex = othLength;
  19716. while (--othIndex) {
  19717. var cache = caches[othIndex];
  19718. if (!(cache
  19719. ? cacheHas(cache, computed)
  19720. : includes(arrays[othIndex], computed, comparator))
  19721. ) {
  19722. continue outer;
  19723. }
  19724. }
  19725. if (seen) {
  19726. seen.push(computed);
  19727. }
  19728. result.push(value);
  19729. }
  19730. }
  19731. return result;
  19732. }
  19733. /**
  19734. * The base implementation of `_.invert` and `_.invertBy` which inverts
  19735. * `object` with values transformed by `iteratee` and set by `setter`.
  19736. *
  19737. * @private
  19738. * @param {Object} object The object to iterate over.
  19739. * @param {Function} setter The function to set `accumulator` values.
  19740. * @param {Function} iteratee The iteratee to transform values.
  19741. * @param {Object} accumulator The initial inverted object.
  19742. * @returns {Function} Returns `accumulator`.
  19743. */
  19744. function baseInverter(object, setter, iteratee, accumulator) {
  19745. baseForOwn(object, function(value, key, object) {
  19746. setter(accumulator, iteratee(value), key, object);
  19747. });
  19748. return accumulator;
  19749. }
  19750. /**
  19751. * The base implementation of `_.invoke` without support for individual
  19752. * method arguments.
  19753. *
  19754. * @private
  19755. * @param {Object} object The object to query.
  19756. * @param {Array|string} path The path of the method to invoke.
  19757. * @param {Array} args The arguments to invoke the method with.
  19758. * @returns {*} Returns the result of the invoked method.
  19759. */
  19760. function baseInvoke(object, path, args) {
  19761. path = castPath(path, object);
  19762. object = parent(object, path);
  19763. var func = object == null ? object : object[toKey(last(path))];
  19764. return func == null ? undefined : apply(func, object, args);
  19765. }
  19766. /**
  19767. * The base implementation of `_.isArguments`.
  19768. *
  19769. * @private
  19770. * @param {*} value The value to check.
  19771. * @returns {boolean} Returns `true` if `value` is an `arguments` object,
  19772. */
  19773. function baseIsArguments(value) {
  19774. return isObjectLike(value) && baseGetTag(value) == argsTag;
  19775. }
  19776. /**
  19777. * The base implementation of `_.isArrayBuffer` without Node.js optimizations.
  19778. *
  19779. * @private
  19780. * @param {*} value The value to check.
  19781. * @returns {boolean} Returns `true` if `value` is an array buffer, else `false`.
  19782. */
  19783. function baseIsArrayBuffer(value) {
  19784. return isObjectLike(value) && baseGetTag(value) == arrayBufferTag;
  19785. }
  19786. /**
  19787. * The base implementation of `_.isDate` without Node.js optimizations.
  19788. *
  19789. * @private
  19790. * @param {*} value The value to check.
  19791. * @returns {boolean} Returns `true` if `value` is a date object, else `false`.
  19792. */
  19793. function baseIsDate(value) {
  19794. return isObjectLike(value) && baseGetTag(value) == dateTag;
  19795. }
  19796. /**
  19797. * The base implementation of `_.isEqual` which supports partial comparisons
  19798. * and tracks traversed objects.
  19799. *
  19800. * @private
  19801. * @param {*} value The value to compare.
  19802. * @param {*} other The other value to compare.
  19803. * @param {boolean} bitmask The bitmask flags.
  19804. * 1 - Unordered comparison
  19805. * 2 - Partial comparison
  19806. * @param {Function} [customizer] The function to customize comparisons.
  19807. * @param {Object} [stack] Tracks traversed `value` and `other` objects.
  19808. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  19809. */
  19810. function baseIsEqual(value, other, bitmask, customizer, stack) {
  19811. if (value === other) {
  19812. return true;
  19813. }
  19814. if (value == null || other == null || (!isObjectLike(value) && !isObjectLike(other))) {
  19815. return value !== value && other !== other;
  19816. }
  19817. return baseIsEqualDeep(value, other, bitmask, customizer, baseIsEqual, stack);
  19818. }
  19819. /**
  19820. * A specialized version of `baseIsEqual` for arrays and objects which performs
  19821. * deep comparisons and tracks traversed objects enabling objects with circular
  19822. * references to be compared.
  19823. *
  19824. * @private
  19825. * @param {Object} object The object to compare.
  19826. * @param {Object} other The other object to compare.
  19827. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
  19828. * @param {Function} customizer The function to customize comparisons.
  19829. * @param {Function} equalFunc The function to determine equivalents of values.
  19830. * @param {Object} [stack] Tracks traversed `object` and `other` objects.
  19831. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  19832. */
  19833. function baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) {
  19834. var objIsArr = isArray(object),
  19835. othIsArr = isArray(other),
  19836. objTag = objIsArr ? arrayTag : getTag(object),
  19837. othTag = othIsArr ? arrayTag : getTag(other);
  19838. objTag = objTag == argsTag ? objectTag : objTag;
  19839. othTag = othTag == argsTag ? objectTag : othTag;
  19840. var objIsObj = objTag == objectTag,
  19841. othIsObj = othTag == objectTag,
  19842. isSameTag = objTag == othTag;
  19843. if (isSameTag && isBuffer(object)) {
  19844. if (!isBuffer(other)) {
  19845. return false;
  19846. }
  19847. objIsArr = true;
  19848. objIsObj = false;
  19849. }
  19850. if (isSameTag && !objIsObj) {
  19851. stack || (stack = new Stack);
  19852. return (objIsArr || isTypedArray(object))
  19853. ? equalArrays(object, other, bitmask, customizer, equalFunc, stack)
  19854. : equalByTag(object, other, objTag, bitmask, customizer, equalFunc, stack);
  19855. }
  19856. if (!(bitmask & COMPARE_PARTIAL_FLAG)) {
  19857. var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'),
  19858. othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__');
  19859. if (objIsWrapped || othIsWrapped) {
  19860. var objUnwrapped = objIsWrapped ? object.value() : object,
  19861. othUnwrapped = othIsWrapped ? other.value() : other;
  19862. stack || (stack = new Stack);
  19863. return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack);
  19864. }
  19865. }
  19866. if (!isSameTag) {
  19867. return false;
  19868. }
  19869. stack || (stack = new Stack);
  19870. return equalObjects(object, other, bitmask, customizer, equalFunc, stack);
  19871. }
  19872. /**
  19873. * The base implementation of `_.isMap` without Node.js optimizations.
  19874. *
  19875. * @private
  19876. * @param {*} value The value to check.
  19877. * @returns {boolean} Returns `true` if `value` is a map, else `false`.
  19878. */
  19879. function baseIsMap(value) {
  19880. return isObjectLike(value) && getTag(value) == mapTag;
  19881. }
  19882. /**
  19883. * The base implementation of `_.isMatch` without support for iteratee shorthands.
  19884. *
  19885. * @private
  19886. * @param {Object} object The object to inspect.
  19887. * @param {Object} source The object of property values to match.
  19888. * @param {Array} matchData The property names, values, and compare flags to match.
  19889. * @param {Function} [customizer] The function to customize comparisons.
  19890. * @returns {boolean} Returns `true` if `object` is a match, else `false`.
  19891. */
  19892. function baseIsMatch(object, source, matchData, customizer) {
  19893. var index = matchData.length,
  19894. length = index,
  19895. noCustomizer = !customizer;
  19896. if (object == null) {
  19897. return !length;
  19898. }
  19899. object = Object(object);
  19900. while (index--) {
  19901. var data = matchData[index];
  19902. if ((noCustomizer && data[2])
  19903. ? data[1] !== object[data[0]]
  19904. : !(data[0] in object)
  19905. ) {
  19906. return false;
  19907. }
  19908. }
  19909. while (++index < length) {
  19910. data = matchData[index];
  19911. var key = data[0],
  19912. objValue = object[key],
  19913. srcValue = data[1];
  19914. if (noCustomizer && data[2]) {
  19915. if (objValue === undefined && !(key in object)) {
  19916. return false;
  19917. }
  19918. } else {
  19919. var stack = new Stack;
  19920. if (customizer) {
  19921. var result = customizer(objValue, srcValue, key, object, source, stack);
  19922. }
  19923. if (!(result === undefined
  19924. ? baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG, customizer, stack)
  19925. : result
  19926. )) {
  19927. return false;
  19928. }
  19929. }
  19930. }
  19931. return true;
  19932. }
  19933. /**
  19934. * The base implementation of `_.isNative` without bad shim checks.
  19935. *
  19936. * @private
  19937. * @param {*} value The value to check.
  19938. * @returns {boolean} Returns `true` if `value` is a native function,
  19939. * else `false`.
  19940. */
  19941. function baseIsNative(value) {
  19942. if (!isObject(value) || isMasked(value)) {
  19943. return false;
  19944. }
  19945. var pattern = isFunction(value) ? reIsNative : reIsHostCtor;
  19946. return pattern.test(toSource(value));
  19947. }
  19948. /**
  19949. * The base implementation of `_.isRegExp` without Node.js optimizations.
  19950. *
  19951. * @private
  19952. * @param {*} value The value to check.
  19953. * @returns {boolean} Returns `true` if `value` is a regexp, else `false`.
  19954. */
  19955. function baseIsRegExp(value) {
  19956. return isObjectLike(value) && baseGetTag(value) == regexpTag;
  19957. }
  19958. /**
  19959. * The base implementation of `_.isSet` without Node.js optimizations.
  19960. *
  19961. * @private
  19962. * @param {*} value The value to check.
  19963. * @returns {boolean} Returns `true` if `value` is a set, else `false`.
  19964. */
  19965. function baseIsSet(value) {
  19966. return isObjectLike(value) && getTag(value) == setTag;
  19967. }
  19968. /**
  19969. * The base implementation of `_.isTypedArray` without Node.js optimizations.
  19970. *
  19971. * @private
  19972. * @param {*} value The value to check.
  19973. * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
  19974. */
  19975. function baseIsTypedArray(value) {
  19976. return isObjectLike(value) &&
  19977. isLength(value.length) && !!typedArrayTags[baseGetTag(value)];
  19978. }
  19979. /**
  19980. * The base implementation of `_.iteratee`.
  19981. *
  19982. * @private
  19983. * @param {*} [value=_.identity] The value to convert to an iteratee.
  19984. * @returns {Function} Returns the iteratee.
  19985. */
  19986. function baseIteratee(value) {
  19987. // Don't store the `typeof` result in a variable to avoid a JIT bug in Safari 9.
  19988. // See https://bugs.webkit.org/show_bug.cgi?id=156034 for more details.
  19989. if (typeof value == 'function') {
  19990. return value;
  19991. }
  19992. if (value == null) {
  19993. return identity;
  19994. }
  19995. if (typeof value == 'object') {
  19996. return isArray(value)
  19997. ? baseMatchesProperty(value[0], value[1])
  19998. : baseMatches(value);
  19999. }
  20000. return property(value);
  20001. }
  20002. /**
  20003. * The base implementation of `_.keys` which doesn't treat sparse arrays as dense.
  20004. *
  20005. * @private
  20006. * @param {Object} object The object to query.
  20007. * @returns {Array} Returns the array of property names.
  20008. */
  20009. function baseKeys(object) {
  20010. if (!isPrototype(object)) {
  20011. return nativeKeys(object);
  20012. }
  20013. var result = [];
  20014. for (var key in Object(object)) {
  20015. if (hasOwnProperty.call(object, key) && key != 'constructor') {
  20016. result.push(key);
  20017. }
  20018. }
  20019. return result;
  20020. }
  20021. /**
  20022. * The base implementation of `_.keysIn` which doesn't treat sparse arrays as dense.
  20023. *
  20024. * @private
  20025. * @param {Object} object The object to query.
  20026. * @returns {Array} Returns the array of property names.
  20027. */
  20028. function baseKeysIn(object) {
  20029. if (!isObject(object)) {
  20030. return nativeKeysIn(object);
  20031. }
  20032. var isProto = isPrototype(object),
  20033. result = [];
  20034. for (var key in object) {
  20035. if (!(key == 'constructor' && (isProto || !hasOwnProperty.call(object, key)))) {
  20036. result.push(key);
  20037. }
  20038. }
  20039. return result;
  20040. }
  20041. /**
  20042. * The base implementation of `_.lt` which doesn't coerce arguments.
  20043. *
  20044. * @private
  20045. * @param {*} value The value to compare.
  20046. * @param {*} other The other value to compare.
  20047. * @returns {boolean} Returns `true` if `value` is less than `other`,
  20048. * else `false`.
  20049. */
  20050. function baseLt(value, other) {
  20051. return value < other;
  20052. }
  20053. /**
  20054. * The base implementation of `_.map` without support for iteratee shorthands.
  20055. *
  20056. * @private
  20057. * @param {Array|Object} collection The collection to iterate over.
  20058. * @param {Function} iteratee The function invoked per iteration.
  20059. * @returns {Array} Returns the new mapped array.
  20060. */
  20061. function baseMap(collection, iteratee) {
  20062. var index = -1,
  20063. result = isArrayLike(collection) ? Array(collection.length) : [];
  20064. baseEach(collection, function(value, key, collection) {
  20065. result[++index] = iteratee(value, key, collection);
  20066. });
  20067. return result;
  20068. }
  20069. /**
  20070. * The base implementation of `_.matches` which doesn't clone `source`.
  20071. *
  20072. * @private
  20073. * @param {Object} source The object of property values to match.
  20074. * @returns {Function} Returns the new spec function.
  20075. */
  20076. function baseMatches(source) {
  20077. var matchData = getMatchData(source);
  20078. if (matchData.length == 1 && matchData[0][2]) {
  20079. return matchesStrictComparable(matchData[0][0], matchData[0][1]);
  20080. }
  20081. return function(object) {
  20082. return object === source || baseIsMatch(object, source, matchData);
  20083. };
  20084. }
  20085. /**
  20086. * The base implementation of `_.matchesProperty` which doesn't clone `srcValue`.
  20087. *
  20088. * @private
  20089. * @param {string} path The path of the property to get.
  20090. * @param {*} srcValue The value to match.
  20091. * @returns {Function} Returns the new spec function.
  20092. */
  20093. function baseMatchesProperty(path, srcValue) {
  20094. if (isKey(path) && isStrictComparable(srcValue)) {
  20095. return matchesStrictComparable(toKey(path), srcValue);
  20096. }
  20097. return function(object) {
  20098. var objValue = get(object, path);
  20099. return (objValue === undefined && objValue === srcValue)
  20100. ? hasIn(object, path)
  20101. : baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG);
  20102. };
  20103. }
  20104. /**
  20105. * The base implementation of `_.merge` without support for multiple sources.
  20106. *
  20107. * @private
  20108. * @param {Object} object The destination object.
  20109. * @param {Object} source The source object.
  20110. * @param {number} srcIndex The index of `source`.
  20111. * @param {Function} [customizer] The function to customize merged values.
  20112. * @param {Object} [stack] Tracks traversed source values and their merged
  20113. * counterparts.
  20114. */
  20115. function baseMerge(object, source, srcIndex, customizer, stack) {
  20116. if (object === source) {
  20117. return;
  20118. }
  20119. baseFor(source, function(srcValue, key) {
  20120. stack || (stack = new Stack);
  20121. if (isObject(srcValue)) {
  20122. baseMergeDeep(object, source, key, srcIndex, baseMerge, customizer, stack);
  20123. }
  20124. else {
  20125. var newValue = customizer
  20126. ? customizer(safeGet(object, key), srcValue, (key + ''), object, source, stack)
  20127. : undefined;
  20128. if (newValue === undefined) {
  20129. newValue = srcValue;
  20130. }
  20131. assignMergeValue(object, key, newValue);
  20132. }
  20133. }, keysIn);
  20134. }
  20135. /**
  20136. * A specialized version of `baseMerge` for arrays and objects which performs
  20137. * deep merges and tracks traversed objects enabling objects with circular
  20138. * references to be merged.
  20139. *
  20140. * @private
  20141. * @param {Object} object The destination object.
  20142. * @param {Object} source The source object.
  20143. * @param {string} key The key of the value to merge.
  20144. * @param {number} srcIndex The index of `source`.
  20145. * @param {Function} mergeFunc The function to merge values.
  20146. * @param {Function} [customizer] The function to customize assigned values.
  20147. * @param {Object} [stack] Tracks traversed source values and their merged
  20148. * counterparts.
  20149. */
  20150. function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, stack) {
  20151. var objValue = safeGet(object, key),
  20152. srcValue = safeGet(source, key),
  20153. stacked = stack.get(srcValue);
  20154. if (stacked) {
  20155. assignMergeValue(object, key, stacked);
  20156. return;
  20157. }
  20158. var newValue = customizer
  20159. ? customizer(objValue, srcValue, (key + ''), object, source, stack)
  20160. : undefined;
  20161. var isCommon = newValue === undefined;
  20162. if (isCommon) {
  20163. var isArr = isArray(srcValue),
  20164. isBuff = !isArr && isBuffer(srcValue),
  20165. isTyped = !isArr && !isBuff && isTypedArray(srcValue);
  20166. newValue = srcValue;
  20167. if (isArr || isBuff || isTyped) {
  20168. if (isArray(objValue)) {
  20169. newValue = objValue;
  20170. }
  20171. else if (isArrayLikeObject(objValue)) {
  20172. newValue = copyArray(objValue);
  20173. }
  20174. else if (isBuff) {
  20175. isCommon = false;
  20176. newValue = cloneBuffer(srcValue, true);
  20177. }
  20178. else if (isTyped) {
  20179. isCommon = false;
  20180. newValue = cloneTypedArray(srcValue, true);
  20181. }
  20182. else {
  20183. newValue = [];
  20184. }
  20185. }
  20186. else if (isPlainObject(srcValue) || isArguments(srcValue)) {
  20187. newValue = objValue;
  20188. if (isArguments(objValue)) {
  20189. newValue = toPlainObject(objValue);
  20190. }
  20191. else if (!isObject(objValue) || isFunction(objValue)) {
  20192. newValue = initCloneObject(srcValue);
  20193. }
  20194. }
  20195. else {
  20196. isCommon = false;
  20197. }
  20198. }
  20199. if (isCommon) {
  20200. // Recursively merge objects and arrays (susceptible to call stack limits).
  20201. stack.set(srcValue, newValue);
  20202. mergeFunc(newValue, srcValue, srcIndex, customizer, stack);
  20203. stack['delete'](srcValue);
  20204. }
  20205. assignMergeValue(object, key, newValue);
  20206. }
  20207. /**
  20208. * The base implementation of `_.nth` which doesn't coerce arguments.
  20209. *
  20210. * @private
  20211. * @param {Array} array The array to query.
  20212. * @param {number} n The index of the element to return.
  20213. * @returns {*} Returns the nth element of `array`.
  20214. */
  20215. function baseNth(array, n) {
  20216. var length = array.length;
  20217. if (!length) {
  20218. return;
  20219. }
  20220. n += n < 0 ? length : 0;
  20221. return isIndex(n, length) ? array[n] : undefined;
  20222. }
  20223. /**
  20224. * The base implementation of `_.orderBy` without param guards.
  20225. *
  20226. * @private
  20227. * @param {Array|Object} collection The collection to iterate over.
  20228. * @param {Function[]|Object[]|string[]} iteratees The iteratees to sort by.
  20229. * @param {string[]} orders The sort orders of `iteratees`.
  20230. * @returns {Array} Returns the new sorted array.
  20231. */
  20232. function baseOrderBy(collection, iteratees, orders) {
  20233. var index = -1;
  20234. iteratees = arrayMap(iteratees.length ? iteratees : [identity], baseUnary(getIteratee()));
  20235. var result = baseMap(collection, function(value, key, collection) {
  20236. var criteria = arrayMap(iteratees, function(iteratee) {
  20237. return iteratee(value);
  20238. });
  20239. return { 'criteria': criteria, 'index': ++index, 'value': value };
  20240. });
  20241. return baseSortBy(result, function(object, other) {
  20242. return compareMultiple(object, other, orders);
  20243. });
  20244. }
  20245. /**
  20246. * The base implementation of `_.pick` without support for individual
  20247. * property identifiers.
  20248. *
  20249. * @private
  20250. * @param {Object} object The source object.
  20251. * @param {string[]} paths The property paths to pick.
  20252. * @returns {Object} Returns the new object.
  20253. */
  20254. function basePick(object, paths) {
  20255. return basePickBy(object, paths, function(value, path) {
  20256. return hasIn(object, path);
  20257. });
  20258. }
  20259. /**
  20260. * The base implementation of `_.pickBy` without support for iteratee shorthands.
  20261. *
  20262. * @private
  20263. * @param {Object} object The source object.
  20264. * @param {string[]} paths The property paths to pick.
  20265. * @param {Function} predicate The function invoked per property.
  20266. * @returns {Object} Returns the new object.
  20267. */
  20268. function basePickBy(object, paths, predicate) {
  20269. var index = -1,
  20270. length = paths.length,
  20271. result = {};
  20272. while (++index < length) {
  20273. var path = paths[index],
  20274. value = baseGet(object, path);
  20275. if (predicate(value, path)) {
  20276. baseSet(result, castPath(path, object), value);
  20277. }
  20278. }
  20279. return result;
  20280. }
  20281. /**
  20282. * A specialized version of `baseProperty` which supports deep paths.
  20283. *
  20284. * @private
  20285. * @param {Array|string} path The path of the property to get.
  20286. * @returns {Function} Returns the new accessor function.
  20287. */
  20288. function basePropertyDeep(path) {
  20289. return function(object) {
  20290. return baseGet(object, path);
  20291. };
  20292. }
  20293. /**
  20294. * The base implementation of `_.pullAllBy` without support for iteratee
  20295. * shorthands.
  20296. *
  20297. * @private
  20298. * @param {Array} array The array to modify.
  20299. * @param {Array} values The values to remove.
  20300. * @param {Function} [iteratee] The iteratee invoked per element.
  20301. * @param {Function} [comparator] The comparator invoked per element.
  20302. * @returns {Array} Returns `array`.
  20303. */
  20304. function basePullAll(array, values, iteratee, comparator) {
  20305. var indexOf = comparator ? baseIndexOfWith : baseIndexOf,
  20306. index = -1,
  20307. length = values.length,
  20308. seen = array;
  20309. if (array === values) {
  20310. values = copyArray(values);
  20311. }
  20312. if (iteratee) {
  20313. seen = arrayMap(array, baseUnary(iteratee));
  20314. }
  20315. while (++index < length) {
  20316. var fromIndex = 0,
  20317. value = values[index],
  20318. computed = iteratee ? iteratee(value) : value;
  20319. while ((fromIndex = indexOf(seen, computed, fromIndex, comparator)) > -1) {
  20320. if (seen !== array) {
  20321. splice.call(seen, fromIndex, 1);
  20322. }
  20323. splice.call(array, fromIndex, 1);
  20324. }
  20325. }
  20326. return array;
  20327. }
  20328. /**
  20329. * The base implementation of `_.pullAt` without support for individual
  20330. * indexes or capturing the removed elements.
  20331. *
  20332. * @private
  20333. * @param {Array} array The array to modify.
  20334. * @param {number[]} indexes The indexes of elements to remove.
  20335. * @returns {Array} Returns `array`.
  20336. */
  20337. function basePullAt(array, indexes) {
  20338. var length = array ? indexes.length : 0,
  20339. lastIndex = length - 1;
  20340. while (length--) {
  20341. var index = indexes[length];
  20342. if (length == lastIndex || index !== previous) {
  20343. var previous = index;
  20344. if (isIndex(index)) {
  20345. splice.call(array, index, 1);
  20346. } else {
  20347. baseUnset(array, index);
  20348. }
  20349. }
  20350. }
  20351. return array;
  20352. }
  20353. /**
  20354. * The base implementation of `_.random` without support for returning
  20355. * floating-point numbers.
  20356. *
  20357. * @private
  20358. * @param {number} lower The lower bound.
  20359. * @param {number} upper The upper bound.
  20360. * @returns {number} Returns the random number.
  20361. */
  20362. function baseRandom(lower, upper) {
  20363. return lower + nativeFloor(nativeRandom() * (upper - lower + 1));
  20364. }
  20365. /**
  20366. * The base implementation of `_.range` and `_.rangeRight` which doesn't
  20367. * coerce arguments.
  20368. *
  20369. * @private
  20370. * @param {number} start The start of the range.
  20371. * @param {number} end The end of the range.
  20372. * @param {number} step The value to increment or decrement by.
  20373. * @param {boolean} [fromRight] Specify iterating from right to left.
  20374. * @returns {Array} Returns the range of numbers.
  20375. */
  20376. function baseRange(start, end, step, fromRight) {
  20377. var index = -1,
  20378. length = nativeMax(nativeCeil((end - start) / (step || 1)), 0),
  20379. result = Array(length);
  20380. while (length--) {
  20381. result[fromRight ? length : ++index] = start;
  20382. start += step;
  20383. }
  20384. return result;
  20385. }
  20386. /**
  20387. * The base implementation of `_.repeat` which doesn't coerce arguments.
  20388. *
  20389. * @private
  20390. * @param {string} string The string to repeat.
  20391. * @param {number} n The number of times to repeat the string.
  20392. * @returns {string} Returns the repeated string.
  20393. */
  20394. function baseRepeat(string, n) {
  20395. var result = '';
  20396. if (!string || n < 1 || n > MAX_SAFE_INTEGER) {
  20397. return result;
  20398. }
  20399. // Leverage the exponentiation by squaring algorithm for a faster repeat.
  20400. // See https://en.wikipedia.org/wiki/Exponentiation_by_squaring for more details.
  20401. do {
  20402. if (n % 2) {
  20403. result += string;
  20404. }
  20405. n = nativeFloor(n / 2);
  20406. if (n) {
  20407. string += string;
  20408. }
  20409. } while (n);
  20410. return result;
  20411. }
  20412. /**
  20413. * The base implementation of `_.rest` which doesn't validate or coerce arguments.
  20414. *
  20415. * @private
  20416. * @param {Function} func The function to apply a rest parameter to.
  20417. * @param {number} [start=func.length-1] The start position of the rest parameter.
  20418. * @returns {Function} Returns the new function.
  20419. */
  20420. function baseRest(func, start) {
  20421. return setToString(overRest(func, start, identity), func + '');
  20422. }
  20423. /**
  20424. * The base implementation of `_.sample`.
  20425. *
  20426. * @private
  20427. * @param {Array|Object} collection The collection to sample.
  20428. * @returns {*} Returns the random element.
  20429. */
  20430. function baseSample(collection) {
  20431. return arraySample(values(collection));
  20432. }
  20433. /**
  20434. * The base implementation of `_.sampleSize` without param guards.
  20435. *
  20436. * @private
  20437. * @param {Array|Object} collection The collection to sample.
  20438. * @param {number} n The number of elements to sample.
  20439. * @returns {Array} Returns the random elements.
  20440. */
  20441. function baseSampleSize(collection, n) {
  20442. var array = values(collection);
  20443. return shuffleSelf(array, baseClamp(n, 0, array.length));
  20444. }
  20445. /**
  20446. * The base implementation of `_.set`.
  20447. *
  20448. * @private
  20449. * @param {Object} object The object to modify.
  20450. * @param {Array|string} path The path of the property to set.
  20451. * @param {*} value The value to set.
  20452. * @param {Function} [customizer] The function to customize path creation.
  20453. * @returns {Object} Returns `object`.
  20454. */
  20455. function baseSet(object, path, value, customizer) {
  20456. if (!isObject(object)) {
  20457. return object;
  20458. }
  20459. path = castPath(path, object);
  20460. var index = -1,
  20461. length = path.length,
  20462. lastIndex = length - 1,
  20463. nested = object;
  20464. while (nested != null && ++index < length) {
  20465. var key = toKey(path[index]),
  20466. newValue = value;
  20467. if (index != lastIndex) {
  20468. var objValue = nested[key];
  20469. newValue = customizer ? customizer(objValue, key, nested) : undefined;
  20470. if (newValue === undefined) {
  20471. newValue = isObject(objValue)
  20472. ? objValue
  20473. : (isIndex(path[index + 1]) ? [] : {});
  20474. }
  20475. }
  20476. assignValue(nested, key, newValue);
  20477. nested = nested[key];
  20478. }
  20479. return object;
  20480. }
  20481. /**
  20482. * The base implementation of `setData` without support for hot loop shorting.
  20483. *
  20484. * @private
  20485. * @param {Function} func The function to associate metadata with.
  20486. * @param {*} data The metadata.
  20487. * @returns {Function} Returns `func`.
  20488. */
  20489. var baseSetData = !metaMap ? identity : function(func, data) {
  20490. metaMap.set(func, data);
  20491. return func;
  20492. };
  20493. /**
  20494. * The base implementation of `setToString` without support for hot loop shorting.
  20495. *
  20496. * @private
  20497. * @param {Function} func The function to modify.
  20498. * @param {Function} string The `toString` result.
  20499. * @returns {Function} Returns `func`.
  20500. */
  20501. var baseSetToString = !defineProperty ? identity : function(func, string) {
  20502. return defineProperty(func, 'toString', {
  20503. 'configurable': true,
  20504. 'enumerable': false,
  20505. 'value': constant(string),
  20506. 'writable': true
  20507. });
  20508. };
  20509. /**
  20510. * The base implementation of `_.shuffle`.
  20511. *
  20512. * @private
  20513. * @param {Array|Object} collection The collection to shuffle.
  20514. * @returns {Array} Returns the new shuffled array.
  20515. */
  20516. function baseShuffle(collection) {
  20517. return shuffleSelf(values(collection));
  20518. }
  20519. /**
  20520. * The base implementation of `_.slice` without an iteratee call guard.
  20521. *
  20522. * @private
  20523. * @param {Array} array The array to slice.
  20524. * @param {number} [start=0] The start position.
  20525. * @param {number} [end=array.length] The end position.
  20526. * @returns {Array} Returns the slice of `array`.
  20527. */
  20528. function baseSlice(array, start, end) {
  20529. var index = -1,
  20530. length = array.length;
  20531. if (start < 0) {
  20532. start = -start > length ? 0 : (length + start);
  20533. }
  20534. end = end > length ? length : end;
  20535. if (end < 0) {
  20536. end += length;
  20537. }
  20538. length = start > end ? 0 : ((end - start) >>> 0);
  20539. start >>>= 0;
  20540. var result = Array(length);
  20541. while (++index < length) {
  20542. result[index] = array[index + start];
  20543. }
  20544. return result;
  20545. }
  20546. /**
  20547. * The base implementation of `_.some` without support for iteratee shorthands.
  20548. *
  20549. * @private
  20550. * @param {Array|Object} collection The collection to iterate over.
  20551. * @param {Function} predicate The function invoked per iteration.
  20552. * @returns {boolean} Returns `true` if any element passes the predicate check,
  20553. * else `false`.
  20554. */
  20555. function baseSome(collection, predicate) {
  20556. var result;
  20557. baseEach(collection, function(value, index, collection) {
  20558. result = predicate(value, index, collection);
  20559. return !result;
  20560. });
  20561. return !!result;
  20562. }
  20563. /**
  20564. * The base implementation of `_.sortedIndex` and `_.sortedLastIndex` which
  20565. * performs a binary search of `array` to determine the index at which `value`
  20566. * should be inserted into `array` in order to maintain its sort order.
  20567. *
  20568. * @private
  20569. * @param {Array} array The sorted array to inspect.
  20570. * @param {*} value The value to evaluate.
  20571. * @param {boolean} [retHighest] Specify returning the highest qualified index.
  20572. * @returns {number} Returns the index at which `value` should be inserted
  20573. * into `array`.
  20574. */
  20575. function baseSortedIndex(array, value, retHighest) {
  20576. var low = 0,
  20577. high = array == null ? low : array.length;
  20578. if (typeof value == 'number' && value === value && high <= HALF_MAX_ARRAY_LENGTH) {
  20579. while (low < high) {
  20580. var mid = (low + high) >>> 1,
  20581. computed = array[mid];
  20582. if (computed !== null && !isSymbol(computed) &&
  20583. (retHighest ? (computed <= value) : (computed < value))) {
  20584. low = mid + 1;
  20585. } else {
  20586. high = mid;
  20587. }
  20588. }
  20589. return high;
  20590. }
  20591. return baseSortedIndexBy(array, value, identity, retHighest);
  20592. }
  20593. /**
  20594. * The base implementation of `_.sortedIndexBy` and `_.sortedLastIndexBy`
  20595. * which invokes `iteratee` for `value` and each element of `array` to compute
  20596. * their sort ranking. The iteratee is invoked with one argument; (value).
  20597. *
  20598. * @private
  20599. * @param {Array} array The sorted array to inspect.
  20600. * @param {*} value The value to evaluate.
  20601. * @param {Function} iteratee The iteratee invoked per element.
  20602. * @param {boolean} [retHighest] Specify returning the highest qualified index.
  20603. * @returns {number} Returns the index at which `value` should be inserted
  20604. * into `array`.
  20605. */
  20606. function baseSortedIndexBy(array, value, iteratee, retHighest) {
  20607. value = iteratee(value);
  20608. var low = 0,
  20609. high = array == null ? 0 : array.length,
  20610. valIsNaN = value !== value,
  20611. valIsNull = value === null,
  20612. valIsSymbol = isSymbol(value),
  20613. valIsUndefined = value === undefined;
  20614. while (low < high) {
  20615. var mid = nativeFloor((low + high) / 2),
  20616. computed = iteratee(array[mid]),
  20617. othIsDefined = computed !== undefined,
  20618. othIsNull = computed === null,
  20619. othIsReflexive = computed === computed,
  20620. othIsSymbol = isSymbol(computed);
  20621. if (valIsNaN) {
  20622. var setLow = retHighest || othIsReflexive;
  20623. } else if (valIsUndefined) {
  20624. setLow = othIsReflexive && (retHighest || othIsDefined);
  20625. } else if (valIsNull) {
  20626. setLow = othIsReflexive && othIsDefined && (retHighest || !othIsNull);
  20627. } else if (valIsSymbol) {
  20628. setLow = othIsReflexive && othIsDefined && !othIsNull && (retHighest || !othIsSymbol);
  20629. } else if (othIsNull || othIsSymbol) {
  20630. setLow = false;
  20631. } else {
  20632. setLow = retHighest ? (computed <= value) : (computed < value);
  20633. }
  20634. if (setLow) {
  20635. low = mid + 1;
  20636. } else {
  20637. high = mid;
  20638. }
  20639. }
  20640. return nativeMin(high, MAX_ARRAY_INDEX);
  20641. }
  20642. /**
  20643. * The base implementation of `_.sortedUniq` and `_.sortedUniqBy` without
  20644. * support for iteratee shorthands.
  20645. *
  20646. * @private
  20647. * @param {Array} array The array to inspect.
  20648. * @param {Function} [iteratee] The iteratee invoked per element.
  20649. * @returns {Array} Returns the new duplicate free array.
  20650. */
  20651. function baseSortedUniq(array, iteratee) {
  20652. var index = -1,
  20653. length = array.length,
  20654. resIndex = 0,
  20655. result = [];
  20656. while (++index < length) {
  20657. var value = array[index],
  20658. computed = iteratee ? iteratee(value) : value;
  20659. if (!index || !eq(computed, seen)) {
  20660. var seen = computed;
  20661. result[resIndex++] = value === 0 ? 0 : value;
  20662. }
  20663. }
  20664. return result;
  20665. }
  20666. /**
  20667. * The base implementation of `_.toNumber` which doesn't ensure correct
  20668. * conversions of binary, hexadecimal, or octal string values.
  20669. *
  20670. * @private
  20671. * @param {*} value The value to process.
  20672. * @returns {number} Returns the number.
  20673. */
  20674. function baseToNumber(value) {
  20675. if (typeof value == 'number') {
  20676. return value;
  20677. }
  20678. if (isSymbol(value)) {
  20679. return NAN;
  20680. }
  20681. return +value;
  20682. }
  20683. /**
  20684. * The base implementation of `_.toString` which doesn't convert nullish
  20685. * values to empty strings.
  20686. *
  20687. * @private
  20688. * @param {*} value The value to process.
  20689. * @returns {string} Returns the string.
  20690. */
  20691. function baseToString(value) {
  20692. // Exit early for strings to avoid a performance hit in some environments.
  20693. if (typeof value == 'string') {
  20694. return value;
  20695. }
  20696. if (isArray(value)) {
  20697. // Recursively convert values (susceptible to call stack limits).
  20698. return arrayMap(value, baseToString) + '';
  20699. }
  20700. if (isSymbol(value)) {
  20701. return symbolToString ? symbolToString.call(value) : '';
  20702. }
  20703. var result = (value + '');
  20704. return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
  20705. }
  20706. /**
  20707. * The base implementation of `_.uniqBy` without support for iteratee shorthands.
  20708. *
  20709. * @private
  20710. * @param {Array} array The array to inspect.
  20711. * @param {Function} [iteratee] The iteratee invoked per element.
  20712. * @param {Function} [comparator] The comparator invoked per element.
  20713. * @returns {Array} Returns the new duplicate free array.
  20714. */
  20715. function baseUniq(array, iteratee, comparator) {
  20716. var index = -1,
  20717. includes = arrayIncludes,
  20718. length = array.length,
  20719. isCommon = true,
  20720. result = [],
  20721. seen = result;
  20722. if (comparator) {
  20723. isCommon = false;
  20724. includes = arrayIncludesWith;
  20725. }
  20726. else if (length >= LARGE_ARRAY_SIZE) {
  20727. var set = iteratee ? null : createSet(array);
  20728. if (set) {
  20729. return setToArray(set);
  20730. }
  20731. isCommon = false;
  20732. includes = cacheHas;
  20733. seen = new SetCache;
  20734. }
  20735. else {
  20736. seen = iteratee ? [] : result;
  20737. }
  20738. outer:
  20739. while (++index < length) {
  20740. var value = array[index],
  20741. computed = iteratee ? iteratee(value) : value;
  20742. value = (comparator || value !== 0) ? value : 0;
  20743. if (isCommon && computed === computed) {
  20744. var seenIndex = seen.length;
  20745. while (seenIndex--) {
  20746. if (seen[seenIndex] === computed) {
  20747. continue outer;
  20748. }
  20749. }
  20750. if (iteratee) {
  20751. seen.push(computed);
  20752. }
  20753. result.push(value);
  20754. }
  20755. else if (!includes(seen, computed, comparator)) {
  20756. if (seen !== result) {
  20757. seen.push(computed);
  20758. }
  20759. result.push(value);
  20760. }
  20761. }
  20762. return result;
  20763. }
  20764. /**
  20765. * The base implementation of `_.unset`.
  20766. *
  20767. * @private
  20768. * @param {Object} object The object to modify.
  20769. * @param {Array|string} path The property path to unset.
  20770. * @returns {boolean} Returns `true` if the property is deleted, else `false`.
  20771. */
  20772. function baseUnset(object, path) {
  20773. path = castPath(path, object);
  20774. object = parent(object, path);
  20775. return object == null || delete object[toKey(last(path))];
  20776. }
  20777. /**
  20778. * The base implementation of `_.update`.
  20779. *
  20780. * @private
  20781. * @param {Object} object The object to modify.
  20782. * @param {Array|string} path The path of the property to update.
  20783. * @param {Function} updater The function to produce the updated value.
  20784. * @param {Function} [customizer] The function to customize path creation.
  20785. * @returns {Object} Returns `object`.
  20786. */
  20787. function baseUpdate(object, path, updater, customizer) {
  20788. return baseSet(object, path, updater(baseGet(object, path)), customizer);
  20789. }
  20790. /**
  20791. * The base implementation of methods like `_.dropWhile` and `_.takeWhile`
  20792. * without support for iteratee shorthands.
  20793. *
  20794. * @private
  20795. * @param {Array} array The array to query.
  20796. * @param {Function} predicate The function invoked per iteration.
  20797. * @param {boolean} [isDrop] Specify dropping elements instead of taking them.
  20798. * @param {boolean} [fromRight] Specify iterating from right to left.
  20799. * @returns {Array} Returns the slice of `array`.
  20800. */
  20801. function baseWhile(array, predicate, isDrop, fromRight) {
  20802. var length = array.length,
  20803. index = fromRight ? length : -1;
  20804. while ((fromRight ? index-- : ++index < length) &&
  20805. predicate(array[index], index, array)) {}
  20806. return isDrop
  20807. ? baseSlice(array, (fromRight ? 0 : index), (fromRight ? index + 1 : length))
  20808. : baseSlice(array, (fromRight ? index + 1 : 0), (fromRight ? length : index));
  20809. }
  20810. /**
  20811. * The base implementation of `wrapperValue` which returns the result of
  20812. * performing a sequence of actions on the unwrapped `value`, where each
  20813. * successive action is supplied the return value of the previous.
  20814. *
  20815. * @private
  20816. * @param {*} value The unwrapped value.
  20817. * @param {Array} actions Actions to perform to resolve the unwrapped value.
  20818. * @returns {*} Returns the resolved value.
  20819. */
  20820. function baseWrapperValue(value, actions) {
  20821. var result = value;
  20822. if (result instanceof LazyWrapper) {
  20823. result = result.value();
  20824. }
  20825. return arrayReduce(actions, function(result, action) {
  20826. return action.func.apply(action.thisArg, arrayPush([result], action.args));
  20827. }, result);
  20828. }
  20829. /**
  20830. * The base implementation of methods like `_.xor`, without support for
  20831. * iteratee shorthands, that accepts an array of arrays to inspect.
  20832. *
  20833. * @private
  20834. * @param {Array} arrays The arrays to inspect.
  20835. * @param {Function} [iteratee] The iteratee invoked per element.
  20836. * @param {Function} [comparator] The comparator invoked per element.
  20837. * @returns {Array} Returns the new array of values.
  20838. */
  20839. function baseXor(arrays, iteratee, comparator) {
  20840. var length = arrays.length;
  20841. if (length < 2) {
  20842. return length ? baseUniq(arrays[0]) : [];
  20843. }
  20844. var index = -1,
  20845. result = Array(length);
  20846. while (++index < length) {
  20847. var array = arrays[index],
  20848. othIndex = -1;
  20849. while (++othIndex < length) {
  20850. if (othIndex != index) {
  20851. result[index] = baseDifference(result[index] || array, arrays[othIndex], iteratee, comparator);
  20852. }
  20853. }
  20854. }
  20855. return baseUniq(baseFlatten(result, 1), iteratee, comparator);
  20856. }
  20857. /**
  20858. * This base implementation of `_.zipObject` which assigns values using `assignFunc`.
  20859. *
  20860. * @private
  20861. * @param {Array} props The property identifiers.
  20862. * @param {Array} values The property values.
  20863. * @param {Function} assignFunc The function to assign values.
  20864. * @returns {Object} Returns the new object.
  20865. */
  20866. function baseZipObject(props, values, assignFunc) {
  20867. var index = -1,
  20868. length = props.length,
  20869. valsLength = values.length,
  20870. result = {};
  20871. while (++index < length) {
  20872. var value = index < valsLength ? values[index] : undefined;
  20873. assignFunc(result, props[index], value);
  20874. }
  20875. return result;
  20876. }
  20877. /**
  20878. * Casts `value` to an empty array if it's not an array like object.
  20879. *
  20880. * @private
  20881. * @param {*} value The value to inspect.
  20882. * @returns {Array|Object} Returns the cast array-like object.
  20883. */
  20884. function castArrayLikeObject(value) {
  20885. return isArrayLikeObject(value) ? value : [];
  20886. }
  20887. /**
  20888. * Casts `value` to `identity` if it's not a function.
  20889. *
  20890. * @private
  20891. * @param {*} value The value to inspect.
  20892. * @returns {Function} Returns cast function.
  20893. */
  20894. function castFunction(value) {
  20895. return typeof value == 'function' ? value : identity;
  20896. }
  20897. /**
  20898. * Casts `value` to a path array if it's not one.
  20899. *
  20900. * @private
  20901. * @param {*} value The value to inspect.
  20902. * @param {Object} [object] The object to query keys on.
  20903. * @returns {Array} Returns the cast property path array.
  20904. */
  20905. function castPath(value, object) {
  20906. if (isArray(value)) {
  20907. return value;
  20908. }
  20909. return isKey(value, object) ? [value] : stringToPath(toString(value));
  20910. }
  20911. /**
  20912. * A `baseRest` alias which can be replaced with `identity` by module
  20913. * replacement plugins.
  20914. *
  20915. * @private
  20916. * @type {Function}
  20917. * @param {Function} func The function to apply a rest parameter to.
  20918. * @returns {Function} Returns the new function.
  20919. */
  20920. var castRest = baseRest;
  20921. /**
  20922. * Casts `array` to a slice if it's needed.
  20923. *
  20924. * @private
  20925. * @param {Array} array The array to inspect.
  20926. * @param {number} start The start position.
  20927. * @param {number} [end=array.length] The end position.
  20928. * @returns {Array} Returns the cast slice.
  20929. */
  20930. function castSlice(array, start, end) {
  20931. var length = array.length;
  20932. end = end === undefined ? length : end;
  20933. return (!start && end >= length) ? array : baseSlice(array, start, end);
  20934. }
  20935. /**
  20936. * A simple wrapper around the global [`clearTimeout`](https://mdn.io/clearTimeout).
  20937. *
  20938. * @private
  20939. * @param {number|Object} id The timer id or timeout object of the timer to clear.
  20940. */
  20941. var clearTimeout = ctxClearTimeout || function(id) {
  20942. return root.clearTimeout(id);
  20943. };
  20944. /**
  20945. * Creates a clone of `buffer`.
  20946. *
  20947. * @private
  20948. * @param {Buffer} buffer The buffer to clone.
  20949. * @param {boolean} [isDeep] Specify a deep clone.
  20950. * @returns {Buffer} Returns the cloned buffer.
  20951. */
  20952. function cloneBuffer(buffer, isDeep) {
  20953. if (isDeep) {
  20954. return buffer.slice();
  20955. }
  20956. var length = buffer.length,
  20957. result = allocUnsafe ? allocUnsafe(length) : new buffer.constructor(length);
  20958. buffer.copy(result);
  20959. return result;
  20960. }
  20961. /**
  20962. * Creates a clone of `arrayBuffer`.
  20963. *
  20964. * @private
  20965. * @param {ArrayBuffer} arrayBuffer The array buffer to clone.
  20966. * @returns {ArrayBuffer} Returns the cloned array buffer.
  20967. */
  20968. function cloneArrayBuffer(arrayBuffer) {
  20969. var result = new arrayBuffer.constructor(arrayBuffer.byteLength);
  20970. new Uint8Array(result).set(new Uint8Array(arrayBuffer));
  20971. return result;
  20972. }
  20973. /**
  20974. * Creates a clone of `dataView`.
  20975. *
  20976. * @private
  20977. * @param {Object} dataView The data view to clone.
  20978. * @param {boolean} [isDeep] Specify a deep clone.
  20979. * @returns {Object} Returns the cloned data view.
  20980. */
  20981. function cloneDataView(dataView, isDeep) {
  20982. var buffer = isDeep ? cloneArrayBuffer(dataView.buffer) : dataView.buffer;
  20983. return new dataView.constructor(buffer, dataView.byteOffset, dataView.byteLength);
  20984. }
  20985. /**
  20986. * Creates a clone of `regexp`.
  20987. *
  20988. * @private
  20989. * @param {Object} regexp The regexp to clone.
  20990. * @returns {Object} Returns the cloned regexp.
  20991. */
  20992. function cloneRegExp(regexp) {
  20993. var result = new regexp.constructor(regexp.source, reFlags.exec(regexp));
  20994. result.lastIndex = regexp.lastIndex;
  20995. return result;
  20996. }
  20997. /**
  20998. * Creates a clone of the `symbol` object.
  20999. *
  21000. * @private
  21001. * @param {Object} symbol The symbol object to clone.
  21002. * @returns {Object} Returns the cloned symbol object.
  21003. */
  21004. function cloneSymbol(symbol) {
  21005. return symbolValueOf ? Object(symbolValueOf.call(symbol)) : {};
  21006. }
  21007. /**
  21008. * Creates a clone of `typedArray`.
  21009. *
  21010. * @private
  21011. * @param {Object} typedArray The typed array to clone.
  21012. * @param {boolean} [isDeep] Specify a deep clone.
  21013. * @returns {Object} Returns the cloned typed array.
  21014. */
  21015. function cloneTypedArray(typedArray, isDeep) {
  21016. var buffer = isDeep ? cloneArrayBuffer(typedArray.buffer) : typedArray.buffer;
  21017. return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length);
  21018. }
  21019. /**
  21020. * Compares values to sort them in ascending order.
  21021. *
  21022. * @private
  21023. * @param {*} value The value to compare.
  21024. * @param {*} other The other value to compare.
  21025. * @returns {number} Returns the sort order indicator for `value`.
  21026. */
  21027. function compareAscending(value, other) {
  21028. if (value !== other) {
  21029. var valIsDefined = value !== undefined,
  21030. valIsNull = value === null,
  21031. valIsReflexive = value === value,
  21032. valIsSymbol = isSymbol(value);
  21033. var othIsDefined = other !== undefined,
  21034. othIsNull = other === null,
  21035. othIsReflexive = other === other,
  21036. othIsSymbol = isSymbol(other);
  21037. if ((!othIsNull && !othIsSymbol && !valIsSymbol && value > other) ||
  21038. (valIsSymbol && othIsDefined && othIsReflexive && !othIsNull && !othIsSymbol) ||
  21039. (valIsNull && othIsDefined && othIsReflexive) ||
  21040. (!valIsDefined && othIsReflexive) ||
  21041. !valIsReflexive) {
  21042. return 1;
  21043. }
  21044. if ((!valIsNull && !valIsSymbol && !othIsSymbol && value < other) ||
  21045. (othIsSymbol && valIsDefined && valIsReflexive && !valIsNull && !valIsSymbol) ||
  21046. (othIsNull && valIsDefined && valIsReflexive) ||
  21047. (!othIsDefined && valIsReflexive) ||
  21048. !othIsReflexive) {
  21049. return -1;
  21050. }
  21051. }
  21052. return 0;
  21053. }
  21054. /**
  21055. * Used by `_.orderBy` to compare multiple properties of a value to another
  21056. * and stable sort them.
  21057. *
  21058. * If `orders` is unspecified, all values are sorted in ascending order. Otherwise,
  21059. * specify an order of "desc" for descending or "asc" for ascending sort order
  21060. * of corresponding values.
  21061. *
  21062. * @private
  21063. * @param {Object} object The object to compare.
  21064. * @param {Object} other The other object to compare.
  21065. * @param {boolean[]|string[]} orders The order to sort by for each property.
  21066. * @returns {number} Returns the sort order indicator for `object`.
  21067. */
  21068. function compareMultiple(object, other, orders) {
  21069. var index = -1,
  21070. objCriteria = object.criteria,
  21071. othCriteria = other.criteria,
  21072. length = objCriteria.length,
  21073. ordersLength = orders.length;
  21074. while (++index < length) {
  21075. var result = compareAscending(objCriteria[index], othCriteria[index]);
  21076. if (result) {
  21077. if (index >= ordersLength) {
  21078. return result;
  21079. }
  21080. var order = orders[index];
  21081. return result * (order == 'desc' ? -1 : 1);
  21082. }
  21083. }
  21084. // Fixes an `Array#sort` bug in the JS engine embedded in Adobe applications
  21085. // that causes it, under certain circumstances, to provide the same value for
  21086. // `object` and `other`. See https://github.com/jashkenas/underscore/pull/1247
  21087. // for more details.
  21088. //
  21089. // This also ensures a stable sort in V8 and other engines.
  21090. // See https://bugs.chromium.org/p/v8/issues/detail?id=90 for more details.
  21091. return object.index - other.index;
  21092. }
  21093. /**
  21094. * Creates an array that is the composition of partially applied arguments,
  21095. * placeholders, and provided arguments into a single array of arguments.
  21096. *
  21097. * @private
  21098. * @param {Array} args The provided arguments.
  21099. * @param {Array} partials The arguments to prepend to those provided.
  21100. * @param {Array} holders The `partials` placeholder indexes.
  21101. * @params {boolean} [isCurried] Specify composing for a curried function.
  21102. * @returns {Array} Returns the new array of composed arguments.
  21103. */
  21104. function composeArgs(args, partials, holders, isCurried) {
  21105. var argsIndex = -1,
  21106. argsLength = args.length,
  21107. holdersLength = holders.length,
  21108. leftIndex = -1,
  21109. leftLength = partials.length,
  21110. rangeLength = nativeMax(argsLength - holdersLength, 0),
  21111. result = Array(leftLength + rangeLength),
  21112. isUncurried = !isCurried;
  21113. while (++leftIndex < leftLength) {
  21114. result[leftIndex] = partials[leftIndex];
  21115. }
  21116. while (++argsIndex < holdersLength) {
  21117. if (isUncurried || argsIndex < argsLength) {
  21118. result[holders[argsIndex]] = args[argsIndex];
  21119. }
  21120. }
  21121. while (rangeLength--) {
  21122. result[leftIndex++] = args[argsIndex++];
  21123. }
  21124. return result;
  21125. }
  21126. /**
  21127. * This function is like `composeArgs` except that the arguments composition
  21128. * is tailored for `_.partialRight`.
  21129. *
  21130. * @private
  21131. * @param {Array} args The provided arguments.
  21132. * @param {Array} partials The arguments to append to those provided.
  21133. * @param {Array} holders The `partials` placeholder indexes.
  21134. * @params {boolean} [isCurried] Specify composing for a curried function.
  21135. * @returns {Array} Returns the new array of composed arguments.
  21136. */
  21137. function composeArgsRight(args, partials, holders, isCurried) {
  21138. var argsIndex = -1,
  21139. argsLength = args.length,
  21140. holdersIndex = -1,
  21141. holdersLength = holders.length,
  21142. rightIndex = -1,
  21143. rightLength = partials.length,
  21144. rangeLength = nativeMax(argsLength - holdersLength, 0),
  21145. result = Array(rangeLength + rightLength),
  21146. isUncurried = !isCurried;
  21147. while (++argsIndex < rangeLength) {
  21148. result[argsIndex] = args[argsIndex];
  21149. }
  21150. var offset = argsIndex;
  21151. while (++rightIndex < rightLength) {
  21152. result[offset + rightIndex] = partials[rightIndex];
  21153. }
  21154. while (++holdersIndex < holdersLength) {
  21155. if (isUncurried || argsIndex < argsLength) {
  21156. result[offset + holders[holdersIndex]] = args[argsIndex++];
  21157. }
  21158. }
  21159. return result;
  21160. }
  21161. /**
  21162. * Copies the values of `source` to `array`.
  21163. *
  21164. * @private
  21165. * @param {Array} source The array to copy values from.
  21166. * @param {Array} [array=[]] The array to copy values to.
  21167. * @returns {Array} Returns `array`.
  21168. */
  21169. function copyArray(source, array) {
  21170. var index = -1,
  21171. length = source.length;
  21172. array || (array = Array(length));
  21173. while (++index < length) {
  21174. array[index] = source[index];
  21175. }
  21176. return array;
  21177. }
  21178. /**
  21179. * Copies properties of `source` to `object`.
  21180. *
  21181. * @private
  21182. * @param {Object} source The object to copy properties from.
  21183. * @param {Array} props The property identifiers to copy.
  21184. * @param {Object} [object={}] The object to copy properties to.
  21185. * @param {Function} [customizer] The function to customize copied values.
  21186. * @returns {Object} Returns `object`.
  21187. */
  21188. function copyObject(source, props, object, customizer) {
  21189. var isNew = !object;
  21190. object || (object = {});
  21191. var index = -1,
  21192. length = props.length;
  21193. while (++index < length) {
  21194. var key = props[index];
  21195. var newValue = customizer
  21196. ? customizer(object[key], source[key], key, object, source)
  21197. : undefined;
  21198. if (newValue === undefined) {
  21199. newValue = source[key];
  21200. }
  21201. if (isNew) {
  21202. baseAssignValue(object, key, newValue);
  21203. } else {
  21204. assignValue(object, key, newValue);
  21205. }
  21206. }
  21207. return object;
  21208. }
  21209. /**
  21210. * Copies own symbols of `source` to `object`.
  21211. *
  21212. * @private
  21213. * @param {Object} source The object to copy symbols from.
  21214. * @param {Object} [object={}] The object to copy symbols to.
  21215. * @returns {Object} Returns `object`.
  21216. */
  21217. function copySymbols(source, object) {
  21218. return copyObject(source, getSymbols(source), object);
  21219. }
  21220. /**
  21221. * Copies own and inherited symbols of `source` to `object`.
  21222. *
  21223. * @private
  21224. * @param {Object} source The object to copy symbols from.
  21225. * @param {Object} [object={}] The object to copy symbols to.
  21226. * @returns {Object} Returns `object`.
  21227. */
  21228. function copySymbolsIn(source, object) {
  21229. return copyObject(source, getSymbolsIn(source), object);
  21230. }
  21231. /**
  21232. * Creates a function like `_.groupBy`.
  21233. *
  21234. * @private
  21235. * @param {Function} setter The function to set accumulator values.
  21236. * @param {Function} [initializer] The accumulator object initializer.
  21237. * @returns {Function} Returns the new aggregator function.
  21238. */
  21239. function createAggregator(setter, initializer) {
  21240. return function(collection, iteratee) {
  21241. var func = isArray(collection) ? arrayAggregator : baseAggregator,
  21242. accumulator = initializer ? initializer() : {};
  21243. return func(collection, setter, getIteratee(iteratee, 2), accumulator);
  21244. };
  21245. }
  21246. /**
  21247. * Creates a function like `_.assign`.
  21248. *
  21249. * @private
  21250. * @param {Function} assigner The function to assign values.
  21251. * @returns {Function} Returns the new assigner function.
  21252. */
  21253. function createAssigner(assigner) {
  21254. return baseRest(function(object, sources) {
  21255. var index = -1,
  21256. length = sources.length,
  21257. customizer = length > 1 ? sources[length - 1] : undefined,
  21258. guard = length > 2 ? sources[2] : undefined;
  21259. customizer = (assigner.length > 3 && typeof customizer == 'function')
  21260. ? (length--, customizer)
  21261. : undefined;
  21262. if (guard && isIterateeCall(sources[0], sources[1], guard)) {
  21263. customizer = length < 3 ? undefined : customizer;
  21264. length = 1;
  21265. }
  21266. object = Object(object);
  21267. while (++index < length) {
  21268. var source = sources[index];
  21269. if (source) {
  21270. assigner(object, source, index, customizer);
  21271. }
  21272. }
  21273. return object;
  21274. });
  21275. }
  21276. /**
  21277. * Creates a `baseEach` or `baseEachRight` function.
  21278. *
  21279. * @private
  21280. * @param {Function} eachFunc The function to iterate over a collection.
  21281. * @param {boolean} [fromRight] Specify iterating from right to left.
  21282. * @returns {Function} Returns the new base function.
  21283. */
  21284. function createBaseEach(eachFunc, fromRight) {
  21285. return function(collection, iteratee) {
  21286. if (collection == null) {
  21287. return collection;
  21288. }
  21289. if (!isArrayLike(collection)) {
  21290. return eachFunc(collection, iteratee);
  21291. }
  21292. var length = collection.length,
  21293. index = fromRight ? length : -1,
  21294. iterable = Object(collection);
  21295. while ((fromRight ? index-- : ++index < length)) {
  21296. if (iteratee(iterable[index], index, iterable) === false) {
  21297. break;
  21298. }
  21299. }
  21300. return collection;
  21301. };
  21302. }
  21303. /**
  21304. * Creates a base function for methods like `_.forIn` and `_.forOwn`.
  21305. *
  21306. * @private
  21307. * @param {boolean} [fromRight] Specify iterating from right to left.
  21308. * @returns {Function} Returns the new base function.
  21309. */
  21310. function createBaseFor(fromRight) {
  21311. return function(object, iteratee, keysFunc) {
  21312. var index = -1,
  21313. iterable = Object(object),
  21314. props = keysFunc(object),
  21315. length = props.length;
  21316. while (length--) {
  21317. var key = props[fromRight ? length : ++index];
  21318. if (iteratee(iterable[key], key, iterable) === false) {
  21319. break;
  21320. }
  21321. }
  21322. return object;
  21323. };
  21324. }
  21325. /**
  21326. * Creates a function that wraps `func` to invoke it with the optional `this`
  21327. * binding of `thisArg`.
  21328. *
  21329. * @private
  21330. * @param {Function} func The function to wrap.
  21331. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  21332. * @param {*} [thisArg] The `this` binding of `func`.
  21333. * @returns {Function} Returns the new wrapped function.
  21334. */
  21335. function createBind(func, bitmask, thisArg) {
  21336. var isBind = bitmask & WRAP_BIND_FLAG,
  21337. Ctor = createCtor(func);
  21338. function wrapper() {
  21339. var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;
  21340. return fn.apply(isBind ? thisArg : this, arguments);
  21341. }
  21342. return wrapper;
  21343. }
  21344. /**
  21345. * Creates a function like `_.lowerFirst`.
  21346. *
  21347. * @private
  21348. * @param {string} methodName The name of the `String` case method to use.
  21349. * @returns {Function} Returns the new case function.
  21350. */
  21351. function createCaseFirst(methodName) {
  21352. return function(string) {
  21353. string = toString(string);
  21354. var strSymbols = hasUnicode(string)
  21355. ? stringToArray(string)
  21356. : undefined;
  21357. var chr = strSymbols
  21358. ? strSymbols[0]
  21359. : string.charAt(0);
  21360. var trailing = strSymbols
  21361. ? castSlice(strSymbols, 1).join('')
  21362. : string.slice(1);
  21363. return chr[methodName]() + trailing;
  21364. };
  21365. }
  21366. /**
  21367. * Creates a function like `_.camelCase`.
  21368. *
  21369. * @private
  21370. * @param {Function} callback The function to combine each word.
  21371. * @returns {Function} Returns the new compounder function.
  21372. */
  21373. function createCompounder(callback) {
  21374. return function(string) {
  21375. return arrayReduce(words(deburr(string).replace(reApos, '')), callback, '');
  21376. };
  21377. }
  21378. /**
  21379. * Creates a function that produces an instance of `Ctor` regardless of
  21380. * whether it was invoked as part of a `new` expression or by `call` or `apply`.
  21381. *
  21382. * @private
  21383. * @param {Function} Ctor The constructor to wrap.
  21384. * @returns {Function} Returns the new wrapped function.
  21385. */
  21386. function createCtor(Ctor) {
  21387. return function() {
  21388. // Use a `switch` statement to work with class constructors. See
  21389. // http://ecma-international.org/ecma-262/7.0/#sec-ecmascript-function-objects-call-thisargument-argumentslist
  21390. // for more details.
  21391. var args = arguments;
  21392. switch (args.length) {
  21393. case 0: return new Ctor;
  21394. case 1: return new Ctor(args[0]);
  21395. case 2: return new Ctor(args[0], args[1]);
  21396. case 3: return new Ctor(args[0], args[1], args[2]);
  21397. case 4: return new Ctor(args[0], args[1], args[2], args[3]);
  21398. case 5: return new Ctor(args[0], args[1], args[2], args[3], args[4]);
  21399. case 6: return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5]);
  21400. case 7: return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5], args[6]);
  21401. }
  21402. var thisBinding = baseCreate(Ctor.prototype),
  21403. result = Ctor.apply(thisBinding, args);
  21404. // Mimic the constructor's `return` behavior.
  21405. // See https://es5.github.io/#x13.2.2 for more details.
  21406. return isObject(result) ? result : thisBinding;
  21407. };
  21408. }
  21409. /**
  21410. * Creates a function that wraps `func` to enable currying.
  21411. *
  21412. * @private
  21413. * @param {Function} func The function to wrap.
  21414. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  21415. * @param {number} arity The arity of `func`.
  21416. * @returns {Function} Returns the new wrapped function.
  21417. */
  21418. function createCurry(func, bitmask, arity) {
  21419. var Ctor = createCtor(func);
  21420. function wrapper() {
  21421. var length = arguments.length,
  21422. args = Array(length),
  21423. index = length,
  21424. placeholder = getHolder(wrapper);
  21425. while (index--) {
  21426. args[index] = arguments[index];
  21427. }
  21428. var holders = (length < 3 && args[0] !== placeholder && args[length - 1] !== placeholder)
  21429. ? []
  21430. : replaceHolders(args, placeholder);
  21431. length -= holders.length;
  21432. if (length < arity) {
  21433. return createRecurry(
  21434. func, bitmask, createHybrid, wrapper.placeholder, undefined,
  21435. args, holders, undefined, undefined, arity - length);
  21436. }
  21437. var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;
  21438. return apply(fn, this, args);
  21439. }
  21440. return wrapper;
  21441. }
  21442. /**
  21443. * Creates a `_.find` or `_.findLast` function.
  21444. *
  21445. * @private
  21446. * @param {Function} findIndexFunc The function to find the collection index.
  21447. * @returns {Function} Returns the new find function.
  21448. */
  21449. function createFind(findIndexFunc) {
  21450. return function(collection, predicate, fromIndex) {
  21451. var iterable = Object(collection);
  21452. if (!isArrayLike(collection)) {
  21453. var iteratee = getIteratee(predicate, 3);
  21454. collection = keys(collection);
  21455. predicate = function(key) { return iteratee(iterable[key], key, iterable); };
  21456. }
  21457. var index = findIndexFunc(collection, predicate, fromIndex);
  21458. return index > -1 ? iterable[iteratee ? collection[index] : index] : undefined;
  21459. };
  21460. }
  21461. /**
  21462. * Creates a `_.flow` or `_.flowRight` function.
  21463. *
  21464. * @private
  21465. * @param {boolean} [fromRight] Specify iterating from right to left.
  21466. * @returns {Function} Returns the new flow function.
  21467. */
  21468. function createFlow(fromRight) {
  21469. return flatRest(function(funcs) {
  21470. var length = funcs.length,
  21471. index = length,
  21472. prereq = LodashWrapper.prototype.thru;
  21473. if (fromRight) {
  21474. funcs.reverse();
  21475. }
  21476. while (index--) {
  21477. var func = funcs[index];
  21478. if (typeof func != 'function') {
  21479. throw new TypeError(FUNC_ERROR_TEXT);
  21480. }
  21481. if (prereq && !wrapper && getFuncName(func) == 'wrapper') {
  21482. var wrapper = new LodashWrapper([], true);
  21483. }
  21484. }
  21485. index = wrapper ? index : length;
  21486. while (++index < length) {
  21487. func = funcs[index];
  21488. var funcName = getFuncName(func),
  21489. data = funcName == 'wrapper' ? getData(func) : undefined;
  21490. if (data && isLaziable(data[0]) &&
  21491. data[1] == (WRAP_ARY_FLAG | WRAP_CURRY_FLAG | WRAP_PARTIAL_FLAG | WRAP_REARG_FLAG) &&
  21492. !data[4].length && data[9] == 1
  21493. ) {
  21494. wrapper = wrapper[getFuncName(data[0])].apply(wrapper, data[3]);
  21495. } else {
  21496. wrapper = (func.length == 1 && isLaziable(func))
  21497. ? wrapper[funcName]()
  21498. : wrapper.thru(func);
  21499. }
  21500. }
  21501. return function() {
  21502. var args = arguments,
  21503. value = args[0];
  21504. if (wrapper && args.length == 1 && isArray(value)) {
  21505. return wrapper.plant(value).value();
  21506. }
  21507. var index = 0,
  21508. result = length ? funcs[index].apply(this, args) : value;
  21509. while (++index < length) {
  21510. result = funcs[index].call(this, result);
  21511. }
  21512. return result;
  21513. };
  21514. });
  21515. }
  21516. /**
  21517. * Creates a function that wraps `func` to invoke it with optional `this`
  21518. * binding of `thisArg`, partial application, and currying.
  21519. *
  21520. * @private
  21521. * @param {Function|string} func The function or method name to wrap.
  21522. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  21523. * @param {*} [thisArg] The `this` binding of `func`.
  21524. * @param {Array} [partials] The arguments to prepend to those provided to
  21525. * the new function.
  21526. * @param {Array} [holders] The `partials` placeholder indexes.
  21527. * @param {Array} [partialsRight] The arguments to append to those provided
  21528. * to the new function.
  21529. * @param {Array} [holdersRight] The `partialsRight` placeholder indexes.
  21530. * @param {Array} [argPos] The argument positions of the new function.
  21531. * @param {number} [ary] The arity cap of `func`.
  21532. * @param {number} [arity] The arity of `func`.
  21533. * @returns {Function} Returns the new wrapped function.
  21534. */
  21535. function createHybrid(func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, argPos, ary, arity) {
  21536. var isAry = bitmask & WRAP_ARY_FLAG,
  21537. isBind = bitmask & WRAP_BIND_FLAG,
  21538. isBindKey = bitmask & WRAP_BIND_KEY_FLAG,
  21539. isCurried = bitmask & (WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG),
  21540. isFlip = bitmask & WRAP_FLIP_FLAG,
  21541. Ctor = isBindKey ? undefined : createCtor(func);
  21542. function wrapper() {
  21543. var length = arguments.length,
  21544. args = Array(length),
  21545. index = length;
  21546. while (index--) {
  21547. args[index] = arguments[index];
  21548. }
  21549. if (isCurried) {
  21550. var placeholder = getHolder(wrapper),
  21551. holdersCount = countHolders(args, placeholder);
  21552. }
  21553. if (partials) {
  21554. args = composeArgs(args, partials, holders, isCurried);
  21555. }
  21556. if (partialsRight) {
  21557. args = composeArgsRight(args, partialsRight, holdersRight, isCurried);
  21558. }
  21559. length -= holdersCount;
  21560. if (isCurried && length < arity) {
  21561. var newHolders = replaceHolders(args, placeholder);
  21562. return createRecurry(
  21563. func, bitmask, createHybrid, wrapper.placeholder, thisArg,
  21564. args, newHolders, argPos, ary, arity - length
  21565. );
  21566. }
  21567. var thisBinding = isBind ? thisArg : this,
  21568. fn = isBindKey ? thisBinding[func] : func;
  21569. length = args.length;
  21570. if (argPos) {
  21571. args = reorder(args, argPos);
  21572. } else if (isFlip && length > 1) {
  21573. args.reverse();
  21574. }
  21575. if (isAry && ary < length) {
  21576. args.length = ary;
  21577. }
  21578. if (this && this !== root && this instanceof wrapper) {
  21579. fn = Ctor || createCtor(fn);
  21580. }
  21581. return fn.apply(thisBinding, args);
  21582. }
  21583. return wrapper;
  21584. }
  21585. /**
  21586. * Creates a function like `_.invertBy`.
  21587. *
  21588. * @private
  21589. * @param {Function} setter The function to set accumulator values.
  21590. * @param {Function} toIteratee The function to resolve iteratees.
  21591. * @returns {Function} Returns the new inverter function.
  21592. */
  21593. function createInverter(setter, toIteratee) {
  21594. return function(object, iteratee) {
  21595. return baseInverter(object, setter, toIteratee(iteratee), {});
  21596. };
  21597. }
  21598. /**
  21599. * Creates a function that performs a mathematical operation on two values.
  21600. *
  21601. * @private
  21602. * @param {Function} operator The function to perform the operation.
  21603. * @param {number} [defaultValue] The value used for `undefined` arguments.
  21604. * @returns {Function} Returns the new mathematical operation function.
  21605. */
  21606. function createMathOperation(operator, defaultValue) {
  21607. return function(value, other) {
  21608. var result;
  21609. if (value === undefined && other === undefined) {
  21610. return defaultValue;
  21611. }
  21612. if (value !== undefined) {
  21613. result = value;
  21614. }
  21615. if (other !== undefined) {
  21616. if (result === undefined) {
  21617. return other;
  21618. }
  21619. if (typeof value == 'string' || typeof other == 'string') {
  21620. value = baseToString(value);
  21621. other = baseToString(other);
  21622. } else {
  21623. value = baseToNumber(value);
  21624. other = baseToNumber(other);
  21625. }
  21626. result = operator(value, other);
  21627. }
  21628. return result;
  21629. };
  21630. }
  21631. /**
  21632. * Creates a function like `_.over`.
  21633. *
  21634. * @private
  21635. * @param {Function} arrayFunc The function to iterate over iteratees.
  21636. * @returns {Function} Returns the new over function.
  21637. */
  21638. function createOver(arrayFunc) {
  21639. return flatRest(function(iteratees) {
  21640. iteratees = arrayMap(iteratees, baseUnary(getIteratee()));
  21641. return baseRest(function(args) {
  21642. var thisArg = this;
  21643. return arrayFunc(iteratees, function(iteratee) {
  21644. return apply(iteratee, thisArg, args);
  21645. });
  21646. });
  21647. });
  21648. }
  21649. /**
  21650. * Creates the padding for `string` based on `length`. The `chars` string
  21651. * is truncated if the number of characters exceeds `length`.
  21652. *
  21653. * @private
  21654. * @param {number} length The padding length.
  21655. * @param {string} [chars=' '] The string used as padding.
  21656. * @returns {string} Returns the padding for `string`.
  21657. */
  21658. function createPadding(length, chars) {
  21659. chars = chars === undefined ? ' ' : baseToString(chars);
  21660. var charsLength = chars.length;
  21661. if (charsLength < 2) {
  21662. return charsLength ? baseRepeat(chars, length) : chars;
  21663. }
  21664. var result = baseRepeat(chars, nativeCeil(length / stringSize(chars)));
  21665. return hasUnicode(chars)
  21666. ? castSlice(stringToArray(result), 0, length).join('')
  21667. : result.slice(0, length);
  21668. }
  21669. /**
  21670. * Creates a function that wraps `func` to invoke it with the `this` binding
  21671. * of `thisArg` and `partials` prepended to the arguments it receives.
  21672. *
  21673. * @private
  21674. * @param {Function} func The function to wrap.
  21675. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  21676. * @param {*} thisArg The `this` binding of `func`.
  21677. * @param {Array} partials The arguments to prepend to those provided to
  21678. * the new function.
  21679. * @returns {Function} Returns the new wrapped function.
  21680. */
  21681. function createPartial(func, bitmask, thisArg, partials) {
  21682. var isBind = bitmask & WRAP_BIND_FLAG,
  21683. Ctor = createCtor(func);
  21684. function wrapper() {
  21685. var argsIndex = -1,
  21686. argsLength = arguments.length,
  21687. leftIndex = -1,
  21688. leftLength = partials.length,
  21689. args = Array(leftLength + argsLength),
  21690. fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;
  21691. while (++leftIndex < leftLength) {
  21692. args[leftIndex] = partials[leftIndex];
  21693. }
  21694. while (argsLength--) {
  21695. args[leftIndex++] = arguments[++argsIndex];
  21696. }
  21697. return apply(fn, isBind ? thisArg : this, args);
  21698. }
  21699. return wrapper;
  21700. }
  21701. /**
  21702. * Creates a `_.range` or `_.rangeRight` function.
  21703. *
  21704. * @private
  21705. * @param {boolean} [fromRight] Specify iterating from right to left.
  21706. * @returns {Function} Returns the new range function.
  21707. */
  21708. function createRange(fromRight) {
  21709. return function(start, end, step) {
  21710. if (step && typeof step != 'number' && isIterateeCall(start, end, step)) {
  21711. end = step = undefined;
  21712. }
  21713. // Ensure the sign of `-0` is preserved.
  21714. start = toFinite(start);
  21715. if (end === undefined) {
  21716. end = start;
  21717. start = 0;
  21718. } else {
  21719. end = toFinite(end);
  21720. }
  21721. step = step === undefined ? (start < end ? 1 : -1) : toFinite(step);
  21722. return baseRange(start, end, step, fromRight);
  21723. };
  21724. }
  21725. /**
  21726. * Creates a function that performs a relational operation on two values.
  21727. *
  21728. * @private
  21729. * @param {Function} operator The function to perform the operation.
  21730. * @returns {Function} Returns the new relational operation function.
  21731. */
  21732. function createRelationalOperation(operator) {
  21733. return function(value, other) {
  21734. if (!(typeof value == 'string' && typeof other == 'string')) {
  21735. value = toNumber(value);
  21736. other = toNumber(other);
  21737. }
  21738. return operator(value, other);
  21739. };
  21740. }
  21741. /**
  21742. * Creates a function that wraps `func` to continue currying.
  21743. *
  21744. * @private
  21745. * @param {Function} func The function to wrap.
  21746. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  21747. * @param {Function} wrapFunc The function to create the `func` wrapper.
  21748. * @param {*} placeholder The placeholder value.
  21749. * @param {*} [thisArg] The `this` binding of `func`.
  21750. * @param {Array} [partials] The arguments to prepend to those provided to
  21751. * the new function.
  21752. * @param {Array} [holders] The `partials` placeholder indexes.
  21753. * @param {Array} [argPos] The argument positions of the new function.
  21754. * @param {number} [ary] The arity cap of `func`.
  21755. * @param {number} [arity] The arity of `func`.
  21756. * @returns {Function} Returns the new wrapped function.
  21757. */
  21758. function createRecurry(func, bitmask, wrapFunc, placeholder, thisArg, partials, holders, argPos, ary, arity) {
  21759. var isCurry = bitmask & WRAP_CURRY_FLAG,
  21760. newHolders = isCurry ? holders : undefined,
  21761. newHoldersRight = isCurry ? undefined : holders,
  21762. newPartials = isCurry ? partials : undefined,
  21763. newPartialsRight = isCurry ? undefined : partials;
  21764. bitmask |= (isCurry ? WRAP_PARTIAL_FLAG : WRAP_PARTIAL_RIGHT_FLAG);
  21765. bitmask &= ~(isCurry ? WRAP_PARTIAL_RIGHT_FLAG : WRAP_PARTIAL_FLAG);
  21766. if (!(bitmask & WRAP_CURRY_BOUND_FLAG)) {
  21767. bitmask &= ~(WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG);
  21768. }
  21769. var newData = [
  21770. func, bitmask, thisArg, newPartials, newHolders, newPartialsRight,
  21771. newHoldersRight, argPos, ary, arity
  21772. ];
  21773. var result = wrapFunc.apply(undefined, newData);
  21774. if (isLaziable(func)) {
  21775. setData(result, newData);
  21776. }
  21777. result.placeholder = placeholder;
  21778. return setWrapToString(result, func, bitmask);
  21779. }
  21780. /**
  21781. * Creates a function like `_.round`.
  21782. *
  21783. * @private
  21784. * @param {string} methodName The name of the `Math` method to use when rounding.
  21785. * @returns {Function} Returns the new round function.
  21786. */
  21787. function createRound(methodName) {
  21788. var func = Math[methodName];
  21789. return function(number, precision) {
  21790. number = toNumber(number);
  21791. precision = precision == null ? 0 : nativeMin(toInteger(precision), 292);
  21792. if (precision && nativeIsFinite(number)) {
  21793. // Shift with exponential notation to avoid floating-point issues.
  21794. // See [MDN](https://mdn.io/round#Examples) for more details.
  21795. var pair = (toString(number) + 'e').split('e'),
  21796. value = func(pair[0] + 'e' + (+pair[1] + precision));
  21797. pair = (toString(value) + 'e').split('e');
  21798. return +(pair[0] + 'e' + (+pair[1] - precision));
  21799. }
  21800. return func(number);
  21801. };
  21802. }
  21803. /**
  21804. * Creates a set object of `values`.
  21805. *
  21806. * @private
  21807. * @param {Array} values The values to add to the set.
  21808. * @returns {Object} Returns the new set.
  21809. */
  21810. var createSet = !(Set && (1 / setToArray(new Set([,-0]))[1]) == INFINITY) ? noop : function(values) {
  21811. return new Set(values);
  21812. };
  21813. /**
  21814. * Creates a `_.toPairs` or `_.toPairsIn` function.
  21815. *
  21816. * @private
  21817. * @param {Function} keysFunc The function to get the keys of a given object.
  21818. * @returns {Function} Returns the new pairs function.
  21819. */
  21820. function createToPairs(keysFunc) {
  21821. return function(object) {
  21822. var tag = getTag(object);
  21823. if (tag == mapTag) {
  21824. return mapToArray(object);
  21825. }
  21826. if (tag == setTag) {
  21827. return setToPairs(object);
  21828. }
  21829. return baseToPairs(object, keysFunc(object));
  21830. };
  21831. }
  21832. /**
  21833. * Creates a function that either curries or invokes `func` with optional
  21834. * `this` binding and partially applied arguments.
  21835. *
  21836. * @private
  21837. * @param {Function|string} func The function or method name to wrap.
  21838. * @param {number} bitmask The bitmask flags.
  21839. * 1 - `_.bind`
  21840. * 2 - `_.bindKey`
  21841. * 4 - `_.curry` or `_.curryRight` of a bound function
  21842. * 8 - `_.curry`
  21843. * 16 - `_.curryRight`
  21844. * 32 - `_.partial`
  21845. * 64 - `_.partialRight`
  21846. * 128 - `_.rearg`
  21847. * 256 - `_.ary`
  21848. * 512 - `_.flip`
  21849. * @param {*} [thisArg] The `this` binding of `func`.
  21850. * @param {Array} [partials] The arguments to be partially applied.
  21851. * @param {Array} [holders] The `partials` placeholder indexes.
  21852. * @param {Array} [argPos] The argument positions of the new function.
  21853. * @param {number} [ary] The arity cap of `func`.
  21854. * @param {number} [arity] The arity of `func`.
  21855. * @returns {Function} Returns the new wrapped function.
  21856. */
  21857. function createWrap(func, bitmask, thisArg, partials, holders, argPos, ary, arity) {
  21858. var isBindKey = bitmask & WRAP_BIND_KEY_FLAG;
  21859. if (!isBindKey && typeof func != 'function') {
  21860. throw new TypeError(FUNC_ERROR_TEXT);
  21861. }
  21862. var length = partials ? partials.length : 0;
  21863. if (!length) {
  21864. bitmask &= ~(WRAP_PARTIAL_FLAG | WRAP_PARTIAL_RIGHT_FLAG);
  21865. partials = holders = undefined;
  21866. }
  21867. ary = ary === undefined ? ary : nativeMax(toInteger(ary), 0);
  21868. arity = arity === undefined ? arity : toInteger(arity);
  21869. length -= holders ? holders.length : 0;
  21870. if (bitmask & WRAP_PARTIAL_RIGHT_FLAG) {
  21871. var partialsRight = partials,
  21872. holdersRight = holders;
  21873. partials = holders = undefined;
  21874. }
  21875. var data = isBindKey ? undefined : getData(func);
  21876. var newData = [
  21877. func, bitmask, thisArg, partials, holders, partialsRight, holdersRight,
  21878. argPos, ary, arity
  21879. ];
  21880. if (data) {
  21881. mergeData(newData, data);
  21882. }
  21883. func = newData[0];
  21884. bitmask = newData[1];
  21885. thisArg = newData[2];
  21886. partials = newData[3];
  21887. holders = newData[4];
  21888. arity = newData[9] = newData[9] === undefined
  21889. ? (isBindKey ? 0 : func.length)
  21890. : nativeMax(newData[9] - length, 0);
  21891. if (!arity && bitmask & (WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG)) {
  21892. bitmask &= ~(WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG);
  21893. }
  21894. if (!bitmask || bitmask == WRAP_BIND_FLAG) {
  21895. var result = createBind(func, bitmask, thisArg);
  21896. } else if (bitmask == WRAP_CURRY_FLAG || bitmask == WRAP_CURRY_RIGHT_FLAG) {
  21897. result = createCurry(func, bitmask, arity);
  21898. } else if ((bitmask == WRAP_PARTIAL_FLAG || bitmask == (WRAP_BIND_FLAG | WRAP_PARTIAL_FLAG)) && !holders.length) {
  21899. result = createPartial(func, bitmask, thisArg, partials);
  21900. } else {
  21901. result = createHybrid.apply(undefined, newData);
  21902. }
  21903. var setter = data ? baseSetData : setData;
  21904. return setWrapToString(setter(result, newData), func, bitmask);
  21905. }
  21906. /**
  21907. * Used by `_.defaults` to customize its `_.assignIn` use to assign properties
  21908. * of source objects to the destination object for all destination properties
  21909. * that resolve to `undefined`.
  21910. *
  21911. * @private
  21912. * @param {*} objValue The destination value.
  21913. * @param {*} srcValue The source value.
  21914. * @param {string} key The key of the property to assign.
  21915. * @param {Object} object The parent object of `objValue`.
  21916. * @returns {*} Returns the value to assign.
  21917. */
  21918. function customDefaultsAssignIn(objValue, srcValue, key, object) {
  21919. if (objValue === undefined ||
  21920. (eq(objValue, objectProto[key]) && !hasOwnProperty.call(object, key))) {
  21921. return srcValue;
  21922. }
  21923. return objValue;
  21924. }
  21925. /**
  21926. * Used by `_.defaultsDeep` to customize its `_.merge` use to merge source
  21927. * objects into destination objects that are passed thru.
  21928. *
  21929. * @private
  21930. * @param {*} objValue The destination value.
  21931. * @param {*} srcValue The source value.
  21932. * @param {string} key The key of the property to merge.
  21933. * @param {Object} object The parent object of `objValue`.
  21934. * @param {Object} source The parent object of `srcValue`.
  21935. * @param {Object} [stack] Tracks traversed source values and their merged
  21936. * counterparts.
  21937. * @returns {*} Returns the value to assign.
  21938. */
  21939. function customDefaultsMerge(objValue, srcValue, key, object, source, stack) {
  21940. if (isObject(objValue) && isObject(srcValue)) {
  21941. // Recursively merge objects and arrays (susceptible to call stack limits).
  21942. stack.set(srcValue, objValue);
  21943. baseMerge(objValue, srcValue, undefined, customDefaultsMerge, stack);
  21944. stack['delete'](srcValue);
  21945. }
  21946. return objValue;
  21947. }
  21948. /**
  21949. * Used by `_.omit` to customize its `_.cloneDeep` use to only clone plain
  21950. * objects.
  21951. *
  21952. * @private
  21953. * @param {*} value The value to inspect.
  21954. * @param {string} key The key of the property to inspect.
  21955. * @returns {*} Returns the uncloned value or `undefined` to defer cloning to `_.cloneDeep`.
  21956. */
  21957. function customOmitClone(value) {
  21958. return isPlainObject(value) ? undefined : value;
  21959. }
  21960. /**
  21961. * A specialized version of `baseIsEqualDeep` for arrays with support for
  21962. * partial deep comparisons.
  21963. *
  21964. * @private
  21965. * @param {Array} array The array to compare.
  21966. * @param {Array} other The other array to compare.
  21967. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
  21968. * @param {Function} customizer The function to customize comparisons.
  21969. * @param {Function} equalFunc The function to determine equivalents of values.
  21970. * @param {Object} stack Tracks traversed `array` and `other` objects.
  21971. * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`.
  21972. */
  21973. function equalArrays(array, other, bitmask, customizer, equalFunc, stack) {
  21974. var isPartial = bitmask & COMPARE_PARTIAL_FLAG,
  21975. arrLength = array.length,
  21976. othLength = other.length;
  21977. if (arrLength != othLength && !(isPartial && othLength > arrLength)) {
  21978. return false;
  21979. }
  21980. // Assume cyclic values are equal.
  21981. var stacked = stack.get(array);
  21982. if (stacked && stack.get(other)) {
  21983. return stacked == other;
  21984. }
  21985. var index = -1,
  21986. result = true,
  21987. seen = (bitmask & COMPARE_UNORDERED_FLAG) ? new SetCache : undefined;
  21988. stack.set(array, other);
  21989. stack.set(other, array);
  21990. // Ignore non-index properties.
  21991. while (++index < arrLength) {
  21992. var arrValue = array[index],
  21993. othValue = other[index];
  21994. if (customizer) {
  21995. var compared = isPartial
  21996. ? customizer(othValue, arrValue, index, other, array, stack)
  21997. : customizer(arrValue, othValue, index, array, other, stack);
  21998. }
  21999. if (compared !== undefined) {
  22000. if (compared) {
  22001. continue;
  22002. }
  22003. result = false;
  22004. break;
  22005. }
  22006. // Recursively compare arrays (susceptible to call stack limits).
  22007. if (seen) {
  22008. if (!arraySome(other, function(othValue, othIndex) {
  22009. if (!cacheHas(seen, othIndex) &&
  22010. (arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) {
  22011. return seen.push(othIndex);
  22012. }
  22013. })) {
  22014. result = false;
  22015. break;
  22016. }
  22017. } else if (!(
  22018. arrValue === othValue ||
  22019. equalFunc(arrValue, othValue, bitmask, customizer, stack)
  22020. )) {
  22021. result = false;
  22022. break;
  22023. }
  22024. }
  22025. stack['delete'](array);
  22026. stack['delete'](other);
  22027. return result;
  22028. }
  22029. /**
  22030. * A specialized version of `baseIsEqualDeep` for comparing objects of
  22031. * the same `toStringTag`.
  22032. *
  22033. * **Note:** This function only supports comparing values with tags of
  22034. * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`.
  22035. *
  22036. * @private
  22037. * @param {Object} object The object to compare.
  22038. * @param {Object} other The other object to compare.
  22039. * @param {string} tag The `toStringTag` of the objects to compare.
  22040. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
  22041. * @param {Function} customizer The function to customize comparisons.
  22042. * @param {Function} equalFunc The function to determine equivalents of values.
  22043. * @param {Object} stack Tracks traversed `object` and `other` objects.
  22044. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  22045. */
  22046. function equalByTag(object, other, tag, bitmask, customizer, equalFunc, stack) {
  22047. switch (tag) {
  22048. case dataViewTag:
  22049. if ((object.byteLength != other.byteLength) ||
  22050. (object.byteOffset != other.byteOffset)) {
  22051. return false;
  22052. }
  22053. object = object.buffer;
  22054. other = other.buffer;
  22055. case arrayBufferTag:
  22056. if ((object.byteLength != other.byteLength) ||
  22057. !equalFunc(new Uint8Array(object), new Uint8Array(other))) {
  22058. return false;
  22059. }
  22060. return true;
  22061. case boolTag:
  22062. case dateTag:
  22063. case numberTag:
  22064. // Coerce booleans to `1` or `0` and dates to milliseconds.
  22065. // Invalid dates are coerced to `NaN`.
  22066. return eq(+object, +other);
  22067. case errorTag:
  22068. return object.name == other.name && object.message == other.message;
  22069. case regexpTag:
  22070. case stringTag:
  22071. // Coerce regexes to strings and treat strings, primitives and objects,
  22072. // as equal. See http://www.ecma-international.org/ecma-262/7.0/#sec-regexp.prototype.tostring
  22073. // for more details.
  22074. return object == (other + '');
  22075. case mapTag:
  22076. var convert = mapToArray;
  22077. case setTag:
  22078. var isPartial = bitmask & COMPARE_PARTIAL_FLAG;
  22079. convert || (convert = setToArray);
  22080. if (object.size != other.size && !isPartial) {
  22081. return false;
  22082. }
  22083. // Assume cyclic values are equal.
  22084. var stacked = stack.get(object);
  22085. if (stacked) {
  22086. return stacked == other;
  22087. }
  22088. bitmask |= COMPARE_UNORDERED_FLAG;
  22089. // Recursively compare objects (susceptible to call stack limits).
  22090. stack.set(object, other);
  22091. var result = equalArrays(convert(object), convert(other), bitmask, customizer, equalFunc, stack);
  22092. stack['delete'](object);
  22093. return result;
  22094. case symbolTag:
  22095. if (symbolValueOf) {
  22096. return symbolValueOf.call(object) == symbolValueOf.call(other);
  22097. }
  22098. }
  22099. return false;
  22100. }
  22101. /**
  22102. * A specialized version of `baseIsEqualDeep` for objects with support for
  22103. * partial deep comparisons.
  22104. *
  22105. * @private
  22106. * @param {Object} object The object to compare.
  22107. * @param {Object} other The other object to compare.
  22108. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
  22109. * @param {Function} customizer The function to customize comparisons.
  22110. * @param {Function} equalFunc The function to determine equivalents of values.
  22111. * @param {Object} stack Tracks traversed `object` and `other` objects.
  22112. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  22113. */
  22114. function equalObjects(object, other, bitmask, customizer, equalFunc, stack) {
  22115. var isPartial = bitmask & COMPARE_PARTIAL_FLAG,
  22116. objProps = getAllKeys(object),
  22117. objLength = objProps.length,
  22118. othProps = getAllKeys(other),
  22119. othLength = othProps.length;
  22120. if (objLength != othLength && !isPartial) {
  22121. return false;
  22122. }
  22123. var index = objLength;
  22124. while (index--) {
  22125. var key = objProps[index];
  22126. if (!(isPartial ? key in other : hasOwnProperty.call(other, key))) {
  22127. return false;
  22128. }
  22129. }
  22130. // Assume cyclic values are equal.
  22131. var stacked = stack.get(object);
  22132. if (stacked && stack.get(other)) {
  22133. return stacked == other;
  22134. }
  22135. var result = true;
  22136. stack.set(object, other);
  22137. stack.set(other, object);
  22138. var skipCtor = isPartial;
  22139. while (++index < objLength) {
  22140. key = objProps[index];
  22141. var objValue = object[key],
  22142. othValue = other[key];
  22143. if (customizer) {
  22144. var compared = isPartial
  22145. ? customizer(othValue, objValue, key, other, object, stack)
  22146. : customizer(objValue, othValue, key, object, other, stack);
  22147. }
  22148. // Recursively compare objects (susceptible to call stack limits).
  22149. if (!(compared === undefined
  22150. ? (objValue === othValue || equalFunc(objValue, othValue, bitmask, customizer, stack))
  22151. : compared
  22152. )) {
  22153. result = false;
  22154. break;
  22155. }
  22156. skipCtor || (skipCtor = key == 'constructor');
  22157. }
  22158. if (result && !skipCtor) {
  22159. var objCtor = object.constructor,
  22160. othCtor = other.constructor;
  22161. // Non `Object` object instances with different constructors are not equal.
  22162. if (objCtor != othCtor &&
  22163. ('constructor' in object && 'constructor' in other) &&
  22164. !(typeof objCtor == 'function' && objCtor instanceof objCtor &&
  22165. typeof othCtor == 'function' && othCtor instanceof othCtor)) {
  22166. result = false;
  22167. }
  22168. }
  22169. stack['delete'](object);
  22170. stack['delete'](other);
  22171. return result;
  22172. }
  22173. /**
  22174. * A specialized version of `baseRest` which flattens the rest array.
  22175. *
  22176. * @private
  22177. * @param {Function} func The function to apply a rest parameter to.
  22178. * @returns {Function} Returns the new function.
  22179. */
  22180. function flatRest(func) {
  22181. return setToString(overRest(func, undefined, flatten), func + '');
  22182. }
  22183. /**
  22184. * Creates an array of own enumerable property names and symbols of `object`.
  22185. *
  22186. * @private
  22187. * @param {Object} object The object to query.
  22188. * @returns {Array} Returns the array of property names and symbols.
  22189. */
  22190. function getAllKeys(object) {
  22191. return baseGetAllKeys(object, keys, getSymbols);
  22192. }
  22193. /**
  22194. * Creates an array of own and inherited enumerable property names and
  22195. * symbols of `object`.
  22196. *
  22197. * @private
  22198. * @param {Object} object The object to query.
  22199. * @returns {Array} Returns the array of property names and symbols.
  22200. */
  22201. function getAllKeysIn(object) {
  22202. return baseGetAllKeys(object, keysIn, getSymbolsIn);
  22203. }
  22204. /**
  22205. * Gets metadata for `func`.
  22206. *
  22207. * @private
  22208. * @param {Function} func The function to query.
  22209. * @returns {*} Returns the metadata for `func`.
  22210. */
  22211. var getData = !metaMap ? noop : function(func) {
  22212. return metaMap.get(func);
  22213. };
  22214. /**
  22215. * Gets the name of `func`.
  22216. *
  22217. * @private
  22218. * @param {Function} func The function to query.
  22219. * @returns {string} Returns the function name.
  22220. */
  22221. function getFuncName(func) {
  22222. var result = (func.name + ''),
  22223. array = realNames[result],
  22224. length = hasOwnProperty.call(realNames, result) ? array.length : 0;
  22225. while (length--) {
  22226. var data = array[length],
  22227. otherFunc = data.func;
  22228. if (otherFunc == null || otherFunc == func) {
  22229. return data.name;
  22230. }
  22231. }
  22232. return result;
  22233. }
  22234. /**
  22235. * Gets the argument placeholder value for `func`.
  22236. *
  22237. * @private
  22238. * @param {Function} func The function to inspect.
  22239. * @returns {*} Returns the placeholder value.
  22240. */
  22241. function getHolder(func) {
  22242. var object = hasOwnProperty.call(lodash, 'placeholder') ? lodash : func;
  22243. return object.placeholder;
  22244. }
  22245. /**
  22246. * Gets the appropriate "iteratee" function. If `_.iteratee` is customized,
  22247. * this function returns the custom method, otherwise it returns `baseIteratee`.
  22248. * If arguments are provided, the chosen function is invoked with them and
  22249. * its result is returned.
  22250. *
  22251. * @private
  22252. * @param {*} [value] The value to convert to an iteratee.
  22253. * @param {number} [arity] The arity of the created iteratee.
  22254. * @returns {Function} Returns the chosen function or its result.
  22255. */
  22256. function getIteratee() {
  22257. var result = lodash.iteratee || iteratee;
  22258. result = result === iteratee ? baseIteratee : result;
  22259. return arguments.length ? result(arguments[0], arguments[1]) : result;
  22260. }
  22261. /**
  22262. * Gets the data for `map`.
  22263. *
  22264. * @private
  22265. * @param {Object} map The map to query.
  22266. * @param {string} key The reference key.
  22267. * @returns {*} Returns the map data.
  22268. */
  22269. function getMapData(map, key) {
  22270. var data = map.__data__;
  22271. return isKeyable(key)
  22272. ? data[typeof key == 'string' ? 'string' : 'hash']
  22273. : data.map;
  22274. }
  22275. /**
  22276. * Gets the property names, values, and compare flags of `object`.
  22277. *
  22278. * @private
  22279. * @param {Object} object The object to query.
  22280. * @returns {Array} Returns the match data of `object`.
  22281. */
  22282. function getMatchData(object) {
  22283. var result = keys(object),
  22284. length = result.length;
  22285. while (length--) {
  22286. var key = result[length],
  22287. value = object[key];
  22288. result[length] = [key, value, isStrictComparable(value)];
  22289. }
  22290. return result;
  22291. }
  22292. /**
  22293. * Gets the native function at `key` of `object`.
  22294. *
  22295. * @private
  22296. * @param {Object} object The object to query.
  22297. * @param {string} key The key of the method to get.
  22298. * @returns {*} Returns the function if it's native, else `undefined`.
  22299. */
  22300. function getNative(object, key) {
  22301. var value = getValue(object, key);
  22302. return baseIsNative(value) ? value : undefined;
  22303. }
  22304. /**
  22305. * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
  22306. *
  22307. * @private
  22308. * @param {*} value The value to query.
  22309. * @returns {string} Returns the raw `toStringTag`.
  22310. */
  22311. function getRawTag(value) {
  22312. var isOwn = hasOwnProperty.call(value, symToStringTag),
  22313. tag = value[symToStringTag];
  22314. try {
  22315. value[symToStringTag] = undefined;
  22316. var unmasked = true;
  22317. } catch (e) {}
  22318. var result = nativeObjectToString.call(value);
  22319. if (unmasked) {
  22320. if (isOwn) {
  22321. value[symToStringTag] = tag;
  22322. } else {
  22323. delete value[symToStringTag];
  22324. }
  22325. }
  22326. return result;
  22327. }
  22328. /**
  22329. * Creates an array of the own enumerable symbols of `object`.
  22330. *
  22331. * @private
  22332. * @param {Object} object The object to query.
  22333. * @returns {Array} Returns the array of symbols.
  22334. */
  22335. var getSymbols = !nativeGetSymbols ? stubArray : function(object) {
  22336. if (object == null) {
  22337. return [];
  22338. }
  22339. object = Object(object);
  22340. return arrayFilter(nativeGetSymbols(object), function(symbol) {
  22341. return propertyIsEnumerable.call(object, symbol);
  22342. });
  22343. };
  22344. /**
  22345. * Creates an array of the own and inherited enumerable symbols of `object`.
  22346. *
  22347. * @private
  22348. * @param {Object} object The object to query.
  22349. * @returns {Array} Returns the array of symbols.
  22350. */
  22351. var getSymbolsIn = !nativeGetSymbols ? stubArray : function(object) {
  22352. var result = [];
  22353. while (object) {
  22354. arrayPush(result, getSymbols(object));
  22355. object = getPrototype(object);
  22356. }
  22357. return result;
  22358. };
  22359. /**
  22360. * Gets the `toStringTag` of `value`.
  22361. *
  22362. * @private
  22363. * @param {*} value The value to query.
  22364. * @returns {string} Returns the `toStringTag`.
  22365. */
  22366. var getTag = baseGetTag;
  22367. // Fallback for data views, maps, sets, and weak maps in IE 11 and promises in Node.js < 6.
  22368. if ((DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag) ||
  22369. (Map && getTag(new Map) != mapTag) ||
  22370. (Promise && getTag(Promise.resolve()) != promiseTag) ||
  22371. (Set && getTag(new Set) != setTag) ||
  22372. (WeakMap && getTag(new WeakMap) != weakMapTag)) {
  22373. getTag = function(value) {
  22374. var result = baseGetTag(value),
  22375. Ctor = result == objectTag ? value.constructor : undefined,
  22376. ctorString = Ctor ? toSource(Ctor) : '';
  22377. if (ctorString) {
  22378. switch (ctorString) {
  22379. case dataViewCtorString: return dataViewTag;
  22380. case mapCtorString: return mapTag;
  22381. case promiseCtorString: return promiseTag;
  22382. case setCtorString: return setTag;
  22383. case weakMapCtorString: return weakMapTag;
  22384. }
  22385. }
  22386. return result;
  22387. };
  22388. }
  22389. /**
  22390. * Gets the view, applying any `transforms` to the `start` and `end` positions.
  22391. *
  22392. * @private
  22393. * @param {number} start The start of the view.
  22394. * @param {number} end The end of the view.
  22395. * @param {Array} transforms The transformations to apply to the view.
  22396. * @returns {Object} Returns an object containing the `start` and `end`
  22397. * positions of the view.
  22398. */
  22399. function getView(start, end, transforms) {
  22400. var index = -1,
  22401. length = transforms.length;
  22402. while (++index < length) {
  22403. var data = transforms[index],
  22404. size = data.size;
  22405. switch (data.type) {
  22406. case 'drop': start += size; break;
  22407. case 'dropRight': end -= size; break;
  22408. case 'take': end = nativeMin(end, start + size); break;
  22409. case 'takeRight': start = nativeMax(start, end - size); break;
  22410. }
  22411. }
  22412. return { 'start': start, 'end': end };
  22413. }
  22414. /**
  22415. * Extracts wrapper details from the `source` body comment.
  22416. *
  22417. * @private
  22418. * @param {string} source The source to inspect.
  22419. * @returns {Array} Returns the wrapper details.
  22420. */
  22421. function getWrapDetails(source) {
  22422. var match = source.match(reWrapDetails);
  22423. return match ? match[1].split(reSplitDetails) : [];
  22424. }
  22425. /**
  22426. * Checks if `path` exists on `object`.
  22427. *
  22428. * @private
  22429. * @param {Object} object The object to query.
  22430. * @param {Array|string} path The path to check.
  22431. * @param {Function} hasFunc The function to check properties.
  22432. * @returns {boolean} Returns `true` if `path` exists, else `false`.
  22433. */
  22434. function hasPath(object, path, hasFunc) {
  22435. path = castPath(path, object);
  22436. var index = -1,
  22437. length = path.length,
  22438. result = false;
  22439. while (++index < length) {
  22440. var key = toKey(path[index]);
  22441. if (!(result = object != null && hasFunc(object, key))) {
  22442. break;
  22443. }
  22444. object = object[key];
  22445. }
  22446. if (result || ++index != length) {
  22447. return result;
  22448. }
  22449. length = object == null ? 0 : object.length;
  22450. return !!length && isLength(length) && isIndex(key, length) &&
  22451. (isArray(object) || isArguments(object));
  22452. }
  22453. /**
  22454. * Initializes an array clone.
  22455. *
  22456. * @private
  22457. * @param {Array} array The array to clone.
  22458. * @returns {Array} Returns the initialized clone.
  22459. */
  22460. function initCloneArray(array) {
  22461. var length = array.length,
  22462. result = new array.constructor(length);
  22463. // Add properties assigned by `RegExp#exec`.
  22464. if (length && typeof array[0] == 'string' && hasOwnProperty.call(array, 'index')) {
  22465. result.index = array.index;
  22466. result.input = array.input;
  22467. }
  22468. return result;
  22469. }
  22470. /**
  22471. * Initializes an object clone.
  22472. *
  22473. * @private
  22474. * @param {Object} object The object to clone.
  22475. * @returns {Object} Returns the initialized clone.
  22476. */
  22477. function initCloneObject(object) {
  22478. return (typeof object.constructor == 'function' && !isPrototype(object))
  22479. ? baseCreate(getPrototype(object))
  22480. : {};
  22481. }
  22482. /**
  22483. * Initializes an object clone based on its `toStringTag`.
  22484. *
  22485. * **Note:** This function only supports cloning values with tags of
  22486. * `Boolean`, `Date`, `Error`, `Map`, `Number`, `RegExp`, `Set`, or `String`.
  22487. *
  22488. * @private
  22489. * @param {Object} object The object to clone.
  22490. * @param {string} tag The `toStringTag` of the object to clone.
  22491. * @param {boolean} [isDeep] Specify a deep clone.
  22492. * @returns {Object} Returns the initialized clone.
  22493. */
  22494. function initCloneByTag(object, tag, isDeep) {
  22495. var Ctor = object.constructor;
  22496. switch (tag) {
  22497. case arrayBufferTag:
  22498. return cloneArrayBuffer(object);
  22499. case boolTag:
  22500. case dateTag:
  22501. return new Ctor(+object);
  22502. case dataViewTag:
  22503. return cloneDataView(object, isDeep);
  22504. case float32Tag: case float64Tag:
  22505. case int8Tag: case int16Tag: case int32Tag:
  22506. case uint8Tag: case uint8ClampedTag: case uint16Tag: case uint32Tag:
  22507. return cloneTypedArray(object, isDeep);
  22508. case mapTag:
  22509. return new Ctor;
  22510. case numberTag:
  22511. case stringTag:
  22512. return new Ctor(object);
  22513. case regexpTag:
  22514. return cloneRegExp(object);
  22515. case setTag:
  22516. return new Ctor;
  22517. case symbolTag:
  22518. return cloneSymbol(object);
  22519. }
  22520. }
  22521. /**
  22522. * Inserts wrapper `details` in a comment at the top of the `source` body.
  22523. *
  22524. * @private
  22525. * @param {string} source The source to modify.
  22526. * @returns {Array} details The details to insert.
  22527. * @returns {string} Returns the modified source.
  22528. */
  22529. function insertWrapDetails(source, details) {
  22530. var length = details.length;
  22531. if (!length) {
  22532. return source;
  22533. }
  22534. var lastIndex = length - 1;
  22535. details[lastIndex] = (length > 1 ? '& ' : '') + details[lastIndex];
  22536. details = details.join(length > 2 ? ', ' : ' ');
  22537. return source.replace(reWrapComment, '{\n/* [wrapped with ' + details + '] */\n');
  22538. }
  22539. /**
  22540. * Checks if `value` is a flattenable `arguments` object or array.
  22541. *
  22542. * @private
  22543. * @param {*} value The value to check.
  22544. * @returns {boolean} Returns `true` if `value` is flattenable, else `false`.
  22545. */
  22546. function isFlattenable(value) {
  22547. return isArray(value) || isArguments(value) ||
  22548. !!(spreadableSymbol && value && value[spreadableSymbol]);
  22549. }
  22550. /**
  22551. * Checks if `value` is a valid array-like index.
  22552. *
  22553. * @private
  22554. * @param {*} value The value to check.
  22555. * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
  22556. * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
  22557. */
  22558. function isIndex(value, length) {
  22559. var type = typeof value;
  22560. length = length == null ? MAX_SAFE_INTEGER : length;
  22561. return !!length &&
  22562. (type == 'number' ||
  22563. (type != 'symbol' && reIsUint.test(value))) &&
  22564. (value > -1 && value % 1 == 0 && value < length);
  22565. }
  22566. /**
  22567. * Checks if the given arguments are from an iteratee call.
  22568. *
  22569. * @private
  22570. * @param {*} value The potential iteratee value argument.
  22571. * @param {*} index The potential iteratee index or key argument.
  22572. * @param {*} object The potential iteratee object argument.
  22573. * @returns {boolean} Returns `true` if the arguments are from an iteratee call,
  22574. * else `false`.
  22575. */
  22576. function isIterateeCall(value, index, object) {
  22577. if (!isObject(object)) {
  22578. return false;
  22579. }
  22580. var type = typeof index;
  22581. if (type == 'number'
  22582. ? (isArrayLike(object) && isIndex(index, object.length))
  22583. : (type == 'string' && index in object)
  22584. ) {
  22585. return eq(object[index], value);
  22586. }
  22587. return false;
  22588. }
  22589. /**
  22590. * Checks if `value` is a property name and not a property path.
  22591. *
  22592. * @private
  22593. * @param {*} value The value to check.
  22594. * @param {Object} [object] The object to query keys on.
  22595. * @returns {boolean} Returns `true` if `value` is a property name, else `false`.
  22596. */
  22597. function isKey(value, object) {
  22598. if (isArray(value)) {
  22599. return false;
  22600. }
  22601. var type = typeof value;
  22602. if (type == 'number' || type == 'symbol' || type == 'boolean' ||
  22603. value == null || isSymbol(value)) {
  22604. return true;
  22605. }
  22606. return reIsPlainProp.test(value) || !reIsDeepProp.test(value) ||
  22607. (object != null && value in Object(object));
  22608. }
  22609. /**
  22610. * Checks if `value` is suitable for use as unique object key.
  22611. *
  22612. * @private
  22613. * @param {*} value The value to check.
  22614. * @returns {boolean} Returns `true` if `value` is suitable, else `false`.
  22615. */
  22616. function isKeyable(value) {
  22617. var type = typeof value;
  22618. return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')
  22619. ? (value !== '__proto__')
  22620. : (value === null);
  22621. }
  22622. /**
  22623. * Checks if `func` has a lazy counterpart.
  22624. *
  22625. * @private
  22626. * @param {Function} func The function to check.
  22627. * @returns {boolean} Returns `true` if `func` has a lazy counterpart,
  22628. * else `false`.
  22629. */
  22630. function isLaziable(func) {
  22631. var funcName = getFuncName(func),
  22632. other = lodash[funcName];
  22633. if (typeof other != 'function' || !(funcName in LazyWrapper.prototype)) {
  22634. return false;
  22635. }
  22636. if (func === other) {
  22637. return true;
  22638. }
  22639. var data = getData(other);
  22640. return !!data && func === data[0];
  22641. }
  22642. /**
  22643. * Checks if `func` has its source masked.
  22644. *
  22645. * @private
  22646. * @param {Function} func The function to check.
  22647. * @returns {boolean} Returns `true` if `func` is masked, else `false`.
  22648. */
  22649. function isMasked(func) {
  22650. return !!maskSrcKey && (maskSrcKey in func);
  22651. }
  22652. /**
  22653. * Checks if `func` is capable of being masked.
  22654. *
  22655. * @private
  22656. * @param {*} value The value to check.
  22657. * @returns {boolean} Returns `true` if `func` is maskable, else `false`.
  22658. */
  22659. var isMaskable = coreJsData ? isFunction : stubFalse;
  22660. /**
  22661. * Checks if `value` is likely a prototype object.
  22662. *
  22663. * @private
  22664. * @param {*} value The value to check.
  22665. * @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
  22666. */
  22667. function isPrototype(value) {
  22668. var Ctor = value && value.constructor,
  22669. proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto;
  22670. return value === proto;
  22671. }
  22672. /**
  22673. * Checks if `value` is suitable for strict equality comparisons, i.e. `===`.
  22674. *
  22675. * @private
  22676. * @param {*} value The value to check.
  22677. * @returns {boolean} Returns `true` if `value` if suitable for strict
  22678. * equality comparisons, else `false`.
  22679. */
  22680. function isStrictComparable(value) {
  22681. return value === value && !isObject(value);
  22682. }
  22683. /**
  22684. * A specialized version of `matchesProperty` for source values suitable
  22685. * for strict equality comparisons, i.e. `===`.
  22686. *
  22687. * @private
  22688. * @param {string} key The key of the property to get.
  22689. * @param {*} srcValue The value to match.
  22690. * @returns {Function} Returns the new spec function.
  22691. */
  22692. function matchesStrictComparable(key, srcValue) {
  22693. return function(object) {
  22694. if (object == null) {
  22695. return false;
  22696. }
  22697. return object[key] === srcValue &&
  22698. (srcValue !== undefined || (key in Object(object)));
  22699. };
  22700. }
  22701. /**
  22702. * A specialized version of `_.memoize` which clears the memoized function's
  22703. * cache when it exceeds `MAX_MEMOIZE_SIZE`.
  22704. *
  22705. * @private
  22706. * @param {Function} func The function to have its output memoized.
  22707. * @returns {Function} Returns the new memoized function.
  22708. */
  22709. function memoizeCapped(func) {
  22710. var result = memoize(func, function(key) {
  22711. if (cache.size === MAX_MEMOIZE_SIZE) {
  22712. cache.clear();
  22713. }
  22714. return key;
  22715. });
  22716. var cache = result.cache;
  22717. return result;
  22718. }
  22719. /**
  22720. * Merges the function metadata of `source` into `data`.
  22721. *
  22722. * Merging metadata reduces the number of wrappers used to invoke a function.
  22723. * This is possible because methods like `_.bind`, `_.curry`, and `_.partial`
  22724. * may be applied regardless of execution order. Methods like `_.ary` and
  22725. * `_.rearg` modify function arguments, making the order in which they are
  22726. * executed important, preventing the merging of metadata. However, we make
  22727. * an exception for a safe combined case where curried functions have `_.ary`
  22728. * and or `_.rearg` applied.
  22729. *
  22730. * @private
  22731. * @param {Array} data The destination metadata.
  22732. * @param {Array} source The source metadata.
  22733. * @returns {Array} Returns `data`.
  22734. */
  22735. function mergeData(data, source) {
  22736. var bitmask = data[1],
  22737. srcBitmask = source[1],
  22738. newBitmask = bitmask | srcBitmask,
  22739. isCommon = newBitmask < (WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG | WRAP_ARY_FLAG);
  22740. var isCombo =
  22741. ((srcBitmask == WRAP_ARY_FLAG) && (bitmask == WRAP_CURRY_FLAG)) ||
  22742. ((srcBitmask == WRAP_ARY_FLAG) && (bitmask == WRAP_REARG_FLAG) && (data[7].length <= source[8])) ||
  22743. ((srcBitmask == (WRAP_ARY_FLAG | WRAP_REARG_FLAG)) && (source[7].length <= source[8]) && (bitmask == WRAP_CURRY_FLAG));
  22744. // Exit early if metadata can't be merged.
  22745. if (!(isCommon || isCombo)) {
  22746. return data;
  22747. }
  22748. // Use source `thisArg` if available.
  22749. if (srcBitmask & WRAP_BIND_FLAG) {
  22750. data[2] = source[2];
  22751. // Set when currying a bound function.
  22752. newBitmask |= bitmask & WRAP_BIND_FLAG ? 0 : WRAP_CURRY_BOUND_FLAG;
  22753. }
  22754. // Compose partial arguments.
  22755. var value = source[3];
  22756. if (value) {
  22757. var partials = data[3];
  22758. data[3] = partials ? composeArgs(partials, value, source[4]) : value;
  22759. data[4] = partials ? replaceHolders(data[3], PLACEHOLDER) : source[4];
  22760. }
  22761. // Compose partial right arguments.
  22762. value = source[5];
  22763. if (value) {
  22764. partials = data[5];
  22765. data[5] = partials ? composeArgsRight(partials, value, source[6]) : value;
  22766. data[6] = partials ? replaceHolders(data[5], PLACEHOLDER) : source[6];
  22767. }
  22768. // Use source `argPos` if available.
  22769. value = source[7];
  22770. if (value) {
  22771. data[7] = value;
  22772. }
  22773. // Use source `ary` if it's smaller.
  22774. if (srcBitmask & WRAP_ARY_FLAG) {
  22775. data[8] = data[8] == null ? source[8] : nativeMin(data[8], source[8]);
  22776. }
  22777. // Use source `arity` if one is not provided.
  22778. if (data[9] == null) {
  22779. data[9] = source[9];
  22780. }
  22781. // Use source `func` and merge bitmasks.
  22782. data[0] = source[0];
  22783. data[1] = newBitmask;
  22784. return data;
  22785. }
  22786. /**
  22787. * This function is like
  22788. * [`Object.keys`](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
  22789. * except that it includes inherited enumerable properties.
  22790. *
  22791. * @private
  22792. * @param {Object} object The object to query.
  22793. * @returns {Array} Returns the array of property names.
  22794. */
  22795. function nativeKeysIn(object) {
  22796. var result = [];
  22797. if (object != null) {
  22798. for (var key in Object(object)) {
  22799. result.push(key);
  22800. }
  22801. }
  22802. return result;
  22803. }
  22804. /**
  22805. * Converts `value` to a string using `Object.prototype.toString`.
  22806. *
  22807. * @private
  22808. * @param {*} value The value to convert.
  22809. * @returns {string} Returns the converted string.
  22810. */
  22811. function objectToString(value) {
  22812. return nativeObjectToString.call(value);
  22813. }
  22814. /**
  22815. * A specialized version of `baseRest` which transforms the rest array.
  22816. *
  22817. * @private
  22818. * @param {Function} func The function to apply a rest parameter to.
  22819. * @param {number} [start=func.length-1] The start position of the rest parameter.
  22820. * @param {Function} transform The rest array transform.
  22821. * @returns {Function} Returns the new function.
  22822. */
  22823. function overRest(func, start, transform) {
  22824. start = nativeMax(start === undefined ? (func.length - 1) : start, 0);
  22825. return function() {
  22826. var args = arguments,
  22827. index = -1,
  22828. length = nativeMax(args.length - start, 0),
  22829. array = Array(length);
  22830. while (++index < length) {
  22831. array[index] = args[start + index];
  22832. }
  22833. index = -1;
  22834. var otherArgs = Array(start + 1);
  22835. while (++index < start) {
  22836. otherArgs[index] = args[index];
  22837. }
  22838. otherArgs[start] = transform(array);
  22839. return apply(func, this, otherArgs);
  22840. };
  22841. }
  22842. /**
  22843. * Gets the parent value at `path` of `object`.
  22844. *
  22845. * @private
  22846. * @param {Object} object The object to query.
  22847. * @param {Array} path The path to get the parent value of.
  22848. * @returns {*} Returns the parent value.
  22849. */
  22850. function parent(object, path) {
  22851. return path.length < 2 ? object : baseGet(object, baseSlice(path, 0, -1));
  22852. }
  22853. /**
  22854. * Reorder `array` according to the specified indexes where the element at
  22855. * the first index is assigned as the first element, the element at
  22856. * the second index is assigned as the second element, and so on.
  22857. *
  22858. * @private
  22859. * @param {Array} array The array to reorder.
  22860. * @param {Array} indexes The arranged array indexes.
  22861. * @returns {Array} Returns `array`.
  22862. */
  22863. function reorder(array, indexes) {
  22864. var arrLength = array.length,
  22865. length = nativeMin(indexes.length, arrLength),
  22866. oldArray = copyArray(array);
  22867. while (length--) {
  22868. var index = indexes[length];
  22869. array[length] = isIndex(index, arrLength) ? oldArray[index] : undefined;
  22870. }
  22871. return array;
  22872. }
  22873. /**
  22874. * Gets the value at `key`, unless `key` is "__proto__" or "constructor".
  22875. *
  22876. * @private
  22877. * @param {Object} object The object to query.
  22878. * @param {string} key The key of the property to get.
  22879. * @returns {*} Returns the property value.
  22880. */
  22881. function safeGet(object, key) {
  22882. if (key === 'constructor' && typeof object[key] === 'function') {
  22883. return;
  22884. }
  22885. if (key == '__proto__') {
  22886. return;
  22887. }
  22888. return object[key];
  22889. }
  22890. /**
  22891. * Sets metadata for `func`.
  22892. *
  22893. * **Note:** If this function becomes hot, i.e. is invoked a lot in a short
  22894. * period of time, it will trip its breaker and transition to an identity
  22895. * function to avoid garbage collection pauses in V8. See
  22896. * [V8 issue 2070](https://bugs.chromium.org/p/v8/issues/detail?id=2070)
  22897. * for more details.
  22898. *
  22899. * @private
  22900. * @param {Function} func The function to associate metadata with.
  22901. * @param {*} data The metadata.
  22902. * @returns {Function} Returns `func`.
  22903. */
  22904. var setData = shortOut(baseSetData);
  22905. /**
  22906. * A simple wrapper around the global [`setTimeout`](https://mdn.io/setTimeout).
  22907. *
  22908. * @private
  22909. * @param {Function} func The function to delay.
  22910. * @param {number} wait The number of milliseconds to delay invocation.
  22911. * @returns {number|Object} Returns the timer id or timeout object.
  22912. */
  22913. var setTimeout = ctxSetTimeout || function(func, wait) {
  22914. return root.setTimeout(func, wait);
  22915. };
  22916. /**
  22917. * Sets the `toString` method of `func` to return `string`.
  22918. *
  22919. * @private
  22920. * @param {Function} func The function to modify.
  22921. * @param {Function} string The `toString` result.
  22922. * @returns {Function} Returns `func`.
  22923. */
  22924. var setToString = shortOut(baseSetToString);
  22925. /**
  22926. * Sets the `toString` method of `wrapper` to mimic the source of `reference`
  22927. * with wrapper details in a comment at the top of the source body.
  22928. *
  22929. * @private
  22930. * @param {Function} wrapper The function to modify.
  22931. * @param {Function} reference The reference function.
  22932. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  22933. * @returns {Function} Returns `wrapper`.
  22934. */
  22935. function setWrapToString(wrapper, reference, bitmask) {
  22936. var source = (reference + '');
  22937. return setToString(wrapper, insertWrapDetails(source, updateWrapDetails(getWrapDetails(source), bitmask)));
  22938. }
  22939. /**
  22940. * Creates a function that'll short out and invoke `identity` instead
  22941. * of `func` when it's called `HOT_COUNT` or more times in `HOT_SPAN`
  22942. * milliseconds.
  22943. *
  22944. * @private
  22945. * @param {Function} func The function to restrict.
  22946. * @returns {Function} Returns the new shortable function.
  22947. */
  22948. function shortOut(func) {
  22949. var count = 0,
  22950. lastCalled = 0;
  22951. return function() {
  22952. var stamp = nativeNow(),
  22953. remaining = HOT_SPAN - (stamp - lastCalled);
  22954. lastCalled = stamp;
  22955. if (remaining > 0) {
  22956. if (++count >= HOT_COUNT) {
  22957. return arguments[0];
  22958. }
  22959. } else {
  22960. count = 0;
  22961. }
  22962. return func.apply(undefined, arguments);
  22963. };
  22964. }
  22965. /**
  22966. * A specialized version of `_.shuffle` which mutates and sets the size of `array`.
  22967. *
  22968. * @private
  22969. * @param {Array} array The array to shuffle.
  22970. * @param {number} [size=array.length] The size of `array`.
  22971. * @returns {Array} Returns `array`.
  22972. */
  22973. function shuffleSelf(array, size) {
  22974. var index = -1,
  22975. length = array.length,
  22976. lastIndex = length - 1;
  22977. size = size === undefined ? length : size;
  22978. while (++index < size) {
  22979. var rand = baseRandom(index, lastIndex),
  22980. value = array[rand];
  22981. array[rand] = array[index];
  22982. array[index] = value;
  22983. }
  22984. array.length = size;
  22985. return array;
  22986. }
  22987. /**
  22988. * Converts `string` to a property path array.
  22989. *
  22990. * @private
  22991. * @param {string} string The string to convert.
  22992. * @returns {Array} Returns the property path array.
  22993. */
  22994. var stringToPath = memoizeCapped(function(string) {
  22995. var result = [];
  22996. if (string.charCodeAt(0) === 46 /* . */) {
  22997. result.push('');
  22998. }
  22999. string.replace(rePropName, function(match, number, quote, subString) {
  23000. result.push(quote ? subString.replace(reEscapeChar, '$1') : (number || match));
  23001. });
  23002. return result;
  23003. });
  23004. /**
  23005. * Converts `value` to a string key if it's not a string or symbol.
  23006. *
  23007. * @private
  23008. * @param {*} value The value to inspect.
  23009. * @returns {string|symbol} Returns the key.
  23010. */
  23011. function toKey(value) {
  23012. if (typeof value == 'string' || isSymbol(value)) {
  23013. return value;
  23014. }
  23015. var result = (value + '');
  23016. return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
  23017. }
  23018. /**
  23019. * Converts `func` to its source code.
  23020. *
  23021. * @private
  23022. * @param {Function} func The function to convert.
  23023. * @returns {string} Returns the source code.
  23024. */
  23025. function toSource(func) {
  23026. if (func != null) {
  23027. try {
  23028. return funcToString.call(func);
  23029. } catch (e) {}
  23030. try {
  23031. return (func + '');
  23032. } catch (e) {}
  23033. }
  23034. return '';
  23035. }
  23036. /**
  23037. * Updates wrapper `details` based on `bitmask` flags.
  23038. *
  23039. * @private
  23040. * @returns {Array} details The details to modify.
  23041. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  23042. * @returns {Array} Returns `details`.
  23043. */
  23044. function updateWrapDetails(details, bitmask) {
  23045. arrayEach(wrapFlags, function(pair) {
  23046. var value = '_.' + pair[0];
  23047. if ((bitmask & pair[1]) && !arrayIncludes(details, value)) {
  23048. details.push(value);
  23049. }
  23050. });
  23051. return details.sort();
  23052. }
  23053. /**
  23054. * Creates a clone of `wrapper`.
  23055. *
  23056. * @private
  23057. * @param {Object} wrapper The wrapper to clone.
  23058. * @returns {Object} Returns the cloned wrapper.
  23059. */
  23060. function wrapperClone(wrapper) {
  23061. if (wrapper instanceof LazyWrapper) {
  23062. return wrapper.clone();
  23063. }
  23064. var result = new LodashWrapper(wrapper.__wrapped__, wrapper.__chain__);
  23065. result.__actions__ = copyArray(wrapper.__actions__);
  23066. result.__index__ = wrapper.__index__;
  23067. result.__values__ = wrapper.__values__;
  23068. return result;
  23069. }
  23070. /*------------------------------------------------------------------------*/
  23071. /**
  23072. * Creates an array of elements split into groups the length of `size`.
  23073. * If `array` can't be split evenly, the final chunk will be the remaining
  23074. * elements.
  23075. *
  23076. * @static
  23077. * @memberOf _
  23078. * @since 3.0.0
  23079. * @category Array
  23080. * @param {Array} array The array to process.
  23081. * @param {number} [size=1] The length of each chunk
  23082. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  23083. * @returns {Array} Returns the new array of chunks.
  23084. * @example
  23085. *
  23086. * _.chunk(['a', 'b', 'c', 'd'], 2);
  23087. * // => [['a', 'b'], ['c', 'd']]
  23088. *
  23089. * _.chunk(['a', 'b', 'c', 'd'], 3);
  23090. * // => [['a', 'b', 'c'], ['d']]
  23091. */
  23092. function chunk(array, size, guard) {
  23093. if ((guard ? isIterateeCall(array, size, guard) : size === undefined)) {
  23094. size = 1;
  23095. } else {
  23096. size = nativeMax(toInteger(size), 0);
  23097. }
  23098. var length = array == null ? 0 : array.length;
  23099. if (!length || size < 1) {
  23100. return [];
  23101. }
  23102. var index = 0,
  23103. resIndex = 0,
  23104. result = Array(nativeCeil(length / size));
  23105. while (index < length) {
  23106. result[resIndex++] = baseSlice(array, index, (index += size));
  23107. }
  23108. return result;
  23109. }
  23110. /**
  23111. * Creates an array with all falsey values removed. The values `false`, `null`,
  23112. * `0`, `""`, `undefined`, and `NaN` are falsey.
  23113. *
  23114. * @static
  23115. * @memberOf _
  23116. * @since 0.1.0
  23117. * @category Array
  23118. * @param {Array} array The array to compact.
  23119. * @returns {Array} Returns the new array of filtered values.
  23120. * @example
  23121. *
  23122. * _.compact([0, 1, false, 2, '', 3]);
  23123. * // => [1, 2, 3]
  23124. */
  23125. function compact(array) {
  23126. var index = -1,
  23127. length = array == null ? 0 : array.length,
  23128. resIndex = 0,
  23129. result = [];
  23130. while (++index < length) {
  23131. var value = array[index];
  23132. if (value) {
  23133. result[resIndex++] = value;
  23134. }
  23135. }
  23136. return result;
  23137. }
  23138. /**
  23139. * Creates a new array concatenating `array` with any additional arrays
  23140. * and/or values.
  23141. *
  23142. * @static
  23143. * @memberOf _
  23144. * @since 4.0.0
  23145. * @category Array
  23146. * @param {Array} array The array to concatenate.
  23147. * @param {...*} [values] The values to concatenate.
  23148. * @returns {Array} Returns the new concatenated array.
  23149. * @example
  23150. *
  23151. * var array = [1];
  23152. * var other = _.concat(array, 2, [3], [[4]]);
  23153. *
  23154. * console.log(other);
  23155. * // => [1, 2, 3, [4]]
  23156. *
  23157. * console.log(array);
  23158. * // => [1]
  23159. */
  23160. function concat() {
  23161. var length = arguments.length;
  23162. if (!length) {
  23163. return [];
  23164. }
  23165. var args = Array(length - 1),
  23166. array = arguments[0],
  23167. index = length;
  23168. while (index--) {
  23169. args[index - 1] = arguments[index];
  23170. }
  23171. return arrayPush(isArray(array) ? copyArray(array) : [array], baseFlatten(args, 1));
  23172. }
  23173. /**
  23174. * Creates an array of `array` values not included in the other given arrays
  23175. * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  23176. * for equality comparisons. The order and references of result values are
  23177. * determined by the first array.
  23178. *
  23179. * **Note:** Unlike `_.pullAll`, this method returns a new array.
  23180. *
  23181. * @static
  23182. * @memberOf _
  23183. * @since 0.1.0
  23184. * @category Array
  23185. * @param {Array} array The array to inspect.
  23186. * @param {...Array} [values] The values to exclude.
  23187. * @returns {Array} Returns the new array of filtered values.
  23188. * @see _.without, _.xor
  23189. * @example
  23190. *
  23191. * _.difference([2, 1], [2, 3]);
  23192. * // => [1]
  23193. */
  23194. var difference = baseRest(function(array, values) {
  23195. return isArrayLikeObject(array)
  23196. ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true))
  23197. : [];
  23198. });
  23199. /**
  23200. * This method is like `_.difference` except that it accepts `iteratee` which
  23201. * is invoked for each element of `array` and `values` to generate the criterion
  23202. * by which they're compared. The order and references of result values are
  23203. * determined by the first array. The iteratee is invoked with one argument:
  23204. * (value).
  23205. *
  23206. * **Note:** Unlike `_.pullAllBy`, this method returns a new array.
  23207. *
  23208. * @static
  23209. * @memberOf _
  23210. * @since 4.0.0
  23211. * @category Array
  23212. * @param {Array} array The array to inspect.
  23213. * @param {...Array} [values] The values to exclude.
  23214. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  23215. * @returns {Array} Returns the new array of filtered values.
  23216. * @example
  23217. *
  23218. * _.differenceBy([2.1, 1.2], [2.3, 3.4], Math.floor);
  23219. * // => [1.2]
  23220. *
  23221. * // The `_.property` iteratee shorthand.
  23222. * _.differenceBy([{ 'x': 2 }, { 'x': 1 }], [{ 'x': 1 }], 'x');
  23223. * // => [{ 'x': 2 }]
  23224. */
  23225. var differenceBy = baseRest(function(array, values) {
  23226. var iteratee = last(values);
  23227. if (isArrayLikeObject(iteratee)) {
  23228. iteratee = undefined;
  23229. }
  23230. return isArrayLikeObject(array)
  23231. ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true), getIteratee(iteratee, 2))
  23232. : [];
  23233. });
  23234. /**
  23235. * This method is like `_.difference` except that it accepts `comparator`
  23236. * which is invoked to compare elements of `array` to `values`. The order and
  23237. * references of result values are determined by the first array. The comparator
  23238. * is invoked with two arguments: (arrVal, othVal).
  23239. *
  23240. * **Note:** Unlike `_.pullAllWith`, this method returns a new array.
  23241. *
  23242. * @static
  23243. * @memberOf _
  23244. * @since 4.0.0
  23245. * @category Array
  23246. * @param {Array} array The array to inspect.
  23247. * @param {...Array} [values] The values to exclude.
  23248. * @param {Function} [comparator] The comparator invoked per element.
  23249. * @returns {Array} Returns the new array of filtered values.
  23250. * @example
  23251. *
  23252. * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
  23253. *
  23254. * _.differenceWith(objects, [{ 'x': 1, 'y': 2 }], _.isEqual);
  23255. * // => [{ 'x': 2, 'y': 1 }]
  23256. */
  23257. var differenceWith = baseRest(function(array, values) {
  23258. var comparator = last(values);
  23259. if (isArrayLikeObject(comparator)) {
  23260. comparator = undefined;
  23261. }
  23262. return isArrayLikeObject(array)
  23263. ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true), undefined, comparator)
  23264. : [];
  23265. });
  23266. /**
  23267. * Creates a slice of `array` with `n` elements dropped from the beginning.
  23268. *
  23269. * @static
  23270. * @memberOf _
  23271. * @since 0.5.0
  23272. * @category Array
  23273. * @param {Array} array The array to query.
  23274. * @param {number} [n=1] The number of elements to drop.
  23275. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  23276. * @returns {Array} Returns the slice of `array`.
  23277. * @example
  23278. *
  23279. * _.drop([1, 2, 3]);
  23280. * // => [2, 3]
  23281. *
  23282. * _.drop([1, 2, 3], 2);
  23283. * // => [3]
  23284. *
  23285. * _.drop([1, 2, 3], 5);
  23286. * // => []
  23287. *
  23288. * _.drop([1, 2, 3], 0);
  23289. * // => [1, 2, 3]
  23290. */
  23291. function drop(array, n, guard) {
  23292. var length = array == null ? 0 : array.length;
  23293. if (!length) {
  23294. return [];
  23295. }
  23296. n = (guard || n === undefined) ? 1 : toInteger(n);
  23297. return baseSlice(array, n < 0 ? 0 : n, length);
  23298. }
  23299. /**
  23300. * Creates a slice of `array` with `n` elements dropped from the end.
  23301. *
  23302. * @static
  23303. * @memberOf _
  23304. * @since 3.0.0
  23305. * @category Array
  23306. * @param {Array} array The array to query.
  23307. * @param {number} [n=1] The number of elements to drop.
  23308. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  23309. * @returns {Array} Returns the slice of `array`.
  23310. * @example
  23311. *
  23312. * _.dropRight([1, 2, 3]);
  23313. * // => [1, 2]
  23314. *
  23315. * _.dropRight([1, 2, 3], 2);
  23316. * // => [1]
  23317. *
  23318. * _.dropRight([1, 2, 3], 5);
  23319. * // => []
  23320. *
  23321. * _.dropRight([1, 2, 3], 0);
  23322. * // => [1, 2, 3]
  23323. */
  23324. function dropRight(array, n, guard) {
  23325. var length = array == null ? 0 : array.length;
  23326. if (!length) {
  23327. return [];
  23328. }
  23329. n = (guard || n === undefined) ? 1 : toInteger(n);
  23330. n = length - n;
  23331. return baseSlice(array, 0, n < 0 ? 0 : n);
  23332. }
  23333. /**
  23334. * Creates a slice of `array` excluding elements dropped from the end.
  23335. * Elements are dropped until `predicate` returns falsey. The predicate is
  23336. * invoked with three arguments: (value, index, array).
  23337. *
  23338. * @static
  23339. * @memberOf _
  23340. * @since 3.0.0
  23341. * @category Array
  23342. * @param {Array} array The array to query.
  23343. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  23344. * @returns {Array} Returns the slice of `array`.
  23345. * @example
  23346. *
  23347. * var users = [
  23348. * { 'user': 'barney', 'active': true },
  23349. * { 'user': 'fred', 'active': false },
  23350. * { 'user': 'pebbles', 'active': false }
  23351. * ];
  23352. *
  23353. * _.dropRightWhile(users, function(o) { return !o.active; });
  23354. * // => objects for ['barney']
  23355. *
  23356. * // The `_.matches` iteratee shorthand.
  23357. * _.dropRightWhile(users, { 'user': 'pebbles', 'active': false });
  23358. * // => objects for ['barney', 'fred']
  23359. *
  23360. * // The `_.matchesProperty` iteratee shorthand.
  23361. * _.dropRightWhile(users, ['active', false]);
  23362. * // => objects for ['barney']
  23363. *
  23364. * // The `_.property` iteratee shorthand.
  23365. * _.dropRightWhile(users, 'active');
  23366. * // => objects for ['barney', 'fred', 'pebbles']
  23367. */
  23368. function dropRightWhile(array, predicate) {
  23369. return (array && array.length)
  23370. ? baseWhile(array, getIteratee(predicate, 3), true, true)
  23371. : [];
  23372. }
  23373. /**
  23374. * Creates a slice of `array` excluding elements dropped from the beginning.
  23375. * Elements are dropped until `predicate` returns falsey. The predicate is
  23376. * invoked with three arguments: (value, index, array).
  23377. *
  23378. * @static
  23379. * @memberOf _
  23380. * @since 3.0.0
  23381. * @category Array
  23382. * @param {Array} array The array to query.
  23383. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  23384. * @returns {Array} Returns the slice of `array`.
  23385. * @example
  23386. *
  23387. * var users = [
  23388. * { 'user': 'barney', 'active': false },
  23389. * { 'user': 'fred', 'active': false },
  23390. * { 'user': 'pebbles', 'active': true }
  23391. * ];
  23392. *
  23393. * _.dropWhile(users, function(o) { return !o.active; });
  23394. * // => objects for ['pebbles']
  23395. *
  23396. * // The `_.matches` iteratee shorthand.
  23397. * _.dropWhile(users, { 'user': 'barney', 'active': false });
  23398. * // => objects for ['fred', 'pebbles']
  23399. *
  23400. * // The `_.matchesProperty` iteratee shorthand.
  23401. * _.dropWhile(users, ['active', false]);
  23402. * // => objects for ['pebbles']
  23403. *
  23404. * // The `_.property` iteratee shorthand.
  23405. * _.dropWhile(users, 'active');
  23406. * // => objects for ['barney', 'fred', 'pebbles']
  23407. */
  23408. function dropWhile(array, predicate) {
  23409. return (array && array.length)
  23410. ? baseWhile(array, getIteratee(predicate, 3), true)
  23411. : [];
  23412. }
  23413. /**
  23414. * Fills elements of `array` with `value` from `start` up to, but not
  23415. * including, `end`.
  23416. *
  23417. * **Note:** This method mutates `array`.
  23418. *
  23419. * @static
  23420. * @memberOf _
  23421. * @since 3.2.0
  23422. * @category Array
  23423. * @param {Array} array The array to fill.
  23424. * @param {*} value The value to fill `array` with.
  23425. * @param {number} [start=0] The start position.
  23426. * @param {number} [end=array.length] The end position.
  23427. * @returns {Array} Returns `array`.
  23428. * @example
  23429. *
  23430. * var array = [1, 2, 3];
  23431. *
  23432. * _.fill(array, 'a');
  23433. * console.log(array);
  23434. * // => ['a', 'a', 'a']
  23435. *
  23436. * _.fill(Array(3), 2);
  23437. * // => [2, 2, 2]
  23438. *
  23439. * _.fill([4, 6, 8, 10], '*', 1, 3);
  23440. * // => [4, '*', '*', 10]
  23441. */
  23442. function fill(array, value, start, end) {
  23443. var length = array == null ? 0 : array.length;
  23444. if (!length) {
  23445. return [];
  23446. }
  23447. if (start && typeof start != 'number' && isIterateeCall(array, value, start)) {
  23448. start = 0;
  23449. end = length;
  23450. }
  23451. return baseFill(array, value, start, end);
  23452. }
  23453. /**
  23454. * This method is like `_.find` except that it returns the index of the first
  23455. * element `predicate` returns truthy for instead of the element itself.
  23456. *
  23457. * @static
  23458. * @memberOf _
  23459. * @since 1.1.0
  23460. * @category Array
  23461. * @param {Array} array The array to inspect.
  23462. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  23463. * @param {number} [fromIndex=0] The index to search from.
  23464. * @returns {number} Returns the index of the found element, else `-1`.
  23465. * @example
  23466. *
  23467. * var users = [
  23468. * { 'user': 'barney', 'active': false },
  23469. * { 'user': 'fred', 'active': false },
  23470. * { 'user': 'pebbles', 'active': true }
  23471. * ];
  23472. *
  23473. * _.findIndex(users, function(o) { return o.user == 'barney'; });
  23474. * // => 0
  23475. *
  23476. * // The `_.matches` iteratee shorthand.
  23477. * _.findIndex(users, { 'user': 'fred', 'active': false });
  23478. * // => 1
  23479. *
  23480. * // The `_.matchesProperty` iteratee shorthand.
  23481. * _.findIndex(users, ['active', false]);
  23482. * // => 0
  23483. *
  23484. * // The `_.property` iteratee shorthand.
  23485. * _.findIndex(users, 'active');
  23486. * // => 2
  23487. */
  23488. function findIndex(array, predicate, fromIndex) {
  23489. var length = array == null ? 0 : array.length;
  23490. if (!length) {
  23491. return -1;
  23492. }
  23493. var index = fromIndex == null ? 0 : toInteger(fromIndex);
  23494. if (index < 0) {
  23495. index = nativeMax(length + index, 0);
  23496. }
  23497. return baseFindIndex(array, getIteratee(predicate, 3), index);
  23498. }
  23499. /**
  23500. * This method is like `_.findIndex` except that it iterates over elements
  23501. * of `collection` from right to left.
  23502. *
  23503. * @static
  23504. * @memberOf _
  23505. * @since 2.0.0
  23506. * @category Array
  23507. * @param {Array} array The array to inspect.
  23508. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  23509. * @param {number} [fromIndex=array.length-1] The index to search from.
  23510. * @returns {number} Returns the index of the found element, else `-1`.
  23511. * @example
  23512. *
  23513. * var users = [
  23514. * { 'user': 'barney', 'active': true },
  23515. * { 'user': 'fred', 'active': false },
  23516. * { 'user': 'pebbles', 'active': false }
  23517. * ];
  23518. *
  23519. * _.findLastIndex(users, function(o) { return o.user == 'pebbles'; });
  23520. * // => 2
  23521. *
  23522. * // The `_.matches` iteratee shorthand.
  23523. * _.findLastIndex(users, { 'user': 'barney', 'active': true });
  23524. * // => 0
  23525. *
  23526. * // The `_.matchesProperty` iteratee shorthand.
  23527. * _.findLastIndex(users, ['active', false]);
  23528. * // => 2
  23529. *
  23530. * // The `_.property` iteratee shorthand.
  23531. * _.findLastIndex(users, 'active');
  23532. * // => 0
  23533. */
  23534. function findLastIndex(array, predicate, fromIndex) {
  23535. var length = array == null ? 0 : array.length;
  23536. if (!length) {
  23537. return -1;
  23538. }
  23539. var index = length - 1;
  23540. if (fromIndex !== undefined) {
  23541. index = toInteger(fromIndex);
  23542. index = fromIndex < 0
  23543. ? nativeMax(length + index, 0)
  23544. : nativeMin(index, length - 1);
  23545. }
  23546. return baseFindIndex(array, getIteratee(predicate, 3), index, true);
  23547. }
  23548. /**
  23549. * Flattens `array` a single level deep.
  23550. *
  23551. * @static
  23552. * @memberOf _
  23553. * @since 0.1.0
  23554. * @category Array
  23555. * @param {Array} array The array to flatten.
  23556. * @returns {Array} Returns the new flattened array.
  23557. * @example
  23558. *
  23559. * _.flatten([1, [2, [3, [4]], 5]]);
  23560. * // => [1, 2, [3, [4]], 5]
  23561. */
  23562. function flatten(array) {
  23563. var length = array == null ? 0 : array.length;
  23564. return length ? baseFlatten(array, 1) : [];
  23565. }
  23566. /**
  23567. * Recursively flattens `array`.
  23568. *
  23569. * @static
  23570. * @memberOf _
  23571. * @since 3.0.0
  23572. * @category Array
  23573. * @param {Array} array The array to flatten.
  23574. * @returns {Array} Returns the new flattened array.
  23575. * @example
  23576. *
  23577. * _.flattenDeep([1, [2, [3, [4]], 5]]);
  23578. * // => [1, 2, 3, 4, 5]
  23579. */
  23580. function flattenDeep(array) {
  23581. var length = array == null ? 0 : array.length;
  23582. return length ? baseFlatten(array, INFINITY) : [];
  23583. }
  23584. /**
  23585. * Recursively flatten `array` up to `depth` times.
  23586. *
  23587. * @static
  23588. * @memberOf _
  23589. * @since 4.4.0
  23590. * @category Array
  23591. * @param {Array} array The array to flatten.
  23592. * @param {number} [depth=1] The maximum recursion depth.
  23593. * @returns {Array} Returns the new flattened array.
  23594. * @example
  23595. *
  23596. * var array = [1, [2, [3, [4]], 5]];
  23597. *
  23598. * _.flattenDepth(array, 1);
  23599. * // => [1, 2, [3, [4]], 5]
  23600. *
  23601. * _.flattenDepth(array, 2);
  23602. * // => [1, 2, 3, [4], 5]
  23603. */
  23604. function flattenDepth(array, depth) {
  23605. var length = array == null ? 0 : array.length;
  23606. if (!length) {
  23607. return [];
  23608. }
  23609. depth = depth === undefined ? 1 : toInteger(depth);
  23610. return baseFlatten(array, depth);
  23611. }
  23612. /**
  23613. * The inverse of `_.toPairs`; this method returns an object composed
  23614. * from key-value `pairs`.
  23615. *
  23616. * @static
  23617. * @memberOf _
  23618. * @since 4.0.0
  23619. * @category Array
  23620. * @param {Array} pairs The key-value pairs.
  23621. * @returns {Object} Returns the new object.
  23622. * @example
  23623. *
  23624. * _.fromPairs([['a', 1], ['b', 2]]);
  23625. * // => { 'a': 1, 'b': 2 }
  23626. */
  23627. function fromPairs(pairs) {
  23628. var index = -1,
  23629. length = pairs == null ? 0 : pairs.length,
  23630. result = {};
  23631. while (++index < length) {
  23632. var pair = pairs[index];
  23633. result[pair[0]] = pair[1];
  23634. }
  23635. return result;
  23636. }
  23637. /**
  23638. * Gets the first element of `array`.
  23639. *
  23640. * @static
  23641. * @memberOf _
  23642. * @since 0.1.0
  23643. * @alias first
  23644. * @category Array
  23645. * @param {Array} array The array to query.
  23646. * @returns {*} Returns the first element of `array`.
  23647. * @example
  23648. *
  23649. * _.head([1, 2, 3]);
  23650. * // => 1
  23651. *
  23652. * _.head([]);
  23653. * // => undefined
  23654. */
  23655. function head(array) {
  23656. return (array && array.length) ? array[0] : undefined;
  23657. }
  23658. /**
  23659. * Gets the index at which the first occurrence of `value` is found in `array`
  23660. * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  23661. * for equality comparisons. If `fromIndex` is negative, it's used as the
  23662. * offset from the end of `array`.
  23663. *
  23664. * @static
  23665. * @memberOf _
  23666. * @since 0.1.0
  23667. * @category Array
  23668. * @param {Array} array The array to inspect.
  23669. * @param {*} value The value to search for.
  23670. * @param {number} [fromIndex=0] The index to search from.
  23671. * @returns {number} Returns the index of the matched value, else `-1`.
  23672. * @example
  23673. *
  23674. * _.indexOf([1, 2, 1, 2], 2);
  23675. * // => 1
  23676. *
  23677. * // Search from the `fromIndex`.
  23678. * _.indexOf([1, 2, 1, 2], 2, 2);
  23679. * // => 3
  23680. */
  23681. function indexOf(array, value, fromIndex) {
  23682. var length = array == null ? 0 : array.length;
  23683. if (!length) {
  23684. return -1;
  23685. }
  23686. var index = fromIndex == null ? 0 : toInteger(fromIndex);
  23687. if (index < 0) {
  23688. index = nativeMax(length + index, 0);
  23689. }
  23690. return baseIndexOf(array, value, index);
  23691. }
  23692. /**
  23693. * Gets all but the last element of `array`.
  23694. *
  23695. * @static
  23696. * @memberOf _
  23697. * @since 0.1.0
  23698. * @category Array
  23699. * @param {Array} array The array to query.
  23700. * @returns {Array} Returns the slice of `array`.
  23701. * @example
  23702. *
  23703. * _.initial([1, 2, 3]);
  23704. * // => [1, 2]
  23705. */
  23706. function initial(array) {
  23707. var length = array == null ? 0 : array.length;
  23708. return length ? baseSlice(array, 0, -1) : [];
  23709. }
  23710. /**
  23711. * Creates an array of unique values that are included in all given arrays
  23712. * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  23713. * for equality comparisons. The order and references of result values are
  23714. * determined by the first array.
  23715. *
  23716. * @static
  23717. * @memberOf _
  23718. * @since 0.1.0
  23719. * @category Array
  23720. * @param {...Array} [arrays] The arrays to inspect.
  23721. * @returns {Array} Returns the new array of intersecting values.
  23722. * @example
  23723. *
  23724. * _.intersection([2, 1], [2, 3]);
  23725. * // => [2]
  23726. */
  23727. var intersection = baseRest(function(arrays) {
  23728. var mapped = arrayMap(arrays, castArrayLikeObject);
  23729. return (mapped.length && mapped[0] === arrays[0])
  23730. ? baseIntersection(mapped)
  23731. : [];
  23732. });
  23733. /**
  23734. * This method is like `_.intersection` except that it accepts `iteratee`
  23735. * which is invoked for each element of each `arrays` to generate the criterion
  23736. * by which they're compared. The order and references of result values are
  23737. * determined by the first array. The iteratee is invoked with one argument:
  23738. * (value).
  23739. *
  23740. * @static
  23741. * @memberOf _
  23742. * @since 4.0.0
  23743. * @category Array
  23744. * @param {...Array} [arrays] The arrays to inspect.
  23745. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  23746. * @returns {Array} Returns the new array of intersecting values.
  23747. * @example
  23748. *
  23749. * _.intersectionBy([2.1, 1.2], [2.3, 3.4], Math.floor);
  23750. * // => [2.1]
  23751. *
  23752. * // The `_.property` iteratee shorthand.
  23753. * _.intersectionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
  23754. * // => [{ 'x': 1 }]
  23755. */
  23756. var intersectionBy = baseRest(function(arrays) {
  23757. var iteratee = last(arrays),
  23758. mapped = arrayMap(arrays, castArrayLikeObject);
  23759. if (iteratee === last(mapped)) {
  23760. iteratee = undefined;
  23761. } else {
  23762. mapped.pop();
  23763. }
  23764. return (mapped.length && mapped[0] === arrays[0])
  23765. ? baseIntersection(mapped, getIteratee(iteratee, 2))
  23766. : [];
  23767. });
  23768. /**
  23769. * This method is like `_.intersection` except that it accepts `comparator`
  23770. * which is invoked to compare elements of `arrays`. The order and references
  23771. * of result values are determined by the first array. The comparator is
  23772. * invoked with two arguments: (arrVal, othVal).
  23773. *
  23774. * @static
  23775. * @memberOf _
  23776. * @since 4.0.0
  23777. * @category Array
  23778. * @param {...Array} [arrays] The arrays to inspect.
  23779. * @param {Function} [comparator] The comparator invoked per element.
  23780. * @returns {Array} Returns the new array of intersecting values.
  23781. * @example
  23782. *
  23783. * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
  23784. * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }];
  23785. *
  23786. * _.intersectionWith(objects, others, _.isEqual);
  23787. * // => [{ 'x': 1, 'y': 2 }]
  23788. */
  23789. var intersectionWith = baseRest(function(arrays) {
  23790. var comparator = last(arrays),
  23791. mapped = arrayMap(arrays, castArrayLikeObject);
  23792. comparator = typeof comparator == 'function' ? comparator : undefined;
  23793. if (comparator) {
  23794. mapped.pop();
  23795. }
  23796. return (mapped.length && mapped[0] === arrays[0])
  23797. ? baseIntersection(mapped, undefined, comparator)
  23798. : [];
  23799. });
  23800. /**
  23801. * Converts all elements in `array` into a string separated by `separator`.
  23802. *
  23803. * @static
  23804. * @memberOf _
  23805. * @since 4.0.0
  23806. * @category Array
  23807. * @param {Array} array The array to convert.
  23808. * @param {string} [separator=','] The element separator.
  23809. * @returns {string} Returns the joined string.
  23810. * @example
  23811. *
  23812. * _.join(['a', 'b', 'c'], '~');
  23813. * // => 'a~b~c'
  23814. */
  23815. function join(array, separator) {
  23816. return array == null ? '' : nativeJoin.call(array, separator);
  23817. }
  23818. /**
  23819. * Gets the last element of `array`.
  23820. *
  23821. * @static
  23822. * @memberOf _
  23823. * @since 0.1.0
  23824. * @category Array
  23825. * @param {Array} array The array to query.
  23826. * @returns {*} Returns the last element of `array`.
  23827. * @example
  23828. *
  23829. * _.last([1, 2, 3]);
  23830. * // => 3
  23831. */
  23832. function last(array) {
  23833. var length = array == null ? 0 : array.length;
  23834. return length ? array[length - 1] : undefined;
  23835. }
  23836. /**
  23837. * This method is like `_.indexOf` except that it iterates over elements of
  23838. * `array` from right to left.
  23839. *
  23840. * @static
  23841. * @memberOf _
  23842. * @since 0.1.0
  23843. * @category Array
  23844. * @param {Array} array The array to inspect.
  23845. * @param {*} value The value to search for.
  23846. * @param {number} [fromIndex=array.length-1] The index to search from.
  23847. * @returns {number} Returns the index of the matched value, else `-1`.
  23848. * @example
  23849. *
  23850. * _.lastIndexOf([1, 2, 1, 2], 2);
  23851. * // => 3
  23852. *
  23853. * // Search from the `fromIndex`.
  23854. * _.lastIndexOf([1, 2, 1, 2], 2, 2);
  23855. * // => 1
  23856. */
  23857. function lastIndexOf(array, value, fromIndex) {
  23858. var length = array == null ? 0 : array.length;
  23859. if (!length) {
  23860. return -1;
  23861. }
  23862. var index = length;
  23863. if (fromIndex !== undefined) {
  23864. index = toInteger(fromIndex);
  23865. index = index < 0 ? nativeMax(length + index, 0) : nativeMin(index, length - 1);
  23866. }
  23867. return value === value
  23868. ? strictLastIndexOf(array, value, index)
  23869. : baseFindIndex(array, baseIsNaN, index, true);
  23870. }
  23871. /**
  23872. * Gets the element at index `n` of `array`. If `n` is negative, the nth
  23873. * element from the end is returned.
  23874. *
  23875. * @static
  23876. * @memberOf _
  23877. * @since 4.11.0
  23878. * @category Array
  23879. * @param {Array} array The array to query.
  23880. * @param {number} [n=0] The index of the element to return.
  23881. * @returns {*} Returns the nth element of `array`.
  23882. * @example
  23883. *
  23884. * var array = ['a', 'b', 'c', 'd'];
  23885. *
  23886. * _.nth(array, 1);
  23887. * // => 'b'
  23888. *
  23889. * _.nth(array, -2);
  23890. * // => 'c';
  23891. */
  23892. function nth(array, n) {
  23893. return (array && array.length) ? baseNth(array, toInteger(n)) : undefined;
  23894. }
  23895. /**
  23896. * Removes all given values from `array` using
  23897. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  23898. * for equality comparisons.
  23899. *
  23900. * **Note:** Unlike `_.without`, this method mutates `array`. Use `_.remove`
  23901. * to remove elements from an array by predicate.
  23902. *
  23903. * @static
  23904. * @memberOf _
  23905. * @since 2.0.0
  23906. * @category Array
  23907. * @param {Array} array The array to modify.
  23908. * @param {...*} [values] The values to remove.
  23909. * @returns {Array} Returns `array`.
  23910. * @example
  23911. *
  23912. * var array = ['a', 'b', 'c', 'a', 'b', 'c'];
  23913. *
  23914. * _.pull(array, 'a', 'c');
  23915. * console.log(array);
  23916. * // => ['b', 'b']
  23917. */
  23918. var pull = baseRest(pullAll);
  23919. /**
  23920. * This method is like `_.pull` except that it accepts an array of values to remove.
  23921. *
  23922. * **Note:** Unlike `_.difference`, this method mutates `array`.
  23923. *
  23924. * @static
  23925. * @memberOf _
  23926. * @since 4.0.0
  23927. * @category Array
  23928. * @param {Array} array The array to modify.
  23929. * @param {Array} values The values to remove.
  23930. * @returns {Array} Returns `array`.
  23931. * @example
  23932. *
  23933. * var array = ['a', 'b', 'c', 'a', 'b', 'c'];
  23934. *
  23935. * _.pullAll(array, ['a', 'c']);
  23936. * console.log(array);
  23937. * // => ['b', 'b']
  23938. */
  23939. function pullAll(array, values) {
  23940. return (array && array.length && values && values.length)
  23941. ? basePullAll(array, values)
  23942. : array;
  23943. }
  23944. /**
  23945. * This method is like `_.pullAll` except that it accepts `iteratee` which is
  23946. * invoked for each element of `array` and `values` to generate the criterion
  23947. * by which they're compared. The iteratee is invoked with one argument: (value).
  23948. *
  23949. * **Note:** Unlike `_.differenceBy`, this method mutates `array`.
  23950. *
  23951. * @static
  23952. * @memberOf _
  23953. * @since 4.0.0
  23954. * @category Array
  23955. * @param {Array} array The array to modify.
  23956. * @param {Array} values The values to remove.
  23957. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  23958. * @returns {Array} Returns `array`.
  23959. * @example
  23960. *
  23961. * var array = [{ 'x': 1 }, { 'x': 2 }, { 'x': 3 }, { 'x': 1 }];
  23962. *
  23963. * _.pullAllBy(array, [{ 'x': 1 }, { 'x': 3 }], 'x');
  23964. * console.log(array);
  23965. * // => [{ 'x': 2 }]
  23966. */
  23967. function pullAllBy(array, values, iteratee) {
  23968. return (array && array.length && values && values.length)
  23969. ? basePullAll(array, values, getIteratee(iteratee, 2))
  23970. : array;
  23971. }
  23972. /**
  23973. * This method is like `_.pullAll` except that it accepts `comparator` which
  23974. * is invoked to compare elements of `array` to `values`. The comparator is
  23975. * invoked with two arguments: (arrVal, othVal).
  23976. *
  23977. * **Note:** Unlike `_.differenceWith`, this method mutates `array`.
  23978. *
  23979. * @static
  23980. * @memberOf _
  23981. * @since 4.6.0
  23982. * @category Array
  23983. * @param {Array} array The array to modify.
  23984. * @param {Array} values The values to remove.
  23985. * @param {Function} [comparator] The comparator invoked per element.
  23986. * @returns {Array} Returns `array`.
  23987. * @example
  23988. *
  23989. * var array = [{ 'x': 1, 'y': 2 }, { 'x': 3, 'y': 4 }, { 'x': 5, 'y': 6 }];
  23990. *
  23991. * _.pullAllWith(array, [{ 'x': 3, 'y': 4 }], _.isEqual);
  23992. * console.log(array);
  23993. * // => [{ 'x': 1, 'y': 2 }, { 'x': 5, 'y': 6 }]
  23994. */
  23995. function pullAllWith(array, values, comparator) {
  23996. return (array && array.length && values && values.length)
  23997. ? basePullAll(array, values, undefined, comparator)
  23998. : array;
  23999. }
  24000. /**
  24001. * Removes elements from `array` corresponding to `indexes` and returns an
  24002. * array of removed elements.
  24003. *
  24004. * **Note:** Unlike `_.at`, this method mutates `array`.
  24005. *
  24006. * @static
  24007. * @memberOf _
  24008. * @since 3.0.0
  24009. * @category Array
  24010. * @param {Array} array The array to modify.
  24011. * @param {...(number|number[])} [indexes] The indexes of elements to remove.
  24012. * @returns {Array} Returns the new array of removed elements.
  24013. * @example
  24014. *
  24015. * var array = ['a', 'b', 'c', 'd'];
  24016. * var pulled = _.pullAt(array, [1, 3]);
  24017. *
  24018. * console.log(array);
  24019. * // => ['a', 'c']
  24020. *
  24021. * console.log(pulled);
  24022. * // => ['b', 'd']
  24023. */
  24024. var pullAt = flatRest(function(array, indexes) {
  24025. var length = array == null ? 0 : array.length,
  24026. result = baseAt(array, indexes);
  24027. basePullAt(array, arrayMap(indexes, function(index) {
  24028. return isIndex(index, length) ? +index : index;
  24029. }).sort(compareAscending));
  24030. return result;
  24031. });
  24032. /**
  24033. * Removes all elements from `array` that `predicate` returns truthy for
  24034. * and returns an array of the removed elements. The predicate is invoked
  24035. * with three arguments: (value, index, array).
  24036. *
  24037. * **Note:** Unlike `_.filter`, this method mutates `array`. Use `_.pull`
  24038. * to pull elements from an array by value.
  24039. *
  24040. * @static
  24041. * @memberOf _
  24042. * @since 2.0.0
  24043. * @category Array
  24044. * @param {Array} array The array to modify.
  24045. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  24046. * @returns {Array} Returns the new array of removed elements.
  24047. * @example
  24048. *
  24049. * var array = [1, 2, 3, 4];
  24050. * var evens = _.remove(array, function(n) {
  24051. * return n % 2 == 0;
  24052. * });
  24053. *
  24054. * console.log(array);
  24055. * // => [1, 3]
  24056. *
  24057. * console.log(evens);
  24058. * // => [2, 4]
  24059. */
  24060. function remove(array, predicate) {
  24061. var result = [];
  24062. if (!(array && array.length)) {
  24063. return result;
  24064. }
  24065. var index = -1,
  24066. indexes = [],
  24067. length = array.length;
  24068. predicate = getIteratee(predicate, 3);
  24069. while (++index < length) {
  24070. var value = array[index];
  24071. if (predicate(value, index, array)) {
  24072. result.push(value);
  24073. indexes.push(index);
  24074. }
  24075. }
  24076. basePullAt(array, indexes);
  24077. return result;
  24078. }
  24079. /**
  24080. * Reverses `array` so that the first element becomes the last, the second
  24081. * element becomes the second to last, and so on.
  24082. *
  24083. * **Note:** This method mutates `array` and is based on
  24084. * [`Array#reverse`](https://mdn.io/Array/reverse).
  24085. *
  24086. * @static
  24087. * @memberOf _
  24088. * @since 4.0.0
  24089. * @category Array
  24090. * @param {Array} array The array to modify.
  24091. * @returns {Array} Returns `array`.
  24092. * @example
  24093. *
  24094. * var array = [1, 2, 3];
  24095. *
  24096. * _.reverse(array);
  24097. * // => [3, 2, 1]
  24098. *
  24099. * console.log(array);
  24100. * // => [3, 2, 1]
  24101. */
  24102. function reverse(array) {
  24103. return array == null ? array : nativeReverse.call(array);
  24104. }
  24105. /**
  24106. * Creates a slice of `array` from `start` up to, but not including, `end`.
  24107. *
  24108. * **Note:** This method is used instead of
  24109. * [`Array#slice`](https://mdn.io/Array/slice) to ensure dense arrays are
  24110. * returned.
  24111. *
  24112. * @static
  24113. * @memberOf _
  24114. * @since 3.0.0
  24115. * @category Array
  24116. * @param {Array} array The array to slice.
  24117. * @param {number} [start=0] The start position.
  24118. * @param {number} [end=array.length] The end position.
  24119. * @returns {Array} Returns the slice of `array`.
  24120. */
  24121. function slice(array, start, end) {
  24122. var length = array == null ? 0 : array.length;
  24123. if (!length) {
  24124. return [];
  24125. }
  24126. if (end && typeof end != 'number' && isIterateeCall(array, start, end)) {
  24127. start = 0;
  24128. end = length;
  24129. }
  24130. else {
  24131. start = start == null ? 0 : toInteger(start);
  24132. end = end === undefined ? length : toInteger(end);
  24133. }
  24134. return baseSlice(array, start, end);
  24135. }
  24136. /**
  24137. * Uses a binary search to determine the lowest index at which `value`
  24138. * should be inserted into `array` in order to maintain its sort order.
  24139. *
  24140. * @static
  24141. * @memberOf _
  24142. * @since 0.1.0
  24143. * @category Array
  24144. * @param {Array} array The sorted array to inspect.
  24145. * @param {*} value The value to evaluate.
  24146. * @returns {number} Returns the index at which `value` should be inserted
  24147. * into `array`.
  24148. * @example
  24149. *
  24150. * _.sortedIndex([30, 50], 40);
  24151. * // => 1
  24152. */
  24153. function sortedIndex(array, value) {
  24154. return baseSortedIndex(array, value);
  24155. }
  24156. /**
  24157. * This method is like `_.sortedIndex` except that it accepts `iteratee`
  24158. * which is invoked for `value` and each element of `array` to compute their
  24159. * sort ranking. The iteratee is invoked with one argument: (value).
  24160. *
  24161. * @static
  24162. * @memberOf _
  24163. * @since 4.0.0
  24164. * @category Array
  24165. * @param {Array} array The sorted array to inspect.
  24166. * @param {*} value The value to evaluate.
  24167. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  24168. * @returns {number} Returns the index at which `value` should be inserted
  24169. * into `array`.
  24170. * @example
  24171. *
  24172. * var objects = [{ 'x': 4 }, { 'x': 5 }];
  24173. *
  24174. * _.sortedIndexBy(objects, { 'x': 4 }, function(o) { return o.x; });
  24175. * // => 0
  24176. *
  24177. * // The `_.property` iteratee shorthand.
  24178. * _.sortedIndexBy(objects, { 'x': 4 }, 'x');
  24179. * // => 0
  24180. */
  24181. function sortedIndexBy(array, value, iteratee) {
  24182. return baseSortedIndexBy(array, value, getIteratee(iteratee, 2));
  24183. }
  24184. /**
  24185. * This method is like `_.indexOf` except that it performs a binary
  24186. * search on a sorted `array`.
  24187. *
  24188. * @static
  24189. * @memberOf _
  24190. * @since 4.0.0
  24191. * @category Array
  24192. * @param {Array} array The array to inspect.
  24193. * @param {*} value The value to search for.
  24194. * @returns {number} Returns the index of the matched value, else `-1`.
  24195. * @example
  24196. *
  24197. * _.sortedIndexOf([4, 5, 5, 5, 6], 5);
  24198. * // => 1
  24199. */
  24200. function sortedIndexOf(array, value) {
  24201. var length = array == null ? 0 : array.length;
  24202. if (length) {
  24203. var index = baseSortedIndex(array, value);
  24204. if (index < length && eq(array[index], value)) {
  24205. return index;
  24206. }
  24207. }
  24208. return -1;
  24209. }
  24210. /**
  24211. * This method is like `_.sortedIndex` except that it returns the highest
  24212. * index at which `value` should be inserted into `array` in order to
  24213. * maintain its sort order.
  24214. *
  24215. * @static
  24216. * @memberOf _
  24217. * @since 3.0.0
  24218. * @category Array
  24219. * @param {Array} array The sorted array to inspect.
  24220. * @param {*} value The value to evaluate.
  24221. * @returns {number} Returns the index at which `value` should be inserted
  24222. * into `array`.
  24223. * @example
  24224. *
  24225. * _.sortedLastIndex([4, 5, 5, 5, 6], 5);
  24226. * // => 4
  24227. */
  24228. function sortedLastIndex(array, value) {
  24229. return baseSortedIndex(array, value, true);
  24230. }
  24231. /**
  24232. * This method is like `_.sortedLastIndex` except that it accepts `iteratee`
  24233. * which is invoked for `value` and each element of `array` to compute their
  24234. * sort ranking. The iteratee is invoked with one argument: (value).
  24235. *
  24236. * @static
  24237. * @memberOf _
  24238. * @since 4.0.0
  24239. * @category Array
  24240. * @param {Array} array The sorted array to inspect.
  24241. * @param {*} value The value to evaluate.
  24242. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  24243. * @returns {number} Returns the index at which `value` should be inserted
  24244. * into `array`.
  24245. * @example
  24246. *
  24247. * var objects = [{ 'x': 4 }, { 'x': 5 }];
  24248. *
  24249. * _.sortedLastIndexBy(objects, { 'x': 4 }, function(o) { return o.x; });
  24250. * // => 1
  24251. *
  24252. * // The `_.property` iteratee shorthand.
  24253. * _.sortedLastIndexBy(objects, { 'x': 4 }, 'x');
  24254. * // => 1
  24255. */
  24256. function sortedLastIndexBy(array, value, iteratee) {
  24257. return baseSortedIndexBy(array, value, getIteratee(iteratee, 2), true);
  24258. }
  24259. /**
  24260. * This method is like `_.lastIndexOf` except that it performs a binary
  24261. * search on a sorted `array`.
  24262. *
  24263. * @static
  24264. * @memberOf _
  24265. * @since 4.0.0
  24266. * @category Array
  24267. * @param {Array} array The array to inspect.
  24268. * @param {*} value The value to search for.
  24269. * @returns {number} Returns the index of the matched value, else `-1`.
  24270. * @example
  24271. *
  24272. * _.sortedLastIndexOf([4, 5, 5, 5, 6], 5);
  24273. * // => 3
  24274. */
  24275. function sortedLastIndexOf(array, value) {
  24276. var length = array == null ? 0 : array.length;
  24277. if (length) {
  24278. var index = baseSortedIndex(array, value, true) - 1;
  24279. if (eq(array[index], value)) {
  24280. return index;
  24281. }
  24282. }
  24283. return -1;
  24284. }
  24285. /**
  24286. * This method is like `_.uniq` except that it's designed and optimized
  24287. * for sorted arrays.
  24288. *
  24289. * @static
  24290. * @memberOf _
  24291. * @since 4.0.0
  24292. * @category Array
  24293. * @param {Array} array The array to inspect.
  24294. * @returns {Array} Returns the new duplicate free array.
  24295. * @example
  24296. *
  24297. * _.sortedUniq([1, 1, 2]);
  24298. * // => [1, 2]
  24299. */
  24300. function sortedUniq(array) {
  24301. return (array && array.length)
  24302. ? baseSortedUniq(array)
  24303. : [];
  24304. }
  24305. /**
  24306. * This method is like `_.uniqBy` except that it's designed and optimized
  24307. * for sorted arrays.
  24308. *
  24309. * @static
  24310. * @memberOf _
  24311. * @since 4.0.0
  24312. * @category Array
  24313. * @param {Array} array The array to inspect.
  24314. * @param {Function} [iteratee] The iteratee invoked per element.
  24315. * @returns {Array} Returns the new duplicate free array.
  24316. * @example
  24317. *
  24318. * _.sortedUniqBy([1.1, 1.2, 2.3, 2.4], Math.floor);
  24319. * // => [1.1, 2.3]
  24320. */
  24321. function sortedUniqBy(array, iteratee) {
  24322. return (array && array.length)
  24323. ? baseSortedUniq(array, getIteratee(iteratee, 2))
  24324. : [];
  24325. }
  24326. /**
  24327. * Gets all but the first element of `array`.
  24328. *
  24329. * @static
  24330. * @memberOf _
  24331. * @since 4.0.0
  24332. * @category Array
  24333. * @param {Array} array The array to query.
  24334. * @returns {Array} Returns the slice of `array`.
  24335. * @example
  24336. *
  24337. * _.tail([1, 2, 3]);
  24338. * // => [2, 3]
  24339. */
  24340. function tail(array) {
  24341. var length = array == null ? 0 : array.length;
  24342. return length ? baseSlice(array, 1, length) : [];
  24343. }
  24344. /**
  24345. * Creates a slice of `array` with `n` elements taken from the beginning.
  24346. *
  24347. * @static
  24348. * @memberOf _
  24349. * @since 0.1.0
  24350. * @category Array
  24351. * @param {Array} array The array to query.
  24352. * @param {number} [n=1] The number of elements to take.
  24353. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  24354. * @returns {Array} Returns the slice of `array`.
  24355. * @example
  24356. *
  24357. * _.take([1, 2, 3]);
  24358. * // => [1]
  24359. *
  24360. * _.take([1, 2, 3], 2);
  24361. * // => [1, 2]
  24362. *
  24363. * _.take([1, 2, 3], 5);
  24364. * // => [1, 2, 3]
  24365. *
  24366. * _.take([1, 2, 3], 0);
  24367. * // => []
  24368. */
  24369. function take(array, n, guard) {
  24370. if (!(array && array.length)) {
  24371. return [];
  24372. }
  24373. n = (guard || n === undefined) ? 1 : toInteger(n);
  24374. return baseSlice(array, 0, n < 0 ? 0 : n);
  24375. }
  24376. /**
  24377. * Creates a slice of `array` with `n` elements taken from the end.
  24378. *
  24379. * @static
  24380. * @memberOf _
  24381. * @since 3.0.0
  24382. * @category Array
  24383. * @param {Array} array The array to query.
  24384. * @param {number} [n=1] The number of elements to take.
  24385. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  24386. * @returns {Array} Returns the slice of `array`.
  24387. * @example
  24388. *
  24389. * _.takeRight([1, 2, 3]);
  24390. * // => [3]
  24391. *
  24392. * _.takeRight([1, 2, 3], 2);
  24393. * // => [2, 3]
  24394. *
  24395. * _.takeRight([1, 2, 3], 5);
  24396. * // => [1, 2, 3]
  24397. *
  24398. * _.takeRight([1, 2, 3], 0);
  24399. * // => []
  24400. */
  24401. function takeRight(array, n, guard) {
  24402. var length = array == null ? 0 : array.length;
  24403. if (!length) {
  24404. return [];
  24405. }
  24406. n = (guard || n === undefined) ? 1 : toInteger(n);
  24407. n = length - n;
  24408. return baseSlice(array, n < 0 ? 0 : n, length);
  24409. }
  24410. /**
  24411. * Creates a slice of `array` with elements taken from the end. Elements are
  24412. * taken until `predicate` returns falsey. The predicate is invoked with
  24413. * three arguments: (value, index, array).
  24414. *
  24415. * @static
  24416. * @memberOf _
  24417. * @since 3.0.0
  24418. * @category Array
  24419. * @param {Array} array The array to query.
  24420. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  24421. * @returns {Array} Returns the slice of `array`.
  24422. * @example
  24423. *
  24424. * var users = [
  24425. * { 'user': 'barney', 'active': true },
  24426. * { 'user': 'fred', 'active': false },
  24427. * { 'user': 'pebbles', 'active': false }
  24428. * ];
  24429. *
  24430. * _.takeRightWhile(users, function(o) { return !o.active; });
  24431. * // => objects for ['fred', 'pebbles']
  24432. *
  24433. * // The `_.matches` iteratee shorthand.
  24434. * _.takeRightWhile(users, { 'user': 'pebbles', 'active': false });
  24435. * // => objects for ['pebbles']
  24436. *
  24437. * // The `_.matchesProperty` iteratee shorthand.
  24438. * _.takeRightWhile(users, ['active', false]);
  24439. * // => objects for ['fred', 'pebbles']
  24440. *
  24441. * // The `_.property` iteratee shorthand.
  24442. * _.takeRightWhile(users, 'active');
  24443. * // => []
  24444. */
  24445. function takeRightWhile(array, predicate) {
  24446. return (array && array.length)
  24447. ? baseWhile(array, getIteratee(predicate, 3), false, true)
  24448. : [];
  24449. }
  24450. /**
  24451. * Creates a slice of `array` with elements taken from the beginning. Elements
  24452. * are taken until `predicate` returns falsey. The predicate is invoked with
  24453. * three arguments: (value, index, array).
  24454. *
  24455. * @static
  24456. * @memberOf _
  24457. * @since 3.0.0
  24458. * @category Array
  24459. * @param {Array} array The array to query.
  24460. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  24461. * @returns {Array} Returns the slice of `array`.
  24462. * @example
  24463. *
  24464. * var users = [
  24465. * { 'user': 'barney', 'active': false },
  24466. * { 'user': 'fred', 'active': false },
  24467. * { 'user': 'pebbles', 'active': true }
  24468. * ];
  24469. *
  24470. * _.takeWhile(users, function(o) { return !o.active; });
  24471. * // => objects for ['barney', 'fred']
  24472. *
  24473. * // The `_.matches` iteratee shorthand.
  24474. * _.takeWhile(users, { 'user': 'barney', 'active': false });
  24475. * // => objects for ['barney']
  24476. *
  24477. * // The `_.matchesProperty` iteratee shorthand.
  24478. * _.takeWhile(users, ['active', false]);
  24479. * // => objects for ['barney', 'fred']
  24480. *
  24481. * // The `_.property` iteratee shorthand.
  24482. * _.takeWhile(users, 'active');
  24483. * // => []
  24484. */
  24485. function takeWhile(array, predicate) {
  24486. return (array && array.length)
  24487. ? baseWhile(array, getIteratee(predicate, 3))
  24488. : [];
  24489. }
  24490. /**
  24491. * Creates an array of unique values, in order, from all given arrays using
  24492. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  24493. * for equality comparisons.
  24494. *
  24495. * @static
  24496. * @memberOf _
  24497. * @since 0.1.0
  24498. * @category Array
  24499. * @param {...Array} [arrays] The arrays to inspect.
  24500. * @returns {Array} Returns the new array of combined values.
  24501. * @example
  24502. *
  24503. * _.union([2], [1, 2]);
  24504. * // => [2, 1]
  24505. */
  24506. var union = baseRest(function(arrays) {
  24507. return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true));
  24508. });
  24509. /**
  24510. * This method is like `_.union` except that it accepts `iteratee` which is
  24511. * invoked for each element of each `arrays` to generate the criterion by
  24512. * which uniqueness is computed. Result values are chosen from the first
  24513. * array in which the value occurs. The iteratee is invoked with one argument:
  24514. * (value).
  24515. *
  24516. * @static
  24517. * @memberOf _
  24518. * @since 4.0.0
  24519. * @category Array
  24520. * @param {...Array} [arrays] The arrays to inspect.
  24521. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  24522. * @returns {Array} Returns the new array of combined values.
  24523. * @example
  24524. *
  24525. * _.unionBy([2.1], [1.2, 2.3], Math.floor);
  24526. * // => [2.1, 1.2]
  24527. *
  24528. * // The `_.property` iteratee shorthand.
  24529. * _.unionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
  24530. * // => [{ 'x': 1 }, { 'x': 2 }]
  24531. */
  24532. var unionBy = baseRest(function(arrays) {
  24533. var iteratee = last(arrays);
  24534. if (isArrayLikeObject(iteratee)) {
  24535. iteratee = undefined;
  24536. }
  24537. return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true), getIteratee(iteratee, 2));
  24538. });
  24539. /**
  24540. * This method is like `_.union` except that it accepts `comparator` which
  24541. * is invoked to compare elements of `arrays`. Result values are chosen from
  24542. * the first array in which the value occurs. The comparator is invoked
  24543. * with two arguments: (arrVal, othVal).
  24544. *
  24545. * @static
  24546. * @memberOf _
  24547. * @since 4.0.0
  24548. * @category Array
  24549. * @param {...Array} [arrays] The arrays to inspect.
  24550. * @param {Function} [comparator] The comparator invoked per element.
  24551. * @returns {Array} Returns the new array of combined values.
  24552. * @example
  24553. *
  24554. * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
  24555. * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }];
  24556. *
  24557. * _.unionWith(objects, others, _.isEqual);
  24558. * // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 1 }]
  24559. */
  24560. var unionWith = baseRest(function(arrays) {
  24561. var comparator = last(arrays);
  24562. comparator = typeof comparator == 'function' ? comparator : undefined;
  24563. return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true), undefined, comparator);
  24564. });
  24565. /**
  24566. * Creates a duplicate-free version of an array, using
  24567. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  24568. * for equality comparisons, in which only the first occurrence of each element
  24569. * is kept. The order of result values is determined by the order they occur
  24570. * in the array.
  24571. *
  24572. * @static
  24573. * @memberOf _
  24574. * @since 0.1.0
  24575. * @category Array
  24576. * @param {Array} array The array to inspect.
  24577. * @returns {Array} Returns the new duplicate free array.
  24578. * @example
  24579. *
  24580. * _.uniq([2, 1, 2]);
  24581. * // => [2, 1]
  24582. */
  24583. function uniq(array) {
  24584. return (array && array.length) ? baseUniq(array) : [];
  24585. }
  24586. /**
  24587. * This method is like `_.uniq` except that it accepts `iteratee` which is
  24588. * invoked for each element in `array` to generate the criterion by which
  24589. * uniqueness is computed. The order of result values is determined by the
  24590. * order they occur in the array. The iteratee is invoked with one argument:
  24591. * (value).
  24592. *
  24593. * @static
  24594. * @memberOf _
  24595. * @since 4.0.0
  24596. * @category Array
  24597. * @param {Array} array The array to inspect.
  24598. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  24599. * @returns {Array} Returns the new duplicate free array.
  24600. * @example
  24601. *
  24602. * _.uniqBy([2.1, 1.2, 2.3], Math.floor);
  24603. * // => [2.1, 1.2]
  24604. *
  24605. * // The `_.property` iteratee shorthand.
  24606. * _.uniqBy([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x');
  24607. * // => [{ 'x': 1 }, { 'x': 2 }]
  24608. */
  24609. function uniqBy(array, iteratee) {
  24610. return (array && array.length) ? baseUniq(array, getIteratee(iteratee, 2)) : [];
  24611. }
  24612. /**
  24613. * This method is like `_.uniq` except that it accepts `comparator` which
  24614. * is invoked to compare elements of `array`. The order of result values is
  24615. * determined by the order they occur in the array.The comparator is invoked
  24616. * with two arguments: (arrVal, othVal).
  24617. *
  24618. * @static
  24619. * @memberOf _
  24620. * @since 4.0.0
  24621. * @category Array
  24622. * @param {Array} array The array to inspect.
  24623. * @param {Function} [comparator] The comparator invoked per element.
  24624. * @returns {Array} Returns the new duplicate free array.
  24625. * @example
  24626. *
  24627. * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 2 }];
  24628. *
  24629. * _.uniqWith(objects, _.isEqual);
  24630. * // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]
  24631. */
  24632. function uniqWith(array, comparator) {
  24633. comparator = typeof comparator == 'function' ? comparator : undefined;
  24634. return (array && array.length) ? baseUniq(array, undefined, comparator) : [];
  24635. }
  24636. /**
  24637. * This method is like `_.zip` except that it accepts an array of grouped
  24638. * elements and creates an array regrouping the elements to their pre-zip
  24639. * configuration.
  24640. *
  24641. * @static
  24642. * @memberOf _
  24643. * @since 1.2.0
  24644. * @category Array
  24645. * @param {Array} array The array of grouped elements to process.
  24646. * @returns {Array} Returns the new array of regrouped elements.
  24647. * @example
  24648. *
  24649. * var zipped = _.zip(['a', 'b'], [1, 2], [true, false]);
  24650. * // => [['a', 1, true], ['b', 2, false]]
  24651. *
  24652. * _.unzip(zipped);
  24653. * // => [['a', 'b'], [1, 2], [true, false]]
  24654. */
  24655. function unzip(array) {
  24656. if (!(array && array.length)) {
  24657. return [];
  24658. }
  24659. var length = 0;
  24660. array = arrayFilter(array, function(group) {
  24661. if (isArrayLikeObject(group)) {
  24662. length = nativeMax(group.length, length);
  24663. return true;
  24664. }
  24665. });
  24666. return baseTimes(length, function(index) {
  24667. return arrayMap(array, baseProperty(index));
  24668. });
  24669. }
  24670. /**
  24671. * This method is like `_.unzip` except that it accepts `iteratee` to specify
  24672. * how regrouped values should be combined. The iteratee is invoked with the
  24673. * elements of each group: (...group).
  24674. *
  24675. * @static
  24676. * @memberOf _
  24677. * @since 3.8.0
  24678. * @category Array
  24679. * @param {Array} array The array of grouped elements to process.
  24680. * @param {Function} [iteratee=_.identity] The function to combine
  24681. * regrouped values.
  24682. * @returns {Array} Returns the new array of regrouped elements.
  24683. * @example
  24684. *
  24685. * var zipped = _.zip([1, 2], [10, 20], [100, 200]);
  24686. * // => [[1, 10, 100], [2, 20, 200]]
  24687. *
  24688. * _.unzipWith(zipped, _.add);
  24689. * // => [3, 30, 300]
  24690. */
  24691. function unzipWith(array, iteratee) {
  24692. if (!(array && array.length)) {
  24693. return [];
  24694. }
  24695. var result = unzip(array);
  24696. if (iteratee == null) {
  24697. return result;
  24698. }
  24699. return arrayMap(result, function(group) {
  24700. return apply(iteratee, undefined, group);
  24701. });
  24702. }
  24703. /**
  24704. * Creates an array excluding all given values using
  24705. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  24706. * for equality comparisons.
  24707. *
  24708. * **Note:** Unlike `_.pull`, this method returns a new array.
  24709. *
  24710. * @static
  24711. * @memberOf _
  24712. * @since 0.1.0
  24713. * @category Array
  24714. * @param {Array} array The array to inspect.
  24715. * @param {...*} [values] The values to exclude.
  24716. * @returns {Array} Returns the new array of filtered values.
  24717. * @see _.difference, _.xor
  24718. * @example
  24719. *
  24720. * _.without([2, 1, 2, 3], 1, 2);
  24721. * // => [3]
  24722. */
  24723. var without = baseRest(function(array, values) {
  24724. return isArrayLikeObject(array)
  24725. ? baseDifference(array, values)
  24726. : [];
  24727. });
  24728. /**
  24729. * Creates an array of unique values that is the
  24730. * [symmetric difference](https://en.wikipedia.org/wiki/Symmetric_difference)
  24731. * of the given arrays. The order of result values is determined by the order
  24732. * they occur in the arrays.
  24733. *
  24734. * @static
  24735. * @memberOf _
  24736. * @since 2.4.0
  24737. * @category Array
  24738. * @param {...Array} [arrays] The arrays to inspect.
  24739. * @returns {Array} Returns the new array of filtered values.
  24740. * @see _.difference, _.without
  24741. * @example
  24742. *
  24743. * _.xor([2, 1], [2, 3]);
  24744. * // => [1, 3]
  24745. */
  24746. var xor = baseRest(function(arrays) {
  24747. return baseXor(arrayFilter(arrays, isArrayLikeObject));
  24748. });
  24749. /**
  24750. * This method is like `_.xor` except that it accepts `iteratee` which is
  24751. * invoked for each element of each `arrays` to generate the criterion by
  24752. * which by which they're compared. The order of result values is determined
  24753. * by the order they occur in the arrays. The iteratee is invoked with one
  24754. * argument: (value).
  24755. *
  24756. * @static
  24757. * @memberOf _
  24758. * @since 4.0.0
  24759. * @category Array
  24760. * @param {...Array} [arrays] The arrays to inspect.
  24761. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  24762. * @returns {Array} Returns the new array of filtered values.
  24763. * @example
  24764. *
  24765. * _.xorBy([2.1, 1.2], [2.3, 3.4], Math.floor);
  24766. * // => [1.2, 3.4]
  24767. *
  24768. * // The `_.property` iteratee shorthand.
  24769. * _.xorBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
  24770. * // => [{ 'x': 2 }]
  24771. */
  24772. var xorBy = baseRest(function(arrays) {
  24773. var iteratee = last(arrays);
  24774. if (isArrayLikeObject(iteratee)) {
  24775. iteratee = undefined;
  24776. }
  24777. return baseXor(arrayFilter(arrays, isArrayLikeObject), getIteratee(iteratee, 2));
  24778. });
  24779. /**
  24780. * This method is like `_.xor` except that it accepts `comparator` which is
  24781. * invoked to compare elements of `arrays`. The order of result values is
  24782. * determined by the order they occur in the arrays. The comparator is invoked
  24783. * with two arguments: (arrVal, othVal).
  24784. *
  24785. * @static
  24786. * @memberOf _
  24787. * @since 4.0.0
  24788. * @category Array
  24789. * @param {...Array} [arrays] The arrays to inspect.
  24790. * @param {Function} [comparator] The comparator invoked per element.
  24791. * @returns {Array} Returns the new array of filtered values.
  24792. * @example
  24793. *
  24794. * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
  24795. * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }];
  24796. *
  24797. * _.xorWith(objects, others, _.isEqual);
  24798. * // => [{ 'x': 2, 'y': 1 }, { 'x': 1, 'y': 1 }]
  24799. */
  24800. var xorWith = baseRest(function(arrays) {
  24801. var comparator = last(arrays);
  24802. comparator = typeof comparator == 'function' ? comparator : undefined;
  24803. return baseXor(arrayFilter(arrays, isArrayLikeObject), undefined, comparator);
  24804. });
  24805. /**
  24806. * Creates an array of grouped elements, the first of which contains the
  24807. * first elements of the given arrays, the second of which contains the
  24808. * second elements of the given arrays, and so on.
  24809. *
  24810. * @static
  24811. * @memberOf _
  24812. * @since 0.1.0
  24813. * @category Array
  24814. * @param {...Array} [arrays] The arrays to process.
  24815. * @returns {Array} Returns the new array of grouped elements.
  24816. * @example
  24817. *
  24818. * _.zip(['a', 'b'], [1, 2], [true, false]);
  24819. * // => [['a', 1, true], ['b', 2, false]]
  24820. */
  24821. var zip = baseRest(unzip);
  24822. /**
  24823. * This method is like `_.fromPairs` except that it accepts two arrays,
  24824. * one of property identifiers and one of corresponding values.
  24825. *
  24826. * @static
  24827. * @memberOf _
  24828. * @since 0.4.0
  24829. * @category Array
  24830. * @param {Array} [props=[]] The property identifiers.
  24831. * @param {Array} [values=[]] The property values.
  24832. * @returns {Object} Returns the new object.
  24833. * @example
  24834. *
  24835. * _.zipObject(['a', 'b'], [1, 2]);
  24836. * // => { 'a': 1, 'b': 2 }
  24837. */
  24838. function zipObject(props, values) {
  24839. return baseZipObject(props || [], values || [], assignValue);
  24840. }
  24841. /**
  24842. * This method is like `_.zipObject` except that it supports property paths.
  24843. *
  24844. * @static
  24845. * @memberOf _
  24846. * @since 4.1.0
  24847. * @category Array
  24848. * @param {Array} [props=[]] The property identifiers.
  24849. * @param {Array} [values=[]] The property values.
  24850. * @returns {Object} Returns the new object.
  24851. * @example
  24852. *
  24853. * _.zipObjectDeep(['a.b[0].c', 'a.b[1].d'], [1, 2]);
  24854. * // => { 'a': { 'b': [{ 'c': 1 }, { 'd': 2 }] } }
  24855. */
  24856. function zipObjectDeep(props, values) {
  24857. return baseZipObject(props || [], values || [], baseSet);
  24858. }
  24859. /**
  24860. * This method is like `_.zip` except that it accepts `iteratee` to specify
  24861. * how grouped values should be combined. The iteratee is invoked with the
  24862. * elements of each group: (...group).
  24863. *
  24864. * @static
  24865. * @memberOf _
  24866. * @since 3.8.0
  24867. * @category Array
  24868. * @param {...Array} [arrays] The arrays to process.
  24869. * @param {Function} [iteratee=_.identity] The function to combine
  24870. * grouped values.
  24871. * @returns {Array} Returns the new array of grouped elements.
  24872. * @example
  24873. *
  24874. * _.zipWith([1, 2], [10, 20], [100, 200], function(a, b, c) {
  24875. * return a + b + c;
  24876. * });
  24877. * // => [111, 222]
  24878. */
  24879. var zipWith = baseRest(function(arrays) {
  24880. var length = arrays.length,
  24881. iteratee = length > 1 ? arrays[length - 1] : undefined;
  24882. iteratee = typeof iteratee == 'function' ? (arrays.pop(), iteratee) : undefined;
  24883. return unzipWith(arrays, iteratee);
  24884. });
  24885. /*------------------------------------------------------------------------*/
  24886. /**
  24887. * Creates a `lodash` wrapper instance that wraps `value` with explicit method
  24888. * chain sequences enabled. The result of such sequences must be unwrapped
  24889. * with `_#value`.
  24890. *
  24891. * @static
  24892. * @memberOf _
  24893. * @since 1.3.0
  24894. * @category Seq
  24895. * @param {*} value The value to wrap.
  24896. * @returns {Object} Returns the new `lodash` wrapper instance.
  24897. * @example
  24898. *
  24899. * var users = [
  24900. * { 'user': 'barney', 'age': 36 },
  24901. * { 'user': 'fred', 'age': 40 },
  24902. * { 'user': 'pebbles', 'age': 1 }
  24903. * ];
  24904. *
  24905. * var youngest = _
  24906. * .chain(users)
  24907. * .sortBy('age')
  24908. * .map(function(o) {
  24909. * return o.user + ' is ' + o.age;
  24910. * })
  24911. * .head()
  24912. * .value();
  24913. * // => 'pebbles is 1'
  24914. */
  24915. function chain(value) {
  24916. var result = lodash(value);
  24917. result.__chain__ = true;
  24918. return result;
  24919. }
  24920. /**
  24921. * This method invokes `interceptor` and returns `value`. The interceptor
  24922. * is invoked with one argument; (value). The purpose of this method is to
  24923. * "tap into" a method chain sequence in order to modify intermediate results.
  24924. *
  24925. * @static
  24926. * @memberOf _
  24927. * @since 0.1.0
  24928. * @category Seq
  24929. * @param {*} value The value to provide to `interceptor`.
  24930. * @param {Function} interceptor The function to invoke.
  24931. * @returns {*} Returns `value`.
  24932. * @example
  24933. *
  24934. * _([1, 2, 3])
  24935. * .tap(function(array) {
  24936. * // Mutate input array.
  24937. * array.pop();
  24938. * })
  24939. * .reverse()
  24940. * .value();
  24941. * // => [2, 1]
  24942. */
  24943. function tap(value, interceptor) {
  24944. interceptor(value);
  24945. return value;
  24946. }
  24947. /**
  24948. * This method is like `_.tap` except that it returns the result of `interceptor`.
  24949. * The purpose of this method is to "pass thru" values replacing intermediate
  24950. * results in a method chain sequence.
  24951. *
  24952. * @static
  24953. * @memberOf _
  24954. * @since 3.0.0
  24955. * @category Seq
  24956. * @param {*} value The value to provide to `interceptor`.
  24957. * @param {Function} interceptor The function to invoke.
  24958. * @returns {*} Returns the result of `interceptor`.
  24959. * @example
  24960. *
  24961. * _(' abc ')
  24962. * .chain()
  24963. * .trim()
  24964. * .thru(function(value) {
  24965. * return [value];
  24966. * })
  24967. * .value();
  24968. * // => ['abc']
  24969. */
  24970. function thru(value, interceptor) {
  24971. return interceptor(value);
  24972. }
  24973. /**
  24974. * This method is the wrapper version of `_.at`.
  24975. *
  24976. * @name at
  24977. * @memberOf _
  24978. * @since 1.0.0
  24979. * @category Seq
  24980. * @param {...(string|string[])} [paths] The property paths to pick.
  24981. * @returns {Object} Returns the new `lodash` wrapper instance.
  24982. * @example
  24983. *
  24984. * var object = { 'a': [{ 'b': { 'c': 3 } }, 4] };
  24985. *
  24986. * _(object).at(['a[0].b.c', 'a[1]']).value();
  24987. * // => [3, 4]
  24988. */
  24989. var wrapperAt = flatRest(function(paths) {
  24990. var length = paths.length,
  24991. start = length ? paths[0] : 0,
  24992. value = this.__wrapped__,
  24993. interceptor = function(object) { return baseAt(object, paths); };
  24994. if (length > 1 || this.__actions__.length ||
  24995. !(value instanceof LazyWrapper) || !isIndex(start)) {
  24996. return this.thru(interceptor);
  24997. }
  24998. value = value.slice(start, +start + (length ? 1 : 0));
  24999. value.__actions__.push({
  25000. 'func': thru,
  25001. 'args': [interceptor],
  25002. 'thisArg': undefined
  25003. });
  25004. return new LodashWrapper(value, this.__chain__).thru(function(array) {
  25005. if (length && !array.length) {
  25006. array.push(undefined);
  25007. }
  25008. return array;
  25009. });
  25010. });
  25011. /**
  25012. * Creates a `lodash` wrapper instance with explicit method chain sequences enabled.
  25013. *
  25014. * @name chain
  25015. * @memberOf _
  25016. * @since 0.1.0
  25017. * @category Seq
  25018. * @returns {Object} Returns the new `lodash` wrapper instance.
  25019. * @example
  25020. *
  25021. * var users = [
  25022. * { 'user': 'barney', 'age': 36 },
  25023. * { 'user': 'fred', 'age': 40 }
  25024. * ];
  25025. *
  25026. * // A sequence without explicit chaining.
  25027. * _(users).head();
  25028. * // => { 'user': 'barney', 'age': 36 }
  25029. *
  25030. * // A sequence with explicit chaining.
  25031. * _(users)
  25032. * .chain()
  25033. * .head()
  25034. * .pick('user')
  25035. * .value();
  25036. * // => { 'user': 'barney' }
  25037. */
  25038. function wrapperChain() {
  25039. return chain(this);
  25040. }
  25041. /**
  25042. * Executes the chain sequence and returns the wrapped result.
  25043. *
  25044. * @name commit
  25045. * @memberOf _
  25046. * @since 3.2.0
  25047. * @category Seq
  25048. * @returns {Object} Returns the new `lodash` wrapper instance.
  25049. * @example
  25050. *
  25051. * var array = [1, 2];
  25052. * var wrapped = _(array).push(3);
  25053. *
  25054. * console.log(array);
  25055. * // => [1, 2]
  25056. *
  25057. * wrapped = wrapped.commit();
  25058. * console.log(array);
  25059. * // => [1, 2, 3]
  25060. *
  25061. * wrapped.last();
  25062. * // => 3
  25063. *
  25064. * console.log(array);
  25065. * // => [1, 2, 3]
  25066. */
  25067. function wrapperCommit() {
  25068. return new LodashWrapper(this.value(), this.__chain__);
  25069. }
  25070. /**
  25071. * Gets the next value on a wrapped object following the
  25072. * [iterator protocol](https://mdn.io/iteration_protocols#iterator).
  25073. *
  25074. * @name next
  25075. * @memberOf _
  25076. * @since 4.0.0
  25077. * @category Seq
  25078. * @returns {Object} Returns the next iterator value.
  25079. * @example
  25080. *
  25081. * var wrapped = _([1, 2]);
  25082. *
  25083. * wrapped.next();
  25084. * // => { 'done': false, 'value': 1 }
  25085. *
  25086. * wrapped.next();
  25087. * // => { 'done': false, 'value': 2 }
  25088. *
  25089. * wrapped.next();
  25090. * // => { 'done': true, 'value': undefined }
  25091. */
  25092. function wrapperNext() {
  25093. if (this.__values__ === undefined) {
  25094. this.__values__ = toArray(this.value());
  25095. }
  25096. var done = this.__index__ >= this.__values__.length,
  25097. value = done ? undefined : this.__values__[this.__index__++];
  25098. return { 'done': done, 'value': value };
  25099. }
  25100. /**
  25101. * Enables the wrapper to be iterable.
  25102. *
  25103. * @name Symbol.iterator
  25104. * @memberOf _
  25105. * @since 4.0.0
  25106. * @category Seq
  25107. * @returns {Object} Returns the wrapper object.
  25108. * @example
  25109. *
  25110. * var wrapped = _([1, 2]);
  25111. *
  25112. * wrapped[Symbol.iterator]() === wrapped;
  25113. * // => true
  25114. *
  25115. * Array.from(wrapped);
  25116. * // => [1, 2]
  25117. */
  25118. function wrapperToIterator() {
  25119. return this;
  25120. }
  25121. /**
  25122. * Creates a clone of the chain sequence planting `value` as the wrapped value.
  25123. *
  25124. * @name plant
  25125. * @memberOf _
  25126. * @since 3.2.0
  25127. * @category Seq
  25128. * @param {*} value The value to plant.
  25129. * @returns {Object} Returns the new `lodash` wrapper instance.
  25130. * @example
  25131. *
  25132. * function square(n) {
  25133. * return n * n;
  25134. * }
  25135. *
  25136. * var wrapped = _([1, 2]).map(square);
  25137. * var other = wrapped.plant([3, 4]);
  25138. *
  25139. * other.value();
  25140. * // => [9, 16]
  25141. *
  25142. * wrapped.value();
  25143. * // => [1, 4]
  25144. */
  25145. function wrapperPlant(value) {
  25146. var result,
  25147. parent = this;
  25148. while (parent instanceof baseLodash) {
  25149. var clone = wrapperClone(parent);
  25150. clone.__index__ = 0;
  25151. clone.__values__ = undefined;
  25152. if (result) {
  25153. previous.__wrapped__ = clone;
  25154. } else {
  25155. result = clone;
  25156. }
  25157. var previous = clone;
  25158. parent = parent.__wrapped__;
  25159. }
  25160. previous.__wrapped__ = value;
  25161. return result;
  25162. }
  25163. /**
  25164. * This method is the wrapper version of `_.reverse`.
  25165. *
  25166. * **Note:** This method mutates the wrapped array.
  25167. *
  25168. * @name reverse
  25169. * @memberOf _
  25170. * @since 0.1.0
  25171. * @category Seq
  25172. * @returns {Object} Returns the new `lodash` wrapper instance.
  25173. * @example
  25174. *
  25175. * var array = [1, 2, 3];
  25176. *
  25177. * _(array).reverse().value()
  25178. * // => [3, 2, 1]
  25179. *
  25180. * console.log(array);
  25181. * // => [3, 2, 1]
  25182. */
  25183. function wrapperReverse() {
  25184. var value = this.__wrapped__;
  25185. if (value instanceof LazyWrapper) {
  25186. var wrapped = value;
  25187. if (this.__actions__.length) {
  25188. wrapped = new LazyWrapper(this);
  25189. }
  25190. wrapped = wrapped.reverse();
  25191. wrapped.__actions__.push({
  25192. 'func': thru,
  25193. 'args': [reverse],
  25194. 'thisArg': undefined
  25195. });
  25196. return new LodashWrapper(wrapped, this.__chain__);
  25197. }
  25198. return this.thru(reverse);
  25199. }
  25200. /**
  25201. * Executes the chain sequence to resolve the unwrapped value.
  25202. *
  25203. * @name value
  25204. * @memberOf _
  25205. * @since 0.1.0
  25206. * @alias toJSON, valueOf
  25207. * @category Seq
  25208. * @returns {*} Returns the resolved unwrapped value.
  25209. * @example
  25210. *
  25211. * _([1, 2, 3]).value();
  25212. * // => [1, 2, 3]
  25213. */
  25214. function wrapperValue() {
  25215. return baseWrapperValue(this.__wrapped__, this.__actions__);
  25216. }
  25217. /*------------------------------------------------------------------------*/
  25218. /**
  25219. * Creates an object composed of keys generated from the results of running
  25220. * each element of `collection` thru `iteratee`. The corresponding value of
  25221. * each key is the number of times the key was returned by `iteratee`. The
  25222. * iteratee is invoked with one argument: (value).
  25223. *
  25224. * @static
  25225. * @memberOf _
  25226. * @since 0.5.0
  25227. * @category Collection
  25228. * @param {Array|Object} collection The collection to iterate over.
  25229. * @param {Function} [iteratee=_.identity] The iteratee to transform keys.
  25230. * @returns {Object} Returns the composed aggregate object.
  25231. * @example
  25232. *
  25233. * _.countBy([6.1, 4.2, 6.3], Math.floor);
  25234. * // => { '4': 1, '6': 2 }
  25235. *
  25236. * // The `_.property` iteratee shorthand.
  25237. * _.countBy(['one', 'two', 'three'], 'length');
  25238. * // => { '3': 2, '5': 1 }
  25239. */
  25240. var countBy = createAggregator(function(result, value, key) {
  25241. if (hasOwnProperty.call(result, key)) {
  25242. ++result[key];
  25243. } else {
  25244. baseAssignValue(result, key, 1);
  25245. }
  25246. });
  25247. /**
  25248. * Checks if `predicate` returns truthy for **all** elements of `collection`.
  25249. * Iteration is stopped once `predicate` returns falsey. The predicate is
  25250. * invoked with three arguments: (value, index|key, collection).
  25251. *
  25252. * **Note:** This method returns `true` for
  25253. * [empty collections](https://en.wikipedia.org/wiki/Empty_set) because
  25254. * [everything is true](https://en.wikipedia.org/wiki/Vacuous_truth) of
  25255. * elements of empty collections.
  25256. *
  25257. * @static
  25258. * @memberOf _
  25259. * @since 0.1.0
  25260. * @category Collection
  25261. * @param {Array|Object} collection The collection to iterate over.
  25262. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  25263. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  25264. * @returns {boolean} Returns `true` if all elements pass the predicate check,
  25265. * else `false`.
  25266. * @example
  25267. *
  25268. * _.every([true, 1, null, 'yes'], Boolean);
  25269. * // => false
  25270. *
  25271. * var users = [
  25272. * { 'user': 'barney', 'age': 36, 'active': false },
  25273. * { 'user': 'fred', 'age': 40, 'active': false }
  25274. * ];
  25275. *
  25276. * // The `_.matches` iteratee shorthand.
  25277. * _.every(users, { 'user': 'barney', 'active': false });
  25278. * // => false
  25279. *
  25280. * // The `_.matchesProperty` iteratee shorthand.
  25281. * _.every(users, ['active', false]);
  25282. * // => true
  25283. *
  25284. * // The `_.property` iteratee shorthand.
  25285. * _.every(users, 'active');
  25286. * // => false
  25287. */
  25288. function every(collection, predicate, guard) {
  25289. var func = isArray(collection) ? arrayEvery : baseEvery;
  25290. if (guard && isIterateeCall(collection, predicate, guard)) {
  25291. predicate = undefined;
  25292. }
  25293. return func(collection, getIteratee(predicate, 3));
  25294. }
  25295. /**
  25296. * Iterates over elements of `collection`, returning an array of all elements
  25297. * `predicate` returns truthy for. The predicate is invoked with three
  25298. * arguments: (value, index|key, collection).
  25299. *
  25300. * **Note:** Unlike `_.remove`, this method returns a new array.
  25301. *
  25302. * @static
  25303. * @memberOf _
  25304. * @since 0.1.0
  25305. * @category Collection
  25306. * @param {Array|Object} collection The collection to iterate over.
  25307. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  25308. * @returns {Array} Returns the new filtered array.
  25309. * @see _.reject
  25310. * @example
  25311. *
  25312. * var users = [
  25313. * { 'user': 'barney', 'age': 36, 'active': true },
  25314. * { 'user': 'fred', 'age': 40, 'active': false }
  25315. * ];
  25316. *
  25317. * _.filter(users, function(o) { return !o.active; });
  25318. * // => objects for ['fred']
  25319. *
  25320. * // The `_.matches` iteratee shorthand.
  25321. * _.filter(users, { 'age': 36, 'active': true });
  25322. * // => objects for ['barney']
  25323. *
  25324. * // The `_.matchesProperty` iteratee shorthand.
  25325. * _.filter(users, ['active', false]);
  25326. * // => objects for ['fred']
  25327. *
  25328. * // The `_.property` iteratee shorthand.
  25329. * _.filter(users, 'active');
  25330. * // => objects for ['barney']
  25331. */
  25332. function filter(collection, predicate) {
  25333. var func = isArray(collection) ? arrayFilter : baseFilter;
  25334. return func(collection, getIteratee(predicate, 3));
  25335. }
  25336. /**
  25337. * Iterates over elements of `collection`, returning the first element
  25338. * `predicate` returns truthy for. The predicate is invoked with three
  25339. * arguments: (value, index|key, collection).
  25340. *
  25341. * @static
  25342. * @memberOf _
  25343. * @since 0.1.0
  25344. * @category Collection
  25345. * @param {Array|Object} collection The collection to inspect.
  25346. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  25347. * @param {number} [fromIndex=0] The index to search from.
  25348. * @returns {*} Returns the matched element, else `undefined`.
  25349. * @example
  25350. *
  25351. * var users = [
  25352. * { 'user': 'barney', 'age': 36, 'active': true },
  25353. * { 'user': 'fred', 'age': 40, 'active': false },
  25354. * { 'user': 'pebbles', 'age': 1, 'active': true }
  25355. * ];
  25356. *
  25357. * _.find(users, function(o) { return o.age < 40; });
  25358. * // => object for 'barney'
  25359. *
  25360. * // The `_.matches` iteratee shorthand.
  25361. * _.find(users, { 'age': 1, 'active': true });
  25362. * // => object for 'pebbles'
  25363. *
  25364. * // The `_.matchesProperty` iteratee shorthand.
  25365. * _.find(users, ['active', false]);
  25366. * // => object for 'fred'
  25367. *
  25368. * // The `_.property` iteratee shorthand.
  25369. * _.find(users, 'active');
  25370. * // => object for 'barney'
  25371. */
  25372. var find = createFind(findIndex);
  25373. /**
  25374. * This method is like `_.find` except that it iterates over elements of
  25375. * `collection` from right to left.
  25376. *
  25377. * @static
  25378. * @memberOf _
  25379. * @since 2.0.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=collection.length-1] The index to search from.
  25384. * @returns {*} Returns the matched element, else `undefined`.
  25385. * @example
  25386. *
  25387. * _.findLast([1, 2, 3, 4], function(n) {
  25388. * return n % 2 == 1;
  25389. * });
  25390. * // => 3
  25391. */
  25392. var findLast = createFind(findLastIndex);
  25393. /**
  25394. * Creates a flattened array of values by running each element in `collection`
  25395. * thru `iteratee` and flattening the mapped results. The iteratee is invoked
  25396. * with three arguments: (value, index|key, collection).
  25397. *
  25398. * @static
  25399. * @memberOf _
  25400. * @since 4.0.0
  25401. * @category Collection
  25402. * @param {Array|Object} collection The collection to iterate over.
  25403. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  25404. * @returns {Array} Returns the new flattened array.
  25405. * @example
  25406. *
  25407. * function duplicate(n) {
  25408. * return [n, n];
  25409. * }
  25410. *
  25411. * _.flatMap([1, 2], duplicate);
  25412. * // => [1, 1, 2, 2]
  25413. */
  25414. function flatMap(collection, iteratee) {
  25415. return baseFlatten(map(collection, iteratee), 1);
  25416. }
  25417. /**
  25418. * This method is like `_.flatMap` except that it recursively flattens the
  25419. * mapped results.
  25420. *
  25421. * @static
  25422. * @memberOf _
  25423. * @since 4.7.0
  25424. * @category Collection
  25425. * @param {Array|Object} collection The collection to iterate over.
  25426. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  25427. * @returns {Array} Returns the new flattened array.
  25428. * @example
  25429. *
  25430. * function duplicate(n) {
  25431. * return [[[n, n]]];
  25432. * }
  25433. *
  25434. * _.flatMapDeep([1, 2], duplicate);
  25435. * // => [1, 1, 2, 2]
  25436. */
  25437. function flatMapDeep(collection, iteratee) {
  25438. return baseFlatten(map(collection, iteratee), INFINITY);
  25439. }
  25440. /**
  25441. * This method is like `_.flatMap` except that it recursively flattens the
  25442. * mapped results up to `depth` times.
  25443. *
  25444. * @static
  25445. * @memberOf _
  25446. * @since 4.7.0
  25447. * @category Collection
  25448. * @param {Array|Object} collection The collection to iterate over.
  25449. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  25450. * @param {number} [depth=1] The maximum recursion depth.
  25451. * @returns {Array} Returns the new flattened array.
  25452. * @example
  25453. *
  25454. * function duplicate(n) {
  25455. * return [[[n, n]]];
  25456. * }
  25457. *
  25458. * _.flatMapDepth([1, 2], duplicate, 2);
  25459. * // => [[1, 1], [2, 2]]
  25460. */
  25461. function flatMapDepth(collection, iteratee, depth) {
  25462. depth = depth === undefined ? 1 : toInteger(depth);
  25463. return baseFlatten(map(collection, iteratee), depth);
  25464. }
  25465. /**
  25466. * Iterates over elements of `collection` and invokes `iteratee` for each element.
  25467. * The iteratee is invoked with three arguments: (value, index|key, collection).
  25468. * Iteratee functions may exit iteration early by explicitly returning `false`.
  25469. *
  25470. * **Note:** As with other "Collections" methods, objects with a "length"
  25471. * property are iterated like arrays. To avoid this behavior use `_.forIn`
  25472. * or `_.forOwn` for object iteration.
  25473. *
  25474. * @static
  25475. * @memberOf _
  25476. * @since 0.1.0
  25477. * @alias each
  25478. * @category Collection
  25479. * @param {Array|Object} collection The collection to iterate over.
  25480. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  25481. * @returns {Array|Object} Returns `collection`.
  25482. * @see _.forEachRight
  25483. * @example
  25484. *
  25485. * _.forEach([1, 2], function(value) {
  25486. * console.log(value);
  25487. * });
  25488. * // => Logs `1` then `2`.
  25489. *
  25490. * _.forEach({ 'a': 1, 'b': 2 }, function(value, key) {
  25491. * console.log(key);
  25492. * });
  25493. * // => Logs 'a' then 'b' (iteration order is not guaranteed).
  25494. */
  25495. function forEach(collection, iteratee) {
  25496. var func = isArray(collection) ? arrayEach : baseEach;
  25497. return func(collection, getIteratee(iteratee, 3));
  25498. }
  25499. /**
  25500. * This method is like `_.forEach` except that it iterates over elements of
  25501. * `collection` from right to left.
  25502. *
  25503. * @static
  25504. * @memberOf _
  25505. * @since 2.0.0
  25506. * @alias eachRight
  25507. * @category Collection
  25508. * @param {Array|Object} collection The collection to iterate over.
  25509. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  25510. * @returns {Array|Object} Returns `collection`.
  25511. * @see _.forEach
  25512. * @example
  25513. *
  25514. * _.forEachRight([1, 2], function(value) {
  25515. * console.log(value);
  25516. * });
  25517. * // => Logs `2` then `1`.
  25518. */
  25519. function forEachRight(collection, iteratee) {
  25520. var func = isArray(collection) ? arrayEachRight : baseEachRight;
  25521. return func(collection, getIteratee(iteratee, 3));
  25522. }
  25523. /**
  25524. * Creates an object composed of keys generated from the results of running
  25525. * each element of `collection` thru `iteratee`. The order of grouped values
  25526. * is determined by the order they occur in `collection`. The corresponding
  25527. * value of each key is an array of elements responsible for generating the
  25528. * key. The iteratee is invoked with one argument: (value).
  25529. *
  25530. * @static
  25531. * @memberOf _
  25532. * @since 0.1.0
  25533. * @category Collection
  25534. * @param {Array|Object} collection The collection to iterate over.
  25535. * @param {Function} [iteratee=_.identity] The iteratee to transform keys.
  25536. * @returns {Object} Returns the composed aggregate object.
  25537. * @example
  25538. *
  25539. * _.groupBy([6.1, 4.2, 6.3], Math.floor);
  25540. * // => { '4': [4.2], '6': [6.1, 6.3] }
  25541. *
  25542. * // The `_.property` iteratee shorthand.
  25543. * _.groupBy(['one', 'two', 'three'], 'length');
  25544. * // => { '3': ['one', 'two'], '5': ['three'] }
  25545. */
  25546. var groupBy = createAggregator(function(result, value, key) {
  25547. if (hasOwnProperty.call(result, key)) {
  25548. result[key].push(value);
  25549. } else {
  25550. baseAssignValue(result, key, [value]);
  25551. }
  25552. });
  25553. /**
  25554. * Checks if `value` is in `collection`. If `collection` is a string, it's
  25555. * checked for a substring of `value`, otherwise
  25556. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  25557. * is used for equality comparisons. If `fromIndex` is negative, it's used as
  25558. * the offset from the end of `collection`.
  25559. *
  25560. * @static
  25561. * @memberOf _
  25562. * @since 0.1.0
  25563. * @category Collection
  25564. * @param {Array|Object|string} collection The collection to inspect.
  25565. * @param {*} value The value to search for.
  25566. * @param {number} [fromIndex=0] The index to search from.
  25567. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.reduce`.
  25568. * @returns {boolean} Returns `true` if `value` is found, else `false`.
  25569. * @example
  25570. *
  25571. * _.includes([1, 2, 3], 1);
  25572. * // => true
  25573. *
  25574. * _.includes([1, 2, 3], 1, 2);
  25575. * // => false
  25576. *
  25577. * _.includes({ 'a': 1, 'b': 2 }, 1);
  25578. * // => true
  25579. *
  25580. * _.includes('abcd', 'bc');
  25581. * // => true
  25582. */
  25583. function includes(collection, value, fromIndex, guard) {
  25584. collection = isArrayLike(collection) ? collection : values(collection);
  25585. fromIndex = (fromIndex && !guard) ? toInteger(fromIndex) : 0;
  25586. var length = collection.length;
  25587. if (fromIndex < 0) {
  25588. fromIndex = nativeMax(length + fromIndex, 0);
  25589. }
  25590. return isString(collection)
  25591. ? (fromIndex <= length && collection.indexOf(value, fromIndex) > -1)
  25592. : (!!length && baseIndexOf(collection, value, fromIndex) > -1);
  25593. }
  25594. /**
  25595. * Invokes the method at `path` of each element in `collection`, returning
  25596. * an array of the results of each invoked method. Any additional arguments
  25597. * are provided to each invoked method. If `path` is a function, it's invoked
  25598. * for, and `this` bound to, each element in `collection`.
  25599. *
  25600. * @static
  25601. * @memberOf _
  25602. * @since 4.0.0
  25603. * @category Collection
  25604. * @param {Array|Object} collection The collection to iterate over.
  25605. * @param {Array|Function|string} path The path of the method to invoke or
  25606. * the function invoked per iteration.
  25607. * @param {...*} [args] The arguments to invoke each method with.
  25608. * @returns {Array} Returns the array of results.
  25609. * @example
  25610. *
  25611. * _.invokeMap([[5, 1, 7], [3, 2, 1]], 'sort');
  25612. * // => [[1, 5, 7], [1, 2, 3]]
  25613. *
  25614. * _.invokeMap([123, 456], String.prototype.split, '');
  25615. * // => [['1', '2', '3'], ['4', '5', '6']]
  25616. */
  25617. var invokeMap = baseRest(function(collection, path, args) {
  25618. var index = -1,
  25619. isFunc = typeof path == 'function',
  25620. result = isArrayLike(collection) ? Array(collection.length) : [];
  25621. baseEach(collection, function(value) {
  25622. result[++index] = isFunc ? apply(path, value, args) : baseInvoke(value, path, args);
  25623. });
  25624. return result;
  25625. });
  25626. /**
  25627. * Creates an object composed of keys generated from the results of running
  25628. * each element of `collection` thru `iteratee`. The corresponding value of
  25629. * each key is the last element responsible for generating the key. The
  25630. * iteratee is invoked with one argument: (value).
  25631. *
  25632. * @static
  25633. * @memberOf _
  25634. * @since 4.0.0
  25635. * @category Collection
  25636. * @param {Array|Object} collection The collection to iterate over.
  25637. * @param {Function} [iteratee=_.identity] The iteratee to transform keys.
  25638. * @returns {Object} Returns the composed aggregate object.
  25639. * @example
  25640. *
  25641. * var array = [
  25642. * { 'dir': 'left', 'code': 97 },
  25643. * { 'dir': 'right', 'code': 100 }
  25644. * ];
  25645. *
  25646. * _.keyBy(array, function(o) {
  25647. * return String.fromCharCode(o.code);
  25648. * });
  25649. * // => { 'a': { 'dir': 'left', 'code': 97 }, 'd': { 'dir': 'right', 'code': 100 } }
  25650. *
  25651. * _.keyBy(array, 'dir');
  25652. * // => { 'left': { 'dir': 'left', 'code': 97 }, 'right': { 'dir': 'right', 'code': 100 } }
  25653. */
  25654. var keyBy = createAggregator(function(result, value, key) {
  25655. baseAssignValue(result, key, value);
  25656. });
  25657. /**
  25658. * Creates an array of values by running each element in `collection` thru
  25659. * `iteratee`. The iteratee is invoked with three arguments:
  25660. * (value, index|key, collection).
  25661. *
  25662. * Many lodash methods are guarded to work as iteratees for methods like
  25663. * `_.every`, `_.filter`, `_.map`, `_.mapValues`, `_.reject`, and `_.some`.
  25664. *
  25665. * The guarded methods are:
  25666. * `ary`, `chunk`, `curry`, `curryRight`, `drop`, `dropRight`, `every`,
  25667. * `fill`, `invert`, `parseInt`, `random`, `range`, `rangeRight`, `repeat`,
  25668. * `sampleSize`, `slice`, `some`, `sortBy`, `split`, `take`, `takeRight`,
  25669. * `template`, `trim`, `trimEnd`, `trimStart`, and `words`
  25670. *
  25671. * @static
  25672. * @memberOf _
  25673. * @since 0.1.0
  25674. * @category Collection
  25675. * @param {Array|Object} collection The collection to iterate over.
  25676. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  25677. * @returns {Array} Returns the new mapped array.
  25678. * @example
  25679. *
  25680. * function square(n) {
  25681. * return n * n;
  25682. * }
  25683. *
  25684. * _.map([4, 8], square);
  25685. * // => [16, 64]
  25686. *
  25687. * _.map({ 'a': 4, 'b': 8 }, square);
  25688. * // => [16, 64] (iteration order is not guaranteed)
  25689. *
  25690. * var users = [
  25691. * { 'user': 'barney' },
  25692. * { 'user': 'fred' }
  25693. * ];
  25694. *
  25695. * // The `_.property` iteratee shorthand.
  25696. * _.map(users, 'user');
  25697. * // => ['barney', 'fred']
  25698. */
  25699. function map(collection, iteratee) {
  25700. var func = isArray(collection) ? arrayMap : baseMap;
  25701. return func(collection, getIteratee(iteratee, 3));
  25702. }
  25703. /**
  25704. * This method is like `_.sortBy` except that it allows specifying the sort
  25705. * orders of the iteratees to sort by. If `orders` is unspecified, all values
  25706. * are sorted in ascending order. Otherwise, specify an order of "desc" for
  25707. * descending or "asc" for ascending sort order of corresponding values.
  25708. *
  25709. * @static
  25710. * @memberOf _
  25711. * @since 4.0.0
  25712. * @category Collection
  25713. * @param {Array|Object} collection The collection to iterate over.
  25714. * @param {Array[]|Function[]|Object[]|string[]} [iteratees=[_.identity]]
  25715. * The iteratees to sort by.
  25716. * @param {string[]} [orders] The sort orders of `iteratees`.
  25717. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.reduce`.
  25718. * @returns {Array} Returns the new sorted array.
  25719. * @example
  25720. *
  25721. * var users = [
  25722. * { 'user': 'fred', 'age': 48 },
  25723. * { 'user': 'barney', 'age': 34 },
  25724. * { 'user': 'fred', 'age': 40 },
  25725. * { 'user': 'barney', 'age': 36 }
  25726. * ];
  25727. *
  25728. * // Sort by `user` in ascending order and by `age` in descending order.
  25729. * _.orderBy(users, ['user', 'age'], ['asc', 'desc']);
  25730. * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 40]]
  25731. */
  25732. function orderBy(collection, iteratees, orders, guard) {
  25733. if (collection == null) {
  25734. return [];
  25735. }
  25736. if (!isArray(iteratees)) {
  25737. iteratees = iteratees == null ? [] : [iteratees];
  25738. }
  25739. orders = guard ? undefined : orders;
  25740. if (!isArray(orders)) {
  25741. orders = orders == null ? [] : [orders];
  25742. }
  25743. return baseOrderBy(collection, iteratees, orders);
  25744. }
  25745. /**
  25746. * Creates an array of elements split into two groups, the first of which
  25747. * contains elements `predicate` returns truthy for, the second of which
  25748. * contains elements `predicate` returns falsey for. The predicate is
  25749. * invoked with one argument: (value).
  25750. *
  25751. * @static
  25752. * @memberOf _
  25753. * @since 3.0.0
  25754. * @category Collection
  25755. * @param {Array|Object} collection The collection to iterate over.
  25756. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  25757. * @returns {Array} Returns the array of grouped elements.
  25758. * @example
  25759. *
  25760. * var users = [
  25761. * { 'user': 'barney', 'age': 36, 'active': false },
  25762. * { 'user': 'fred', 'age': 40, 'active': true },
  25763. * { 'user': 'pebbles', 'age': 1, 'active': false }
  25764. * ];
  25765. *
  25766. * _.partition(users, function(o) { return o.active; });
  25767. * // => objects for [['fred'], ['barney', 'pebbles']]
  25768. *
  25769. * // The `_.matches` iteratee shorthand.
  25770. * _.partition(users, { 'age': 1, 'active': false });
  25771. * // => objects for [['pebbles'], ['barney', 'fred']]
  25772. *
  25773. * // The `_.matchesProperty` iteratee shorthand.
  25774. * _.partition(users, ['active', false]);
  25775. * // => objects for [['barney', 'pebbles'], ['fred']]
  25776. *
  25777. * // The `_.property` iteratee shorthand.
  25778. * _.partition(users, 'active');
  25779. * // => objects for [['fred'], ['barney', 'pebbles']]
  25780. */
  25781. var partition = createAggregator(function(result, value, key) {
  25782. result[key ? 0 : 1].push(value);
  25783. }, function() { return [[], []]; });
  25784. /**
  25785. * Reduces `collection` to a value which is the accumulated result of running
  25786. * each element in `collection` thru `iteratee`, where each successive
  25787. * invocation is supplied the return value of the previous. If `accumulator`
  25788. * is not given, the first element of `collection` is used as the initial
  25789. * value. The iteratee is invoked with four arguments:
  25790. * (accumulator, value, index|key, collection).
  25791. *
  25792. * Many lodash methods are guarded to work as iteratees for methods like
  25793. * `_.reduce`, `_.reduceRight`, and `_.transform`.
  25794. *
  25795. * The guarded methods are:
  25796. * `assign`, `defaults`, `defaultsDeep`, `includes`, `merge`, `orderBy`,
  25797. * and `sortBy`
  25798. *
  25799. * @static
  25800. * @memberOf _
  25801. * @since 0.1.0
  25802. * @category Collection
  25803. * @param {Array|Object} collection The collection to iterate over.
  25804. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  25805. * @param {*} [accumulator] The initial value.
  25806. * @returns {*} Returns the accumulated value.
  25807. * @see _.reduceRight
  25808. * @example
  25809. *
  25810. * _.reduce([1, 2], function(sum, n) {
  25811. * return sum + n;
  25812. * }, 0);
  25813. * // => 3
  25814. *
  25815. * _.reduce({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) {
  25816. * (result[value] || (result[value] = [])).push(key);
  25817. * return result;
  25818. * }, {});
  25819. * // => { '1': ['a', 'c'], '2': ['b'] } (iteration order is not guaranteed)
  25820. */
  25821. function reduce(collection, iteratee, accumulator) {
  25822. var func = isArray(collection) ? arrayReduce : baseReduce,
  25823. initAccum = arguments.length < 3;
  25824. return func(collection, getIteratee(iteratee, 4), accumulator, initAccum, baseEach);
  25825. }
  25826. /**
  25827. * This method is like `_.reduce` except that it iterates over elements of
  25828. * `collection` from right to left.
  25829. *
  25830. * @static
  25831. * @memberOf _
  25832. * @since 0.1.0
  25833. * @category Collection
  25834. * @param {Array|Object} collection The collection to iterate over.
  25835. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  25836. * @param {*} [accumulator] The initial value.
  25837. * @returns {*} Returns the accumulated value.
  25838. * @see _.reduce
  25839. * @example
  25840. *
  25841. * var array = [[0, 1], [2, 3], [4, 5]];
  25842. *
  25843. * _.reduceRight(array, function(flattened, other) {
  25844. * return flattened.concat(other);
  25845. * }, []);
  25846. * // => [4, 5, 2, 3, 0, 1]
  25847. */
  25848. function reduceRight(collection, iteratee, accumulator) {
  25849. var func = isArray(collection) ? arrayReduceRight : baseReduce,
  25850. initAccum = arguments.length < 3;
  25851. return func(collection, getIteratee(iteratee, 4), accumulator, initAccum, baseEachRight);
  25852. }
  25853. /**
  25854. * The opposite of `_.filter`; this method returns the elements of `collection`
  25855. * that `predicate` does **not** return truthy for.
  25856. *
  25857. * @static
  25858. * @memberOf _
  25859. * @since 0.1.0
  25860. * @category Collection
  25861. * @param {Array|Object} collection The collection to iterate over.
  25862. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  25863. * @returns {Array} Returns the new filtered array.
  25864. * @see _.filter
  25865. * @example
  25866. *
  25867. * var users = [
  25868. * { 'user': 'barney', 'age': 36, 'active': false },
  25869. * { 'user': 'fred', 'age': 40, 'active': true }
  25870. * ];
  25871. *
  25872. * _.reject(users, function(o) { return !o.active; });
  25873. * // => objects for ['fred']
  25874. *
  25875. * // The `_.matches` iteratee shorthand.
  25876. * _.reject(users, { 'age': 40, 'active': true });
  25877. * // => objects for ['barney']
  25878. *
  25879. * // The `_.matchesProperty` iteratee shorthand.
  25880. * _.reject(users, ['active', false]);
  25881. * // => objects for ['fred']
  25882. *
  25883. * // The `_.property` iteratee shorthand.
  25884. * _.reject(users, 'active');
  25885. * // => objects for ['barney']
  25886. */
  25887. function reject(collection, predicate) {
  25888. var func = isArray(collection) ? arrayFilter : baseFilter;
  25889. return func(collection, negate(getIteratee(predicate, 3)));
  25890. }
  25891. /**
  25892. * Gets a random element from `collection`.
  25893. *
  25894. * @static
  25895. * @memberOf _
  25896. * @since 2.0.0
  25897. * @category Collection
  25898. * @param {Array|Object} collection The collection to sample.
  25899. * @returns {*} Returns the random element.
  25900. * @example
  25901. *
  25902. * _.sample([1, 2, 3, 4]);
  25903. * // => 2
  25904. */
  25905. function sample(collection) {
  25906. var func = isArray(collection) ? arraySample : baseSample;
  25907. return func(collection);
  25908. }
  25909. /**
  25910. * Gets `n` random elements at unique keys from `collection` up to the
  25911. * size of `collection`.
  25912. *
  25913. * @static
  25914. * @memberOf _
  25915. * @since 4.0.0
  25916. * @category Collection
  25917. * @param {Array|Object} collection The collection to sample.
  25918. * @param {number} [n=1] The number of elements to sample.
  25919. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  25920. * @returns {Array} Returns the random elements.
  25921. * @example
  25922. *
  25923. * _.sampleSize([1, 2, 3], 2);
  25924. * // => [3, 1]
  25925. *
  25926. * _.sampleSize([1, 2, 3], 4);
  25927. * // => [2, 3, 1]
  25928. */
  25929. function sampleSize(collection, n, guard) {
  25930. if ((guard ? isIterateeCall(collection, n, guard) : n === undefined)) {
  25931. n = 1;
  25932. } else {
  25933. n = toInteger(n);
  25934. }
  25935. var func = isArray(collection) ? arraySampleSize : baseSampleSize;
  25936. return func(collection, n);
  25937. }
  25938. /**
  25939. * Creates an array of shuffled values, using a version of the
  25940. * [Fisher-Yates shuffle](https://en.wikipedia.org/wiki/Fisher-Yates_shuffle).
  25941. *
  25942. * @static
  25943. * @memberOf _
  25944. * @since 0.1.0
  25945. * @category Collection
  25946. * @param {Array|Object} collection The collection to shuffle.
  25947. * @returns {Array} Returns the new shuffled array.
  25948. * @example
  25949. *
  25950. * _.shuffle([1, 2, 3, 4]);
  25951. * // => [4, 1, 3, 2]
  25952. */
  25953. function shuffle(collection) {
  25954. var func = isArray(collection) ? arrayShuffle : baseShuffle;
  25955. return func(collection);
  25956. }
  25957. /**
  25958. * Gets the size of `collection` by returning its length for array-like
  25959. * values or the number of own enumerable string keyed properties for objects.
  25960. *
  25961. * @static
  25962. * @memberOf _
  25963. * @since 0.1.0
  25964. * @category Collection
  25965. * @param {Array|Object|string} collection The collection to inspect.
  25966. * @returns {number} Returns the collection size.
  25967. * @example
  25968. *
  25969. * _.size([1, 2, 3]);
  25970. * // => 3
  25971. *
  25972. * _.size({ 'a': 1, 'b': 2 });
  25973. * // => 2
  25974. *
  25975. * _.size('pebbles');
  25976. * // => 7
  25977. */
  25978. function size(collection) {
  25979. if (collection == null) {
  25980. return 0;
  25981. }
  25982. if (isArrayLike(collection)) {
  25983. return isString(collection) ? stringSize(collection) : collection.length;
  25984. }
  25985. var tag = getTag(collection);
  25986. if (tag == mapTag || tag == setTag) {
  25987. return collection.size;
  25988. }
  25989. return baseKeys(collection).length;
  25990. }
  25991. /**
  25992. * Checks if `predicate` returns truthy for **any** element of `collection`.
  25993. * Iteration is stopped once `predicate` returns truthy. The predicate is
  25994. * invoked with three arguments: (value, index|key, collection).
  25995. *
  25996. * @static
  25997. * @memberOf _
  25998. * @since 0.1.0
  25999. * @category Collection
  26000. * @param {Array|Object} collection The collection to iterate over.
  26001. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  26002. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  26003. * @returns {boolean} Returns `true` if any element passes the predicate check,
  26004. * else `false`.
  26005. * @example
  26006. *
  26007. * _.some([null, 0, 'yes', false], Boolean);
  26008. * // => true
  26009. *
  26010. * var users = [
  26011. * { 'user': 'barney', 'active': true },
  26012. * { 'user': 'fred', 'active': false }
  26013. * ];
  26014. *
  26015. * // The `_.matches` iteratee shorthand.
  26016. * _.some(users, { 'user': 'barney', 'active': false });
  26017. * // => false
  26018. *
  26019. * // The `_.matchesProperty` iteratee shorthand.
  26020. * _.some(users, ['active', false]);
  26021. * // => true
  26022. *
  26023. * // The `_.property` iteratee shorthand.
  26024. * _.some(users, 'active');
  26025. * // => true
  26026. */
  26027. function some(collection, predicate, guard) {
  26028. var func = isArray(collection) ? arraySome : baseSome;
  26029. if (guard && isIterateeCall(collection, predicate, guard)) {
  26030. predicate = undefined;
  26031. }
  26032. return func(collection, getIteratee(predicate, 3));
  26033. }
  26034. /**
  26035. * Creates an array of elements, sorted in ascending order by the results of
  26036. * running each element in a collection thru each iteratee. This method
  26037. * performs a stable sort, that is, it preserves the original sort order of
  26038. * equal elements. The iteratees are invoked with one argument: (value).
  26039. *
  26040. * @static
  26041. * @memberOf _
  26042. * @since 0.1.0
  26043. * @category Collection
  26044. * @param {Array|Object} collection The collection to iterate over.
  26045. * @param {...(Function|Function[])} [iteratees=[_.identity]]
  26046. * The iteratees to sort by.
  26047. * @returns {Array} Returns the new sorted array.
  26048. * @example
  26049. *
  26050. * var users = [
  26051. * { 'user': 'fred', 'age': 48 },
  26052. * { 'user': 'barney', 'age': 36 },
  26053. * { 'user': 'fred', 'age': 40 },
  26054. * { 'user': 'barney', 'age': 34 }
  26055. * ];
  26056. *
  26057. * _.sortBy(users, [function(o) { return o.user; }]);
  26058. * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 40]]
  26059. *
  26060. * _.sortBy(users, ['user', 'age']);
  26061. * // => objects for [['barney', 34], ['barney', 36], ['fred', 40], ['fred', 48]]
  26062. */
  26063. var sortBy = baseRest(function(collection, iteratees) {
  26064. if (collection == null) {
  26065. return [];
  26066. }
  26067. var length = iteratees.length;
  26068. if (length > 1 && isIterateeCall(collection, iteratees[0], iteratees[1])) {
  26069. iteratees = [];
  26070. } else if (length > 2 && isIterateeCall(iteratees[0], iteratees[1], iteratees[2])) {
  26071. iteratees = [iteratees[0]];
  26072. }
  26073. return baseOrderBy(collection, baseFlatten(iteratees, 1), []);
  26074. });
  26075. /*------------------------------------------------------------------------*/
  26076. /**
  26077. * Gets the timestamp of the number of milliseconds that have elapsed since
  26078. * the Unix epoch (1 January 1970 00:00:00 UTC).
  26079. *
  26080. * @static
  26081. * @memberOf _
  26082. * @since 2.4.0
  26083. * @category Date
  26084. * @returns {number} Returns the timestamp.
  26085. * @example
  26086. *
  26087. * _.defer(function(stamp) {
  26088. * console.log(_.now() - stamp);
  26089. * }, _.now());
  26090. * // => Logs the number of milliseconds it took for the deferred invocation.
  26091. */
  26092. var now = ctxNow || function() {
  26093. return root.Date.now();
  26094. };
  26095. /*------------------------------------------------------------------------*/
  26096. /**
  26097. * The opposite of `_.before`; this method creates a function that invokes
  26098. * `func` once it's called `n` or more times.
  26099. *
  26100. * @static
  26101. * @memberOf _
  26102. * @since 0.1.0
  26103. * @category Function
  26104. * @param {number} n The number of calls before `func` is invoked.
  26105. * @param {Function} func The function to restrict.
  26106. * @returns {Function} Returns the new restricted function.
  26107. * @example
  26108. *
  26109. * var saves = ['profile', 'settings'];
  26110. *
  26111. * var done = _.after(saves.length, function() {
  26112. * console.log('done saving!');
  26113. * });
  26114. *
  26115. * _.forEach(saves, function(type) {
  26116. * asyncSave({ 'type': type, 'complete': done });
  26117. * });
  26118. * // => Logs 'done saving!' after the two async saves have completed.
  26119. */
  26120. function after(n, func) {
  26121. if (typeof func != 'function') {
  26122. throw new TypeError(FUNC_ERROR_TEXT);
  26123. }
  26124. n = toInteger(n);
  26125. return function() {
  26126. if (--n < 1) {
  26127. return func.apply(this, arguments);
  26128. }
  26129. };
  26130. }
  26131. /**
  26132. * Creates a function that invokes `func`, with up to `n` arguments,
  26133. * ignoring any additional arguments.
  26134. *
  26135. * @static
  26136. * @memberOf _
  26137. * @since 3.0.0
  26138. * @category Function
  26139. * @param {Function} func The function to cap arguments for.
  26140. * @param {number} [n=func.length] The arity cap.
  26141. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  26142. * @returns {Function} Returns the new capped function.
  26143. * @example
  26144. *
  26145. * _.map(['6', '8', '10'], _.ary(parseInt, 1));
  26146. * // => [6, 8, 10]
  26147. */
  26148. function ary(func, n, guard) {
  26149. n = guard ? undefined : n;
  26150. n = (func && n == null) ? func.length : n;
  26151. return createWrap(func, WRAP_ARY_FLAG, undefined, undefined, undefined, undefined, n);
  26152. }
  26153. /**
  26154. * Creates a function that invokes `func`, with the `this` binding and arguments
  26155. * of the created function, while it's called less than `n` times. Subsequent
  26156. * calls to the created function return the result of the last `func` invocation.
  26157. *
  26158. * @static
  26159. * @memberOf _
  26160. * @since 3.0.0
  26161. * @category Function
  26162. * @param {number} n The number of calls at which `func` is no longer invoked.
  26163. * @param {Function} func The function to restrict.
  26164. * @returns {Function} Returns the new restricted function.
  26165. * @example
  26166. *
  26167. * jQuery(element).on('click', _.before(5, addContactToList));
  26168. * // => Allows adding up to 4 contacts to the list.
  26169. */
  26170. function before(n, func) {
  26171. var result;
  26172. if (typeof func != 'function') {
  26173. throw new TypeError(FUNC_ERROR_TEXT);
  26174. }
  26175. n = toInteger(n);
  26176. return function() {
  26177. if (--n > 0) {
  26178. result = func.apply(this, arguments);
  26179. }
  26180. if (n <= 1) {
  26181. func = undefined;
  26182. }
  26183. return result;
  26184. };
  26185. }
  26186. /**
  26187. * Creates a function that invokes `func` with the `this` binding of `thisArg`
  26188. * and `partials` prepended to the arguments it receives.
  26189. *
  26190. * The `_.bind.placeholder` value, which defaults to `_` in monolithic builds,
  26191. * may be used as a placeholder for partially applied arguments.
  26192. *
  26193. * **Note:** Unlike native `Function#bind`, this method doesn't set the "length"
  26194. * property of bound functions.
  26195. *
  26196. * @static
  26197. * @memberOf _
  26198. * @since 0.1.0
  26199. * @category Function
  26200. * @param {Function} func The function to bind.
  26201. * @param {*} thisArg The `this` binding of `func`.
  26202. * @param {...*} [partials] The arguments to be partially applied.
  26203. * @returns {Function} Returns the new bound function.
  26204. * @example
  26205. *
  26206. * function greet(greeting, punctuation) {
  26207. * return greeting + ' ' + this.user + punctuation;
  26208. * }
  26209. *
  26210. * var object = { 'user': 'fred' };
  26211. *
  26212. * var bound = _.bind(greet, object, 'hi');
  26213. * bound('!');
  26214. * // => 'hi fred!'
  26215. *
  26216. * // Bound with placeholders.
  26217. * var bound = _.bind(greet, object, _, '!');
  26218. * bound('hi');
  26219. * // => 'hi fred!'
  26220. */
  26221. var bind = baseRest(function(func, thisArg, partials) {
  26222. var bitmask = WRAP_BIND_FLAG;
  26223. if (partials.length) {
  26224. var holders = replaceHolders(partials, getHolder(bind));
  26225. bitmask |= WRAP_PARTIAL_FLAG;
  26226. }
  26227. return createWrap(func, bitmask, thisArg, partials, holders);
  26228. });
  26229. /**
  26230. * Creates a function that invokes the method at `object[key]` with `partials`
  26231. * prepended to the arguments it receives.
  26232. *
  26233. * This method differs from `_.bind` by allowing bound functions to reference
  26234. * methods that may be redefined or don't yet exist. See
  26235. * [Peter Michaux's article](http://peter.michaux.ca/articles/lazy-function-definition-pattern)
  26236. * for more details.
  26237. *
  26238. * The `_.bindKey.placeholder` value, which defaults to `_` in monolithic
  26239. * builds, may be used as a placeholder for partially applied arguments.
  26240. *
  26241. * @static
  26242. * @memberOf _
  26243. * @since 0.10.0
  26244. * @category Function
  26245. * @param {Object} object The object to invoke the method on.
  26246. * @param {string} key The key of the method.
  26247. * @param {...*} [partials] The arguments to be partially applied.
  26248. * @returns {Function} Returns the new bound function.
  26249. * @example
  26250. *
  26251. * var object = {
  26252. * 'user': 'fred',
  26253. * 'greet': function(greeting, punctuation) {
  26254. * return greeting + ' ' + this.user + punctuation;
  26255. * }
  26256. * };
  26257. *
  26258. * var bound = _.bindKey(object, 'greet', 'hi');
  26259. * bound('!');
  26260. * // => 'hi fred!'
  26261. *
  26262. * object.greet = function(greeting, punctuation) {
  26263. * return greeting + 'ya ' + this.user + punctuation;
  26264. * };
  26265. *
  26266. * bound('!');
  26267. * // => 'hiya fred!'
  26268. *
  26269. * // Bound with placeholders.
  26270. * var bound = _.bindKey(object, 'greet', _, '!');
  26271. * bound('hi');
  26272. * // => 'hiya fred!'
  26273. */
  26274. var bindKey = baseRest(function(object, key, partials) {
  26275. var bitmask = WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG;
  26276. if (partials.length) {
  26277. var holders = replaceHolders(partials, getHolder(bindKey));
  26278. bitmask |= WRAP_PARTIAL_FLAG;
  26279. }
  26280. return createWrap(key, bitmask, object, partials, holders);
  26281. });
  26282. /**
  26283. * Creates a function that accepts arguments of `func` and either invokes
  26284. * `func` returning its result, if at least `arity` number of arguments have
  26285. * been provided, or returns a function that accepts the remaining `func`
  26286. * arguments, and so on. The arity of `func` may be specified if `func.length`
  26287. * is not sufficient.
  26288. *
  26289. * The `_.curry.placeholder` value, which defaults to `_` in monolithic builds,
  26290. * may be used as a placeholder for provided arguments.
  26291. *
  26292. * **Note:** This method doesn't set the "length" property of curried functions.
  26293. *
  26294. * @static
  26295. * @memberOf _
  26296. * @since 2.0.0
  26297. * @category Function
  26298. * @param {Function} func The function to curry.
  26299. * @param {number} [arity=func.length] The arity of `func`.
  26300. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  26301. * @returns {Function} Returns the new curried function.
  26302. * @example
  26303. *
  26304. * var abc = function(a, b, c) {
  26305. * return [a, b, c];
  26306. * };
  26307. *
  26308. * var curried = _.curry(abc);
  26309. *
  26310. * curried(1)(2)(3);
  26311. * // => [1, 2, 3]
  26312. *
  26313. * curried(1, 2)(3);
  26314. * // => [1, 2, 3]
  26315. *
  26316. * curried(1, 2, 3);
  26317. * // => [1, 2, 3]
  26318. *
  26319. * // Curried with placeholders.
  26320. * curried(1)(_, 3)(2);
  26321. * // => [1, 2, 3]
  26322. */
  26323. function curry(func, arity, guard) {
  26324. arity = guard ? undefined : arity;
  26325. var result = createWrap(func, WRAP_CURRY_FLAG, undefined, undefined, undefined, undefined, undefined, arity);
  26326. result.placeholder = curry.placeholder;
  26327. return result;
  26328. }
  26329. /**
  26330. * This method is like `_.curry` except that arguments are applied to `func`
  26331. * in the manner of `_.partialRight` instead of `_.partial`.
  26332. *
  26333. * The `_.curryRight.placeholder` value, which defaults to `_` in monolithic
  26334. * builds, may be used as a placeholder for provided arguments.
  26335. *
  26336. * **Note:** This method doesn't set the "length" property of curried functions.
  26337. *
  26338. * @static
  26339. * @memberOf _
  26340. * @since 3.0.0
  26341. * @category Function
  26342. * @param {Function} func The function to curry.
  26343. * @param {number} [arity=func.length] The arity of `func`.
  26344. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  26345. * @returns {Function} Returns the new curried function.
  26346. * @example
  26347. *
  26348. * var abc = function(a, b, c) {
  26349. * return [a, b, c];
  26350. * };
  26351. *
  26352. * var curried = _.curryRight(abc);
  26353. *
  26354. * curried(3)(2)(1);
  26355. * // => [1, 2, 3]
  26356. *
  26357. * curried(2, 3)(1);
  26358. * // => [1, 2, 3]
  26359. *
  26360. * curried(1, 2, 3);
  26361. * // => [1, 2, 3]
  26362. *
  26363. * // Curried with placeholders.
  26364. * curried(3)(1, _)(2);
  26365. * // => [1, 2, 3]
  26366. */
  26367. function curryRight(func, arity, guard) {
  26368. arity = guard ? undefined : arity;
  26369. var result = createWrap(func, WRAP_CURRY_RIGHT_FLAG, undefined, undefined, undefined, undefined, undefined, arity);
  26370. result.placeholder = curryRight.placeholder;
  26371. return result;
  26372. }
  26373. /**
  26374. * Creates a debounced function that delays invoking `func` until after `wait`
  26375. * milliseconds have elapsed since the last time the debounced function was
  26376. * invoked. The debounced function comes with a `cancel` method to cancel
  26377. * delayed `func` invocations and a `flush` method to immediately invoke them.
  26378. * Provide `options` to indicate whether `func` should be invoked on the
  26379. * leading and/or trailing edge of the `wait` timeout. The `func` is invoked
  26380. * with the last arguments provided to the debounced function. Subsequent
  26381. * calls to the debounced function return the result of the last `func`
  26382. * invocation.
  26383. *
  26384. * **Note:** If `leading` and `trailing` options are `true`, `func` is
  26385. * invoked on the trailing edge of the timeout only if the debounced function
  26386. * is invoked more than once during the `wait` timeout.
  26387. *
  26388. * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
  26389. * until to the next tick, similar to `setTimeout` with a timeout of `0`.
  26390. *
  26391. * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
  26392. * for details over the differences between `_.debounce` and `_.throttle`.
  26393. *
  26394. * @static
  26395. * @memberOf _
  26396. * @since 0.1.0
  26397. * @category Function
  26398. * @param {Function} func The function to debounce.
  26399. * @param {number} [wait=0] The number of milliseconds to delay.
  26400. * @param {Object} [options={}] The options object.
  26401. * @param {boolean} [options.leading=false]
  26402. * Specify invoking on the leading edge of the timeout.
  26403. * @param {number} [options.maxWait]
  26404. * The maximum time `func` is allowed to be delayed before it's invoked.
  26405. * @param {boolean} [options.trailing=true]
  26406. * Specify invoking on the trailing edge of the timeout.
  26407. * @returns {Function} Returns the new debounced function.
  26408. * @example
  26409. *
  26410. * // Avoid costly calculations while the window size is in flux.
  26411. * jQuery(window).on('resize', _.debounce(calculateLayout, 150));
  26412. *
  26413. * // Invoke `sendMail` when clicked, debouncing subsequent calls.
  26414. * jQuery(element).on('click', _.debounce(sendMail, 300, {
  26415. * 'leading': true,
  26416. * 'trailing': false
  26417. * }));
  26418. *
  26419. * // Ensure `batchLog` is invoked once after 1 second of debounced calls.
  26420. * var debounced = _.debounce(batchLog, 250, { 'maxWait': 1000 });
  26421. * var source = new EventSource('/stream');
  26422. * jQuery(source).on('message', debounced);
  26423. *
  26424. * // Cancel the trailing debounced invocation.
  26425. * jQuery(window).on('popstate', debounced.cancel);
  26426. */
  26427. function debounce(func, wait, options) {
  26428. var lastArgs,
  26429. lastThis,
  26430. maxWait,
  26431. result,
  26432. timerId,
  26433. lastCallTime,
  26434. lastInvokeTime = 0,
  26435. leading = false,
  26436. maxing = false,
  26437. trailing = true;
  26438. if (typeof func != 'function') {
  26439. throw new TypeError(FUNC_ERROR_TEXT);
  26440. }
  26441. wait = toNumber(wait) || 0;
  26442. if (isObject(options)) {
  26443. leading = !!options.leading;
  26444. maxing = 'maxWait' in options;
  26445. maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait;
  26446. trailing = 'trailing' in options ? !!options.trailing : trailing;
  26447. }
  26448. function invokeFunc(time) {
  26449. var args = lastArgs,
  26450. thisArg = lastThis;
  26451. lastArgs = lastThis = undefined;
  26452. lastInvokeTime = time;
  26453. result = func.apply(thisArg, args);
  26454. return result;
  26455. }
  26456. function leadingEdge(time) {
  26457. // Reset any `maxWait` timer.
  26458. lastInvokeTime = time;
  26459. // Start the timer for the trailing edge.
  26460. timerId = setTimeout(timerExpired, wait);
  26461. // Invoke the leading edge.
  26462. return leading ? invokeFunc(time) : result;
  26463. }
  26464. function remainingWait(time) {
  26465. var timeSinceLastCall = time - lastCallTime,
  26466. timeSinceLastInvoke = time - lastInvokeTime,
  26467. timeWaiting = wait - timeSinceLastCall;
  26468. return maxing
  26469. ? nativeMin(timeWaiting, maxWait - timeSinceLastInvoke)
  26470. : timeWaiting;
  26471. }
  26472. function shouldInvoke(time) {
  26473. var timeSinceLastCall = time - lastCallTime,
  26474. timeSinceLastInvoke = time - lastInvokeTime;
  26475. // Either this is the first call, activity has stopped and we're at the
  26476. // trailing edge, the system time has gone backwards and we're treating
  26477. // it as the trailing edge, or we've hit the `maxWait` limit.
  26478. return (lastCallTime === undefined || (timeSinceLastCall >= wait) ||
  26479. (timeSinceLastCall < 0) || (maxing && timeSinceLastInvoke >= maxWait));
  26480. }
  26481. function timerExpired() {
  26482. var time = now();
  26483. if (shouldInvoke(time)) {
  26484. return trailingEdge(time);
  26485. }
  26486. // Restart the timer.
  26487. timerId = setTimeout(timerExpired, remainingWait(time));
  26488. }
  26489. function trailingEdge(time) {
  26490. timerId = undefined;
  26491. // Only invoke if we have `lastArgs` which means `func` has been
  26492. // debounced at least once.
  26493. if (trailing && lastArgs) {
  26494. return invokeFunc(time);
  26495. }
  26496. lastArgs = lastThis = undefined;
  26497. return result;
  26498. }
  26499. function cancel() {
  26500. if (timerId !== undefined) {
  26501. clearTimeout(timerId);
  26502. }
  26503. lastInvokeTime = 0;
  26504. lastArgs = lastCallTime = lastThis = timerId = undefined;
  26505. }
  26506. function flush() {
  26507. return timerId === undefined ? result : trailingEdge(now());
  26508. }
  26509. function debounced() {
  26510. var time = now(),
  26511. isInvoking = shouldInvoke(time);
  26512. lastArgs = arguments;
  26513. lastThis = this;
  26514. lastCallTime = time;
  26515. if (isInvoking) {
  26516. if (timerId === undefined) {
  26517. return leadingEdge(lastCallTime);
  26518. }
  26519. if (maxing) {
  26520. // Handle invocations in a tight loop.
  26521. clearTimeout(timerId);
  26522. timerId = setTimeout(timerExpired, wait);
  26523. return invokeFunc(lastCallTime);
  26524. }
  26525. }
  26526. if (timerId === undefined) {
  26527. timerId = setTimeout(timerExpired, wait);
  26528. }
  26529. return result;
  26530. }
  26531. debounced.cancel = cancel;
  26532. debounced.flush = flush;
  26533. return debounced;
  26534. }
  26535. /**
  26536. * Defers invoking the `func` until the current call stack has cleared. Any
  26537. * additional arguments are provided to `func` when it's invoked.
  26538. *
  26539. * @static
  26540. * @memberOf _
  26541. * @since 0.1.0
  26542. * @category Function
  26543. * @param {Function} func The function to defer.
  26544. * @param {...*} [args] The arguments to invoke `func` with.
  26545. * @returns {number} Returns the timer id.
  26546. * @example
  26547. *
  26548. * _.defer(function(text) {
  26549. * console.log(text);
  26550. * }, 'deferred');
  26551. * // => Logs 'deferred' after one millisecond.
  26552. */
  26553. var defer = baseRest(function(func, args) {
  26554. return baseDelay(func, 1, args);
  26555. });
  26556. /**
  26557. * Invokes `func` after `wait` milliseconds. Any additional arguments are
  26558. * provided to `func` when it's invoked.
  26559. *
  26560. * @static
  26561. * @memberOf _
  26562. * @since 0.1.0
  26563. * @category Function
  26564. * @param {Function} func The function to delay.
  26565. * @param {number} wait The number of milliseconds to delay invocation.
  26566. * @param {...*} [args] The arguments to invoke `func` with.
  26567. * @returns {number} Returns the timer id.
  26568. * @example
  26569. *
  26570. * _.delay(function(text) {
  26571. * console.log(text);
  26572. * }, 1000, 'later');
  26573. * // => Logs 'later' after one second.
  26574. */
  26575. var delay = baseRest(function(func, wait, args) {
  26576. return baseDelay(func, toNumber(wait) || 0, args);
  26577. });
  26578. /**
  26579. * Creates a function that invokes `func` with arguments reversed.
  26580. *
  26581. * @static
  26582. * @memberOf _
  26583. * @since 4.0.0
  26584. * @category Function
  26585. * @param {Function} func The function to flip arguments for.
  26586. * @returns {Function} Returns the new flipped function.
  26587. * @example
  26588. *
  26589. * var flipped = _.flip(function() {
  26590. * return _.toArray(arguments);
  26591. * });
  26592. *
  26593. * flipped('a', 'b', 'c', 'd');
  26594. * // => ['d', 'c', 'b', 'a']
  26595. */
  26596. function flip(func) {
  26597. return createWrap(func, WRAP_FLIP_FLAG);
  26598. }
  26599. /**
  26600. * Creates a function that memoizes the result of `func`. If `resolver` is
  26601. * provided, it determines the cache key for storing the result based on the
  26602. * arguments provided to the memoized function. By default, the first argument
  26603. * provided to the memoized function is used as the map cache key. The `func`
  26604. * is invoked with the `this` binding of the memoized function.
  26605. *
  26606. * **Note:** The cache is exposed as the `cache` property on the memoized
  26607. * function. Its creation may be customized by replacing the `_.memoize.Cache`
  26608. * constructor with one whose instances implement the
  26609. * [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object)
  26610. * method interface of `clear`, `delete`, `get`, `has`, and `set`.
  26611. *
  26612. * @static
  26613. * @memberOf _
  26614. * @since 0.1.0
  26615. * @category Function
  26616. * @param {Function} func The function to have its output memoized.
  26617. * @param {Function} [resolver] The function to resolve the cache key.
  26618. * @returns {Function} Returns the new memoized function.
  26619. * @example
  26620. *
  26621. * var object = { 'a': 1, 'b': 2 };
  26622. * var other = { 'c': 3, 'd': 4 };
  26623. *
  26624. * var values = _.memoize(_.values);
  26625. * values(object);
  26626. * // => [1, 2]
  26627. *
  26628. * values(other);
  26629. * // => [3, 4]
  26630. *
  26631. * object.a = 2;
  26632. * values(object);
  26633. * // => [1, 2]
  26634. *
  26635. * // Modify the result cache.
  26636. * values.cache.set(object, ['a', 'b']);
  26637. * values(object);
  26638. * // => ['a', 'b']
  26639. *
  26640. * // Replace `_.memoize.Cache`.
  26641. * _.memoize.Cache = WeakMap;
  26642. */
  26643. function memoize(func, resolver) {
  26644. if (typeof func != 'function' || (resolver != null && typeof resolver != 'function')) {
  26645. throw new TypeError(FUNC_ERROR_TEXT);
  26646. }
  26647. var memoized = function() {
  26648. var args = arguments,
  26649. key = resolver ? resolver.apply(this, args) : args[0],
  26650. cache = memoized.cache;
  26651. if (cache.has(key)) {
  26652. return cache.get(key);
  26653. }
  26654. var result = func.apply(this, args);
  26655. memoized.cache = cache.set(key, result) || cache;
  26656. return result;
  26657. };
  26658. memoized.cache = new (memoize.Cache || MapCache);
  26659. return memoized;
  26660. }
  26661. // Expose `MapCache`.
  26662. memoize.Cache = MapCache;
  26663. /**
  26664. * Creates a function that negates the result of the predicate `func`. The
  26665. * `func` predicate is invoked with the `this` binding and arguments of the
  26666. * created function.
  26667. *
  26668. * @static
  26669. * @memberOf _
  26670. * @since 3.0.0
  26671. * @category Function
  26672. * @param {Function} predicate The predicate to negate.
  26673. * @returns {Function} Returns the new negated function.
  26674. * @example
  26675. *
  26676. * function isEven(n) {
  26677. * return n % 2 == 0;
  26678. * }
  26679. *
  26680. * _.filter([1, 2, 3, 4, 5, 6], _.negate(isEven));
  26681. * // => [1, 3, 5]
  26682. */
  26683. function negate(predicate) {
  26684. if (typeof predicate != 'function') {
  26685. throw new TypeError(FUNC_ERROR_TEXT);
  26686. }
  26687. return function() {
  26688. var args = arguments;
  26689. switch (args.length) {
  26690. case 0: return !predicate.call(this);
  26691. case 1: return !predicate.call(this, args[0]);
  26692. case 2: return !predicate.call(this, args[0], args[1]);
  26693. case 3: return !predicate.call(this, args[0], args[1], args[2]);
  26694. }
  26695. return !predicate.apply(this, args);
  26696. };
  26697. }
  26698. /**
  26699. * Creates a function that is restricted to invoking `func` once. Repeat calls
  26700. * to the function return the value of the first invocation. The `func` is
  26701. * invoked with the `this` binding and arguments of the created function.
  26702. *
  26703. * @static
  26704. * @memberOf _
  26705. * @since 0.1.0
  26706. * @category Function
  26707. * @param {Function} func The function to restrict.
  26708. * @returns {Function} Returns the new restricted function.
  26709. * @example
  26710. *
  26711. * var initialize = _.once(createApplication);
  26712. * initialize();
  26713. * initialize();
  26714. * // => `createApplication` is invoked once
  26715. */
  26716. function once(func) {
  26717. return before(2, func);
  26718. }
  26719. /**
  26720. * Creates a function that invokes `func` with its arguments transformed.
  26721. *
  26722. * @static
  26723. * @since 4.0.0
  26724. * @memberOf _
  26725. * @category Function
  26726. * @param {Function} func The function to wrap.
  26727. * @param {...(Function|Function[])} [transforms=[_.identity]]
  26728. * The argument transforms.
  26729. * @returns {Function} Returns the new function.
  26730. * @example
  26731. *
  26732. * function doubled(n) {
  26733. * return n * 2;
  26734. * }
  26735. *
  26736. * function square(n) {
  26737. * return n * n;
  26738. * }
  26739. *
  26740. * var func = _.overArgs(function(x, y) {
  26741. * return [x, y];
  26742. * }, [square, doubled]);
  26743. *
  26744. * func(9, 3);
  26745. * // => [81, 6]
  26746. *
  26747. * func(10, 5);
  26748. * // => [100, 10]
  26749. */
  26750. var overArgs = castRest(function(func, transforms) {
  26751. transforms = (transforms.length == 1 && isArray(transforms[0]))
  26752. ? arrayMap(transforms[0], baseUnary(getIteratee()))
  26753. : arrayMap(baseFlatten(transforms, 1), baseUnary(getIteratee()));
  26754. var funcsLength = transforms.length;
  26755. return baseRest(function(args) {
  26756. var index = -1,
  26757. length = nativeMin(args.length, funcsLength);
  26758. while (++index < length) {
  26759. args[index] = transforms[index].call(this, args[index]);
  26760. }
  26761. return apply(func, this, args);
  26762. });
  26763. });
  26764. /**
  26765. * Creates a function that invokes `func` with `partials` prepended to the
  26766. * arguments it receives. This method is like `_.bind` except it does **not**
  26767. * alter the `this` binding.
  26768. *
  26769. * The `_.partial.placeholder` value, which defaults to `_` in monolithic
  26770. * builds, may be used as a placeholder for partially applied arguments.
  26771. *
  26772. * **Note:** This method doesn't set the "length" property of partially
  26773. * applied functions.
  26774. *
  26775. * @static
  26776. * @memberOf _
  26777. * @since 0.2.0
  26778. * @category Function
  26779. * @param {Function} func The function to partially apply arguments to.
  26780. * @param {...*} [partials] The arguments to be partially applied.
  26781. * @returns {Function} Returns the new partially applied function.
  26782. * @example
  26783. *
  26784. * function greet(greeting, name) {
  26785. * return greeting + ' ' + name;
  26786. * }
  26787. *
  26788. * var sayHelloTo = _.partial(greet, 'hello');
  26789. * sayHelloTo('fred');
  26790. * // => 'hello fred'
  26791. *
  26792. * // Partially applied with placeholders.
  26793. * var greetFred = _.partial(greet, _, 'fred');
  26794. * greetFred('hi');
  26795. * // => 'hi fred'
  26796. */
  26797. var partial = baseRest(function(func, partials) {
  26798. var holders = replaceHolders(partials, getHolder(partial));
  26799. return createWrap(func, WRAP_PARTIAL_FLAG, undefined, partials, holders);
  26800. });
  26801. /**
  26802. * This method is like `_.partial` except that partially applied arguments
  26803. * are appended to the arguments it receives.
  26804. *
  26805. * The `_.partialRight.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 1.0.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 greetFred = _.partialRight(greet, 'fred');
  26825. * greetFred('hi');
  26826. * // => 'hi fred'
  26827. *
  26828. * // Partially applied with placeholders.
  26829. * var sayHelloTo = _.partialRight(greet, 'hello', _);
  26830. * sayHelloTo('fred');
  26831. * // => 'hello fred'
  26832. */
  26833. var partialRight = baseRest(function(func, partials) {
  26834. var holders = replaceHolders(partials, getHolder(partialRight));
  26835. return createWrap(func, WRAP_PARTIAL_RIGHT_FLAG, undefined, partials, holders);
  26836. });
  26837. /**
  26838. * Creates a function that invokes `func` with arguments arranged according
  26839. * to the specified `indexes` where the argument value at the first index is
  26840. * provided as the first argument, the argument value at the second index is
  26841. * provided as the second argument, and so on.
  26842. *
  26843. * @static
  26844. * @memberOf _
  26845. * @since 3.0.0
  26846. * @category Function
  26847. * @param {Function} func The function to rearrange arguments for.
  26848. * @param {...(number|number[])} indexes The arranged argument indexes.
  26849. * @returns {Function} Returns the new function.
  26850. * @example
  26851. *
  26852. * var rearged = _.rearg(function(a, b, c) {
  26853. * return [a, b, c];
  26854. * }, [2, 0, 1]);
  26855. *
  26856. * rearged('b', 'c', 'a')
  26857. * // => ['a', 'b', 'c']
  26858. */
  26859. var rearg = flatRest(function(func, indexes) {
  26860. return createWrap(func, WRAP_REARG_FLAG, undefined, undefined, undefined, indexes);
  26861. });
  26862. /**
  26863. * Creates a function that invokes `func` with the `this` binding of the
  26864. * created function and arguments from `start` and beyond provided as
  26865. * an array.
  26866. *
  26867. * **Note:** This method is based on the
  26868. * [rest parameter](https://mdn.io/rest_parameters).
  26869. *
  26870. * @static
  26871. * @memberOf _
  26872. * @since 4.0.0
  26873. * @category Function
  26874. * @param {Function} func The function to apply a rest parameter to.
  26875. * @param {number} [start=func.length-1] The start position of the rest parameter.
  26876. * @returns {Function} Returns the new function.
  26877. * @example
  26878. *
  26879. * var say = _.rest(function(what, names) {
  26880. * return what + ' ' + _.initial(names).join(', ') +
  26881. * (_.size(names) > 1 ? ', & ' : '') + _.last(names);
  26882. * });
  26883. *
  26884. * say('hello', 'fred', 'barney', 'pebbles');
  26885. * // => 'hello fred, barney, & pebbles'
  26886. */
  26887. function rest(func, start) {
  26888. if (typeof func != 'function') {
  26889. throw new TypeError(FUNC_ERROR_TEXT);
  26890. }
  26891. start = start === undefined ? start : toInteger(start);
  26892. return baseRest(func, start);
  26893. }
  26894. /**
  26895. * Creates a function that invokes `func` with the `this` binding of the
  26896. * create function and an array of arguments much like
  26897. * [`Function#apply`](http://www.ecma-international.org/ecma-262/7.0/#sec-function.prototype.apply).
  26898. *
  26899. * **Note:** This method is based on the
  26900. * [spread operator](https://mdn.io/spread_operator).
  26901. *
  26902. * @static
  26903. * @memberOf _
  26904. * @since 3.2.0
  26905. * @category Function
  26906. * @param {Function} func The function to spread arguments over.
  26907. * @param {number} [start=0] The start position of the spread.
  26908. * @returns {Function} Returns the new function.
  26909. * @example
  26910. *
  26911. * var say = _.spread(function(who, what) {
  26912. * return who + ' says ' + what;
  26913. * });
  26914. *
  26915. * say(['fred', 'hello']);
  26916. * // => 'fred says hello'
  26917. *
  26918. * var numbers = Promise.all([
  26919. * Promise.resolve(40),
  26920. * Promise.resolve(36)
  26921. * ]);
  26922. *
  26923. * numbers.then(_.spread(function(x, y) {
  26924. * return x + y;
  26925. * }));
  26926. * // => a Promise of 76
  26927. */
  26928. function spread(func, start) {
  26929. if (typeof func != 'function') {
  26930. throw new TypeError(FUNC_ERROR_TEXT);
  26931. }
  26932. start = start == null ? 0 : nativeMax(toInteger(start), 0);
  26933. return baseRest(function(args) {
  26934. var array = args[start],
  26935. otherArgs = castSlice(args, 0, start);
  26936. if (array) {
  26937. arrayPush(otherArgs, array);
  26938. }
  26939. return apply(func, this, otherArgs);
  26940. });
  26941. }
  26942. /**
  26943. * Creates a throttled function that only invokes `func` at most once per
  26944. * every `wait` milliseconds. The throttled function comes with a `cancel`
  26945. * method to cancel delayed `func` invocations and a `flush` method to
  26946. * immediately invoke them. Provide `options` to indicate whether `func`
  26947. * should be invoked on the leading and/or trailing edge of the `wait`
  26948. * timeout. The `func` is invoked with the last arguments provided to the
  26949. * throttled function. Subsequent calls to the throttled function return the
  26950. * result of the last `func` invocation.
  26951. *
  26952. * **Note:** If `leading` and `trailing` options are `true`, `func` is
  26953. * invoked on the trailing edge of the timeout only if the throttled function
  26954. * is invoked more than once during the `wait` timeout.
  26955. *
  26956. * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
  26957. * until to the next tick, similar to `setTimeout` with a timeout of `0`.
  26958. *
  26959. * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
  26960. * for details over the differences between `_.throttle` and `_.debounce`.
  26961. *
  26962. * @static
  26963. * @memberOf _
  26964. * @since 0.1.0
  26965. * @category Function
  26966. * @param {Function} func The function to throttle.
  26967. * @param {number} [wait=0] The number of milliseconds to throttle invocations to.
  26968. * @param {Object} [options={}] The options object.
  26969. * @param {boolean} [options.leading=true]
  26970. * Specify invoking on the leading edge of the timeout.
  26971. * @param {boolean} [options.trailing=true]
  26972. * Specify invoking on the trailing edge of the timeout.
  26973. * @returns {Function} Returns the new throttled function.
  26974. * @example
  26975. *
  26976. * // Avoid excessively updating the position while scrolling.
  26977. * jQuery(window).on('scroll', _.throttle(updatePosition, 100));
  26978. *
  26979. * // Invoke `renewToken` when the click event is fired, but not more than once every 5 minutes.
  26980. * var throttled = _.throttle(renewToken, 300000, { 'trailing': false });
  26981. * jQuery(element).on('click', throttled);
  26982. *
  26983. * // Cancel the trailing throttled invocation.
  26984. * jQuery(window).on('popstate', throttled.cancel);
  26985. */
  26986. function throttle(func, wait, options) {
  26987. var leading = true,
  26988. trailing = true;
  26989. if (typeof func != 'function') {
  26990. throw new TypeError(FUNC_ERROR_TEXT);
  26991. }
  26992. if (isObject(options)) {
  26993. leading = 'leading' in options ? !!options.leading : leading;
  26994. trailing = 'trailing' in options ? !!options.trailing : trailing;
  26995. }
  26996. return debounce(func, wait, {
  26997. 'leading': leading,
  26998. 'maxWait': wait,
  26999. 'trailing': trailing
  27000. });
  27001. }
  27002. /**
  27003. * Creates a function that accepts up to one argument, ignoring any
  27004. * additional arguments.
  27005. *
  27006. * @static
  27007. * @memberOf _
  27008. * @since 4.0.0
  27009. * @category Function
  27010. * @param {Function} func The function to cap arguments for.
  27011. * @returns {Function} Returns the new capped function.
  27012. * @example
  27013. *
  27014. * _.map(['6', '8', '10'], _.unary(parseInt));
  27015. * // => [6, 8, 10]
  27016. */
  27017. function unary(func) {
  27018. return ary(func, 1);
  27019. }
  27020. /**
  27021. * Creates a function that provides `value` to `wrapper` as its first
  27022. * argument. Any additional arguments provided to the function are appended
  27023. * to those provided to the `wrapper`. The wrapper is invoked with the `this`
  27024. * binding of the created function.
  27025. *
  27026. * @static
  27027. * @memberOf _
  27028. * @since 0.1.0
  27029. * @category Function
  27030. * @param {*} value The value to wrap.
  27031. * @param {Function} [wrapper=identity] The wrapper function.
  27032. * @returns {Function} Returns the new function.
  27033. * @example
  27034. *
  27035. * var p = _.wrap(_.escape, function(func, text) {
  27036. * return '<p>' + func(text) + '</p>';
  27037. * });
  27038. *
  27039. * p('fred, barney, & pebbles');
  27040. * // => '<p>fred, barney, &amp; pebbles</p>'
  27041. */
  27042. function wrap(value, wrapper) {
  27043. return partial(castFunction(wrapper), value);
  27044. }
  27045. /*------------------------------------------------------------------------*/
  27046. /**
  27047. * Casts `value` as an array if it's not one.
  27048. *
  27049. * @static
  27050. * @memberOf _
  27051. * @since 4.4.0
  27052. * @category Lang
  27053. * @param {*} value The value to inspect.
  27054. * @returns {Array} Returns the cast array.
  27055. * @example
  27056. *
  27057. * _.castArray(1);
  27058. * // => [1]
  27059. *
  27060. * _.castArray({ 'a': 1 });
  27061. * // => [{ 'a': 1 }]
  27062. *
  27063. * _.castArray('abc');
  27064. * // => ['abc']
  27065. *
  27066. * _.castArray(null);
  27067. * // => [null]
  27068. *
  27069. * _.castArray(undefined);
  27070. * // => [undefined]
  27071. *
  27072. * _.castArray();
  27073. * // => []
  27074. *
  27075. * var array = [1, 2, 3];
  27076. * console.log(_.castArray(array) === array);
  27077. * // => true
  27078. */
  27079. function castArray() {
  27080. if (!arguments.length) {
  27081. return [];
  27082. }
  27083. var value = arguments[0];
  27084. return isArray(value) ? value : [value];
  27085. }
  27086. /**
  27087. * Creates a shallow clone of `value`.
  27088. *
  27089. * **Note:** This method is loosely based on the
  27090. * [structured clone algorithm](https://mdn.io/Structured_clone_algorithm)
  27091. * and supports cloning arrays, array buffers, booleans, date objects, maps,
  27092. * numbers, `Object` objects, regexes, sets, strings, symbols, and typed
  27093. * arrays. The own enumerable properties of `arguments` objects are cloned
  27094. * as plain objects. An empty object is returned for uncloneable values such
  27095. * as error objects, functions, DOM nodes, and WeakMaps.
  27096. *
  27097. * @static
  27098. * @memberOf _
  27099. * @since 0.1.0
  27100. * @category Lang
  27101. * @param {*} value The value to clone.
  27102. * @returns {*} Returns the cloned value.
  27103. * @see _.cloneDeep
  27104. * @example
  27105. *
  27106. * var objects = [{ 'a': 1 }, { 'b': 2 }];
  27107. *
  27108. * var shallow = _.clone(objects);
  27109. * console.log(shallow[0] === objects[0]);
  27110. * // => true
  27111. */
  27112. function clone(value) {
  27113. return baseClone(value, CLONE_SYMBOLS_FLAG);
  27114. }
  27115. /**
  27116. * This method is like `_.clone` except that it accepts `customizer` which
  27117. * is invoked to produce the cloned value. If `customizer` returns `undefined`,
  27118. * cloning is handled by the method instead. The `customizer` is invoked with
  27119. * up to four arguments; (value [, index|key, object, stack]).
  27120. *
  27121. * @static
  27122. * @memberOf _
  27123. * @since 4.0.0
  27124. * @category Lang
  27125. * @param {*} value The value to clone.
  27126. * @param {Function} [customizer] The function to customize cloning.
  27127. * @returns {*} Returns the cloned value.
  27128. * @see _.cloneDeepWith
  27129. * @example
  27130. *
  27131. * function customizer(value) {
  27132. * if (_.isElement(value)) {
  27133. * return value.cloneNode(false);
  27134. * }
  27135. * }
  27136. *
  27137. * var el = _.cloneWith(document.body, customizer);
  27138. *
  27139. * console.log(el === document.body);
  27140. * // => false
  27141. * console.log(el.nodeName);
  27142. * // => 'BODY'
  27143. * console.log(el.childNodes.length);
  27144. * // => 0
  27145. */
  27146. function cloneWith(value, customizer) {
  27147. customizer = typeof customizer == 'function' ? customizer : undefined;
  27148. return baseClone(value, CLONE_SYMBOLS_FLAG, customizer);
  27149. }
  27150. /**
  27151. * This method is like `_.clone` except that it recursively clones `value`.
  27152. *
  27153. * @static
  27154. * @memberOf _
  27155. * @since 1.0.0
  27156. * @category Lang
  27157. * @param {*} value The value to recursively clone.
  27158. * @returns {*} Returns the deep cloned value.
  27159. * @see _.clone
  27160. * @example
  27161. *
  27162. * var objects = [{ 'a': 1 }, { 'b': 2 }];
  27163. *
  27164. * var deep = _.cloneDeep(objects);
  27165. * console.log(deep[0] === objects[0]);
  27166. * // => false
  27167. */
  27168. function cloneDeep(value) {
  27169. return baseClone(value, CLONE_DEEP_FLAG | CLONE_SYMBOLS_FLAG);
  27170. }
  27171. /**
  27172. * This method is like `_.cloneWith` except that it recursively clones `value`.
  27173. *
  27174. * @static
  27175. * @memberOf _
  27176. * @since 4.0.0
  27177. * @category Lang
  27178. * @param {*} value The value to recursively clone.
  27179. * @param {Function} [customizer] The function to customize cloning.
  27180. * @returns {*} Returns the deep cloned value.
  27181. * @see _.cloneWith
  27182. * @example
  27183. *
  27184. * function customizer(value) {
  27185. * if (_.isElement(value)) {
  27186. * return value.cloneNode(true);
  27187. * }
  27188. * }
  27189. *
  27190. * var el = _.cloneDeepWith(document.body, customizer);
  27191. *
  27192. * console.log(el === document.body);
  27193. * // => false
  27194. * console.log(el.nodeName);
  27195. * // => 'BODY'
  27196. * console.log(el.childNodes.length);
  27197. * // => 20
  27198. */
  27199. function cloneDeepWith(value, customizer) {
  27200. customizer = typeof customizer == 'function' ? customizer : undefined;
  27201. return baseClone(value, CLONE_DEEP_FLAG | CLONE_SYMBOLS_FLAG, customizer);
  27202. }
  27203. /**
  27204. * Checks if `object` conforms to `source` by invoking the predicate
  27205. * properties of `source` with the corresponding property values of `object`.
  27206. *
  27207. * **Note:** This method is equivalent to `_.conforms` when `source` is
  27208. * partially applied.
  27209. *
  27210. * @static
  27211. * @memberOf _
  27212. * @since 4.14.0
  27213. * @category Lang
  27214. * @param {Object} object The object to inspect.
  27215. * @param {Object} source The object of property predicates to conform to.
  27216. * @returns {boolean} Returns `true` if `object` conforms, else `false`.
  27217. * @example
  27218. *
  27219. * var object = { 'a': 1, 'b': 2 };
  27220. *
  27221. * _.conformsTo(object, { 'b': function(n) { return n > 1; } });
  27222. * // => true
  27223. *
  27224. * _.conformsTo(object, { 'b': function(n) { return n > 2; } });
  27225. * // => false
  27226. */
  27227. function conformsTo(object, source) {
  27228. return source == null || baseConformsTo(object, source, keys(source));
  27229. }
  27230. /**
  27231. * Performs a
  27232. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  27233. * comparison between two values to determine if they are equivalent.
  27234. *
  27235. * @static
  27236. * @memberOf _
  27237. * @since 4.0.0
  27238. * @category Lang
  27239. * @param {*} value The value to compare.
  27240. * @param {*} other The other value to compare.
  27241. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  27242. * @example
  27243. *
  27244. * var object = { 'a': 1 };
  27245. * var other = { 'a': 1 };
  27246. *
  27247. * _.eq(object, object);
  27248. * // => true
  27249. *
  27250. * _.eq(object, other);
  27251. * // => false
  27252. *
  27253. * _.eq('a', 'a');
  27254. * // => true
  27255. *
  27256. * _.eq('a', Object('a'));
  27257. * // => false
  27258. *
  27259. * _.eq(NaN, NaN);
  27260. * // => true
  27261. */
  27262. function eq(value, other) {
  27263. return value === other || (value !== value && other !== other);
  27264. }
  27265. /**
  27266. * Checks if `value` is greater than `other`.
  27267. *
  27268. * @static
  27269. * @memberOf _
  27270. * @since 3.9.0
  27271. * @category Lang
  27272. * @param {*} value The value to compare.
  27273. * @param {*} other The other value to compare.
  27274. * @returns {boolean} Returns `true` if `value` is greater than `other`,
  27275. * else `false`.
  27276. * @see _.lt
  27277. * @example
  27278. *
  27279. * _.gt(3, 1);
  27280. * // => true
  27281. *
  27282. * _.gt(3, 3);
  27283. * // => false
  27284. *
  27285. * _.gt(1, 3);
  27286. * // => false
  27287. */
  27288. var gt = createRelationalOperation(baseGt);
  27289. /**
  27290. * Checks if `value` is greater than or equal to `other`.
  27291. *
  27292. * @static
  27293. * @memberOf _
  27294. * @since 3.9.0
  27295. * @category Lang
  27296. * @param {*} value The value to compare.
  27297. * @param {*} other The other value to compare.
  27298. * @returns {boolean} Returns `true` if `value` is greater than or equal to
  27299. * `other`, else `false`.
  27300. * @see _.lte
  27301. * @example
  27302. *
  27303. * _.gte(3, 1);
  27304. * // => true
  27305. *
  27306. * _.gte(3, 3);
  27307. * // => true
  27308. *
  27309. * _.gte(1, 3);
  27310. * // => false
  27311. */
  27312. var gte = createRelationalOperation(function(value, other) {
  27313. return value >= other;
  27314. });
  27315. /**
  27316. * Checks if `value` is likely an `arguments` object.
  27317. *
  27318. * @static
  27319. * @memberOf _
  27320. * @since 0.1.0
  27321. * @category Lang
  27322. * @param {*} value The value to check.
  27323. * @returns {boolean} Returns `true` if `value` is an `arguments` object,
  27324. * else `false`.
  27325. * @example
  27326. *
  27327. * _.isArguments(function() { return arguments; }());
  27328. * // => true
  27329. *
  27330. * _.isArguments([1, 2, 3]);
  27331. * // => false
  27332. */
  27333. var isArguments = baseIsArguments(function() { return arguments; }()) ? baseIsArguments : function(value) {
  27334. return isObjectLike(value) && hasOwnProperty.call(value, 'callee') &&
  27335. !propertyIsEnumerable.call(value, 'callee');
  27336. };
  27337. /**
  27338. * Checks if `value` is classified as an `Array` object.
  27339. *
  27340. * @static
  27341. * @memberOf _
  27342. * @since 0.1.0
  27343. * @category Lang
  27344. * @param {*} value The value to check.
  27345. * @returns {boolean} Returns `true` if `value` is an array, else `false`.
  27346. * @example
  27347. *
  27348. * _.isArray([1, 2, 3]);
  27349. * // => true
  27350. *
  27351. * _.isArray(document.body.children);
  27352. * // => false
  27353. *
  27354. * _.isArray('abc');
  27355. * // => false
  27356. *
  27357. * _.isArray(_.noop);
  27358. * // => false
  27359. */
  27360. var isArray = Array.isArray;
  27361. /**
  27362. * Checks if `value` is classified as an `ArrayBuffer` object.
  27363. *
  27364. * @static
  27365. * @memberOf _
  27366. * @since 4.3.0
  27367. * @category Lang
  27368. * @param {*} value The value to check.
  27369. * @returns {boolean} Returns `true` if `value` is an array buffer, else `false`.
  27370. * @example
  27371. *
  27372. * _.isArrayBuffer(new ArrayBuffer(2));
  27373. * // => true
  27374. *
  27375. * _.isArrayBuffer(new Array(2));
  27376. * // => false
  27377. */
  27378. var isArrayBuffer = nodeIsArrayBuffer ? baseUnary(nodeIsArrayBuffer) : baseIsArrayBuffer;
  27379. /**
  27380. * Checks if `value` is array-like. A value is considered array-like if it's
  27381. * not a function and has a `value.length` that's an integer greater than or
  27382. * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
  27383. *
  27384. * @static
  27385. * @memberOf _
  27386. * @since 4.0.0
  27387. * @category Lang
  27388. * @param {*} value The value to check.
  27389. * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
  27390. * @example
  27391. *
  27392. * _.isArrayLike([1, 2, 3]);
  27393. * // => true
  27394. *
  27395. * _.isArrayLike(document.body.children);
  27396. * // => true
  27397. *
  27398. * _.isArrayLike('abc');
  27399. * // => true
  27400. *
  27401. * _.isArrayLike(_.noop);
  27402. * // => false
  27403. */
  27404. function isArrayLike(value) {
  27405. return value != null && isLength(value.length) && !isFunction(value);
  27406. }
  27407. /**
  27408. * This method is like `_.isArrayLike` except that it also checks if `value`
  27409. * is an object.
  27410. *
  27411. * @static
  27412. * @memberOf _
  27413. * @since 4.0.0
  27414. * @category Lang
  27415. * @param {*} value The value to check.
  27416. * @returns {boolean} Returns `true` if `value` is an array-like object,
  27417. * else `false`.
  27418. * @example
  27419. *
  27420. * _.isArrayLikeObject([1, 2, 3]);
  27421. * // => true
  27422. *
  27423. * _.isArrayLikeObject(document.body.children);
  27424. * // => true
  27425. *
  27426. * _.isArrayLikeObject('abc');
  27427. * // => false
  27428. *
  27429. * _.isArrayLikeObject(_.noop);
  27430. * // => false
  27431. */
  27432. function isArrayLikeObject(value) {
  27433. return isObjectLike(value) && isArrayLike(value);
  27434. }
  27435. /**
  27436. * Checks if `value` is classified as a boolean primitive or object.
  27437. *
  27438. * @static
  27439. * @memberOf _
  27440. * @since 0.1.0
  27441. * @category Lang
  27442. * @param {*} value The value to check.
  27443. * @returns {boolean} Returns `true` if `value` is a boolean, else `false`.
  27444. * @example
  27445. *
  27446. * _.isBoolean(false);
  27447. * // => true
  27448. *
  27449. * _.isBoolean(null);
  27450. * // => false
  27451. */
  27452. function isBoolean(value) {
  27453. return value === true || value === false ||
  27454. (isObjectLike(value) && baseGetTag(value) == boolTag);
  27455. }
  27456. /**
  27457. * Checks if `value` is a buffer.
  27458. *
  27459. * @static
  27460. * @memberOf _
  27461. * @since 4.3.0
  27462. * @category Lang
  27463. * @param {*} value The value to check.
  27464. * @returns {boolean} Returns `true` if `value` is a buffer, else `false`.
  27465. * @example
  27466. *
  27467. * _.isBuffer(new Buffer(2));
  27468. * // => true
  27469. *
  27470. * _.isBuffer(new Uint8Array(2));
  27471. * // => false
  27472. */
  27473. var isBuffer = nativeIsBuffer || stubFalse;
  27474. /**
  27475. * Checks if `value` is classified as a `Date` object.
  27476. *
  27477. * @static
  27478. * @memberOf _
  27479. * @since 0.1.0
  27480. * @category Lang
  27481. * @param {*} value The value to check.
  27482. * @returns {boolean} Returns `true` if `value` is a date object, else `false`.
  27483. * @example
  27484. *
  27485. * _.isDate(new Date);
  27486. * // => true
  27487. *
  27488. * _.isDate('Mon April 23 2012');
  27489. * // => false
  27490. */
  27491. var isDate = nodeIsDate ? baseUnary(nodeIsDate) : baseIsDate;
  27492. /**
  27493. * Checks if `value` is likely a DOM element.
  27494. *
  27495. * @static
  27496. * @memberOf _
  27497. * @since 0.1.0
  27498. * @category Lang
  27499. * @param {*} value The value to check.
  27500. * @returns {boolean} Returns `true` if `value` is a DOM element, else `false`.
  27501. * @example
  27502. *
  27503. * _.isElement(document.body);
  27504. * // => true
  27505. *
  27506. * _.isElement('<body>');
  27507. * // => false
  27508. */
  27509. function isElement(value) {
  27510. return isObjectLike(value) && value.nodeType === 1 && !isPlainObject(value);
  27511. }
  27512. /**
  27513. * Checks if `value` is an empty object, collection, map, or set.
  27514. *
  27515. * Objects are considered empty if they have no own enumerable string keyed
  27516. * properties.
  27517. *
  27518. * Array-like values such as `arguments` objects, arrays, buffers, strings, or
  27519. * jQuery-like collections are considered empty if they have a `length` of `0`.
  27520. * Similarly, maps and sets are considered empty if they have a `size` of `0`.
  27521. *
  27522. * @static
  27523. * @memberOf _
  27524. * @since 0.1.0
  27525. * @category Lang
  27526. * @param {*} value The value to check.
  27527. * @returns {boolean} Returns `true` if `value` is empty, else `false`.
  27528. * @example
  27529. *
  27530. * _.isEmpty(null);
  27531. * // => true
  27532. *
  27533. * _.isEmpty(true);
  27534. * // => true
  27535. *
  27536. * _.isEmpty(1);
  27537. * // => true
  27538. *
  27539. * _.isEmpty([1, 2, 3]);
  27540. * // => false
  27541. *
  27542. * _.isEmpty({ 'a': 1 });
  27543. * // => false
  27544. */
  27545. function isEmpty(value) {
  27546. if (value == null) {
  27547. return true;
  27548. }
  27549. if (isArrayLike(value) &&
  27550. (isArray(value) || typeof value == 'string' || typeof value.splice == 'function' ||
  27551. isBuffer(value) || isTypedArray(value) || isArguments(value))) {
  27552. return !value.length;
  27553. }
  27554. var tag = getTag(value);
  27555. if (tag == mapTag || tag == setTag) {
  27556. return !value.size;
  27557. }
  27558. if (isPrototype(value)) {
  27559. return !baseKeys(value).length;
  27560. }
  27561. for (var key in value) {
  27562. if (hasOwnProperty.call(value, key)) {
  27563. return false;
  27564. }
  27565. }
  27566. return true;
  27567. }
  27568. /**
  27569. * Performs a deep comparison between two values to determine if they are
  27570. * equivalent.
  27571. *
  27572. * **Note:** This method supports comparing arrays, array buffers, booleans,
  27573. * date objects, error objects, maps, numbers, `Object` objects, regexes,
  27574. * sets, strings, symbols, and typed arrays. `Object` objects are compared
  27575. * by their own, not inherited, enumerable properties. Functions and DOM
  27576. * nodes are compared by strict equality, i.e. `===`.
  27577. *
  27578. * @static
  27579. * @memberOf _
  27580. * @since 0.1.0
  27581. * @category Lang
  27582. * @param {*} value The value to compare.
  27583. * @param {*} other The other value to compare.
  27584. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  27585. * @example
  27586. *
  27587. * var object = { 'a': 1 };
  27588. * var other = { 'a': 1 };
  27589. *
  27590. * _.isEqual(object, other);
  27591. * // => true
  27592. *
  27593. * object === other;
  27594. * // => false
  27595. */
  27596. function isEqual(value, other) {
  27597. return baseIsEqual(value, other);
  27598. }
  27599. /**
  27600. * This method is like `_.isEqual` except that it accepts `customizer` which
  27601. * is invoked to compare values. If `customizer` returns `undefined`, comparisons
  27602. * are handled by the method instead. The `customizer` is invoked with up to
  27603. * six arguments: (objValue, othValue [, index|key, object, other, stack]).
  27604. *
  27605. * @static
  27606. * @memberOf _
  27607. * @since 4.0.0
  27608. * @category Lang
  27609. * @param {*} value The value to compare.
  27610. * @param {*} other The other value to compare.
  27611. * @param {Function} [customizer] The function to customize comparisons.
  27612. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  27613. * @example
  27614. *
  27615. * function isGreeting(value) {
  27616. * return /^h(?:i|ello)$/.test(value);
  27617. * }
  27618. *
  27619. * function customizer(objValue, othValue) {
  27620. * if (isGreeting(objValue) && isGreeting(othValue)) {
  27621. * return true;
  27622. * }
  27623. * }
  27624. *
  27625. * var array = ['hello', 'goodbye'];
  27626. * var other = ['hi', 'goodbye'];
  27627. *
  27628. * _.isEqualWith(array, other, customizer);
  27629. * // => true
  27630. */
  27631. function isEqualWith(value, other, customizer) {
  27632. customizer = typeof customizer == 'function' ? customizer : undefined;
  27633. var result = customizer ? customizer(value, other) : undefined;
  27634. return result === undefined ? baseIsEqual(value, other, undefined, customizer) : !!result;
  27635. }
  27636. /**
  27637. * Checks if `value` is an `Error`, `EvalError`, `RangeError`, `ReferenceError`,
  27638. * `SyntaxError`, `TypeError`, or `URIError` object.
  27639. *
  27640. * @static
  27641. * @memberOf _
  27642. * @since 3.0.0
  27643. * @category Lang
  27644. * @param {*} value The value to check.
  27645. * @returns {boolean} Returns `true` if `value` is an error object, else `false`.
  27646. * @example
  27647. *
  27648. * _.isError(new Error);
  27649. * // => true
  27650. *
  27651. * _.isError(Error);
  27652. * // => false
  27653. */
  27654. function isError(value) {
  27655. if (!isObjectLike(value)) {
  27656. return false;
  27657. }
  27658. var tag = baseGetTag(value);
  27659. return tag == errorTag || tag == domExcTag ||
  27660. (typeof value.message == 'string' && typeof value.name == 'string' && !isPlainObject(value));
  27661. }
  27662. /**
  27663. * Checks if `value` is a finite primitive number.
  27664. *
  27665. * **Note:** This method is based on
  27666. * [`Number.isFinite`](https://mdn.io/Number/isFinite).
  27667. *
  27668. * @static
  27669. * @memberOf _
  27670. * @since 0.1.0
  27671. * @category Lang
  27672. * @param {*} value The value to check.
  27673. * @returns {boolean} Returns `true` if `value` is a finite number, else `false`.
  27674. * @example
  27675. *
  27676. * _.isFinite(3);
  27677. * // => true
  27678. *
  27679. * _.isFinite(Number.MIN_VALUE);
  27680. * // => true
  27681. *
  27682. * _.isFinite(Infinity);
  27683. * // => false
  27684. *
  27685. * _.isFinite('3');
  27686. * // => false
  27687. */
  27688. function isFinite(value) {
  27689. return typeof value == 'number' && nativeIsFinite(value);
  27690. }
  27691. /**
  27692. * Checks if `value` is classified as a `Function` object.
  27693. *
  27694. * @static
  27695. * @memberOf _
  27696. * @since 0.1.0
  27697. * @category Lang
  27698. * @param {*} value The value to check.
  27699. * @returns {boolean} Returns `true` if `value` is a function, else `false`.
  27700. * @example
  27701. *
  27702. * _.isFunction(_);
  27703. * // => true
  27704. *
  27705. * _.isFunction(/abc/);
  27706. * // => false
  27707. */
  27708. function isFunction(value) {
  27709. if (!isObject(value)) {
  27710. return false;
  27711. }
  27712. // The use of `Object#toString` avoids issues with the `typeof` operator
  27713. // in Safari 9 which returns 'object' for typed arrays and other constructors.
  27714. var tag = baseGetTag(value);
  27715. return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag;
  27716. }
  27717. /**
  27718. * Checks if `value` is an integer.
  27719. *
  27720. * **Note:** This method is based on
  27721. * [`Number.isInteger`](https://mdn.io/Number/isInteger).
  27722. *
  27723. * @static
  27724. * @memberOf _
  27725. * @since 4.0.0
  27726. * @category Lang
  27727. * @param {*} value The value to check.
  27728. * @returns {boolean} Returns `true` if `value` is an integer, else `false`.
  27729. * @example
  27730. *
  27731. * _.isInteger(3);
  27732. * // => true
  27733. *
  27734. * _.isInteger(Number.MIN_VALUE);
  27735. * // => false
  27736. *
  27737. * _.isInteger(Infinity);
  27738. * // => false
  27739. *
  27740. * _.isInteger('3');
  27741. * // => false
  27742. */
  27743. function isInteger(value) {
  27744. return typeof value == 'number' && value == toInteger(value);
  27745. }
  27746. /**
  27747. * Checks if `value` is a valid array-like length.
  27748. *
  27749. * **Note:** This method is loosely based on
  27750. * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
  27751. *
  27752. * @static
  27753. * @memberOf _
  27754. * @since 4.0.0
  27755. * @category Lang
  27756. * @param {*} value The value to check.
  27757. * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
  27758. * @example
  27759. *
  27760. * _.isLength(3);
  27761. * // => true
  27762. *
  27763. * _.isLength(Number.MIN_VALUE);
  27764. * // => false
  27765. *
  27766. * _.isLength(Infinity);
  27767. * // => false
  27768. *
  27769. * _.isLength('3');
  27770. * // => false
  27771. */
  27772. function isLength(value) {
  27773. return typeof value == 'number' &&
  27774. value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
  27775. }
  27776. /**
  27777. * Checks if `value` is the
  27778. * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
  27779. * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
  27780. *
  27781. * @static
  27782. * @memberOf _
  27783. * @since 0.1.0
  27784. * @category Lang
  27785. * @param {*} value The value to check.
  27786. * @returns {boolean} Returns `true` if `value` is an object, else `false`.
  27787. * @example
  27788. *
  27789. * _.isObject({});
  27790. * // => true
  27791. *
  27792. * _.isObject([1, 2, 3]);
  27793. * // => true
  27794. *
  27795. * _.isObject(_.noop);
  27796. * // => true
  27797. *
  27798. * _.isObject(null);
  27799. * // => false
  27800. */
  27801. function isObject(value) {
  27802. var type = typeof value;
  27803. return value != null && (type == 'object' || type == 'function');
  27804. }
  27805. /**
  27806. * Checks if `value` is object-like. A value is object-like if it's not `null`
  27807. * and has a `typeof` result of "object".
  27808. *
  27809. * @static
  27810. * @memberOf _
  27811. * @since 4.0.0
  27812. * @category Lang
  27813. * @param {*} value The value to check.
  27814. * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
  27815. * @example
  27816. *
  27817. * _.isObjectLike({});
  27818. * // => true
  27819. *
  27820. * _.isObjectLike([1, 2, 3]);
  27821. * // => true
  27822. *
  27823. * _.isObjectLike(_.noop);
  27824. * // => false
  27825. *
  27826. * _.isObjectLike(null);
  27827. * // => false
  27828. */
  27829. function isObjectLike(value) {
  27830. return value != null && typeof value == 'object';
  27831. }
  27832. /**
  27833. * Checks if `value` is classified as a `Map` object.
  27834. *
  27835. * @static
  27836. * @memberOf _
  27837. * @since 4.3.0
  27838. * @category Lang
  27839. * @param {*} value The value to check.
  27840. * @returns {boolean} Returns `true` if `value` is a map, else `false`.
  27841. * @example
  27842. *
  27843. * _.isMap(new Map);
  27844. * // => true
  27845. *
  27846. * _.isMap(new WeakMap);
  27847. * // => false
  27848. */
  27849. var isMap = nodeIsMap ? baseUnary(nodeIsMap) : baseIsMap;
  27850. /**
  27851. * Performs a partial deep comparison between `object` and `source` to
  27852. * determine if `object` contains equivalent property values.
  27853. *
  27854. * **Note:** This method is equivalent to `_.matches` when `source` is
  27855. * partially applied.
  27856. *
  27857. * Partial comparisons will match empty array and empty object `source`
  27858. * values against any array or object value, respectively. See `_.isEqual`
  27859. * for a list of supported value comparisons.
  27860. *
  27861. * @static
  27862. * @memberOf _
  27863. * @since 3.0.0
  27864. * @category Lang
  27865. * @param {Object} object The object to inspect.
  27866. * @param {Object} source The object of property values to match.
  27867. * @returns {boolean} Returns `true` if `object` is a match, else `false`.
  27868. * @example
  27869. *
  27870. * var object = { 'a': 1, 'b': 2 };
  27871. *
  27872. * _.isMatch(object, { 'b': 2 });
  27873. * // => true
  27874. *
  27875. * _.isMatch(object, { 'b': 1 });
  27876. * // => false
  27877. */
  27878. function isMatch(object, source) {
  27879. return object === source || baseIsMatch(object, source, getMatchData(source));
  27880. }
  27881. /**
  27882. * This method is like `_.isMatch` except that it accepts `customizer` which
  27883. * is invoked to compare values. If `customizer` returns `undefined`, comparisons
  27884. * are handled by the method instead. The `customizer` is invoked with five
  27885. * arguments: (objValue, srcValue, index|key, object, source).
  27886. *
  27887. * @static
  27888. * @memberOf _
  27889. * @since 4.0.0
  27890. * @category Lang
  27891. * @param {Object} object The object to inspect.
  27892. * @param {Object} source The object of property values to match.
  27893. * @param {Function} [customizer] The function to customize comparisons.
  27894. * @returns {boolean} Returns `true` if `object` is a match, else `false`.
  27895. * @example
  27896. *
  27897. * function isGreeting(value) {
  27898. * return /^h(?:i|ello)$/.test(value);
  27899. * }
  27900. *
  27901. * function customizer(objValue, srcValue) {
  27902. * if (isGreeting(objValue) && isGreeting(srcValue)) {
  27903. * return true;
  27904. * }
  27905. * }
  27906. *
  27907. * var object = { 'greeting': 'hello' };
  27908. * var source = { 'greeting': 'hi' };
  27909. *
  27910. * _.isMatchWith(object, source, customizer);
  27911. * // => true
  27912. */
  27913. function isMatchWith(object, source, customizer) {
  27914. customizer = typeof customizer == 'function' ? customizer : undefined;
  27915. return baseIsMatch(object, source, getMatchData(source), customizer);
  27916. }
  27917. /**
  27918. * Checks if `value` is `NaN`.
  27919. *
  27920. * **Note:** This method is based on
  27921. * [`Number.isNaN`](https://mdn.io/Number/isNaN) and is not the same as
  27922. * global [`isNaN`](https://mdn.io/isNaN) which returns `true` for
  27923. * `undefined` and other non-number values.
  27924. *
  27925. * @static
  27926. * @memberOf _
  27927. * @since 0.1.0
  27928. * @category Lang
  27929. * @param {*} value The value to check.
  27930. * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`.
  27931. * @example
  27932. *
  27933. * _.isNaN(NaN);
  27934. * // => true
  27935. *
  27936. * _.isNaN(new Number(NaN));
  27937. * // => true
  27938. *
  27939. * isNaN(undefined);
  27940. * // => true
  27941. *
  27942. * _.isNaN(undefined);
  27943. * // => false
  27944. */
  27945. function isNaN(value) {
  27946. // An `NaN` primitive is the only value that is not equal to itself.
  27947. // Perform the `toStringTag` check first to avoid errors with some
  27948. // ActiveX objects in IE.
  27949. return isNumber(value) && value != +value;
  27950. }
  27951. /**
  27952. * Checks if `value` is a pristine native function.
  27953. *
  27954. * **Note:** This method can't reliably detect native functions in the presence
  27955. * of the core-js package because core-js circumvents this kind of detection.
  27956. * Despite multiple requests, the core-js maintainer has made it clear: any
  27957. * attempt to fix the detection will be obstructed. As a result, we're left
  27958. * with little choice but to throw an error. Unfortunately, this also affects
  27959. * packages, like [babel-polyfill](https://www.npmjs.com/package/babel-polyfill),
  27960. * which rely on core-js.
  27961. *
  27962. * @static
  27963. * @memberOf _
  27964. * @since 3.0.0
  27965. * @category Lang
  27966. * @param {*} value The value to check.
  27967. * @returns {boolean} Returns `true` if `value` is a native function,
  27968. * else `false`.
  27969. * @example
  27970. *
  27971. * _.isNative(Array.prototype.push);
  27972. * // => true
  27973. *
  27974. * _.isNative(_);
  27975. * // => false
  27976. */
  27977. function isNative(value) {
  27978. if (isMaskable(value)) {
  27979. throw new Error(CORE_ERROR_TEXT);
  27980. }
  27981. return baseIsNative(value);
  27982. }
  27983. /**
  27984. * Checks if `value` is `null`.
  27985. *
  27986. * @static
  27987. * @memberOf _
  27988. * @since 0.1.0
  27989. * @category Lang
  27990. * @param {*} value The value to check.
  27991. * @returns {boolean} Returns `true` if `value` is `null`, else `false`.
  27992. * @example
  27993. *
  27994. * _.isNull(null);
  27995. * // => true
  27996. *
  27997. * _.isNull(void 0);
  27998. * // => false
  27999. */
  28000. function isNull(value) {
  28001. return value === null;
  28002. }
  28003. /**
  28004. * Checks if `value` is `null` or `undefined`.
  28005. *
  28006. * @static
  28007. * @memberOf _
  28008. * @since 4.0.0
  28009. * @category Lang
  28010. * @param {*} value The value to check.
  28011. * @returns {boolean} Returns `true` if `value` is nullish, else `false`.
  28012. * @example
  28013. *
  28014. * _.isNil(null);
  28015. * // => true
  28016. *
  28017. * _.isNil(void 0);
  28018. * // => true
  28019. *
  28020. * _.isNil(NaN);
  28021. * // => false
  28022. */
  28023. function isNil(value) {
  28024. return value == null;
  28025. }
  28026. /**
  28027. * Checks if `value` is classified as a `Number` primitive or object.
  28028. *
  28029. * **Note:** To exclude `Infinity`, `-Infinity`, and `NaN`, which are
  28030. * classified as numbers, use the `_.isFinite` method.
  28031. *
  28032. * @static
  28033. * @memberOf _
  28034. * @since 0.1.0
  28035. * @category Lang
  28036. * @param {*} value The value to check.
  28037. * @returns {boolean} Returns `true` if `value` is a number, else `false`.
  28038. * @example
  28039. *
  28040. * _.isNumber(3);
  28041. * // => true
  28042. *
  28043. * _.isNumber(Number.MIN_VALUE);
  28044. * // => true
  28045. *
  28046. * _.isNumber(Infinity);
  28047. * // => true
  28048. *
  28049. * _.isNumber('3');
  28050. * // => false
  28051. */
  28052. function isNumber(value) {
  28053. return typeof value == 'number' ||
  28054. (isObjectLike(value) && baseGetTag(value) == numberTag);
  28055. }
  28056. /**
  28057. * Checks if `value` is a plain object, that is, an object created by the
  28058. * `Object` constructor or one with a `[[Prototype]]` of `null`.
  28059. *
  28060. * @static
  28061. * @memberOf _
  28062. * @since 0.8.0
  28063. * @category Lang
  28064. * @param {*} value The value to check.
  28065. * @returns {boolean} Returns `true` if `value` is a plain object, else `false`.
  28066. * @example
  28067. *
  28068. * function Foo() {
  28069. * this.a = 1;
  28070. * }
  28071. *
  28072. * _.isPlainObject(new Foo);
  28073. * // => false
  28074. *
  28075. * _.isPlainObject([1, 2, 3]);
  28076. * // => false
  28077. *
  28078. * _.isPlainObject({ 'x': 0, 'y': 0 });
  28079. * // => true
  28080. *
  28081. * _.isPlainObject(Object.create(null));
  28082. * // => true
  28083. */
  28084. function isPlainObject(value) {
  28085. if (!isObjectLike(value) || baseGetTag(value) != objectTag) {
  28086. return false;
  28087. }
  28088. var proto = getPrototype(value);
  28089. if (proto === null) {
  28090. return true;
  28091. }
  28092. var Ctor = hasOwnProperty.call(proto, 'constructor') && proto.constructor;
  28093. return typeof Ctor == 'function' && Ctor instanceof Ctor &&
  28094. funcToString.call(Ctor) == objectCtorString;
  28095. }
  28096. /**
  28097. * Checks if `value` is classified as a `RegExp` object.
  28098. *
  28099. * @static
  28100. * @memberOf _
  28101. * @since 0.1.0
  28102. * @category Lang
  28103. * @param {*} value The value to check.
  28104. * @returns {boolean} Returns `true` if `value` is a regexp, else `false`.
  28105. * @example
  28106. *
  28107. * _.isRegExp(/abc/);
  28108. * // => true
  28109. *
  28110. * _.isRegExp('/abc/');
  28111. * // => false
  28112. */
  28113. var isRegExp = nodeIsRegExp ? baseUnary(nodeIsRegExp) : baseIsRegExp;
  28114. /**
  28115. * Checks if `value` is a safe integer. An integer is safe if it's an IEEE-754
  28116. * double precision number which isn't the result of a rounded unsafe integer.
  28117. *
  28118. * **Note:** This method is based on
  28119. * [`Number.isSafeInteger`](https://mdn.io/Number/isSafeInteger).
  28120. *
  28121. * @static
  28122. * @memberOf _
  28123. * @since 4.0.0
  28124. * @category Lang
  28125. * @param {*} value The value to check.
  28126. * @returns {boolean} Returns `true` if `value` is a safe integer, else `false`.
  28127. * @example
  28128. *
  28129. * _.isSafeInteger(3);
  28130. * // => true
  28131. *
  28132. * _.isSafeInteger(Number.MIN_VALUE);
  28133. * // => false
  28134. *
  28135. * _.isSafeInteger(Infinity);
  28136. * // => false
  28137. *
  28138. * _.isSafeInteger('3');
  28139. * // => false
  28140. */
  28141. function isSafeInteger(value) {
  28142. return isInteger(value) && value >= -MAX_SAFE_INTEGER && value <= MAX_SAFE_INTEGER;
  28143. }
  28144. /**
  28145. * Checks if `value` is classified as a `Set` object.
  28146. *
  28147. * @static
  28148. * @memberOf _
  28149. * @since 4.3.0
  28150. * @category Lang
  28151. * @param {*} value The value to check.
  28152. * @returns {boolean} Returns `true` if `value` is a set, else `false`.
  28153. * @example
  28154. *
  28155. * _.isSet(new Set);
  28156. * // => true
  28157. *
  28158. * _.isSet(new WeakSet);
  28159. * // => false
  28160. */
  28161. var isSet = nodeIsSet ? baseUnary(nodeIsSet) : baseIsSet;
  28162. /**
  28163. * Checks if `value` is classified as a `String` primitive or object.
  28164. *
  28165. * @static
  28166. * @since 0.1.0
  28167. * @memberOf _
  28168. * @category Lang
  28169. * @param {*} value The value to check.
  28170. * @returns {boolean} Returns `true` if `value` is a string, else `false`.
  28171. * @example
  28172. *
  28173. * _.isString('abc');
  28174. * // => true
  28175. *
  28176. * _.isString(1);
  28177. * // => false
  28178. */
  28179. function isString(value) {
  28180. return typeof value == 'string' ||
  28181. (!isArray(value) && isObjectLike(value) && baseGetTag(value) == stringTag);
  28182. }
  28183. /**
  28184. * Checks if `value` is classified as a `Symbol` primitive or object.
  28185. *
  28186. * @static
  28187. * @memberOf _
  28188. * @since 4.0.0
  28189. * @category Lang
  28190. * @param {*} value The value to check.
  28191. * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
  28192. * @example
  28193. *
  28194. * _.isSymbol(Symbol.iterator);
  28195. * // => true
  28196. *
  28197. * _.isSymbol('abc');
  28198. * // => false
  28199. */
  28200. function isSymbol(value) {
  28201. return typeof value == 'symbol' ||
  28202. (isObjectLike(value) && baseGetTag(value) == symbolTag);
  28203. }
  28204. /**
  28205. * Checks if `value` is classified as a typed array.
  28206. *
  28207. * @static
  28208. * @memberOf _
  28209. * @since 3.0.0
  28210. * @category Lang
  28211. * @param {*} value The value to check.
  28212. * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
  28213. * @example
  28214. *
  28215. * _.isTypedArray(new Uint8Array);
  28216. * // => true
  28217. *
  28218. * _.isTypedArray([]);
  28219. * // => false
  28220. */
  28221. var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray;
  28222. /**
  28223. * Checks if `value` is `undefined`.
  28224. *
  28225. * @static
  28226. * @since 0.1.0
  28227. * @memberOf _
  28228. * @category Lang
  28229. * @param {*} value The value to check.
  28230. * @returns {boolean} Returns `true` if `value` is `undefined`, else `false`.
  28231. * @example
  28232. *
  28233. * _.isUndefined(void 0);
  28234. * // => true
  28235. *
  28236. * _.isUndefined(null);
  28237. * // => false
  28238. */
  28239. function isUndefined(value) {
  28240. return value === undefined;
  28241. }
  28242. /**
  28243. * Checks if `value` is classified as a `WeakMap` object.
  28244. *
  28245. * @static
  28246. * @memberOf _
  28247. * @since 4.3.0
  28248. * @category Lang
  28249. * @param {*} value The value to check.
  28250. * @returns {boolean} Returns `true` if `value` is a weak map, else `false`.
  28251. * @example
  28252. *
  28253. * _.isWeakMap(new WeakMap);
  28254. * // => true
  28255. *
  28256. * _.isWeakMap(new Map);
  28257. * // => false
  28258. */
  28259. function isWeakMap(value) {
  28260. return isObjectLike(value) && getTag(value) == weakMapTag;
  28261. }
  28262. /**
  28263. * Checks if `value` is classified as a `WeakSet` object.
  28264. *
  28265. * @static
  28266. * @memberOf _
  28267. * @since 4.3.0
  28268. * @category Lang
  28269. * @param {*} value The value to check.
  28270. * @returns {boolean} Returns `true` if `value` is a weak set, else `false`.
  28271. * @example
  28272. *
  28273. * _.isWeakSet(new WeakSet);
  28274. * // => true
  28275. *
  28276. * _.isWeakSet(new Set);
  28277. * // => false
  28278. */
  28279. function isWeakSet(value) {
  28280. return isObjectLike(value) && baseGetTag(value) == weakSetTag;
  28281. }
  28282. /**
  28283. * Checks if `value` is less than `other`.
  28284. *
  28285. * @static
  28286. * @memberOf _
  28287. * @since 3.9.0
  28288. * @category Lang
  28289. * @param {*} value The value to compare.
  28290. * @param {*} other The other value to compare.
  28291. * @returns {boolean} Returns `true` if `value` is less than `other`,
  28292. * else `false`.
  28293. * @see _.gt
  28294. * @example
  28295. *
  28296. * _.lt(1, 3);
  28297. * // => true
  28298. *
  28299. * _.lt(3, 3);
  28300. * // => false
  28301. *
  28302. * _.lt(3, 1);
  28303. * // => false
  28304. */
  28305. var lt = createRelationalOperation(baseLt);
  28306. /**
  28307. * Checks if `value` is less than or equal to `other`.
  28308. *
  28309. * @static
  28310. * @memberOf _
  28311. * @since 3.9.0
  28312. * @category Lang
  28313. * @param {*} value The value to compare.
  28314. * @param {*} other The other value to compare.
  28315. * @returns {boolean} Returns `true` if `value` is less than or equal to
  28316. * `other`, else `false`.
  28317. * @see _.gte
  28318. * @example
  28319. *
  28320. * _.lte(1, 3);
  28321. * // => true
  28322. *
  28323. * _.lte(3, 3);
  28324. * // => true
  28325. *
  28326. * _.lte(3, 1);
  28327. * // => false
  28328. */
  28329. var lte = createRelationalOperation(function(value, other) {
  28330. return value <= other;
  28331. });
  28332. /**
  28333. * Converts `value` to an array.
  28334. *
  28335. * @static
  28336. * @since 0.1.0
  28337. * @memberOf _
  28338. * @category Lang
  28339. * @param {*} value The value to convert.
  28340. * @returns {Array} Returns the converted array.
  28341. * @example
  28342. *
  28343. * _.toArray({ 'a': 1, 'b': 2 });
  28344. * // => [1, 2]
  28345. *
  28346. * _.toArray('abc');
  28347. * // => ['a', 'b', 'c']
  28348. *
  28349. * _.toArray(1);
  28350. * // => []
  28351. *
  28352. * _.toArray(null);
  28353. * // => []
  28354. */
  28355. function toArray(value) {
  28356. if (!value) {
  28357. return [];
  28358. }
  28359. if (isArrayLike(value)) {
  28360. return isString(value) ? stringToArray(value) : copyArray(value);
  28361. }
  28362. if (symIterator && value[symIterator]) {
  28363. return iteratorToArray(value[symIterator]());
  28364. }
  28365. var tag = getTag(value),
  28366. func = tag == mapTag ? mapToArray : (tag == setTag ? setToArray : values);
  28367. return func(value);
  28368. }
  28369. /**
  28370. * Converts `value` to a finite number.
  28371. *
  28372. * @static
  28373. * @memberOf _
  28374. * @since 4.12.0
  28375. * @category Lang
  28376. * @param {*} value The value to convert.
  28377. * @returns {number} Returns the converted number.
  28378. * @example
  28379. *
  28380. * _.toFinite(3.2);
  28381. * // => 3.2
  28382. *
  28383. * _.toFinite(Number.MIN_VALUE);
  28384. * // => 5e-324
  28385. *
  28386. * _.toFinite(Infinity);
  28387. * // => 1.7976931348623157e+308
  28388. *
  28389. * _.toFinite('3.2');
  28390. * // => 3.2
  28391. */
  28392. function toFinite(value) {
  28393. if (!value) {
  28394. return value === 0 ? value : 0;
  28395. }
  28396. value = toNumber(value);
  28397. if (value === INFINITY || value === -INFINITY) {
  28398. var sign = (value < 0 ? -1 : 1);
  28399. return sign * MAX_INTEGER;
  28400. }
  28401. return value === value ? value : 0;
  28402. }
  28403. /**
  28404. * Converts `value` to an integer.
  28405. *
  28406. * **Note:** This method is loosely based on
  28407. * [`ToInteger`](http://www.ecma-international.org/ecma-262/7.0/#sec-tointeger).
  28408. *
  28409. * @static
  28410. * @memberOf _
  28411. * @since 4.0.0
  28412. * @category Lang
  28413. * @param {*} value The value to convert.
  28414. * @returns {number} Returns the converted integer.
  28415. * @example
  28416. *
  28417. * _.toInteger(3.2);
  28418. * // => 3
  28419. *
  28420. * _.toInteger(Number.MIN_VALUE);
  28421. * // => 0
  28422. *
  28423. * _.toInteger(Infinity);
  28424. * // => 1.7976931348623157e+308
  28425. *
  28426. * _.toInteger('3.2');
  28427. * // => 3
  28428. */
  28429. function toInteger(value) {
  28430. var result = toFinite(value),
  28431. remainder = result % 1;
  28432. return result === result ? (remainder ? result - remainder : result) : 0;
  28433. }
  28434. /**
  28435. * Converts `value` to an integer suitable for use as the length of an
  28436. * array-like object.
  28437. *
  28438. * **Note:** This method is based on
  28439. * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
  28440. *
  28441. * @static
  28442. * @memberOf _
  28443. * @since 4.0.0
  28444. * @category Lang
  28445. * @param {*} value The value to convert.
  28446. * @returns {number} Returns the converted integer.
  28447. * @example
  28448. *
  28449. * _.toLength(3.2);
  28450. * // => 3
  28451. *
  28452. * _.toLength(Number.MIN_VALUE);
  28453. * // => 0
  28454. *
  28455. * _.toLength(Infinity);
  28456. * // => 4294967295
  28457. *
  28458. * _.toLength('3.2');
  28459. * // => 3
  28460. */
  28461. function toLength(value) {
  28462. return value ? baseClamp(toInteger(value), 0, MAX_ARRAY_LENGTH) : 0;
  28463. }
  28464. /**
  28465. * Converts `value` to a number.
  28466. *
  28467. * @static
  28468. * @memberOf _
  28469. * @since 4.0.0
  28470. * @category Lang
  28471. * @param {*} value The value to process.
  28472. * @returns {number} Returns the number.
  28473. * @example
  28474. *
  28475. * _.toNumber(3.2);
  28476. * // => 3.2
  28477. *
  28478. * _.toNumber(Number.MIN_VALUE);
  28479. * // => 5e-324
  28480. *
  28481. * _.toNumber(Infinity);
  28482. * // => Infinity
  28483. *
  28484. * _.toNumber('3.2');
  28485. * // => 3.2
  28486. */
  28487. function toNumber(value) {
  28488. if (typeof value == 'number') {
  28489. return value;
  28490. }
  28491. if (isSymbol(value)) {
  28492. return NAN;
  28493. }
  28494. if (isObject(value)) {
  28495. var other = typeof value.valueOf == 'function' ? value.valueOf() : value;
  28496. value = isObject(other) ? (other + '') : other;
  28497. }
  28498. if (typeof value != 'string') {
  28499. return value === 0 ? value : +value;
  28500. }
  28501. value = value.replace(reTrim, '');
  28502. var isBinary = reIsBinary.test(value);
  28503. return (isBinary || reIsOctal.test(value))
  28504. ? freeParseInt(value.slice(2), isBinary ? 2 : 8)
  28505. : (reIsBadHex.test(value) ? NAN : +value);
  28506. }
  28507. /**
  28508. * Converts `value` to a plain object flattening inherited enumerable string
  28509. * keyed properties of `value` to own properties of the plain object.
  28510. *
  28511. * @static
  28512. * @memberOf _
  28513. * @since 3.0.0
  28514. * @category Lang
  28515. * @param {*} value The value to convert.
  28516. * @returns {Object} Returns the converted plain object.
  28517. * @example
  28518. *
  28519. * function Foo() {
  28520. * this.b = 2;
  28521. * }
  28522. *
  28523. * Foo.prototype.c = 3;
  28524. *
  28525. * _.assign({ 'a': 1 }, new Foo);
  28526. * // => { 'a': 1, 'b': 2 }
  28527. *
  28528. * _.assign({ 'a': 1 }, _.toPlainObject(new Foo));
  28529. * // => { 'a': 1, 'b': 2, 'c': 3 }
  28530. */
  28531. function toPlainObject(value) {
  28532. return copyObject(value, keysIn(value));
  28533. }
  28534. /**
  28535. * Converts `value` to a safe integer. A safe integer can be compared and
  28536. * represented correctly.
  28537. *
  28538. * @static
  28539. * @memberOf _
  28540. * @since 4.0.0
  28541. * @category Lang
  28542. * @param {*} value The value to convert.
  28543. * @returns {number} Returns the converted integer.
  28544. * @example
  28545. *
  28546. * _.toSafeInteger(3.2);
  28547. * // => 3
  28548. *
  28549. * _.toSafeInteger(Number.MIN_VALUE);
  28550. * // => 0
  28551. *
  28552. * _.toSafeInteger(Infinity);
  28553. * // => 9007199254740991
  28554. *
  28555. * _.toSafeInteger('3.2');
  28556. * // => 3
  28557. */
  28558. function toSafeInteger(value) {
  28559. return value
  28560. ? baseClamp(toInteger(value), -MAX_SAFE_INTEGER, MAX_SAFE_INTEGER)
  28561. : (value === 0 ? value : 0);
  28562. }
  28563. /**
  28564. * Converts `value` to a string. An empty string is returned for `null`
  28565. * and `undefined` values. The sign of `-0` is preserved.
  28566. *
  28567. * @static
  28568. * @memberOf _
  28569. * @since 4.0.0
  28570. * @category Lang
  28571. * @param {*} value The value to convert.
  28572. * @returns {string} Returns the converted string.
  28573. * @example
  28574. *
  28575. * _.toString(null);
  28576. * // => ''
  28577. *
  28578. * _.toString(-0);
  28579. * // => '-0'
  28580. *
  28581. * _.toString([1, 2, 3]);
  28582. * // => '1,2,3'
  28583. */
  28584. function toString(value) {
  28585. return value == null ? '' : baseToString(value);
  28586. }
  28587. /*------------------------------------------------------------------------*/
  28588. /**
  28589. * Assigns own enumerable string keyed properties of source objects to the
  28590. * destination object. Source objects are applied from left to right.
  28591. * Subsequent sources overwrite property assignments of previous sources.
  28592. *
  28593. * **Note:** This method mutates `object` and is loosely based on
  28594. * [`Object.assign`](https://mdn.io/Object/assign).
  28595. *
  28596. * @static
  28597. * @memberOf _
  28598. * @since 0.10.0
  28599. * @category Object
  28600. * @param {Object} object The destination object.
  28601. * @param {...Object} [sources] The source objects.
  28602. * @returns {Object} Returns `object`.
  28603. * @see _.assignIn
  28604. * @example
  28605. *
  28606. * function Foo() {
  28607. * this.a = 1;
  28608. * }
  28609. *
  28610. * function Bar() {
  28611. * this.c = 3;
  28612. * }
  28613. *
  28614. * Foo.prototype.b = 2;
  28615. * Bar.prototype.d = 4;
  28616. *
  28617. * _.assign({ 'a': 0 }, new Foo, new Bar);
  28618. * // => { 'a': 1, 'c': 3 }
  28619. */
  28620. var assign = createAssigner(function(object, source) {
  28621. if (isPrototype(source) || isArrayLike(source)) {
  28622. copyObject(source, keys(source), object);
  28623. return;
  28624. }
  28625. for (var key in source) {
  28626. if (hasOwnProperty.call(source, key)) {
  28627. assignValue(object, key, source[key]);
  28628. }
  28629. }
  28630. });
  28631. /**
  28632. * This method is like `_.assign` except that it iterates over own and
  28633. * inherited source properties.
  28634. *
  28635. * **Note:** This method mutates `object`.
  28636. *
  28637. * @static
  28638. * @memberOf _
  28639. * @since 4.0.0
  28640. * @alias extend
  28641. * @category Object
  28642. * @param {Object} object The destination object.
  28643. * @param {...Object} [sources] The source objects.
  28644. * @returns {Object} Returns `object`.
  28645. * @see _.assign
  28646. * @example
  28647. *
  28648. * function Foo() {
  28649. * this.a = 1;
  28650. * }
  28651. *
  28652. * function Bar() {
  28653. * this.c = 3;
  28654. * }
  28655. *
  28656. * Foo.prototype.b = 2;
  28657. * Bar.prototype.d = 4;
  28658. *
  28659. * _.assignIn({ 'a': 0 }, new Foo, new Bar);
  28660. * // => { 'a': 1, 'b': 2, 'c': 3, 'd': 4 }
  28661. */
  28662. var assignIn = createAssigner(function(object, source) {
  28663. copyObject(source, keysIn(source), object);
  28664. });
  28665. /**
  28666. * This method is like `_.assignIn` except that it accepts `customizer`
  28667. * which is invoked to produce the assigned values. If `customizer` returns
  28668. * `undefined`, assignment is handled by the method instead. The `customizer`
  28669. * is invoked with five arguments: (objValue, srcValue, key, object, source).
  28670. *
  28671. * **Note:** This method mutates `object`.
  28672. *
  28673. * @static
  28674. * @memberOf _
  28675. * @since 4.0.0
  28676. * @alias extendWith
  28677. * @category Object
  28678. * @param {Object} object The destination object.
  28679. * @param {...Object} sources The source objects.
  28680. * @param {Function} [customizer] The function to customize assigned values.
  28681. * @returns {Object} Returns `object`.
  28682. * @see _.assignWith
  28683. * @example
  28684. *
  28685. * function customizer(objValue, srcValue) {
  28686. * return _.isUndefined(objValue) ? srcValue : objValue;
  28687. * }
  28688. *
  28689. * var defaults = _.partialRight(_.assignInWith, customizer);
  28690. *
  28691. * defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
  28692. * // => { 'a': 1, 'b': 2 }
  28693. */
  28694. var assignInWith = createAssigner(function(object, source, srcIndex, customizer) {
  28695. copyObject(source, keysIn(source), object, customizer);
  28696. });
  28697. /**
  28698. * This method is like `_.assign` except that it accepts `customizer`
  28699. * which is invoked to produce the assigned values. If `customizer` returns
  28700. * `undefined`, assignment is handled by the method instead. The `customizer`
  28701. * is invoked with five arguments: (objValue, srcValue, key, object, source).
  28702. *
  28703. * **Note:** This method mutates `object`.
  28704. *
  28705. * @static
  28706. * @memberOf _
  28707. * @since 4.0.0
  28708. * @category Object
  28709. * @param {Object} object The destination object.
  28710. * @param {...Object} sources The source objects.
  28711. * @param {Function} [customizer] The function to customize assigned values.
  28712. * @returns {Object} Returns `object`.
  28713. * @see _.assignInWith
  28714. * @example
  28715. *
  28716. * function customizer(objValue, srcValue) {
  28717. * return _.isUndefined(objValue) ? srcValue : objValue;
  28718. * }
  28719. *
  28720. * var defaults = _.partialRight(_.assignWith, customizer);
  28721. *
  28722. * defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
  28723. * // => { 'a': 1, 'b': 2 }
  28724. */
  28725. var assignWith = createAssigner(function(object, source, srcIndex, customizer) {
  28726. copyObject(source, keys(source), object, customizer);
  28727. });
  28728. /**
  28729. * Creates an array of values corresponding to `paths` of `object`.
  28730. *
  28731. * @static
  28732. * @memberOf _
  28733. * @since 1.0.0
  28734. * @category Object
  28735. * @param {Object} object The object to iterate over.
  28736. * @param {...(string|string[])} [paths] The property paths to pick.
  28737. * @returns {Array} Returns the picked values.
  28738. * @example
  28739. *
  28740. * var object = { 'a': [{ 'b': { 'c': 3 } }, 4] };
  28741. *
  28742. * _.at(object, ['a[0].b.c', 'a[1]']);
  28743. * // => [3, 4]
  28744. */
  28745. var at = flatRest(baseAt);
  28746. /**
  28747. * Creates an object that inherits from the `prototype` object. If a
  28748. * `properties` object is given, its own enumerable string keyed properties
  28749. * are assigned to the created object.
  28750. *
  28751. * @static
  28752. * @memberOf _
  28753. * @since 2.3.0
  28754. * @category Object
  28755. * @param {Object} prototype The object to inherit from.
  28756. * @param {Object} [properties] The properties to assign to the object.
  28757. * @returns {Object} Returns the new object.
  28758. * @example
  28759. *
  28760. * function Shape() {
  28761. * this.x = 0;
  28762. * this.y = 0;
  28763. * }
  28764. *
  28765. * function Circle() {
  28766. * Shape.call(this);
  28767. * }
  28768. *
  28769. * Circle.prototype = _.create(Shape.prototype, {
  28770. * 'constructor': Circle
  28771. * });
  28772. *
  28773. * var circle = new Circle;
  28774. * circle instanceof Circle;
  28775. * // => true
  28776. *
  28777. * circle instanceof Shape;
  28778. * // => true
  28779. */
  28780. function create(prototype, properties) {
  28781. var result = baseCreate(prototype);
  28782. return properties == null ? result : baseAssign(result, properties);
  28783. }
  28784. /**
  28785. * Assigns own and inherited enumerable string keyed properties of source
  28786. * objects to the destination object for all destination properties that
  28787. * resolve to `undefined`. Source objects are applied from left to right.
  28788. * Once a property is set, additional values of the same property are ignored.
  28789. *
  28790. * **Note:** This method mutates `object`.
  28791. *
  28792. * @static
  28793. * @since 0.1.0
  28794. * @memberOf _
  28795. * @category Object
  28796. * @param {Object} object The destination object.
  28797. * @param {...Object} [sources] The source objects.
  28798. * @returns {Object} Returns `object`.
  28799. * @see _.defaultsDeep
  28800. * @example
  28801. *
  28802. * _.defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
  28803. * // => { 'a': 1, 'b': 2 }
  28804. */
  28805. var defaults = baseRest(function(object, sources) {
  28806. object = Object(object);
  28807. var index = -1;
  28808. var length = sources.length;
  28809. var guard = length > 2 ? sources[2] : undefined;
  28810. if (guard && isIterateeCall(sources[0], sources[1], guard)) {
  28811. length = 1;
  28812. }
  28813. while (++index < length) {
  28814. var source = sources[index];
  28815. var props = keysIn(source);
  28816. var propsIndex = -1;
  28817. var propsLength = props.length;
  28818. while (++propsIndex < propsLength) {
  28819. var key = props[propsIndex];
  28820. var value = object[key];
  28821. if (value === undefined ||
  28822. (eq(value, objectProto[key]) && !hasOwnProperty.call(object, key))) {
  28823. object[key] = source[key];
  28824. }
  28825. }
  28826. }
  28827. return object;
  28828. });
  28829. /**
  28830. * This method is like `_.defaults` except that it recursively assigns
  28831. * default properties.
  28832. *
  28833. * **Note:** This method mutates `object`.
  28834. *
  28835. * @static
  28836. * @memberOf _
  28837. * @since 3.10.0
  28838. * @category Object
  28839. * @param {Object} object The destination object.
  28840. * @param {...Object} [sources] The source objects.
  28841. * @returns {Object} Returns `object`.
  28842. * @see _.defaults
  28843. * @example
  28844. *
  28845. * _.defaultsDeep({ 'a': { 'b': 2 } }, { 'a': { 'b': 1, 'c': 3 } });
  28846. * // => { 'a': { 'b': 2, 'c': 3 } }
  28847. */
  28848. var defaultsDeep = baseRest(function(args) {
  28849. args.push(undefined, customDefaultsMerge);
  28850. return apply(mergeWith, undefined, args);
  28851. });
  28852. /**
  28853. * This method is like `_.find` except that it returns the key of the first
  28854. * element `predicate` returns truthy for instead of the element itself.
  28855. *
  28856. * @static
  28857. * @memberOf _
  28858. * @since 1.1.0
  28859. * @category Object
  28860. * @param {Object} object The object to inspect.
  28861. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  28862. * @returns {string|undefined} Returns the key of the matched element,
  28863. * else `undefined`.
  28864. * @example
  28865. *
  28866. * var users = {
  28867. * 'barney': { 'age': 36, 'active': true },
  28868. * 'fred': { 'age': 40, 'active': false },
  28869. * 'pebbles': { 'age': 1, 'active': true }
  28870. * };
  28871. *
  28872. * _.findKey(users, function(o) { return o.age < 40; });
  28873. * // => 'barney' (iteration order is not guaranteed)
  28874. *
  28875. * // The `_.matches` iteratee shorthand.
  28876. * _.findKey(users, { 'age': 1, 'active': true });
  28877. * // => 'pebbles'
  28878. *
  28879. * // The `_.matchesProperty` iteratee shorthand.
  28880. * _.findKey(users, ['active', false]);
  28881. * // => 'fred'
  28882. *
  28883. * // The `_.property` iteratee shorthand.
  28884. * _.findKey(users, 'active');
  28885. * // => 'barney'
  28886. */
  28887. function findKey(object, predicate) {
  28888. return baseFindKey(object, getIteratee(predicate, 3), baseForOwn);
  28889. }
  28890. /**
  28891. * This method is like `_.findKey` except that it iterates over elements of
  28892. * a collection in the opposite order.
  28893. *
  28894. * @static
  28895. * @memberOf _
  28896. * @since 2.0.0
  28897. * @category Object
  28898. * @param {Object} object The object to inspect.
  28899. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  28900. * @returns {string|undefined} Returns the key of the matched element,
  28901. * else `undefined`.
  28902. * @example
  28903. *
  28904. * var users = {
  28905. * 'barney': { 'age': 36, 'active': true },
  28906. * 'fred': { 'age': 40, 'active': false },
  28907. * 'pebbles': { 'age': 1, 'active': true }
  28908. * };
  28909. *
  28910. * _.findLastKey(users, function(o) { return o.age < 40; });
  28911. * // => returns 'pebbles' assuming `_.findKey` returns 'barney'
  28912. *
  28913. * // The `_.matches` iteratee shorthand.
  28914. * _.findLastKey(users, { 'age': 36, 'active': true });
  28915. * // => 'barney'
  28916. *
  28917. * // The `_.matchesProperty` iteratee shorthand.
  28918. * _.findLastKey(users, ['active', false]);
  28919. * // => 'fred'
  28920. *
  28921. * // The `_.property` iteratee shorthand.
  28922. * _.findLastKey(users, 'active');
  28923. * // => 'pebbles'
  28924. */
  28925. function findLastKey(object, predicate) {
  28926. return baseFindKey(object, getIteratee(predicate, 3), baseForOwnRight);
  28927. }
  28928. /**
  28929. * Iterates over own and inherited enumerable string keyed properties of an
  28930. * object and invokes `iteratee` for each property. The iteratee is invoked
  28931. * with three arguments: (value, key, object). Iteratee functions may exit
  28932. * iteration early by explicitly returning `false`.
  28933. *
  28934. * @static
  28935. * @memberOf _
  28936. * @since 0.3.0
  28937. * @category Object
  28938. * @param {Object} object The object to iterate over.
  28939. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  28940. * @returns {Object} Returns `object`.
  28941. * @see _.forInRight
  28942. * @example
  28943. *
  28944. * function Foo() {
  28945. * this.a = 1;
  28946. * this.b = 2;
  28947. * }
  28948. *
  28949. * Foo.prototype.c = 3;
  28950. *
  28951. * _.forIn(new Foo, function(value, key) {
  28952. * console.log(key);
  28953. * });
  28954. * // => Logs 'a', 'b', then 'c' (iteration order is not guaranteed).
  28955. */
  28956. function forIn(object, iteratee) {
  28957. return object == null
  28958. ? object
  28959. : baseFor(object, getIteratee(iteratee, 3), keysIn);
  28960. }
  28961. /**
  28962. * This method is like `_.forIn` except that it iterates over properties of
  28963. * `object` in the opposite order.
  28964. *
  28965. * @static
  28966. * @memberOf _
  28967. * @since 2.0.0
  28968. * @category Object
  28969. * @param {Object} object The object to iterate over.
  28970. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  28971. * @returns {Object} Returns `object`.
  28972. * @see _.forIn
  28973. * @example
  28974. *
  28975. * function Foo() {
  28976. * this.a = 1;
  28977. * this.b = 2;
  28978. * }
  28979. *
  28980. * Foo.prototype.c = 3;
  28981. *
  28982. * _.forInRight(new Foo, function(value, key) {
  28983. * console.log(key);
  28984. * });
  28985. * // => Logs 'c', 'b', then 'a' assuming `_.forIn` logs 'a', 'b', then 'c'.
  28986. */
  28987. function forInRight(object, iteratee) {
  28988. return object == null
  28989. ? object
  28990. : baseForRight(object, getIteratee(iteratee, 3), keysIn);
  28991. }
  28992. /**
  28993. * Iterates over own enumerable string keyed properties of an object and
  28994. * invokes `iteratee` for each property. The iteratee is invoked with three
  28995. * arguments: (value, key, object). Iteratee functions may exit iteration
  28996. * early by explicitly returning `false`.
  28997. *
  28998. * @static
  28999. * @memberOf _
  29000. * @since 0.3.0
  29001. * @category Object
  29002. * @param {Object} object The object to iterate over.
  29003. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  29004. * @returns {Object} Returns `object`.
  29005. * @see _.forOwnRight
  29006. * @example
  29007. *
  29008. * function Foo() {
  29009. * this.a = 1;
  29010. * this.b = 2;
  29011. * }
  29012. *
  29013. * Foo.prototype.c = 3;
  29014. *
  29015. * _.forOwn(new Foo, function(value, key) {
  29016. * console.log(key);
  29017. * });
  29018. * // => Logs 'a' then 'b' (iteration order is not guaranteed).
  29019. */
  29020. function forOwn(object, iteratee) {
  29021. return object && baseForOwn(object, getIteratee(iteratee, 3));
  29022. }
  29023. /**
  29024. * This method is like `_.forOwn` except that it iterates over properties of
  29025. * `object` in the opposite order.
  29026. *
  29027. * @static
  29028. * @memberOf _
  29029. * @since 2.0.0
  29030. * @category Object
  29031. * @param {Object} object The object to iterate over.
  29032. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  29033. * @returns {Object} Returns `object`.
  29034. * @see _.forOwn
  29035. * @example
  29036. *
  29037. * function Foo() {
  29038. * this.a = 1;
  29039. * this.b = 2;
  29040. * }
  29041. *
  29042. * Foo.prototype.c = 3;
  29043. *
  29044. * _.forOwnRight(new Foo, function(value, key) {
  29045. * console.log(key);
  29046. * });
  29047. * // => Logs 'b' then 'a' assuming `_.forOwn` logs 'a' then 'b'.
  29048. */
  29049. function forOwnRight(object, iteratee) {
  29050. return object && baseForOwnRight(object, getIteratee(iteratee, 3));
  29051. }
  29052. /**
  29053. * Creates an array of function property names from own enumerable properties
  29054. * of `object`.
  29055. *
  29056. * @static
  29057. * @since 0.1.0
  29058. * @memberOf _
  29059. * @category Object
  29060. * @param {Object} object The object to inspect.
  29061. * @returns {Array} Returns the function names.
  29062. * @see _.functionsIn
  29063. * @example
  29064. *
  29065. * function Foo() {
  29066. * this.a = _.constant('a');
  29067. * this.b = _.constant('b');
  29068. * }
  29069. *
  29070. * Foo.prototype.c = _.constant('c');
  29071. *
  29072. * _.functions(new Foo);
  29073. * // => ['a', 'b']
  29074. */
  29075. function functions(object) {
  29076. return object == null ? [] : baseFunctions(object, keys(object));
  29077. }
  29078. /**
  29079. * Creates an array of function property names from own and inherited
  29080. * enumerable properties of `object`.
  29081. *
  29082. * @static
  29083. * @memberOf _
  29084. * @since 4.0.0
  29085. * @category Object
  29086. * @param {Object} object The object to inspect.
  29087. * @returns {Array} Returns the function names.
  29088. * @see _.functions
  29089. * @example
  29090. *
  29091. * function Foo() {
  29092. * this.a = _.constant('a');
  29093. * this.b = _.constant('b');
  29094. * }
  29095. *
  29096. * Foo.prototype.c = _.constant('c');
  29097. *
  29098. * _.functionsIn(new Foo);
  29099. * // => ['a', 'b', 'c']
  29100. */
  29101. function functionsIn(object) {
  29102. return object == null ? [] : baseFunctions(object, keysIn(object));
  29103. }
  29104. /**
  29105. * Gets the value at `path` of `object`. If the resolved value is
  29106. * `undefined`, the `defaultValue` is returned in its place.
  29107. *
  29108. * @static
  29109. * @memberOf _
  29110. * @since 3.7.0
  29111. * @category Object
  29112. * @param {Object} object The object to query.
  29113. * @param {Array|string} path The path of the property to get.
  29114. * @param {*} [defaultValue] The value returned for `undefined` resolved values.
  29115. * @returns {*} Returns the resolved value.
  29116. * @example
  29117. *
  29118. * var object = { 'a': [{ 'b': { 'c': 3 } }] };
  29119. *
  29120. * _.get(object, 'a[0].b.c');
  29121. * // => 3
  29122. *
  29123. * _.get(object, ['a', '0', 'b', 'c']);
  29124. * // => 3
  29125. *
  29126. * _.get(object, 'a.b.c', 'default');
  29127. * // => 'default'
  29128. */
  29129. function get(object, path, defaultValue) {
  29130. var result = object == null ? undefined : baseGet(object, path);
  29131. return result === undefined ? defaultValue : result;
  29132. }
  29133. /**
  29134. * Checks if `path` is a direct property of `object`.
  29135. *
  29136. * @static
  29137. * @since 0.1.0
  29138. * @memberOf _
  29139. * @category Object
  29140. * @param {Object} object The object to query.
  29141. * @param {Array|string} path The path to check.
  29142. * @returns {boolean} Returns `true` if `path` exists, else `false`.
  29143. * @example
  29144. *
  29145. * var object = { 'a': { 'b': 2 } };
  29146. * var other = _.create({ 'a': _.create({ 'b': 2 }) });
  29147. *
  29148. * _.has(object, 'a');
  29149. * // => true
  29150. *
  29151. * _.has(object, 'a.b');
  29152. * // => true
  29153. *
  29154. * _.has(object, ['a', 'b']);
  29155. * // => true
  29156. *
  29157. * _.has(other, 'a');
  29158. * // => false
  29159. */
  29160. function has(object, path) {
  29161. return object != null && hasPath(object, path, baseHas);
  29162. }
  29163. /**
  29164. * Checks if `path` is a direct or inherited property of `object`.
  29165. *
  29166. * @static
  29167. * @memberOf _
  29168. * @since 4.0.0
  29169. * @category Object
  29170. * @param {Object} object The object to query.
  29171. * @param {Array|string} path The path to check.
  29172. * @returns {boolean} Returns `true` if `path` exists, else `false`.
  29173. * @example
  29174. *
  29175. * var object = _.create({ 'a': _.create({ 'b': 2 }) });
  29176. *
  29177. * _.hasIn(object, 'a');
  29178. * // => true
  29179. *
  29180. * _.hasIn(object, 'a.b');
  29181. * // => true
  29182. *
  29183. * _.hasIn(object, ['a', 'b']);
  29184. * // => true
  29185. *
  29186. * _.hasIn(object, 'b');
  29187. * // => false
  29188. */
  29189. function hasIn(object, path) {
  29190. return object != null && hasPath(object, path, baseHasIn);
  29191. }
  29192. /**
  29193. * Creates an object composed of the inverted keys and values of `object`.
  29194. * If `object` contains duplicate values, subsequent values overwrite
  29195. * property assignments of previous values.
  29196. *
  29197. * @static
  29198. * @memberOf _
  29199. * @since 0.7.0
  29200. * @category Object
  29201. * @param {Object} object The object to invert.
  29202. * @returns {Object} Returns the new inverted object.
  29203. * @example
  29204. *
  29205. * var object = { 'a': 1, 'b': 2, 'c': 1 };
  29206. *
  29207. * _.invert(object);
  29208. * // => { '1': 'c', '2': 'b' }
  29209. */
  29210. var invert = createInverter(function(result, value, key) {
  29211. if (value != null &&
  29212. typeof value.toString != 'function') {
  29213. value = nativeObjectToString.call(value);
  29214. }
  29215. result[value] = key;
  29216. }, constant(identity));
  29217. /**
  29218. * This method is like `_.invert` except that the inverted object is generated
  29219. * from the results of running each element of `object` thru `iteratee`. The
  29220. * corresponding inverted value of each inverted key is an array of keys
  29221. * responsible for generating the inverted value. The iteratee is invoked
  29222. * with one argument: (value).
  29223. *
  29224. * @static
  29225. * @memberOf _
  29226. * @since 4.1.0
  29227. * @category Object
  29228. * @param {Object} object The object to invert.
  29229. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  29230. * @returns {Object} Returns the new inverted object.
  29231. * @example
  29232. *
  29233. * var object = { 'a': 1, 'b': 2, 'c': 1 };
  29234. *
  29235. * _.invertBy(object);
  29236. * // => { '1': ['a', 'c'], '2': ['b'] }
  29237. *
  29238. * _.invertBy(object, function(value) {
  29239. * return 'group' + value;
  29240. * });
  29241. * // => { 'group1': ['a', 'c'], 'group2': ['b'] }
  29242. */
  29243. var invertBy = createInverter(function(result, value, key) {
  29244. if (value != null &&
  29245. typeof value.toString != 'function') {
  29246. value = nativeObjectToString.call(value);
  29247. }
  29248. if (hasOwnProperty.call(result, value)) {
  29249. result[value].push(key);
  29250. } else {
  29251. result[value] = [key];
  29252. }
  29253. }, getIteratee);
  29254. /**
  29255. * Invokes the method at `path` of `object`.
  29256. *
  29257. * @static
  29258. * @memberOf _
  29259. * @since 4.0.0
  29260. * @category Object
  29261. * @param {Object} object The object to query.
  29262. * @param {Array|string} path The path of the method to invoke.
  29263. * @param {...*} [args] The arguments to invoke the method with.
  29264. * @returns {*} Returns the result of the invoked method.
  29265. * @example
  29266. *
  29267. * var object = { 'a': [{ 'b': { 'c': [1, 2, 3, 4] } }] };
  29268. *
  29269. * _.invoke(object, 'a[0].b.c.slice', 1, 3);
  29270. * // => [2, 3]
  29271. */
  29272. var invoke = baseRest(baseInvoke);
  29273. /**
  29274. * Creates an array of the own enumerable property names of `object`.
  29275. *
  29276. * **Note:** Non-object values are coerced to objects. See the
  29277. * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
  29278. * for more details.
  29279. *
  29280. * @static
  29281. * @since 0.1.0
  29282. * @memberOf _
  29283. * @category Object
  29284. * @param {Object} object The object to query.
  29285. * @returns {Array} Returns the array of property names.
  29286. * @example
  29287. *
  29288. * function Foo() {
  29289. * this.a = 1;
  29290. * this.b = 2;
  29291. * }
  29292. *
  29293. * Foo.prototype.c = 3;
  29294. *
  29295. * _.keys(new Foo);
  29296. * // => ['a', 'b'] (iteration order is not guaranteed)
  29297. *
  29298. * _.keys('hi');
  29299. * // => ['0', '1']
  29300. */
  29301. function keys(object) {
  29302. return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object);
  29303. }
  29304. /**
  29305. * Creates an array of the own and inherited enumerable property names of `object`.
  29306. *
  29307. * **Note:** Non-object values are coerced to objects.
  29308. *
  29309. * @static
  29310. * @memberOf _
  29311. * @since 3.0.0
  29312. * @category Object
  29313. * @param {Object} object The object to query.
  29314. * @returns {Array} Returns the array of property names.
  29315. * @example
  29316. *
  29317. * function Foo() {
  29318. * this.a = 1;
  29319. * this.b = 2;
  29320. * }
  29321. *
  29322. * Foo.prototype.c = 3;
  29323. *
  29324. * _.keysIn(new Foo);
  29325. * // => ['a', 'b', 'c'] (iteration order is not guaranteed)
  29326. */
  29327. function keysIn(object) {
  29328. return isArrayLike(object) ? arrayLikeKeys(object, true) : baseKeysIn(object);
  29329. }
  29330. /**
  29331. * The opposite of `_.mapValues`; this method creates an object with the
  29332. * same values as `object` and keys generated by running each own enumerable
  29333. * string keyed property of `object` thru `iteratee`. The iteratee is invoked
  29334. * with three arguments: (value, key, object).
  29335. *
  29336. * @static
  29337. * @memberOf _
  29338. * @since 3.8.0
  29339. * @category Object
  29340. * @param {Object} object The object to iterate over.
  29341. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  29342. * @returns {Object} Returns the new mapped object.
  29343. * @see _.mapValues
  29344. * @example
  29345. *
  29346. * _.mapKeys({ 'a': 1, 'b': 2 }, function(value, key) {
  29347. * return key + value;
  29348. * });
  29349. * // => { 'a1': 1, 'b2': 2 }
  29350. */
  29351. function mapKeys(object, iteratee) {
  29352. var result = {};
  29353. iteratee = getIteratee(iteratee, 3);
  29354. baseForOwn(object, function(value, key, object) {
  29355. baseAssignValue(result, iteratee(value, key, object), value);
  29356. });
  29357. return result;
  29358. }
  29359. /**
  29360. * Creates an object with the same keys as `object` and values generated
  29361. * by running each own enumerable string keyed property of `object` thru
  29362. * `iteratee`. The iteratee is invoked with three arguments:
  29363. * (value, key, object).
  29364. *
  29365. * @static
  29366. * @memberOf _
  29367. * @since 2.4.0
  29368. * @category Object
  29369. * @param {Object} object The object to iterate over.
  29370. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  29371. * @returns {Object} Returns the new mapped object.
  29372. * @see _.mapKeys
  29373. * @example
  29374. *
  29375. * var users = {
  29376. * 'fred': { 'user': 'fred', 'age': 40 },
  29377. * 'pebbles': { 'user': 'pebbles', 'age': 1 }
  29378. * };
  29379. *
  29380. * _.mapValues(users, function(o) { return o.age; });
  29381. * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)
  29382. *
  29383. * // The `_.property` iteratee shorthand.
  29384. * _.mapValues(users, 'age');
  29385. * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)
  29386. */
  29387. function mapValues(object, iteratee) {
  29388. var result = {};
  29389. iteratee = getIteratee(iteratee, 3);
  29390. baseForOwn(object, function(value, key, object) {
  29391. baseAssignValue(result, key, iteratee(value, key, object));
  29392. });
  29393. return result;
  29394. }
  29395. /**
  29396. * This method is like `_.assign` except that it recursively merges own and
  29397. * inherited enumerable string keyed properties of source objects into the
  29398. * destination object. Source properties that resolve to `undefined` are
  29399. * skipped if a destination value exists. Array and plain object properties
  29400. * are merged recursively. Other objects and value types are overridden by
  29401. * assignment. Source objects are applied from left to right. Subsequent
  29402. * sources overwrite property assignments of previous sources.
  29403. *
  29404. * **Note:** This method mutates `object`.
  29405. *
  29406. * @static
  29407. * @memberOf _
  29408. * @since 0.5.0
  29409. * @category Object
  29410. * @param {Object} object The destination object.
  29411. * @param {...Object} [sources] The source objects.
  29412. * @returns {Object} Returns `object`.
  29413. * @example
  29414. *
  29415. * var object = {
  29416. * 'a': [{ 'b': 2 }, { 'd': 4 }]
  29417. * };
  29418. *
  29419. * var other = {
  29420. * 'a': [{ 'c': 3 }, { 'e': 5 }]
  29421. * };
  29422. *
  29423. * _.merge(object, other);
  29424. * // => { 'a': [{ 'b': 2, 'c': 3 }, { 'd': 4, 'e': 5 }] }
  29425. */
  29426. var merge = createAssigner(function(object, source, srcIndex) {
  29427. baseMerge(object, source, srcIndex);
  29428. });
  29429. /**
  29430. * This method is like `_.merge` except that it accepts `customizer` which
  29431. * is invoked to produce the merged values of the destination and source
  29432. * properties. If `customizer` returns `undefined`, merging is handled by the
  29433. * method instead. The `customizer` is invoked with six arguments:
  29434. * (objValue, srcValue, key, object, source, stack).
  29435. *
  29436. * **Note:** This method mutates `object`.
  29437. *
  29438. * @static
  29439. * @memberOf _
  29440. * @since 4.0.0
  29441. * @category Object
  29442. * @param {Object} object The destination object.
  29443. * @param {...Object} sources The source objects.
  29444. * @param {Function} customizer The function to customize assigned values.
  29445. * @returns {Object} Returns `object`.
  29446. * @example
  29447. *
  29448. * function customizer(objValue, srcValue) {
  29449. * if (_.isArray(objValue)) {
  29450. * return objValue.concat(srcValue);
  29451. * }
  29452. * }
  29453. *
  29454. * var object = { 'a': [1], 'b': [2] };
  29455. * var other = { 'a': [3], 'b': [4] };
  29456. *
  29457. * _.mergeWith(object, other, customizer);
  29458. * // => { 'a': [1, 3], 'b': [2, 4] }
  29459. */
  29460. var mergeWith = createAssigner(function(object, source, srcIndex, customizer) {
  29461. baseMerge(object, source, srcIndex, customizer);
  29462. });
  29463. /**
  29464. * The opposite of `_.pick`; this method creates an object composed of the
  29465. * own and inherited enumerable property paths of `object` that are not omitted.
  29466. *
  29467. * **Note:** This method is considerably slower than `_.pick`.
  29468. *
  29469. * @static
  29470. * @since 0.1.0
  29471. * @memberOf _
  29472. * @category Object
  29473. * @param {Object} object The source object.
  29474. * @param {...(string|string[])} [paths] The property paths to omit.
  29475. * @returns {Object} Returns the new object.
  29476. * @example
  29477. *
  29478. * var object = { 'a': 1, 'b': '2', 'c': 3 };
  29479. *
  29480. * _.omit(object, ['a', 'c']);
  29481. * // => { 'b': '2' }
  29482. */
  29483. var omit = flatRest(function(object, paths) {
  29484. var result = {};
  29485. if (object == null) {
  29486. return result;
  29487. }
  29488. var isDeep = false;
  29489. paths = arrayMap(paths, function(path) {
  29490. path = castPath(path, object);
  29491. isDeep || (isDeep = path.length > 1);
  29492. return path;
  29493. });
  29494. copyObject(object, getAllKeysIn(object), result);
  29495. if (isDeep) {
  29496. result = baseClone(result, CLONE_DEEP_FLAG | CLONE_FLAT_FLAG | CLONE_SYMBOLS_FLAG, customOmitClone);
  29497. }
  29498. var length = paths.length;
  29499. while (length--) {
  29500. baseUnset(result, paths[length]);
  29501. }
  29502. return result;
  29503. });
  29504. /**
  29505. * The opposite of `_.pickBy`; this method creates an object composed of
  29506. * the own and inherited enumerable string keyed properties of `object` that
  29507. * `predicate` doesn't return truthy for. The predicate is invoked with two
  29508. * arguments: (value, key).
  29509. *
  29510. * @static
  29511. * @memberOf _
  29512. * @since 4.0.0
  29513. * @category Object
  29514. * @param {Object} object The source object.
  29515. * @param {Function} [predicate=_.identity] The function invoked per property.
  29516. * @returns {Object} Returns the new object.
  29517. * @example
  29518. *
  29519. * var object = { 'a': 1, 'b': '2', 'c': 3 };
  29520. *
  29521. * _.omitBy(object, _.isNumber);
  29522. * // => { 'b': '2' }
  29523. */
  29524. function omitBy(object, predicate) {
  29525. return pickBy(object, negate(getIteratee(predicate)));
  29526. }
  29527. /**
  29528. * Creates an object composed of the picked `object` properties.
  29529. *
  29530. * @static
  29531. * @since 0.1.0
  29532. * @memberOf _
  29533. * @category Object
  29534. * @param {Object} object The source object.
  29535. * @param {...(string|string[])} [paths] The property paths to pick.
  29536. * @returns {Object} Returns the new object.
  29537. * @example
  29538. *
  29539. * var object = { 'a': 1, 'b': '2', 'c': 3 };
  29540. *
  29541. * _.pick(object, ['a', 'c']);
  29542. * // => { 'a': 1, 'c': 3 }
  29543. */
  29544. var pick = flatRest(function(object, paths) {
  29545. return object == null ? {} : basePick(object, paths);
  29546. });
  29547. /**
  29548. * Creates an object composed of the `object` properties `predicate` returns
  29549. * truthy for. The predicate is invoked with two arguments: (value, key).
  29550. *
  29551. * @static
  29552. * @memberOf _
  29553. * @since 4.0.0
  29554. * @category Object
  29555. * @param {Object} object The source object.
  29556. * @param {Function} [predicate=_.identity] The function invoked per property.
  29557. * @returns {Object} Returns the new object.
  29558. * @example
  29559. *
  29560. * var object = { 'a': 1, 'b': '2', 'c': 3 };
  29561. *
  29562. * _.pickBy(object, _.isNumber);
  29563. * // => { 'a': 1, 'c': 3 }
  29564. */
  29565. function pickBy(object, predicate) {
  29566. if (object == null) {
  29567. return {};
  29568. }
  29569. var props = arrayMap(getAllKeysIn(object), function(prop) {
  29570. return [prop];
  29571. });
  29572. predicate = getIteratee(predicate);
  29573. return basePickBy(object, props, function(value, path) {
  29574. return predicate(value, path[0]);
  29575. });
  29576. }
  29577. /**
  29578. * This method is like `_.get` except that if the resolved value is a
  29579. * function it's invoked with the `this` binding of its parent object and
  29580. * its result is returned.
  29581. *
  29582. * @static
  29583. * @since 0.1.0
  29584. * @memberOf _
  29585. * @category Object
  29586. * @param {Object} object The object to query.
  29587. * @param {Array|string} path The path of the property to resolve.
  29588. * @param {*} [defaultValue] The value returned for `undefined` resolved values.
  29589. * @returns {*} Returns the resolved value.
  29590. * @example
  29591. *
  29592. * var object = { 'a': [{ 'b': { 'c1': 3, 'c2': _.constant(4) } }] };
  29593. *
  29594. * _.result(object, 'a[0].b.c1');
  29595. * // => 3
  29596. *
  29597. * _.result(object, 'a[0].b.c2');
  29598. * // => 4
  29599. *
  29600. * _.result(object, 'a[0].b.c3', 'default');
  29601. * // => 'default'
  29602. *
  29603. * _.result(object, 'a[0].b.c3', _.constant('default'));
  29604. * // => 'default'
  29605. */
  29606. function result(object, path, defaultValue) {
  29607. path = castPath(path, object);
  29608. var index = -1,
  29609. length = path.length;
  29610. // Ensure the loop is entered when path is empty.
  29611. if (!length) {
  29612. length = 1;
  29613. object = undefined;
  29614. }
  29615. while (++index < length) {
  29616. var value = object == null ? undefined : object[toKey(path[index])];
  29617. if (value === undefined) {
  29618. index = length;
  29619. value = defaultValue;
  29620. }
  29621. object = isFunction(value) ? value.call(object) : value;
  29622. }
  29623. return object;
  29624. }
  29625. /**
  29626. * Sets the value at `path` of `object`. If a portion of `path` doesn't exist,
  29627. * it's created. Arrays are created for missing index properties while objects
  29628. * are created for all other missing properties. Use `_.setWith` to customize
  29629. * `path` creation.
  29630. *
  29631. * **Note:** This method mutates `object`.
  29632. *
  29633. * @static
  29634. * @memberOf _
  29635. * @since 3.7.0
  29636. * @category Object
  29637. * @param {Object} object The object to modify.
  29638. * @param {Array|string} path The path of the property to set.
  29639. * @param {*} value The value to set.
  29640. * @returns {Object} Returns `object`.
  29641. * @example
  29642. *
  29643. * var object = { 'a': [{ 'b': { 'c': 3 } }] };
  29644. *
  29645. * _.set(object, 'a[0].b.c', 4);
  29646. * console.log(object.a[0].b.c);
  29647. * // => 4
  29648. *
  29649. * _.set(object, ['x', '0', 'y', 'z'], 5);
  29650. * console.log(object.x[0].y.z);
  29651. * // => 5
  29652. */
  29653. function set(object, path, value) {
  29654. return object == null ? object : baseSet(object, path, value);
  29655. }
  29656. /**
  29657. * This method is like `_.set` except that it accepts `customizer` which is
  29658. * invoked to produce the objects of `path`. If `customizer` returns `undefined`
  29659. * path creation is handled by the method instead. The `customizer` is invoked
  29660. * with three arguments: (nsValue, key, nsObject).
  29661. *
  29662. * **Note:** This method mutates `object`.
  29663. *
  29664. * @static
  29665. * @memberOf _
  29666. * @since 4.0.0
  29667. * @category Object
  29668. * @param {Object} object The object to modify.
  29669. * @param {Array|string} path The path of the property to set.
  29670. * @param {*} value The value to set.
  29671. * @param {Function} [customizer] The function to customize assigned values.
  29672. * @returns {Object} Returns `object`.
  29673. * @example
  29674. *
  29675. * var object = {};
  29676. *
  29677. * _.setWith(object, '[0][1]', 'a', Object);
  29678. * // => { '0': { '1': 'a' } }
  29679. */
  29680. function setWith(object, path, value, customizer) {
  29681. customizer = typeof customizer == 'function' ? customizer : undefined;
  29682. return object == null ? object : baseSet(object, path, value, customizer);
  29683. }
  29684. /**
  29685. * Creates an array of own enumerable string keyed-value pairs for `object`
  29686. * which can be consumed by `_.fromPairs`. If `object` is a map or set, its
  29687. * entries are returned.
  29688. *
  29689. * @static
  29690. * @memberOf _
  29691. * @since 4.0.0
  29692. * @alias entries
  29693. * @category Object
  29694. * @param {Object} object The object to query.
  29695. * @returns {Array} Returns the key-value pairs.
  29696. * @example
  29697. *
  29698. * function Foo() {
  29699. * this.a = 1;
  29700. * this.b = 2;
  29701. * }
  29702. *
  29703. * Foo.prototype.c = 3;
  29704. *
  29705. * _.toPairs(new Foo);
  29706. * // => [['a', 1], ['b', 2]] (iteration order is not guaranteed)
  29707. */
  29708. var toPairs = createToPairs(keys);
  29709. /**
  29710. * Creates an array of own and inherited enumerable string keyed-value pairs
  29711. * for `object` which can be consumed by `_.fromPairs`. If `object` is a map
  29712. * or set, its entries are returned.
  29713. *
  29714. * @static
  29715. * @memberOf _
  29716. * @since 4.0.0
  29717. * @alias entriesIn
  29718. * @category Object
  29719. * @param {Object} object The object to query.
  29720. * @returns {Array} Returns the key-value pairs.
  29721. * @example
  29722. *
  29723. * function Foo() {
  29724. * this.a = 1;
  29725. * this.b = 2;
  29726. * }
  29727. *
  29728. * Foo.prototype.c = 3;
  29729. *
  29730. * _.toPairsIn(new Foo);
  29731. * // => [['a', 1], ['b', 2], ['c', 3]] (iteration order is not guaranteed)
  29732. */
  29733. var toPairsIn = createToPairs(keysIn);
  29734. /**
  29735. * An alternative to `_.reduce`; this method transforms `object` to a new
  29736. * `accumulator` object which is the result of running each of its own
  29737. * enumerable string keyed properties thru `iteratee`, with each invocation
  29738. * potentially mutating the `accumulator` object. If `accumulator` is not
  29739. * provided, a new object with the same `[[Prototype]]` will be used. The
  29740. * iteratee is invoked with four arguments: (accumulator, value, key, object).
  29741. * Iteratee functions may exit iteration early by explicitly returning `false`.
  29742. *
  29743. * @static
  29744. * @memberOf _
  29745. * @since 1.3.0
  29746. * @category Object
  29747. * @param {Object} object The object to iterate over.
  29748. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  29749. * @param {*} [accumulator] The custom accumulator value.
  29750. * @returns {*} Returns the accumulated value.
  29751. * @example
  29752. *
  29753. * _.transform([2, 3, 4], function(result, n) {
  29754. * result.push(n *= n);
  29755. * return n % 2 == 0;
  29756. * }, []);
  29757. * // => [4, 9]
  29758. *
  29759. * _.transform({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) {
  29760. * (result[value] || (result[value] = [])).push(key);
  29761. * }, {});
  29762. * // => { '1': ['a', 'c'], '2': ['b'] }
  29763. */
  29764. function transform(object, iteratee, accumulator) {
  29765. var isArr = isArray(object),
  29766. isArrLike = isArr || isBuffer(object) || isTypedArray(object);
  29767. iteratee = getIteratee(iteratee, 4);
  29768. if (accumulator == null) {
  29769. var Ctor = object && object.constructor;
  29770. if (isArrLike) {
  29771. accumulator = isArr ? new Ctor : [];
  29772. }
  29773. else if (isObject(object)) {
  29774. accumulator = isFunction(Ctor) ? baseCreate(getPrototype(object)) : {};
  29775. }
  29776. else {
  29777. accumulator = {};
  29778. }
  29779. }
  29780. (isArrLike ? arrayEach : baseForOwn)(object, function(value, index, object) {
  29781. return iteratee(accumulator, value, index, object);
  29782. });
  29783. return accumulator;
  29784. }
  29785. /**
  29786. * Removes the property at `path` of `object`.
  29787. *
  29788. * **Note:** This method mutates `object`.
  29789. *
  29790. * @static
  29791. * @memberOf _
  29792. * @since 4.0.0
  29793. * @category Object
  29794. * @param {Object} object The object to modify.
  29795. * @param {Array|string} path The path of the property to unset.
  29796. * @returns {boolean} Returns `true` if the property is deleted, else `false`.
  29797. * @example
  29798. *
  29799. * var object = { 'a': [{ 'b': { 'c': 7 } }] };
  29800. * _.unset(object, 'a[0].b.c');
  29801. * // => true
  29802. *
  29803. * console.log(object);
  29804. * // => { 'a': [{ 'b': {} }] };
  29805. *
  29806. * _.unset(object, ['a', '0', 'b', 'c']);
  29807. * // => true
  29808. *
  29809. * console.log(object);
  29810. * // => { 'a': [{ 'b': {} }] };
  29811. */
  29812. function unset(object, path) {
  29813. return object == null ? true : baseUnset(object, path);
  29814. }
  29815. /**
  29816. * This method is like `_.set` except that accepts `updater` to produce the
  29817. * value to set. Use `_.updateWith` to customize `path` creation. The `updater`
  29818. * is invoked with one argument: (value).
  29819. *
  29820. * **Note:** This method mutates `object`.
  29821. *
  29822. * @static
  29823. * @memberOf _
  29824. * @since 4.6.0
  29825. * @category Object
  29826. * @param {Object} object The object to modify.
  29827. * @param {Array|string} path The path of the property to set.
  29828. * @param {Function} updater The function to produce the updated value.
  29829. * @returns {Object} Returns `object`.
  29830. * @example
  29831. *
  29832. * var object = { 'a': [{ 'b': { 'c': 3 } }] };
  29833. *
  29834. * _.update(object, 'a[0].b.c', function(n) { return n * n; });
  29835. * console.log(object.a[0].b.c);
  29836. * // => 9
  29837. *
  29838. * _.update(object, 'x[0].y.z', function(n) { return n ? n + 1 : 0; });
  29839. * console.log(object.x[0].y.z);
  29840. * // => 0
  29841. */
  29842. function update(object, path, updater) {
  29843. return object == null ? object : baseUpdate(object, path, castFunction(updater));
  29844. }
  29845. /**
  29846. * This method is like `_.update` except that it accepts `customizer` which is
  29847. * invoked to produce the objects of `path`. If `customizer` returns `undefined`
  29848. * path creation is handled by the method instead. The `customizer` is invoked
  29849. * with three arguments: (nsValue, key, nsObject).
  29850. *
  29851. * **Note:** This method mutates `object`.
  29852. *
  29853. * @static
  29854. * @memberOf _
  29855. * @since 4.6.0
  29856. * @category Object
  29857. * @param {Object} object The object to modify.
  29858. * @param {Array|string} path The path of the property to set.
  29859. * @param {Function} updater The function to produce the updated value.
  29860. * @param {Function} [customizer] The function to customize assigned values.
  29861. * @returns {Object} Returns `object`.
  29862. * @example
  29863. *
  29864. * var object = {};
  29865. *
  29866. * _.updateWith(object, '[0][1]', _.constant('a'), Object);
  29867. * // => { '0': { '1': 'a' } }
  29868. */
  29869. function updateWith(object, path, updater, customizer) {
  29870. customizer = typeof customizer == 'function' ? customizer : undefined;
  29871. return object == null ? object : baseUpdate(object, path, castFunction(updater), customizer);
  29872. }
  29873. /**
  29874. * Creates an array of the own enumerable string keyed property values of `object`.
  29875. *
  29876. * **Note:** Non-object values are coerced to objects.
  29877. *
  29878. * @static
  29879. * @since 0.1.0
  29880. * @memberOf _
  29881. * @category Object
  29882. * @param {Object} object The object to query.
  29883. * @returns {Array} Returns the array of property values.
  29884. * @example
  29885. *
  29886. * function Foo() {
  29887. * this.a = 1;
  29888. * this.b = 2;
  29889. * }
  29890. *
  29891. * Foo.prototype.c = 3;
  29892. *
  29893. * _.values(new Foo);
  29894. * // => [1, 2] (iteration order is not guaranteed)
  29895. *
  29896. * _.values('hi');
  29897. * // => ['h', 'i']
  29898. */
  29899. function values(object) {
  29900. return object == null ? [] : baseValues(object, keys(object));
  29901. }
  29902. /**
  29903. * Creates an array of the own and inherited enumerable string keyed property
  29904. * values of `object`.
  29905. *
  29906. * **Note:** Non-object values are coerced to objects.
  29907. *
  29908. * @static
  29909. * @memberOf _
  29910. * @since 3.0.0
  29911. * @category Object
  29912. * @param {Object} object The object to query.
  29913. * @returns {Array} Returns the array of property values.
  29914. * @example
  29915. *
  29916. * function Foo() {
  29917. * this.a = 1;
  29918. * this.b = 2;
  29919. * }
  29920. *
  29921. * Foo.prototype.c = 3;
  29922. *
  29923. * _.valuesIn(new Foo);
  29924. * // => [1, 2, 3] (iteration order is not guaranteed)
  29925. */
  29926. function valuesIn(object) {
  29927. return object == null ? [] : baseValues(object, keysIn(object));
  29928. }
  29929. /*------------------------------------------------------------------------*/
  29930. /**
  29931. * Clamps `number` within the inclusive `lower` and `upper` bounds.
  29932. *
  29933. * @static
  29934. * @memberOf _
  29935. * @since 4.0.0
  29936. * @category Number
  29937. * @param {number} number The number to clamp.
  29938. * @param {number} [lower] The lower bound.
  29939. * @param {number} upper The upper bound.
  29940. * @returns {number} Returns the clamped number.
  29941. * @example
  29942. *
  29943. * _.clamp(-10, -5, 5);
  29944. * // => -5
  29945. *
  29946. * _.clamp(10, -5, 5);
  29947. * // => 5
  29948. */
  29949. function clamp(number, lower, upper) {
  29950. if (upper === undefined) {
  29951. upper = lower;
  29952. lower = undefined;
  29953. }
  29954. if (upper !== undefined) {
  29955. upper = toNumber(upper);
  29956. upper = upper === upper ? upper : 0;
  29957. }
  29958. if (lower !== undefined) {
  29959. lower = toNumber(lower);
  29960. lower = lower === lower ? lower : 0;
  29961. }
  29962. return baseClamp(toNumber(number), lower, upper);
  29963. }
  29964. /**
  29965. * Checks if `n` is between `start` and up to, but not including, `end`. If
  29966. * `end` is not specified, it's set to `start` with `start` then set to `0`.
  29967. * If `start` is greater than `end` the params are swapped to support
  29968. * negative ranges.
  29969. *
  29970. * @static
  29971. * @memberOf _
  29972. * @since 3.3.0
  29973. * @category Number
  29974. * @param {number} number The number to check.
  29975. * @param {number} [start=0] The start of the range.
  29976. * @param {number} end The end of the range.
  29977. * @returns {boolean} Returns `true` if `number` is in the range, else `false`.
  29978. * @see _.range, _.rangeRight
  29979. * @example
  29980. *
  29981. * _.inRange(3, 2, 4);
  29982. * // => true
  29983. *
  29984. * _.inRange(4, 8);
  29985. * // => true
  29986. *
  29987. * _.inRange(4, 2);
  29988. * // => false
  29989. *
  29990. * _.inRange(2, 2);
  29991. * // => false
  29992. *
  29993. * _.inRange(1.2, 2);
  29994. * // => true
  29995. *
  29996. * _.inRange(5.2, 4);
  29997. * // => false
  29998. *
  29999. * _.inRange(-3, -2, -6);
  30000. * // => true
  30001. */
  30002. function inRange(number, start, end) {
  30003. start = toFinite(start);
  30004. if (end === undefined) {
  30005. end = start;
  30006. start = 0;
  30007. } else {
  30008. end = toFinite(end);
  30009. }
  30010. number = toNumber(number);
  30011. return baseInRange(number, start, end);
  30012. }
  30013. /**
  30014. * Produces a random number between the inclusive `lower` and `upper` bounds.
  30015. * If only one argument is provided a number between `0` and the given number
  30016. * is returned. If `floating` is `true`, or either `lower` or `upper` are
  30017. * floats, a floating-point number is returned instead of an integer.
  30018. *
  30019. * **Note:** JavaScript follows the IEEE-754 standard for resolving
  30020. * floating-point values which can produce unexpected results.
  30021. *
  30022. * @static
  30023. * @memberOf _
  30024. * @since 0.7.0
  30025. * @category Number
  30026. * @param {number} [lower=0] The lower bound.
  30027. * @param {number} [upper=1] The upper bound.
  30028. * @param {boolean} [floating] Specify returning a floating-point number.
  30029. * @returns {number} Returns the random number.
  30030. * @example
  30031. *
  30032. * _.random(0, 5);
  30033. * // => an integer between 0 and 5
  30034. *
  30035. * _.random(5);
  30036. * // => also an integer between 0 and 5
  30037. *
  30038. * _.random(5, true);
  30039. * // => a floating-point number between 0 and 5
  30040. *
  30041. * _.random(1.2, 5.2);
  30042. * // => a floating-point number between 1.2 and 5.2
  30043. */
  30044. function random(lower, upper, floating) {
  30045. if (floating && typeof floating != 'boolean' && isIterateeCall(lower, upper, floating)) {
  30046. upper = floating = undefined;
  30047. }
  30048. if (floating === undefined) {
  30049. if (typeof upper == 'boolean') {
  30050. floating = upper;
  30051. upper = undefined;
  30052. }
  30053. else if (typeof lower == 'boolean') {
  30054. floating = lower;
  30055. lower = undefined;
  30056. }
  30057. }
  30058. if (lower === undefined && upper === undefined) {
  30059. lower = 0;
  30060. upper = 1;
  30061. }
  30062. else {
  30063. lower = toFinite(lower);
  30064. if (upper === undefined) {
  30065. upper = lower;
  30066. lower = 0;
  30067. } else {
  30068. upper = toFinite(upper);
  30069. }
  30070. }
  30071. if (lower > upper) {
  30072. var temp = lower;
  30073. lower = upper;
  30074. upper = temp;
  30075. }
  30076. if (floating || lower % 1 || upper % 1) {
  30077. var rand = nativeRandom();
  30078. return nativeMin(lower + (rand * (upper - lower + freeParseFloat('1e-' + ((rand + '').length - 1)))), upper);
  30079. }
  30080. return baseRandom(lower, upper);
  30081. }
  30082. /*------------------------------------------------------------------------*/
  30083. /**
  30084. * Converts `string` to [camel case](https://en.wikipedia.org/wiki/CamelCase).
  30085. *
  30086. * @static
  30087. * @memberOf _
  30088. * @since 3.0.0
  30089. * @category String
  30090. * @param {string} [string=''] The string to convert.
  30091. * @returns {string} Returns the camel cased string.
  30092. * @example
  30093. *
  30094. * _.camelCase('Foo Bar');
  30095. * // => 'fooBar'
  30096. *
  30097. * _.camelCase('--foo-bar--');
  30098. * // => 'fooBar'
  30099. *
  30100. * _.camelCase('__FOO_BAR__');
  30101. * // => 'fooBar'
  30102. */
  30103. var camelCase = createCompounder(function(result, word, index) {
  30104. word = word.toLowerCase();
  30105. return result + (index ? capitalize(word) : word);
  30106. });
  30107. /**
  30108. * Converts the first character of `string` to upper case and the remaining
  30109. * to lower case.
  30110. *
  30111. * @static
  30112. * @memberOf _
  30113. * @since 3.0.0
  30114. * @category String
  30115. * @param {string} [string=''] The string to capitalize.
  30116. * @returns {string} Returns the capitalized string.
  30117. * @example
  30118. *
  30119. * _.capitalize('FRED');
  30120. * // => 'Fred'
  30121. */
  30122. function capitalize(string) {
  30123. return upperFirst(toString(string).toLowerCase());
  30124. }
  30125. /**
  30126. * Deburrs `string` by converting
  30127. * [Latin-1 Supplement](https://en.wikipedia.org/wiki/Latin-1_Supplement_(Unicode_block)#Character_table)
  30128. * and [Latin Extended-A](https://en.wikipedia.org/wiki/Latin_Extended-A)
  30129. * letters to basic Latin letters and removing
  30130. * [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks).
  30131. *
  30132. * @static
  30133. * @memberOf _
  30134. * @since 3.0.0
  30135. * @category String
  30136. * @param {string} [string=''] The string to deburr.
  30137. * @returns {string} Returns the deburred string.
  30138. * @example
  30139. *
  30140. * _.deburr('déjà vu');
  30141. * // => 'deja vu'
  30142. */
  30143. function deburr(string) {
  30144. string = toString(string);
  30145. return string && string.replace(reLatin, deburrLetter).replace(reComboMark, '');
  30146. }
  30147. /**
  30148. * Checks if `string` ends with the given target string.
  30149. *
  30150. * @static
  30151. * @memberOf _
  30152. * @since 3.0.0
  30153. * @category String
  30154. * @param {string} [string=''] The string to inspect.
  30155. * @param {string} [target] The string to search for.
  30156. * @param {number} [position=string.length] The position to search up to.
  30157. * @returns {boolean} Returns `true` if `string` ends with `target`,
  30158. * else `false`.
  30159. * @example
  30160. *
  30161. * _.endsWith('abc', 'c');
  30162. * // => true
  30163. *
  30164. * _.endsWith('abc', 'b');
  30165. * // => false
  30166. *
  30167. * _.endsWith('abc', 'b', 2);
  30168. * // => true
  30169. */
  30170. function endsWith(string, target, position) {
  30171. string = toString(string);
  30172. target = baseToString(target);
  30173. var length = string.length;
  30174. position = position === undefined
  30175. ? length
  30176. : baseClamp(toInteger(position), 0, length);
  30177. var end = position;
  30178. position -= target.length;
  30179. return position >= 0 && string.slice(position, end) == target;
  30180. }
  30181. /**
  30182. * Converts the characters "&", "<", ">", '"', and "'" in `string` to their
  30183. * corresponding HTML entities.
  30184. *
  30185. * **Note:** No other characters are escaped. To escape additional
  30186. * characters use a third-party library like [_he_](https://mths.be/he).
  30187. *
  30188. * Though the ">" character is escaped for symmetry, characters like
  30189. * ">" and "/" don't need escaping in HTML and have no special meaning
  30190. * unless they're part of a tag or unquoted attribute value. See
  30191. * [Mathias Bynens's article](https://mathiasbynens.be/notes/ambiguous-ampersands)
  30192. * (under "semi-related fun fact") for more details.
  30193. *
  30194. * When working with HTML you should always
  30195. * [quote attribute values](http://wonko.com/post/html-escaping) to reduce
  30196. * XSS vectors.
  30197. *
  30198. * @static
  30199. * @since 0.1.0
  30200. * @memberOf _
  30201. * @category String
  30202. * @param {string} [string=''] The string to escape.
  30203. * @returns {string} Returns the escaped string.
  30204. * @example
  30205. *
  30206. * _.escape('fred, barney, & pebbles');
  30207. * // => 'fred, barney, &amp; pebbles'
  30208. */
  30209. function escape(string) {
  30210. string = toString(string);
  30211. return (string && reHasUnescapedHtml.test(string))
  30212. ? string.replace(reUnescapedHtml, escapeHtmlChar)
  30213. : string;
  30214. }
  30215. /**
  30216. * Escapes the `RegExp` special characters "^", "$", "\", ".", "*", "+",
  30217. * "?", "(", ")", "[", "]", "{", "}", and "|" in `string`.
  30218. *
  30219. * @static
  30220. * @memberOf _
  30221. * @since 3.0.0
  30222. * @category String
  30223. * @param {string} [string=''] The string to escape.
  30224. * @returns {string} Returns the escaped string.
  30225. * @example
  30226. *
  30227. * _.escapeRegExp('[lodash](https://lodash.com/)');
  30228. * // => '\[lodash\]\(https://lodash\.com/\)'
  30229. */
  30230. function escapeRegExp(string) {
  30231. string = toString(string);
  30232. return (string && reHasRegExpChar.test(string))
  30233. ? string.replace(reRegExpChar, '\\$&')
  30234. : string;
  30235. }
  30236. /**
  30237. * Converts `string` to
  30238. * [kebab case](https://en.wikipedia.org/wiki/Letter_case#Special_case_styles).
  30239. *
  30240. * @static
  30241. * @memberOf _
  30242. * @since 3.0.0
  30243. * @category String
  30244. * @param {string} [string=''] The string to convert.
  30245. * @returns {string} Returns the kebab cased string.
  30246. * @example
  30247. *
  30248. * _.kebabCase('Foo Bar');
  30249. * // => 'foo-bar'
  30250. *
  30251. * _.kebabCase('fooBar');
  30252. * // => 'foo-bar'
  30253. *
  30254. * _.kebabCase('__FOO_BAR__');
  30255. * // => 'foo-bar'
  30256. */
  30257. var kebabCase = createCompounder(function(result, word, index) {
  30258. return result + (index ? '-' : '') + word.toLowerCase();
  30259. });
  30260. /**
  30261. * Converts `string`, as space separated words, to lower case.
  30262. *
  30263. * @static
  30264. * @memberOf _
  30265. * @since 4.0.0
  30266. * @category String
  30267. * @param {string} [string=''] The string to convert.
  30268. * @returns {string} Returns the lower cased string.
  30269. * @example
  30270. *
  30271. * _.lowerCase('--Foo-Bar--');
  30272. * // => 'foo bar'
  30273. *
  30274. * _.lowerCase('fooBar');
  30275. * // => 'foo bar'
  30276. *
  30277. * _.lowerCase('__FOO_BAR__');
  30278. * // => 'foo bar'
  30279. */
  30280. var lowerCase = createCompounder(function(result, word, index) {
  30281. return result + (index ? ' ' : '') + word.toLowerCase();
  30282. });
  30283. /**
  30284. * Converts the first character of `string` to lower case.
  30285. *
  30286. * @static
  30287. * @memberOf _
  30288. * @since 4.0.0
  30289. * @category String
  30290. * @param {string} [string=''] The string to convert.
  30291. * @returns {string} Returns the converted string.
  30292. * @example
  30293. *
  30294. * _.lowerFirst('Fred');
  30295. * // => 'fred'
  30296. *
  30297. * _.lowerFirst('FRED');
  30298. * // => 'fRED'
  30299. */
  30300. var lowerFirst = createCaseFirst('toLowerCase');
  30301. /**
  30302. * Pads `string` on the left and right sides if it's shorter than `length`.
  30303. * Padding characters are truncated if they can't be evenly divided by `length`.
  30304. *
  30305. * @static
  30306. * @memberOf _
  30307. * @since 3.0.0
  30308. * @category String
  30309. * @param {string} [string=''] The string to pad.
  30310. * @param {number} [length=0] The padding length.
  30311. * @param {string} [chars=' '] The string used as padding.
  30312. * @returns {string} Returns the padded string.
  30313. * @example
  30314. *
  30315. * _.pad('abc', 8);
  30316. * // => ' abc '
  30317. *
  30318. * _.pad('abc', 8, '_-');
  30319. * // => '_-abc_-_'
  30320. *
  30321. * _.pad('abc', 3);
  30322. * // => 'abc'
  30323. */
  30324. function pad(string, length, chars) {
  30325. string = toString(string);
  30326. length = toInteger(length);
  30327. var strLength = length ? stringSize(string) : 0;
  30328. if (!length || strLength >= length) {
  30329. return string;
  30330. }
  30331. var mid = (length - strLength) / 2;
  30332. return (
  30333. createPadding(nativeFloor(mid), chars) +
  30334. string +
  30335. createPadding(nativeCeil(mid), chars)
  30336. );
  30337. }
  30338. /**
  30339. * Pads `string` on the right side if it's shorter than `length`. Padding
  30340. * characters are truncated if they exceed `length`.
  30341. *
  30342. * @static
  30343. * @memberOf _
  30344. * @since 4.0.0
  30345. * @category String
  30346. * @param {string} [string=''] The string to pad.
  30347. * @param {number} [length=0] The padding length.
  30348. * @param {string} [chars=' '] The string used as padding.
  30349. * @returns {string} Returns the padded string.
  30350. * @example
  30351. *
  30352. * _.padEnd('abc', 6);
  30353. * // => 'abc '
  30354. *
  30355. * _.padEnd('abc', 6, '_-');
  30356. * // => 'abc_-_'
  30357. *
  30358. * _.padEnd('abc', 3);
  30359. * // => 'abc'
  30360. */
  30361. function padEnd(string, length, chars) {
  30362. string = toString(string);
  30363. length = toInteger(length);
  30364. var strLength = length ? stringSize(string) : 0;
  30365. return (length && strLength < length)
  30366. ? (string + createPadding(length - strLength, chars))
  30367. : string;
  30368. }
  30369. /**
  30370. * Pads `string` on the left side if it's shorter than `length`. Padding
  30371. * characters are truncated if they exceed `length`.
  30372. *
  30373. * @static
  30374. * @memberOf _
  30375. * @since 4.0.0
  30376. * @category String
  30377. * @param {string} [string=''] The string to pad.
  30378. * @param {number} [length=0] The padding length.
  30379. * @param {string} [chars=' '] The string used as padding.
  30380. * @returns {string} Returns the padded string.
  30381. * @example
  30382. *
  30383. * _.padStart('abc', 6);
  30384. * // => ' abc'
  30385. *
  30386. * _.padStart('abc', 6, '_-');
  30387. * // => '_-_abc'
  30388. *
  30389. * _.padStart('abc', 3);
  30390. * // => 'abc'
  30391. */
  30392. function padStart(string, length, chars) {
  30393. string = toString(string);
  30394. length = toInteger(length);
  30395. var strLength = length ? stringSize(string) : 0;
  30396. return (length && strLength < length)
  30397. ? (createPadding(length - strLength, chars) + string)
  30398. : string;
  30399. }
  30400. /**
  30401. * Converts `string` to an integer of the specified radix. If `radix` is
  30402. * `undefined` or `0`, a `radix` of `10` is used unless `value` is a
  30403. * hexadecimal, in which case a `radix` of `16` is used.
  30404. *
  30405. * **Note:** This method aligns with the
  30406. * [ES5 implementation](https://es5.github.io/#x15.1.2.2) of `parseInt`.
  30407. *
  30408. * @static
  30409. * @memberOf _
  30410. * @since 1.1.0
  30411. * @category String
  30412. * @param {string} string The string to convert.
  30413. * @param {number} [radix=10] The radix to interpret `value` by.
  30414. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  30415. * @returns {number} Returns the converted integer.
  30416. * @example
  30417. *
  30418. * _.parseInt('08');
  30419. * // => 8
  30420. *
  30421. * _.map(['6', '08', '10'], _.parseInt);
  30422. * // => [6, 8, 10]
  30423. */
  30424. function parseInt(string, radix, guard) {
  30425. if (guard || radix == null) {
  30426. radix = 0;
  30427. } else if (radix) {
  30428. radix = +radix;
  30429. }
  30430. return nativeParseInt(toString(string).replace(reTrimStart, ''), radix || 0);
  30431. }
  30432. /**
  30433. * Repeats the given string `n` times.
  30434. *
  30435. * @static
  30436. * @memberOf _
  30437. * @since 3.0.0
  30438. * @category String
  30439. * @param {string} [string=''] The string to repeat.
  30440. * @param {number} [n=1] The number of times to repeat the string.
  30441. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  30442. * @returns {string} Returns the repeated string.
  30443. * @example
  30444. *
  30445. * _.repeat('*', 3);
  30446. * // => '***'
  30447. *
  30448. * _.repeat('abc', 2);
  30449. * // => 'abcabc'
  30450. *
  30451. * _.repeat('abc', 0);
  30452. * // => ''
  30453. */
  30454. function repeat(string, n, guard) {
  30455. if ((guard ? isIterateeCall(string, n, guard) : n === undefined)) {
  30456. n = 1;
  30457. } else {
  30458. n = toInteger(n);
  30459. }
  30460. return baseRepeat(toString(string), n);
  30461. }
  30462. /**
  30463. * Replaces matches for `pattern` in `string` with `replacement`.
  30464. *
  30465. * **Note:** This method is based on
  30466. * [`String#replace`](https://mdn.io/String/replace).
  30467. *
  30468. * @static
  30469. * @memberOf _
  30470. * @since 4.0.0
  30471. * @category String
  30472. * @param {string} [string=''] The string to modify.
  30473. * @param {RegExp|string} pattern The pattern to replace.
  30474. * @param {Function|string} replacement The match replacement.
  30475. * @returns {string} Returns the modified string.
  30476. * @example
  30477. *
  30478. * _.replace('Hi Fred', 'Fred', 'Barney');
  30479. * // => 'Hi Barney'
  30480. */
  30481. function replace() {
  30482. var args = arguments,
  30483. string = toString(args[0]);
  30484. return args.length < 3 ? string : string.replace(args[1], args[2]);
  30485. }
  30486. /**
  30487. * Converts `string` to
  30488. * [snake case](https://en.wikipedia.org/wiki/Snake_case).
  30489. *
  30490. * @static
  30491. * @memberOf _
  30492. * @since 3.0.0
  30493. * @category String
  30494. * @param {string} [string=''] The string to convert.
  30495. * @returns {string} Returns the snake cased string.
  30496. * @example
  30497. *
  30498. * _.snakeCase('Foo Bar');
  30499. * // => 'foo_bar'
  30500. *
  30501. * _.snakeCase('fooBar');
  30502. * // => 'foo_bar'
  30503. *
  30504. * _.snakeCase('--FOO-BAR--');
  30505. * // => 'foo_bar'
  30506. */
  30507. var snakeCase = createCompounder(function(result, word, index) {
  30508. return result + (index ? '_' : '') + word.toLowerCase();
  30509. });
  30510. /**
  30511. * Splits `string` by `separator`.
  30512. *
  30513. * **Note:** This method is based on
  30514. * [`String#split`](https://mdn.io/String/split).
  30515. *
  30516. * @static
  30517. * @memberOf _
  30518. * @since 4.0.0
  30519. * @category String
  30520. * @param {string} [string=''] The string to split.
  30521. * @param {RegExp|string} separator The separator pattern to split by.
  30522. * @param {number} [limit] The length to truncate results to.
  30523. * @returns {Array} Returns the string segments.
  30524. * @example
  30525. *
  30526. * _.split('a-b-c', '-', 2);
  30527. * // => ['a', 'b']
  30528. */
  30529. function split(string, separator, limit) {
  30530. if (limit && typeof limit != 'number' && isIterateeCall(string, separator, limit)) {
  30531. separator = limit = undefined;
  30532. }
  30533. limit = limit === undefined ? MAX_ARRAY_LENGTH : limit >>> 0;
  30534. if (!limit) {
  30535. return [];
  30536. }
  30537. string = toString(string);
  30538. if (string && (
  30539. typeof separator == 'string' ||
  30540. (separator != null && !isRegExp(separator))
  30541. )) {
  30542. separator = baseToString(separator);
  30543. if (!separator && hasUnicode(string)) {
  30544. return castSlice(stringToArray(string), 0, limit);
  30545. }
  30546. }
  30547. return string.split(separator, limit);
  30548. }
  30549. /**
  30550. * Converts `string` to
  30551. * [start case](https://en.wikipedia.org/wiki/Letter_case#Stylistic_or_specialised_usage).
  30552. *
  30553. * @static
  30554. * @memberOf _
  30555. * @since 3.1.0
  30556. * @category String
  30557. * @param {string} [string=''] The string to convert.
  30558. * @returns {string} Returns the start cased string.
  30559. * @example
  30560. *
  30561. * _.startCase('--foo-bar--');
  30562. * // => 'Foo Bar'
  30563. *
  30564. * _.startCase('fooBar');
  30565. * // => 'Foo Bar'
  30566. *
  30567. * _.startCase('__FOO_BAR__');
  30568. * // => 'FOO BAR'
  30569. */
  30570. var startCase = createCompounder(function(result, word, index) {
  30571. return result + (index ? ' ' : '') + upperFirst(word);
  30572. });
  30573. /**
  30574. * Checks if `string` starts with the given target string.
  30575. *
  30576. * @static
  30577. * @memberOf _
  30578. * @since 3.0.0
  30579. * @category String
  30580. * @param {string} [string=''] The string to inspect.
  30581. * @param {string} [target] The string to search for.
  30582. * @param {number} [position=0] The position to search from.
  30583. * @returns {boolean} Returns `true` if `string` starts with `target`,
  30584. * else `false`.
  30585. * @example
  30586. *
  30587. * _.startsWith('abc', 'a');
  30588. * // => true
  30589. *
  30590. * _.startsWith('abc', 'b');
  30591. * // => false
  30592. *
  30593. * _.startsWith('abc', 'b', 1);
  30594. * // => true
  30595. */
  30596. function startsWith(string, target, position) {
  30597. string = toString(string);
  30598. position = position == null
  30599. ? 0
  30600. : baseClamp(toInteger(position), 0, string.length);
  30601. target = baseToString(target);
  30602. return string.slice(position, position + target.length) == target;
  30603. }
  30604. /**
  30605. * Creates a compiled template function that can interpolate data properties
  30606. * in "interpolate" delimiters, HTML-escape interpolated data properties in
  30607. * "escape" delimiters, and execute JavaScript in "evaluate" delimiters. Data
  30608. * properties may be accessed as free variables in the template. If a setting
  30609. * object is given, it takes precedence over `_.templateSettings` values.
  30610. *
  30611. * **Note:** In the development build `_.template` utilizes
  30612. * [sourceURLs](http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/#toc-sourceurl)
  30613. * for easier debugging.
  30614. *
  30615. * For more information on precompiling templates see
  30616. * [lodash's custom builds documentation](https://lodash.com/custom-builds).
  30617. *
  30618. * For more information on Chrome extension sandboxes see
  30619. * [Chrome's extensions documentation](https://developer.chrome.com/extensions/sandboxingEval).
  30620. *
  30621. * @static
  30622. * @since 0.1.0
  30623. * @memberOf _
  30624. * @category String
  30625. * @param {string} [string=''] The template string.
  30626. * @param {Object} [options={}] The options object.
  30627. * @param {RegExp} [options.escape=_.templateSettings.escape]
  30628. * The HTML "escape" delimiter.
  30629. * @param {RegExp} [options.evaluate=_.templateSettings.evaluate]
  30630. * The "evaluate" delimiter.
  30631. * @param {Object} [options.imports=_.templateSettings.imports]
  30632. * An object to import into the template as free variables.
  30633. * @param {RegExp} [options.interpolate=_.templateSettings.interpolate]
  30634. * The "interpolate" delimiter.
  30635. * @param {string} [options.sourceURL='lodash.templateSources[n]']
  30636. * The sourceURL of the compiled template.
  30637. * @param {string} [options.variable='obj']
  30638. * The data object variable name.
  30639. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  30640. * @returns {Function} Returns the compiled template function.
  30641. * @example
  30642. *
  30643. * // Use the "interpolate" delimiter to create a compiled template.
  30644. * var compiled = _.template('hello <%= user %>!');
  30645. * compiled({ 'user': 'fred' });
  30646. * // => 'hello fred!'
  30647. *
  30648. * // Use the HTML "escape" delimiter to escape data property values.
  30649. * var compiled = _.template('<b><%- value %></b>');
  30650. * compiled({ 'value': '<script>' });
  30651. * // => '<b>&lt;script&gt;</b>'
  30652. *
  30653. * // Use the "evaluate" delimiter to execute JavaScript and generate HTML.
  30654. * var compiled = _.template('<% _.forEach(users, function(user) { %><li><%- user %></li><% }); %>');
  30655. * compiled({ 'users': ['fred', 'barney'] });
  30656. * // => '<li>fred</li><li>barney</li>'
  30657. *
  30658. * // Use the internal `print` function in "evaluate" delimiters.
  30659. * var compiled = _.template('<% print("hello " + user); %>!');
  30660. * compiled({ 'user': 'barney' });
  30661. * // => 'hello barney!'
  30662. *
  30663. * // Use the ES template literal delimiter as an "interpolate" delimiter.
  30664. * // Disable support by replacing the "interpolate" delimiter.
  30665. * var compiled = _.template('hello ${ user }!');
  30666. * compiled({ 'user': 'pebbles' });
  30667. * // => 'hello pebbles!'
  30668. *
  30669. * // Use backslashes to treat delimiters as plain text.
  30670. * var compiled = _.template('<%= "\\<%- value %\\>" %>');
  30671. * compiled({ 'value': 'ignored' });
  30672. * // => '<%- value %>'
  30673. *
  30674. * // Use the `imports` option to import `jQuery` as `jq`.
  30675. * var text = '<% jq.each(users, function(user) { %><li><%- user %></li><% }); %>';
  30676. * var compiled = _.template(text, { 'imports': { 'jq': jQuery } });
  30677. * compiled({ 'users': ['fred', 'barney'] });
  30678. * // => '<li>fred</li><li>barney</li>'
  30679. *
  30680. * // Use the `sourceURL` option to specify a custom sourceURL for the template.
  30681. * var compiled = _.template('hello <%= user %>!', { 'sourceURL': '/basic/greeting.jst' });
  30682. * compiled(data);
  30683. * // => Find the source of "greeting.jst" under the Sources tab or Resources panel of the web inspector.
  30684. *
  30685. * // Use the `variable` option to ensure a with-statement isn't used in the compiled template.
  30686. * var compiled = _.template('hi <%= data.user %>!', { 'variable': 'data' });
  30687. * compiled.source;
  30688. * // => function(data) {
  30689. * // var __t, __p = '';
  30690. * // __p += 'hi ' + ((__t = ( data.user )) == null ? '' : __t) + '!';
  30691. * // return __p;
  30692. * // }
  30693. *
  30694. * // Use custom template delimiters.
  30695. * _.templateSettings.interpolate = /{{([\s\S]+?)}}/g;
  30696. * var compiled = _.template('hello {{ user }}!');
  30697. * compiled({ 'user': 'mustache' });
  30698. * // => 'hello mustache!'
  30699. *
  30700. * // Use the `source` property to inline compiled templates for meaningful
  30701. * // line numbers in error messages and stack traces.
  30702. * fs.writeFileSync(path.join(process.cwd(), 'jst.js'), '\
  30703. * var JST = {\
  30704. * "main": ' + _.template(mainText).source + '\
  30705. * };\
  30706. * ');
  30707. */
  30708. function template(string, options, guard) {
  30709. // Based on John Resig's `tmpl` implementation
  30710. // (http://ejohn.org/blog/javascript-micro-templating/)
  30711. // and Laura Doktorova's doT.js (https://github.com/olado/doT).
  30712. var settings = lodash.templateSettings;
  30713. if (guard && isIterateeCall(string, options, guard)) {
  30714. options = undefined;
  30715. }
  30716. string = toString(string);
  30717. options = assignInWith({}, options, settings, customDefaultsAssignIn);
  30718. var imports = assignInWith({}, options.imports, settings.imports, customDefaultsAssignIn),
  30719. importsKeys = keys(imports),
  30720. importsValues = baseValues(imports, importsKeys);
  30721. var isEscaping,
  30722. isEvaluating,
  30723. index = 0,
  30724. interpolate = options.interpolate || reNoMatch,
  30725. source = "__p += '";
  30726. // Compile the regexp to match each delimiter.
  30727. var reDelimiters = RegExp(
  30728. (options.escape || reNoMatch).source + '|' +
  30729. interpolate.source + '|' +
  30730. (interpolate === reInterpolate ? reEsTemplate : reNoMatch).source + '|' +
  30731. (options.evaluate || reNoMatch).source + '|$'
  30732. , 'g');
  30733. // Use a sourceURL for easier debugging.
  30734. // The sourceURL gets injected into the source that's eval-ed, so be careful
  30735. // with lookup (in case of e.g. prototype pollution), and strip newlines if any.
  30736. // A newline wouldn't be a valid sourceURL anyway, and it'd enable code injection.
  30737. var sourceURL = '//# sourceURL=' +
  30738. (hasOwnProperty.call(options, 'sourceURL')
  30739. ? (options.sourceURL + '').replace(/[\r\n]/g, ' ')
  30740. : ('lodash.templateSources[' + (++templateCounter) + ']')
  30741. ) + '\n';
  30742. string.replace(reDelimiters, function(match, escapeValue, interpolateValue, esTemplateValue, evaluateValue, offset) {
  30743. interpolateValue || (interpolateValue = esTemplateValue);
  30744. // Escape characters that can't be included in string literals.
  30745. source += string.slice(index, offset).replace(reUnescapedString, escapeStringChar);
  30746. // Replace delimiters with snippets.
  30747. if (escapeValue) {
  30748. isEscaping = true;
  30749. source += "' +\n__e(" + escapeValue + ") +\n'";
  30750. }
  30751. if (evaluateValue) {
  30752. isEvaluating = true;
  30753. source += "';\n" + evaluateValue + ";\n__p += '";
  30754. }
  30755. if (interpolateValue) {
  30756. source += "' +\n((__t = (" + interpolateValue + ")) == null ? '' : __t) +\n'";
  30757. }
  30758. index = offset + match.length;
  30759. // The JS engine embedded in Adobe products needs `match` returned in
  30760. // order to produce the correct `offset` value.
  30761. return match;
  30762. });
  30763. source += "';\n";
  30764. // If `variable` is not specified wrap a with-statement around the generated
  30765. // code to add the data object to the top of the scope chain.
  30766. // Like with sourceURL, we take care to not check the option's prototype,
  30767. // as this configuration is a code injection vector.
  30768. var variable = hasOwnProperty.call(options, 'variable') && options.variable;
  30769. if (!variable) {
  30770. source = 'with (obj) {\n' + source + '\n}\n';
  30771. }
  30772. // Cleanup code by stripping empty strings.
  30773. source = (isEvaluating ? source.replace(reEmptyStringLeading, '') : source)
  30774. .replace(reEmptyStringMiddle, '$1')
  30775. .replace(reEmptyStringTrailing, '$1;');
  30776. // Frame code as the function body.
  30777. source = 'function(' + (variable || 'obj') + ') {\n' +
  30778. (variable
  30779. ? ''
  30780. : 'obj || (obj = {});\n'
  30781. ) +
  30782. "var __t, __p = ''" +
  30783. (isEscaping
  30784. ? ', __e = _.escape'
  30785. : ''
  30786. ) +
  30787. (isEvaluating
  30788. ? ', __j = Array.prototype.join;\n' +
  30789. "function print() { __p += __j.call(arguments, '') }\n"
  30790. : ';\n'
  30791. ) +
  30792. source +
  30793. 'return __p\n}';
  30794. var result = attempt(function() {
  30795. return Function(importsKeys, sourceURL + 'return ' + source)
  30796. .apply(undefined, importsValues);
  30797. });
  30798. // Provide the compiled function's source by its `toString` method or
  30799. // the `source` property as a convenience for inlining compiled templates.
  30800. result.source = source;
  30801. if (isError(result)) {
  30802. throw result;
  30803. }
  30804. return result;
  30805. }
  30806. /**
  30807. * Converts `string`, as a whole, to lower case just like
  30808. * [String#toLowerCase](https://mdn.io/toLowerCase).
  30809. *
  30810. * @static
  30811. * @memberOf _
  30812. * @since 4.0.0
  30813. * @category String
  30814. * @param {string} [string=''] The string to convert.
  30815. * @returns {string} Returns the lower cased string.
  30816. * @example
  30817. *
  30818. * _.toLower('--Foo-Bar--');
  30819. * // => '--foo-bar--'
  30820. *
  30821. * _.toLower('fooBar');
  30822. * // => 'foobar'
  30823. *
  30824. * _.toLower('__FOO_BAR__');
  30825. * // => '__foo_bar__'
  30826. */
  30827. function toLower(value) {
  30828. return toString(value).toLowerCase();
  30829. }
  30830. /**
  30831. * Converts `string`, as a whole, to upper case just like
  30832. * [String#toUpperCase](https://mdn.io/toUpperCase).
  30833. *
  30834. * @static
  30835. * @memberOf _
  30836. * @since 4.0.0
  30837. * @category String
  30838. * @param {string} [string=''] The string to convert.
  30839. * @returns {string} Returns the upper cased string.
  30840. * @example
  30841. *
  30842. * _.toUpper('--foo-bar--');
  30843. * // => '--FOO-BAR--'
  30844. *
  30845. * _.toUpper('fooBar');
  30846. * // => 'FOOBAR'
  30847. *
  30848. * _.toUpper('__foo_bar__');
  30849. * // => '__FOO_BAR__'
  30850. */
  30851. function toUpper(value) {
  30852. return toString(value).toUpperCase();
  30853. }
  30854. /**
  30855. * Removes leading and trailing whitespace or specified characters from `string`.
  30856. *
  30857. * @static
  30858. * @memberOf _
  30859. * @since 3.0.0
  30860. * @category String
  30861. * @param {string} [string=''] The string to trim.
  30862. * @param {string} [chars=whitespace] The characters to trim.
  30863. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  30864. * @returns {string} Returns the trimmed string.
  30865. * @example
  30866. *
  30867. * _.trim(' abc ');
  30868. * // => 'abc'
  30869. *
  30870. * _.trim('-_-abc-_-', '_-');
  30871. * // => 'abc'
  30872. *
  30873. * _.map([' foo ', ' bar '], _.trim);
  30874. * // => ['foo', 'bar']
  30875. */
  30876. function trim(string, chars, guard) {
  30877. string = toString(string);
  30878. if (string && (guard || chars === undefined)) {
  30879. return string.replace(reTrim, '');
  30880. }
  30881. if (!string || !(chars = baseToString(chars))) {
  30882. return string;
  30883. }
  30884. var strSymbols = stringToArray(string),
  30885. chrSymbols = stringToArray(chars),
  30886. start = charsStartIndex(strSymbols, chrSymbols),
  30887. end = charsEndIndex(strSymbols, chrSymbols) + 1;
  30888. return castSlice(strSymbols, start, end).join('');
  30889. }
  30890. /**
  30891. * Removes trailing whitespace or specified characters from `string`.
  30892. *
  30893. * @static
  30894. * @memberOf _
  30895. * @since 4.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. * _.trimEnd(' abc ');
  30904. * // => ' abc'
  30905. *
  30906. * _.trimEnd('-_-abc-_-', '_-');
  30907. * // => '-_-abc'
  30908. */
  30909. function trimEnd(string, chars, guard) {
  30910. string = toString(string);
  30911. if (string && (guard || chars === undefined)) {
  30912. return string.replace(reTrimEnd, '');
  30913. }
  30914. if (!string || !(chars = baseToString(chars))) {
  30915. return string;
  30916. }
  30917. var strSymbols = stringToArray(string),
  30918. end = charsEndIndex(strSymbols, stringToArray(chars)) + 1;
  30919. return castSlice(strSymbols, 0, end).join('');
  30920. }
  30921. /**
  30922. * Removes leading whitespace or specified characters from `string`.
  30923. *
  30924. * @static
  30925. * @memberOf _
  30926. * @since 4.0.0
  30927. * @category String
  30928. * @param {string} [string=''] The string to trim.
  30929. * @param {string} [chars=whitespace] The characters to trim.
  30930. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  30931. * @returns {string} Returns the trimmed string.
  30932. * @example
  30933. *
  30934. * _.trimStart(' abc ');
  30935. * // => 'abc '
  30936. *
  30937. * _.trimStart('-_-abc-_-', '_-');
  30938. * // => 'abc-_-'
  30939. */
  30940. function trimStart(string, chars, guard) {
  30941. string = toString(string);
  30942. if (string && (guard || chars === undefined)) {
  30943. return string.replace(reTrimStart, '');
  30944. }
  30945. if (!string || !(chars = baseToString(chars))) {
  30946. return string;
  30947. }
  30948. var strSymbols = stringToArray(string),
  30949. start = charsStartIndex(strSymbols, stringToArray(chars));
  30950. return castSlice(strSymbols, start).join('');
  30951. }
  30952. /**
  30953. * Truncates `string` if it's longer than the given maximum string length.
  30954. * The last characters of the truncated string are replaced with the omission
  30955. * string which defaults to "...".
  30956. *
  30957. * @static
  30958. * @memberOf _
  30959. * @since 4.0.0
  30960. * @category String
  30961. * @param {string} [string=''] The string to truncate.
  30962. * @param {Object} [options={}] The options object.
  30963. * @param {number} [options.length=30] The maximum string length.
  30964. * @param {string} [options.omission='...'] The string to indicate text is omitted.
  30965. * @param {RegExp|string} [options.separator] The separator pattern to truncate to.
  30966. * @returns {string} Returns the truncated string.
  30967. * @example
  30968. *
  30969. * _.truncate('hi-diddly-ho there, neighborino');
  30970. * // => 'hi-diddly-ho there, neighbo...'
  30971. *
  30972. * _.truncate('hi-diddly-ho there, neighborino', {
  30973. * 'length': 24,
  30974. * 'separator': ' '
  30975. * });
  30976. * // => 'hi-diddly-ho there,...'
  30977. *
  30978. * _.truncate('hi-diddly-ho there, neighborino', {
  30979. * 'length': 24,
  30980. * 'separator': /,? +/
  30981. * });
  30982. * // => 'hi-diddly-ho there...'
  30983. *
  30984. * _.truncate('hi-diddly-ho there, neighborino', {
  30985. * 'omission': ' [...]'
  30986. * });
  30987. * // => 'hi-diddly-ho there, neig [...]'
  30988. */
  30989. function truncate(string, options) {
  30990. var length = DEFAULT_TRUNC_LENGTH,
  30991. omission = DEFAULT_TRUNC_OMISSION;
  30992. if (isObject(options)) {
  30993. var separator = 'separator' in options ? options.separator : separator;
  30994. length = 'length' in options ? toInteger(options.length) : length;
  30995. omission = 'omission' in options ? baseToString(options.omission) : omission;
  30996. }
  30997. string = toString(string);
  30998. var strLength = string.length;
  30999. if (hasUnicode(string)) {
  31000. var strSymbols = stringToArray(string);
  31001. strLength = strSymbols.length;
  31002. }
  31003. if (length >= strLength) {
  31004. return string;
  31005. }
  31006. var end = length - stringSize(omission);
  31007. if (end < 1) {
  31008. return omission;
  31009. }
  31010. var result = strSymbols
  31011. ? castSlice(strSymbols, 0, end).join('')
  31012. : string.slice(0, end);
  31013. if (separator === undefined) {
  31014. return result + omission;
  31015. }
  31016. if (strSymbols) {
  31017. end += (result.length - end);
  31018. }
  31019. if (isRegExp(separator)) {
  31020. if (string.slice(end).search(separator)) {
  31021. var match,
  31022. substring = result;
  31023. if (!separator.global) {
  31024. separator = RegExp(separator.source, toString(reFlags.exec(separator)) + 'g');
  31025. }
  31026. separator.lastIndex = 0;
  31027. while ((match = separator.exec(substring))) {
  31028. var newEnd = match.index;
  31029. }
  31030. result = result.slice(0, newEnd === undefined ? end : newEnd);
  31031. }
  31032. } else if (string.indexOf(baseToString(separator), end) != end) {
  31033. var index = result.lastIndexOf(separator);
  31034. if (index > -1) {
  31035. result = result.slice(0, index);
  31036. }
  31037. }
  31038. return result + omission;
  31039. }
  31040. /**
  31041. * The inverse of `_.escape`; this method converts the HTML entities
  31042. * `&amp;`, `&lt;`, `&gt;`, `&quot;`, and `&#39;` in `string` to
  31043. * their corresponding characters.
  31044. *
  31045. * **Note:** No other HTML entities are unescaped. To unescape additional
  31046. * HTML entities use a third-party library like [_he_](https://mths.be/he).
  31047. *
  31048. * @static
  31049. * @memberOf _
  31050. * @since 0.6.0
  31051. * @category String
  31052. * @param {string} [string=''] The string to unescape.
  31053. * @returns {string} Returns the unescaped string.
  31054. * @example
  31055. *
  31056. * _.unescape('fred, barney, &amp; pebbles');
  31057. * // => 'fred, barney, & pebbles'
  31058. */
  31059. function unescape(string) {
  31060. string = toString(string);
  31061. return (string && reHasEscapedHtml.test(string))
  31062. ? string.replace(reEscapedHtml, unescapeHtmlChar)
  31063. : string;
  31064. }
  31065. /**
  31066. * Converts `string`, as space separated words, to upper case.
  31067. *
  31068. * @static
  31069. * @memberOf _
  31070. * @since 4.0.0
  31071. * @category String
  31072. * @param {string} [string=''] The string to convert.
  31073. * @returns {string} Returns the upper cased string.
  31074. * @example
  31075. *
  31076. * _.upperCase('--foo-bar');
  31077. * // => 'FOO BAR'
  31078. *
  31079. * _.upperCase('fooBar');
  31080. * // => 'FOO BAR'
  31081. *
  31082. * _.upperCase('__foo_bar__');
  31083. * // => 'FOO BAR'
  31084. */
  31085. var upperCase = createCompounder(function(result, word, index) {
  31086. return result + (index ? ' ' : '') + word.toUpperCase();
  31087. });
  31088. /**
  31089. * Converts the first character of `string` to upper case.
  31090. *
  31091. * @static
  31092. * @memberOf _
  31093. * @since 4.0.0
  31094. * @category String
  31095. * @param {string} [string=''] The string to convert.
  31096. * @returns {string} Returns the converted string.
  31097. * @example
  31098. *
  31099. * _.upperFirst('fred');
  31100. * // => 'Fred'
  31101. *
  31102. * _.upperFirst('FRED');
  31103. * // => 'FRED'
  31104. */
  31105. var upperFirst = createCaseFirst('toUpperCase');
  31106. /**
  31107. * Splits `string` into an array of its words.
  31108. *
  31109. * @static
  31110. * @memberOf _
  31111. * @since 3.0.0
  31112. * @category String
  31113. * @param {string} [string=''] The string to inspect.
  31114. * @param {RegExp|string} [pattern] The pattern to match words.
  31115. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  31116. * @returns {Array} Returns the words of `string`.
  31117. * @example
  31118. *
  31119. * _.words('fred, barney, & pebbles');
  31120. * // => ['fred', 'barney', 'pebbles']
  31121. *
  31122. * _.words('fred, barney, & pebbles', /[^, ]+/g);
  31123. * // => ['fred', 'barney', '&', 'pebbles']
  31124. */
  31125. function words(string, pattern, guard) {
  31126. string = toString(string);
  31127. pattern = guard ? undefined : pattern;
  31128. if (pattern === undefined) {
  31129. return hasUnicodeWord(string) ? unicodeWords(string) : asciiWords(string);
  31130. }
  31131. return string.match(pattern) || [];
  31132. }
  31133. /*------------------------------------------------------------------------*/
  31134. /**
  31135. * Attempts to invoke `func`, returning either the result or the caught error
  31136. * object. Any additional arguments are provided to `func` when it's invoked.
  31137. *
  31138. * @static
  31139. * @memberOf _
  31140. * @since 3.0.0
  31141. * @category Util
  31142. * @param {Function} func The function to attempt.
  31143. * @param {...*} [args] The arguments to invoke `func` with.
  31144. * @returns {*} Returns the `func` result or error object.
  31145. * @example
  31146. *
  31147. * // Avoid throwing errors for invalid selectors.
  31148. * var elements = _.attempt(function(selector) {
  31149. * return document.querySelectorAll(selector);
  31150. * }, '>_>');
  31151. *
  31152. * if (_.isError(elements)) {
  31153. * elements = [];
  31154. * }
  31155. */
  31156. var attempt = baseRest(function(func, args) {
  31157. try {
  31158. return apply(func, undefined, args);
  31159. } catch (e) {
  31160. return isError(e) ? e : new Error(e);
  31161. }
  31162. });
  31163. /**
  31164. * Binds methods of an object to the object itself, overwriting the existing
  31165. * method.
  31166. *
  31167. * **Note:** This method doesn't set the "length" property of bound functions.
  31168. *
  31169. * @static
  31170. * @since 0.1.0
  31171. * @memberOf _
  31172. * @category Util
  31173. * @param {Object} object The object to bind and assign the bound methods to.
  31174. * @param {...(string|string[])} methodNames The object method names to bind.
  31175. * @returns {Object} Returns `object`.
  31176. * @example
  31177. *
  31178. * var view = {
  31179. * 'label': 'docs',
  31180. * 'click': function() {
  31181. * console.log('clicked ' + this.label);
  31182. * }
  31183. * };
  31184. *
  31185. * _.bindAll(view, ['click']);
  31186. * jQuery(element).on('click', view.click);
  31187. * // => Logs 'clicked docs' when clicked.
  31188. */
  31189. var bindAll = flatRest(function(object, methodNames) {
  31190. arrayEach(methodNames, function(key) {
  31191. key = toKey(key);
  31192. baseAssignValue(object, key, bind(object[key], object));
  31193. });
  31194. return object;
  31195. });
  31196. /**
  31197. * Creates a function that iterates over `pairs` and invokes the corresponding
  31198. * function of the first predicate to return truthy. The predicate-function
  31199. * pairs are invoked with the `this` binding and arguments of the created
  31200. * function.
  31201. *
  31202. * @static
  31203. * @memberOf _
  31204. * @since 4.0.0
  31205. * @category Util
  31206. * @param {Array} pairs The predicate-function pairs.
  31207. * @returns {Function} Returns the new composite function.
  31208. * @example
  31209. *
  31210. * var func = _.cond([
  31211. * [_.matches({ 'a': 1 }), _.constant('matches A')],
  31212. * [_.conforms({ 'b': _.isNumber }), _.constant('matches B')],
  31213. * [_.stubTrue, _.constant('no match')]
  31214. * ]);
  31215. *
  31216. * func({ 'a': 1, 'b': 2 });
  31217. * // => 'matches A'
  31218. *
  31219. * func({ 'a': 0, 'b': 1 });
  31220. * // => 'matches B'
  31221. *
  31222. * func({ 'a': '1', 'b': '2' });
  31223. * // => 'no match'
  31224. */
  31225. function cond(pairs) {
  31226. var length = pairs == null ? 0 : pairs.length,
  31227. toIteratee = getIteratee();
  31228. pairs = !length ? [] : arrayMap(pairs, function(pair) {
  31229. if (typeof pair[1] != 'function') {
  31230. throw new TypeError(FUNC_ERROR_TEXT);
  31231. }
  31232. return [toIteratee(pair[0]), pair[1]];
  31233. });
  31234. return baseRest(function(args) {
  31235. var index = -1;
  31236. while (++index < length) {
  31237. var pair = pairs[index];
  31238. if (apply(pair[0], this, args)) {
  31239. return apply(pair[1], this, args);
  31240. }
  31241. }
  31242. });
  31243. }
  31244. /**
  31245. * Creates a function that invokes the predicate properties of `source` with
  31246. * the corresponding property values of a given object, returning `true` if
  31247. * all predicates return truthy, else `false`.
  31248. *
  31249. * **Note:** The created function is equivalent to `_.conformsTo` with
  31250. * `source` partially applied.
  31251. *
  31252. * @static
  31253. * @memberOf _
  31254. * @since 4.0.0
  31255. * @category Util
  31256. * @param {Object} source The object of property predicates to conform to.
  31257. * @returns {Function} Returns the new spec function.
  31258. * @example
  31259. *
  31260. * var objects = [
  31261. * { 'a': 2, 'b': 1 },
  31262. * { 'a': 1, 'b': 2 }
  31263. * ];
  31264. *
  31265. * _.filter(objects, _.conforms({ 'b': function(n) { return n > 1; } }));
  31266. * // => [{ 'a': 1, 'b': 2 }]
  31267. */
  31268. function conforms(source) {
  31269. return baseConforms(baseClone(source, CLONE_DEEP_FLAG));
  31270. }
  31271. /**
  31272. * Creates a function that returns `value`.
  31273. *
  31274. * @static
  31275. * @memberOf _
  31276. * @since 2.4.0
  31277. * @category Util
  31278. * @param {*} value The value to return from the new function.
  31279. * @returns {Function} Returns the new constant function.
  31280. * @example
  31281. *
  31282. * var objects = _.times(2, _.constant({ 'a': 1 }));
  31283. *
  31284. * console.log(objects);
  31285. * // => [{ 'a': 1 }, { 'a': 1 }]
  31286. *
  31287. * console.log(objects[0] === objects[1]);
  31288. * // => true
  31289. */
  31290. function constant(value) {
  31291. return function() {
  31292. return value;
  31293. };
  31294. }
  31295. /**
  31296. * Checks `value` to determine whether a default value should be returned in
  31297. * its place. The `defaultValue` is returned if `value` is `NaN`, `null`,
  31298. * or `undefined`.
  31299. *
  31300. * @static
  31301. * @memberOf _
  31302. * @since 4.14.0
  31303. * @category Util
  31304. * @param {*} value The value to check.
  31305. * @param {*} defaultValue The default value.
  31306. * @returns {*} Returns the resolved value.
  31307. * @example
  31308. *
  31309. * _.defaultTo(1, 10);
  31310. * // => 1
  31311. *
  31312. * _.defaultTo(undefined, 10);
  31313. * // => 10
  31314. */
  31315. function defaultTo(value, defaultValue) {
  31316. return (value == null || value !== value) ? defaultValue : value;
  31317. }
  31318. /**
  31319. * Creates a function that returns the result of invoking the given functions
  31320. * with the `this` binding of the created function, where each successive
  31321. * invocation is supplied the return value of the previous.
  31322. *
  31323. * @static
  31324. * @memberOf _
  31325. * @since 3.0.0
  31326. * @category Util
  31327. * @param {...(Function|Function[])} [funcs] The functions to invoke.
  31328. * @returns {Function} Returns the new composite function.
  31329. * @see _.flowRight
  31330. * @example
  31331. *
  31332. * function square(n) {
  31333. * return n * n;
  31334. * }
  31335. *
  31336. * var addSquare = _.flow([_.add, square]);
  31337. * addSquare(1, 2);
  31338. * // => 9
  31339. */
  31340. var flow = createFlow();
  31341. /**
  31342. * This method is like `_.flow` except that it creates a function that
  31343. * invokes the given functions from right to left.
  31344. *
  31345. * @static
  31346. * @since 3.0.0
  31347. * @memberOf _
  31348. * @category Util
  31349. * @param {...(Function|Function[])} [funcs] The functions to invoke.
  31350. * @returns {Function} Returns the new composite function.
  31351. * @see _.flow
  31352. * @example
  31353. *
  31354. * function square(n) {
  31355. * return n * n;
  31356. * }
  31357. *
  31358. * var addSquare = _.flowRight([square, _.add]);
  31359. * addSquare(1, 2);
  31360. * // => 9
  31361. */
  31362. var flowRight = createFlow(true);
  31363. /**
  31364. * This method returns the first argument it receives.
  31365. *
  31366. * @static
  31367. * @since 0.1.0
  31368. * @memberOf _
  31369. * @category Util
  31370. * @param {*} value Any value.
  31371. * @returns {*} Returns `value`.
  31372. * @example
  31373. *
  31374. * var object = { 'a': 1 };
  31375. *
  31376. * console.log(_.identity(object) === object);
  31377. * // => true
  31378. */
  31379. function identity(value) {
  31380. return value;
  31381. }
  31382. /**
  31383. * Creates a function that invokes `func` with the arguments of the created
  31384. * function. If `func` is a property name, the created function returns the
  31385. * property value for a given element. If `func` is an array or object, the
  31386. * created function returns `true` for elements that contain the equivalent
  31387. * source properties, otherwise it returns `false`.
  31388. *
  31389. * @static
  31390. * @since 4.0.0
  31391. * @memberOf _
  31392. * @category Util
  31393. * @param {*} [func=_.identity] The value to convert to a callback.
  31394. * @returns {Function} Returns the callback.
  31395. * @example
  31396. *
  31397. * var users = [
  31398. * { 'user': 'barney', 'age': 36, 'active': true },
  31399. * { 'user': 'fred', 'age': 40, 'active': false }
  31400. * ];
  31401. *
  31402. * // The `_.matches` iteratee shorthand.
  31403. * _.filter(users, _.iteratee({ 'user': 'barney', 'active': true }));
  31404. * // => [{ 'user': 'barney', 'age': 36, 'active': true }]
  31405. *
  31406. * // The `_.matchesProperty` iteratee shorthand.
  31407. * _.filter(users, _.iteratee(['user', 'fred']));
  31408. * // => [{ 'user': 'fred', 'age': 40 }]
  31409. *
  31410. * // The `_.property` iteratee shorthand.
  31411. * _.map(users, _.iteratee('user'));
  31412. * // => ['barney', 'fred']
  31413. *
  31414. * // Create custom iteratee shorthands.
  31415. * _.iteratee = _.wrap(_.iteratee, function(iteratee, func) {
  31416. * return !_.isRegExp(func) ? iteratee(func) : function(string) {
  31417. * return func.test(string);
  31418. * };
  31419. * });
  31420. *
  31421. * _.filter(['abc', 'def'], /ef/);
  31422. * // => ['def']
  31423. */
  31424. function iteratee(func) {
  31425. return baseIteratee(typeof func == 'function' ? func : baseClone(func, CLONE_DEEP_FLAG));
  31426. }
  31427. /**
  31428. * Creates a function that performs a partial deep comparison between a given
  31429. * object and `source`, returning `true` if the given object has equivalent
  31430. * property values, else `false`.
  31431. *
  31432. * **Note:** The created function is equivalent to `_.isMatch` with `source`
  31433. * partially applied.
  31434. *
  31435. * Partial comparisons will match empty array and empty object `source`
  31436. * values against any array or object value, respectively. See `_.isEqual`
  31437. * for a list of supported value comparisons.
  31438. *
  31439. * @static
  31440. * @memberOf _
  31441. * @since 3.0.0
  31442. * @category Util
  31443. * @param {Object} source The object of property values to match.
  31444. * @returns {Function} Returns the new spec function.
  31445. * @example
  31446. *
  31447. * var objects = [
  31448. * { 'a': 1, 'b': 2, 'c': 3 },
  31449. * { 'a': 4, 'b': 5, 'c': 6 }
  31450. * ];
  31451. *
  31452. * _.filter(objects, _.matches({ 'a': 4, 'c': 6 }));
  31453. * // => [{ 'a': 4, 'b': 5, 'c': 6 }]
  31454. */
  31455. function matches(source) {
  31456. return baseMatches(baseClone(source, CLONE_DEEP_FLAG));
  31457. }
  31458. /**
  31459. * Creates a function that performs a partial deep comparison between the
  31460. * value at `path` of a given object to `srcValue`, returning `true` if the
  31461. * object value is equivalent, else `false`.
  31462. *
  31463. * **Note:** Partial comparisons will match empty array and empty object
  31464. * `srcValue` values against any array or object value, respectively. See
  31465. * `_.isEqual` for a list of supported value comparisons.
  31466. *
  31467. * @static
  31468. * @memberOf _
  31469. * @since 3.2.0
  31470. * @category Util
  31471. * @param {Array|string} path The path of the property to get.
  31472. * @param {*} srcValue The value to match.
  31473. * @returns {Function} Returns the new spec function.
  31474. * @example
  31475. *
  31476. * var objects = [
  31477. * { 'a': 1, 'b': 2, 'c': 3 },
  31478. * { 'a': 4, 'b': 5, 'c': 6 }
  31479. * ];
  31480. *
  31481. * _.find(objects, _.matchesProperty('a', 4));
  31482. * // => { 'a': 4, 'b': 5, 'c': 6 }
  31483. */
  31484. function matchesProperty(path, srcValue) {
  31485. return baseMatchesProperty(path, baseClone(srcValue, CLONE_DEEP_FLAG));
  31486. }
  31487. /**
  31488. * Creates a function that invokes the method at `path` of a given object.
  31489. * Any additional arguments are provided to the invoked method.
  31490. *
  31491. * @static
  31492. * @memberOf _
  31493. * @since 3.7.0
  31494. * @category Util
  31495. * @param {Array|string} path The path of the method to invoke.
  31496. * @param {...*} [args] The arguments to invoke the method with.
  31497. * @returns {Function} Returns the new invoker function.
  31498. * @example
  31499. *
  31500. * var objects = [
  31501. * { 'a': { 'b': _.constant(2) } },
  31502. * { 'a': { 'b': _.constant(1) } }
  31503. * ];
  31504. *
  31505. * _.map(objects, _.method('a.b'));
  31506. * // => [2, 1]
  31507. *
  31508. * _.map(objects, _.method(['a', 'b']));
  31509. * // => [2, 1]
  31510. */
  31511. var method = baseRest(function(path, args) {
  31512. return function(object) {
  31513. return baseInvoke(object, path, args);
  31514. };
  31515. });
  31516. /**
  31517. * The opposite of `_.method`; this method creates a function that invokes
  31518. * the method at a given path of `object`. Any additional arguments are
  31519. * provided to the invoked method.
  31520. *
  31521. * @static
  31522. * @memberOf _
  31523. * @since 3.7.0
  31524. * @category Util
  31525. * @param {Object} object The object to query.
  31526. * @param {...*} [args] The arguments to invoke the method with.
  31527. * @returns {Function} Returns the new invoker function.
  31528. * @example
  31529. *
  31530. * var array = _.times(3, _.constant),
  31531. * object = { 'a': array, 'b': array, 'c': array };
  31532. *
  31533. * _.map(['a[2]', 'c[0]'], _.methodOf(object));
  31534. * // => [2, 0]
  31535. *
  31536. * _.map([['a', '2'], ['c', '0']], _.methodOf(object));
  31537. * // => [2, 0]
  31538. */
  31539. var methodOf = baseRest(function(object, args) {
  31540. return function(path) {
  31541. return baseInvoke(object, path, args);
  31542. };
  31543. });
  31544. /**
  31545. * Adds all own enumerable string keyed function properties of a source
  31546. * object to the destination object. If `object` is a function, then methods
  31547. * are added to its prototype as well.
  31548. *
  31549. * **Note:** Use `_.runInContext` to create a pristine `lodash` function to
  31550. * avoid conflicts caused by modifying the original.
  31551. *
  31552. * @static
  31553. * @since 0.1.0
  31554. * @memberOf _
  31555. * @category Util
  31556. * @param {Function|Object} [object=lodash] The destination object.
  31557. * @param {Object} source The object of functions to add.
  31558. * @param {Object} [options={}] The options object.
  31559. * @param {boolean} [options.chain=true] Specify whether mixins are chainable.
  31560. * @returns {Function|Object} Returns `object`.
  31561. * @example
  31562. *
  31563. * function vowels(string) {
  31564. * return _.filter(string, function(v) {
  31565. * return /[aeiou]/i.test(v);
  31566. * });
  31567. * }
  31568. *
  31569. * _.mixin({ 'vowels': vowels });
  31570. * _.vowels('fred');
  31571. * // => ['e']
  31572. *
  31573. * _('fred').vowels().value();
  31574. * // => ['e']
  31575. *
  31576. * _.mixin({ 'vowels': vowels }, { 'chain': false });
  31577. * _('fred').vowels();
  31578. * // => ['e']
  31579. */
  31580. function mixin(object, source, options) {
  31581. var props = keys(source),
  31582. methodNames = baseFunctions(source, props);
  31583. if (options == null &&
  31584. !(isObject(source) && (methodNames.length || !props.length))) {
  31585. options = source;
  31586. source = object;
  31587. object = this;
  31588. methodNames = baseFunctions(source, keys(source));
  31589. }
  31590. var chain = !(isObject(options) && 'chain' in options) || !!options.chain,
  31591. isFunc = isFunction(object);
  31592. arrayEach(methodNames, function(methodName) {
  31593. var func = source[methodName];
  31594. object[methodName] = func;
  31595. if (isFunc) {
  31596. object.prototype[methodName] = function() {
  31597. var chainAll = this.__chain__;
  31598. if (chain || chainAll) {
  31599. var result = object(this.__wrapped__),
  31600. actions = result.__actions__ = copyArray(this.__actions__);
  31601. actions.push({ 'func': func, 'args': arguments, 'thisArg': object });
  31602. result.__chain__ = chainAll;
  31603. return result;
  31604. }
  31605. return func.apply(object, arrayPush([this.value()], arguments));
  31606. };
  31607. }
  31608. });
  31609. return object;
  31610. }
  31611. /**
  31612. * Reverts the `_` variable to its previous value and returns a reference to
  31613. * the `lodash` function.
  31614. *
  31615. * @static
  31616. * @since 0.1.0
  31617. * @memberOf _
  31618. * @category Util
  31619. * @returns {Function} Returns the `lodash` function.
  31620. * @example
  31621. *
  31622. * var lodash = _.noConflict();
  31623. */
  31624. function noConflict() {
  31625. if (root._ === this) {
  31626. root._ = oldDash;
  31627. }
  31628. return this;
  31629. }
  31630. /**
  31631. * This method returns `undefined`.
  31632. *
  31633. * @static
  31634. * @memberOf _
  31635. * @since 2.3.0
  31636. * @category Util
  31637. * @example
  31638. *
  31639. * _.times(2, _.noop);
  31640. * // => [undefined, undefined]
  31641. */
  31642. function noop() {
  31643. // No operation performed.
  31644. }
  31645. /**
  31646. * Creates a function that gets the argument at index `n`. If `n` is negative,
  31647. * the nth argument from the end is returned.
  31648. *
  31649. * @static
  31650. * @memberOf _
  31651. * @since 4.0.0
  31652. * @category Util
  31653. * @param {number} [n=0] The index of the argument to return.
  31654. * @returns {Function} Returns the new pass-thru function.
  31655. * @example
  31656. *
  31657. * var func = _.nthArg(1);
  31658. * func('a', 'b', 'c', 'd');
  31659. * // => 'b'
  31660. *
  31661. * var func = _.nthArg(-2);
  31662. * func('a', 'b', 'c', 'd');
  31663. * // => 'c'
  31664. */
  31665. function nthArg(n) {
  31666. n = toInteger(n);
  31667. return baseRest(function(args) {
  31668. return baseNth(args, n);
  31669. });
  31670. }
  31671. /**
  31672. * Creates a function that invokes `iteratees` with the arguments it receives
  31673. * and returns their results.
  31674. *
  31675. * @static
  31676. * @memberOf _
  31677. * @since 4.0.0
  31678. * @category Util
  31679. * @param {...(Function|Function[])} [iteratees=[_.identity]]
  31680. * The iteratees to invoke.
  31681. * @returns {Function} Returns the new function.
  31682. * @example
  31683. *
  31684. * var func = _.over([Math.max, Math.min]);
  31685. *
  31686. * func(1, 2, 3, 4);
  31687. * // => [4, 1]
  31688. */
  31689. var over = createOver(arrayMap);
  31690. /**
  31691. * Creates a function that checks if **all** of the `predicates` return
  31692. * truthy when invoked with the arguments it receives.
  31693. *
  31694. * @static
  31695. * @memberOf _
  31696. * @since 4.0.0
  31697. * @category Util
  31698. * @param {...(Function|Function[])} [predicates=[_.identity]]
  31699. * The predicates to check.
  31700. * @returns {Function} Returns the new function.
  31701. * @example
  31702. *
  31703. * var func = _.overEvery([Boolean, isFinite]);
  31704. *
  31705. * func('1');
  31706. * // => true
  31707. *
  31708. * func(null);
  31709. * // => false
  31710. *
  31711. * func(NaN);
  31712. * // => false
  31713. */
  31714. var overEvery = createOver(arrayEvery);
  31715. /**
  31716. * Creates a function that checks if **any** of the `predicates` return
  31717. * truthy when invoked with the arguments it receives.
  31718. *
  31719. * @static
  31720. * @memberOf _
  31721. * @since 4.0.0
  31722. * @category Util
  31723. * @param {...(Function|Function[])} [predicates=[_.identity]]
  31724. * The predicates to check.
  31725. * @returns {Function} Returns the new function.
  31726. * @example
  31727. *
  31728. * var func = _.overSome([Boolean, isFinite]);
  31729. *
  31730. * func('1');
  31731. * // => true
  31732. *
  31733. * func(null);
  31734. * // => true
  31735. *
  31736. * func(NaN);
  31737. * // => false
  31738. */
  31739. var overSome = createOver(arraySome);
  31740. /**
  31741. * Creates a function that returns the value at `path` of a given object.
  31742. *
  31743. * @static
  31744. * @memberOf _
  31745. * @since 2.4.0
  31746. * @category Util
  31747. * @param {Array|string} path The path of the property to get.
  31748. * @returns {Function} Returns the new accessor function.
  31749. * @example
  31750. *
  31751. * var objects = [
  31752. * { 'a': { 'b': 2 } },
  31753. * { 'a': { 'b': 1 } }
  31754. * ];
  31755. *
  31756. * _.map(objects, _.property('a.b'));
  31757. * // => [2, 1]
  31758. *
  31759. * _.map(_.sortBy(objects, _.property(['a', 'b'])), 'a.b');
  31760. * // => [1, 2]
  31761. */
  31762. function property(path) {
  31763. return isKey(path) ? baseProperty(toKey(path)) : basePropertyDeep(path);
  31764. }
  31765. /**
  31766. * The opposite of `_.property`; this method creates a function that returns
  31767. * the value at a given path of `object`.
  31768. *
  31769. * @static
  31770. * @memberOf _
  31771. * @since 3.0.0
  31772. * @category Util
  31773. * @param {Object} object The object to query.
  31774. * @returns {Function} Returns the new accessor function.
  31775. * @example
  31776. *
  31777. * var array = [0, 1, 2],
  31778. * object = { 'a': array, 'b': array, 'c': array };
  31779. *
  31780. * _.map(['a[2]', 'c[0]'], _.propertyOf(object));
  31781. * // => [2, 0]
  31782. *
  31783. * _.map([['a', '2'], ['c', '0']], _.propertyOf(object));
  31784. * // => [2, 0]
  31785. */
  31786. function propertyOf(object) {
  31787. return function(path) {
  31788. return object == null ? undefined : baseGet(object, path);
  31789. };
  31790. }
  31791. /**
  31792. * Creates an array of numbers (positive and/or negative) progressing from
  31793. * `start` up to, but not including, `end`. A step of `-1` is used if a negative
  31794. * `start` is specified without an `end` or `step`. If `end` is not specified,
  31795. * it's set to `start` with `start` then set to `0`.
  31796. *
  31797. * **Note:** JavaScript follows the IEEE-754 standard for resolving
  31798. * floating-point values which can produce unexpected results.
  31799. *
  31800. * @static
  31801. * @since 0.1.0
  31802. * @memberOf _
  31803. * @category Util
  31804. * @param {number} [start=0] The start of the range.
  31805. * @param {number} end The end of the range.
  31806. * @param {number} [step=1] The value to increment or decrement by.
  31807. * @returns {Array} Returns the range of numbers.
  31808. * @see _.inRange, _.rangeRight
  31809. * @example
  31810. *
  31811. * _.range(4);
  31812. * // => [0, 1, 2, 3]
  31813. *
  31814. * _.range(-4);
  31815. * // => [0, -1, -2, -3]
  31816. *
  31817. * _.range(1, 5);
  31818. * // => [1, 2, 3, 4]
  31819. *
  31820. * _.range(0, 20, 5);
  31821. * // => [0, 5, 10, 15]
  31822. *
  31823. * _.range(0, -4, -1);
  31824. * // => [0, -1, -2, -3]
  31825. *
  31826. * _.range(1, 4, 0);
  31827. * // => [1, 1, 1]
  31828. *
  31829. * _.range(0);
  31830. * // => []
  31831. */
  31832. var range = createRange();
  31833. /**
  31834. * This method is like `_.range` except that it populates values in
  31835. * descending order.
  31836. *
  31837. * @static
  31838. * @memberOf _
  31839. * @since 4.0.0
  31840. * @category Util
  31841. * @param {number} [start=0] The start of the range.
  31842. * @param {number} end The end of the range.
  31843. * @param {number} [step=1] The value to increment or decrement by.
  31844. * @returns {Array} Returns the range of numbers.
  31845. * @see _.inRange, _.range
  31846. * @example
  31847. *
  31848. * _.rangeRight(4);
  31849. * // => [3, 2, 1, 0]
  31850. *
  31851. * _.rangeRight(-4);
  31852. * // => [-3, -2, -1, 0]
  31853. *
  31854. * _.rangeRight(1, 5);
  31855. * // => [4, 3, 2, 1]
  31856. *
  31857. * _.rangeRight(0, 20, 5);
  31858. * // => [15, 10, 5, 0]
  31859. *
  31860. * _.rangeRight(0, -4, -1);
  31861. * // => [-3, -2, -1, 0]
  31862. *
  31863. * _.rangeRight(1, 4, 0);
  31864. * // => [1, 1, 1]
  31865. *
  31866. * _.rangeRight(0);
  31867. * // => []
  31868. */
  31869. var rangeRight = createRange(true);
  31870. /**
  31871. * This method returns a new empty array.
  31872. *
  31873. * @static
  31874. * @memberOf _
  31875. * @since 4.13.0
  31876. * @category Util
  31877. * @returns {Array} Returns the new empty array.
  31878. * @example
  31879. *
  31880. * var arrays = _.times(2, _.stubArray);
  31881. *
  31882. * console.log(arrays);
  31883. * // => [[], []]
  31884. *
  31885. * console.log(arrays[0] === arrays[1]);
  31886. * // => false
  31887. */
  31888. function stubArray() {
  31889. return [];
  31890. }
  31891. /**
  31892. * This method returns `false`.
  31893. *
  31894. * @static
  31895. * @memberOf _
  31896. * @since 4.13.0
  31897. * @category Util
  31898. * @returns {boolean} Returns `false`.
  31899. * @example
  31900. *
  31901. * _.times(2, _.stubFalse);
  31902. * // => [false, false]
  31903. */
  31904. function stubFalse() {
  31905. return false;
  31906. }
  31907. /**
  31908. * This method returns a new empty object.
  31909. *
  31910. * @static
  31911. * @memberOf _
  31912. * @since 4.13.0
  31913. * @category Util
  31914. * @returns {Object} Returns the new empty object.
  31915. * @example
  31916. *
  31917. * var objects = _.times(2, _.stubObject);
  31918. *
  31919. * console.log(objects);
  31920. * // => [{}, {}]
  31921. *
  31922. * console.log(objects[0] === objects[1]);
  31923. * // => false
  31924. */
  31925. function stubObject() {
  31926. return {};
  31927. }
  31928. /**
  31929. * This method returns an empty string.
  31930. *
  31931. * @static
  31932. * @memberOf _
  31933. * @since 4.13.0
  31934. * @category Util
  31935. * @returns {string} Returns the empty string.
  31936. * @example
  31937. *
  31938. * _.times(2, _.stubString);
  31939. * // => ['', '']
  31940. */
  31941. function stubString() {
  31942. return '';
  31943. }
  31944. /**
  31945. * This method returns `true`.
  31946. *
  31947. * @static
  31948. * @memberOf _
  31949. * @since 4.13.0
  31950. * @category Util
  31951. * @returns {boolean} Returns `true`.
  31952. * @example
  31953. *
  31954. * _.times(2, _.stubTrue);
  31955. * // => [true, true]
  31956. */
  31957. function stubTrue() {
  31958. return true;
  31959. }
  31960. /**
  31961. * Invokes the iteratee `n` times, returning an array of the results of
  31962. * each invocation. The iteratee is invoked with one argument; (index).
  31963. *
  31964. * @static
  31965. * @since 0.1.0
  31966. * @memberOf _
  31967. * @category Util
  31968. * @param {number} n The number of times to invoke `iteratee`.
  31969. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  31970. * @returns {Array} Returns the array of results.
  31971. * @example
  31972. *
  31973. * _.times(3, String);
  31974. * // => ['0', '1', '2']
  31975. *
  31976. * _.times(4, _.constant(0));
  31977. * // => [0, 0, 0, 0]
  31978. */
  31979. function times(n, iteratee) {
  31980. n = toInteger(n);
  31981. if (n < 1 || n > MAX_SAFE_INTEGER) {
  31982. return [];
  31983. }
  31984. var index = MAX_ARRAY_LENGTH,
  31985. length = nativeMin(n, MAX_ARRAY_LENGTH);
  31986. iteratee = getIteratee(iteratee);
  31987. n -= MAX_ARRAY_LENGTH;
  31988. var result = baseTimes(length, iteratee);
  31989. while (++index < n) {
  31990. iteratee(index);
  31991. }
  31992. return result;
  31993. }
  31994. /**
  31995. * Converts `value` to a property path array.
  31996. *
  31997. * @static
  31998. * @memberOf _
  31999. * @since 4.0.0
  32000. * @category Util
  32001. * @param {*} value The value to convert.
  32002. * @returns {Array} Returns the new property path array.
  32003. * @example
  32004. *
  32005. * _.toPath('a.b.c');
  32006. * // => ['a', 'b', 'c']
  32007. *
  32008. * _.toPath('a[0].b.c');
  32009. * // => ['a', '0', 'b', 'c']
  32010. */
  32011. function toPath(value) {
  32012. if (isArray(value)) {
  32013. return arrayMap(value, toKey);
  32014. }
  32015. return isSymbol(value) ? [value] : copyArray(stringToPath(toString(value)));
  32016. }
  32017. /**
  32018. * Generates a unique ID. If `prefix` is given, the ID is appended to it.
  32019. *
  32020. * @static
  32021. * @since 0.1.0
  32022. * @memberOf _
  32023. * @category Util
  32024. * @param {string} [prefix=''] The value to prefix the ID with.
  32025. * @returns {string} Returns the unique ID.
  32026. * @example
  32027. *
  32028. * _.uniqueId('contact_');
  32029. * // => 'contact_104'
  32030. *
  32031. * _.uniqueId();
  32032. * // => '105'
  32033. */
  32034. function uniqueId(prefix) {
  32035. var id = ++idCounter;
  32036. return toString(prefix) + id;
  32037. }
  32038. /*------------------------------------------------------------------------*/
  32039. /**
  32040. * Adds two numbers.
  32041. *
  32042. * @static
  32043. * @memberOf _
  32044. * @since 3.4.0
  32045. * @category Math
  32046. * @param {number} augend The first number in an addition.
  32047. * @param {number} addend The second number in an addition.
  32048. * @returns {number} Returns the total.
  32049. * @example
  32050. *
  32051. * _.add(6, 4);
  32052. * // => 10
  32053. */
  32054. var add = createMathOperation(function(augend, addend) {
  32055. return augend + addend;
  32056. }, 0);
  32057. /**
  32058. * Computes `number` rounded up to `precision`.
  32059. *
  32060. * @static
  32061. * @memberOf _
  32062. * @since 3.10.0
  32063. * @category Math
  32064. * @param {number} number The number to round up.
  32065. * @param {number} [precision=0] The precision to round up to.
  32066. * @returns {number} Returns the rounded up number.
  32067. * @example
  32068. *
  32069. * _.ceil(4.006);
  32070. * // => 5
  32071. *
  32072. * _.ceil(6.004, 2);
  32073. * // => 6.01
  32074. *
  32075. * _.ceil(6040, -2);
  32076. * // => 6100
  32077. */
  32078. var ceil = createRound('ceil');
  32079. /**
  32080. * Divide two numbers.
  32081. *
  32082. * @static
  32083. * @memberOf _
  32084. * @since 4.7.0
  32085. * @category Math
  32086. * @param {number} dividend The first number in a division.
  32087. * @param {number} divisor The second number in a division.
  32088. * @returns {number} Returns the quotient.
  32089. * @example
  32090. *
  32091. * _.divide(6, 4);
  32092. * // => 1.5
  32093. */
  32094. var divide = createMathOperation(function(dividend, divisor) {
  32095. return dividend / divisor;
  32096. }, 1);
  32097. /**
  32098. * Computes `number` rounded down to `precision`.
  32099. *
  32100. * @static
  32101. * @memberOf _
  32102. * @since 3.10.0
  32103. * @category Math
  32104. * @param {number} number The number to round down.
  32105. * @param {number} [precision=0] The precision to round down to.
  32106. * @returns {number} Returns the rounded down number.
  32107. * @example
  32108. *
  32109. * _.floor(4.006);
  32110. * // => 4
  32111. *
  32112. * _.floor(0.046, 2);
  32113. * // => 0.04
  32114. *
  32115. * _.floor(4060, -2);
  32116. * // => 4000
  32117. */
  32118. var floor = createRound('floor');
  32119. /**
  32120. * Computes the maximum value of `array`. If `array` is empty or falsey,
  32121. * `undefined` is returned.
  32122. *
  32123. * @static
  32124. * @since 0.1.0
  32125. * @memberOf _
  32126. * @category Math
  32127. * @param {Array} array The array to iterate over.
  32128. * @returns {*} Returns the maximum value.
  32129. * @example
  32130. *
  32131. * _.max([4, 2, 8, 6]);
  32132. * // => 8
  32133. *
  32134. * _.max([]);
  32135. * // => undefined
  32136. */
  32137. function max(array) {
  32138. return (array && array.length)
  32139. ? baseExtremum(array, identity, baseGt)
  32140. : undefined;
  32141. }
  32142. /**
  32143. * This method is like `_.max` except that it accepts `iteratee` which is
  32144. * invoked for each element in `array` to generate the criterion by which
  32145. * the value is ranked. The iteratee is invoked with one argument: (value).
  32146. *
  32147. * @static
  32148. * @memberOf _
  32149. * @since 4.0.0
  32150. * @category Math
  32151. * @param {Array} array The array to iterate over.
  32152. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  32153. * @returns {*} Returns the maximum value.
  32154. * @example
  32155. *
  32156. * var objects = [{ 'n': 1 }, { 'n': 2 }];
  32157. *
  32158. * _.maxBy(objects, function(o) { return o.n; });
  32159. * // => { 'n': 2 }
  32160. *
  32161. * // The `_.property` iteratee shorthand.
  32162. * _.maxBy(objects, 'n');
  32163. * // => { 'n': 2 }
  32164. */
  32165. function maxBy(array, iteratee) {
  32166. return (array && array.length)
  32167. ? baseExtremum(array, getIteratee(iteratee, 2), baseGt)
  32168. : undefined;
  32169. }
  32170. /**
  32171. * Computes the mean of the values in `array`.
  32172. *
  32173. * @static
  32174. * @memberOf _
  32175. * @since 4.0.0
  32176. * @category Math
  32177. * @param {Array} array The array to iterate over.
  32178. * @returns {number} Returns the mean.
  32179. * @example
  32180. *
  32181. * _.mean([4, 2, 8, 6]);
  32182. * // => 5
  32183. */
  32184. function mean(array) {
  32185. return baseMean(array, identity);
  32186. }
  32187. /**
  32188. * This method is like `_.mean` except that it accepts `iteratee` which is
  32189. * invoked for each element in `array` to generate the value to be averaged.
  32190. * The iteratee is invoked with one argument: (value).
  32191. *
  32192. * @static
  32193. * @memberOf _
  32194. * @since 4.7.0
  32195. * @category Math
  32196. * @param {Array} array The array to iterate over.
  32197. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  32198. * @returns {number} Returns the mean.
  32199. * @example
  32200. *
  32201. * var objects = [{ 'n': 4 }, { 'n': 2 }, { 'n': 8 }, { 'n': 6 }];
  32202. *
  32203. * _.meanBy(objects, function(o) { return o.n; });
  32204. * // => 5
  32205. *
  32206. * // The `_.property` iteratee shorthand.
  32207. * _.meanBy(objects, 'n');
  32208. * // => 5
  32209. */
  32210. function meanBy(array, iteratee) {
  32211. return baseMean(array, getIteratee(iteratee, 2));
  32212. }
  32213. /**
  32214. * Computes the minimum value of `array`. If `array` is empty or falsey,
  32215. * `undefined` is returned.
  32216. *
  32217. * @static
  32218. * @since 0.1.0
  32219. * @memberOf _
  32220. * @category Math
  32221. * @param {Array} array The array to iterate over.
  32222. * @returns {*} Returns the minimum value.
  32223. * @example
  32224. *
  32225. * _.min([4, 2, 8, 6]);
  32226. * // => 2
  32227. *
  32228. * _.min([]);
  32229. * // => undefined
  32230. */
  32231. function min(array) {
  32232. return (array && array.length)
  32233. ? baseExtremum(array, identity, baseLt)
  32234. : undefined;
  32235. }
  32236. /**
  32237. * This method is like `_.min` except that it accepts `iteratee` which is
  32238. * invoked for each element in `array` to generate the criterion by which
  32239. * the value is ranked. The iteratee is invoked with one argument: (value).
  32240. *
  32241. * @static
  32242. * @memberOf _
  32243. * @since 4.0.0
  32244. * @category Math
  32245. * @param {Array} array The array to iterate over.
  32246. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  32247. * @returns {*} Returns the minimum value.
  32248. * @example
  32249. *
  32250. * var objects = [{ 'n': 1 }, { 'n': 2 }];
  32251. *
  32252. * _.minBy(objects, function(o) { return o.n; });
  32253. * // => { 'n': 1 }
  32254. *
  32255. * // The `_.property` iteratee shorthand.
  32256. * _.minBy(objects, 'n');
  32257. * // => { 'n': 1 }
  32258. */
  32259. function minBy(array, iteratee) {
  32260. return (array && array.length)
  32261. ? baseExtremum(array, getIteratee(iteratee, 2), baseLt)
  32262. : undefined;
  32263. }
  32264. /**
  32265. * Multiply two numbers.
  32266. *
  32267. * @static
  32268. * @memberOf _
  32269. * @since 4.7.0
  32270. * @category Math
  32271. * @param {number} multiplier The first number in a multiplication.
  32272. * @param {number} multiplicand The second number in a multiplication.
  32273. * @returns {number} Returns the product.
  32274. * @example
  32275. *
  32276. * _.multiply(6, 4);
  32277. * // => 24
  32278. */
  32279. var multiply = createMathOperation(function(multiplier, multiplicand) {
  32280. return multiplier * multiplicand;
  32281. }, 1);
  32282. /**
  32283. * Computes `number` rounded to `precision`.
  32284. *
  32285. * @static
  32286. * @memberOf _
  32287. * @since 3.10.0
  32288. * @category Math
  32289. * @param {number} number The number to round.
  32290. * @param {number} [precision=0] The precision to round to.
  32291. * @returns {number} Returns the rounded number.
  32292. * @example
  32293. *
  32294. * _.round(4.006);
  32295. * // => 4
  32296. *
  32297. * _.round(4.006, 2);
  32298. * // => 4.01
  32299. *
  32300. * _.round(4060, -2);
  32301. * // => 4100
  32302. */
  32303. var round = createRound('round');
  32304. /**
  32305. * Subtract two numbers.
  32306. *
  32307. * @static
  32308. * @memberOf _
  32309. * @since 4.0.0
  32310. * @category Math
  32311. * @param {number} minuend The first number in a subtraction.
  32312. * @param {number} subtrahend The second number in a subtraction.
  32313. * @returns {number} Returns the difference.
  32314. * @example
  32315. *
  32316. * _.subtract(6, 4);
  32317. * // => 2
  32318. */
  32319. var subtract = createMathOperation(function(minuend, subtrahend) {
  32320. return minuend - subtrahend;
  32321. }, 0);
  32322. /**
  32323. * Computes the sum of the values in `array`.
  32324. *
  32325. * @static
  32326. * @memberOf _
  32327. * @since 3.4.0
  32328. * @category Math
  32329. * @param {Array} array The array to iterate over.
  32330. * @returns {number} Returns the sum.
  32331. * @example
  32332. *
  32333. * _.sum([4, 2, 8, 6]);
  32334. * // => 20
  32335. */
  32336. function sum(array) {
  32337. return (array && array.length)
  32338. ? baseSum(array, identity)
  32339. : 0;
  32340. }
  32341. /**
  32342. * This method is like `_.sum` except that it accepts `iteratee` which is
  32343. * invoked for each element in `array` to generate the value to be summed.
  32344. * The iteratee is invoked with one argument: (value).
  32345. *
  32346. * @static
  32347. * @memberOf _
  32348. * @since 4.0.0
  32349. * @category Math
  32350. * @param {Array} array The array to iterate over.
  32351. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  32352. * @returns {number} Returns the sum.
  32353. * @example
  32354. *
  32355. * var objects = [{ 'n': 4 }, { 'n': 2 }, { 'n': 8 }, { 'n': 6 }];
  32356. *
  32357. * _.sumBy(objects, function(o) { return o.n; });
  32358. * // => 20
  32359. *
  32360. * // The `_.property` iteratee shorthand.
  32361. * _.sumBy(objects, 'n');
  32362. * // => 20
  32363. */
  32364. function sumBy(array, iteratee) {
  32365. return (array && array.length)
  32366. ? baseSum(array, getIteratee(iteratee, 2))
  32367. : 0;
  32368. }
  32369. /*------------------------------------------------------------------------*/
  32370. // Add methods that return wrapped values in chain sequences.
  32371. lodash.after = after;
  32372. lodash.ary = ary;
  32373. lodash.assign = assign;
  32374. lodash.assignIn = assignIn;
  32375. lodash.assignInWith = assignInWith;
  32376. lodash.assignWith = assignWith;
  32377. lodash.at = at;
  32378. lodash.before = before;
  32379. lodash.bind = bind;
  32380. lodash.bindAll = bindAll;
  32381. lodash.bindKey = bindKey;
  32382. lodash.castArray = castArray;
  32383. lodash.chain = chain;
  32384. lodash.chunk = chunk;
  32385. lodash.compact = compact;
  32386. lodash.concat = concat;
  32387. lodash.cond = cond;
  32388. lodash.conforms = conforms;
  32389. lodash.constant = constant;
  32390. lodash.countBy = countBy;
  32391. lodash.create = create;
  32392. lodash.curry = curry;
  32393. lodash.curryRight = curryRight;
  32394. lodash.debounce = debounce;
  32395. lodash.defaults = defaults;
  32396. lodash.defaultsDeep = defaultsDeep;
  32397. lodash.defer = defer;
  32398. lodash.delay = delay;
  32399. lodash.difference = difference;
  32400. lodash.differenceBy = differenceBy;
  32401. lodash.differenceWith = differenceWith;
  32402. lodash.drop = drop;
  32403. lodash.dropRight = dropRight;
  32404. lodash.dropRightWhile = dropRightWhile;
  32405. lodash.dropWhile = dropWhile;
  32406. lodash.fill = fill;
  32407. lodash.filter = filter;
  32408. lodash.flatMap = flatMap;
  32409. lodash.flatMapDeep = flatMapDeep;
  32410. lodash.flatMapDepth = flatMapDepth;
  32411. lodash.flatten = flatten;
  32412. lodash.flattenDeep = flattenDeep;
  32413. lodash.flattenDepth = flattenDepth;
  32414. lodash.flip = flip;
  32415. lodash.flow = flow;
  32416. lodash.flowRight = flowRight;
  32417. lodash.fromPairs = fromPairs;
  32418. lodash.functions = functions;
  32419. lodash.functionsIn = functionsIn;
  32420. lodash.groupBy = groupBy;
  32421. lodash.initial = initial;
  32422. lodash.intersection = intersection;
  32423. lodash.intersectionBy = intersectionBy;
  32424. lodash.intersectionWith = intersectionWith;
  32425. lodash.invert = invert;
  32426. lodash.invertBy = invertBy;
  32427. lodash.invokeMap = invokeMap;
  32428. lodash.iteratee = iteratee;
  32429. lodash.keyBy = keyBy;
  32430. lodash.keys = keys;
  32431. lodash.keysIn = keysIn;
  32432. lodash.map = map;
  32433. lodash.mapKeys = mapKeys;
  32434. lodash.mapValues = mapValues;
  32435. lodash.matches = matches;
  32436. lodash.matchesProperty = matchesProperty;
  32437. lodash.memoize = memoize;
  32438. lodash.merge = merge;
  32439. lodash.mergeWith = mergeWith;
  32440. lodash.method = method;
  32441. lodash.methodOf = methodOf;
  32442. lodash.mixin = mixin;
  32443. lodash.negate = negate;
  32444. lodash.nthArg = nthArg;
  32445. lodash.omit = omit;
  32446. lodash.omitBy = omitBy;
  32447. lodash.once = once;
  32448. lodash.orderBy = orderBy;
  32449. lodash.over = over;
  32450. lodash.overArgs = overArgs;
  32451. lodash.overEvery = overEvery;
  32452. lodash.overSome = overSome;
  32453. lodash.partial = partial;
  32454. lodash.partialRight = partialRight;
  32455. lodash.partition = partition;
  32456. lodash.pick = pick;
  32457. lodash.pickBy = pickBy;
  32458. lodash.property = property;
  32459. lodash.propertyOf = propertyOf;
  32460. lodash.pull = pull;
  32461. lodash.pullAll = pullAll;
  32462. lodash.pullAllBy = pullAllBy;
  32463. lodash.pullAllWith = pullAllWith;
  32464. lodash.pullAt = pullAt;
  32465. lodash.range = range;
  32466. lodash.rangeRight = rangeRight;
  32467. lodash.rearg = rearg;
  32468. lodash.reject = reject;
  32469. lodash.remove = remove;
  32470. lodash.rest = rest;
  32471. lodash.reverse = reverse;
  32472. lodash.sampleSize = sampleSize;
  32473. lodash.set = set;
  32474. lodash.setWith = setWith;
  32475. lodash.shuffle = shuffle;
  32476. lodash.slice = slice;
  32477. lodash.sortBy = sortBy;
  32478. lodash.sortedUniq = sortedUniq;
  32479. lodash.sortedUniqBy = sortedUniqBy;
  32480. lodash.split = split;
  32481. lodash.spread = spread;
  32482. lodash.tail = tail;
  32483. lodash.take = take;
  32484. lodash.takeRight = takeRight;
  32485. lodash.takeRightWhile = takeRightWhile;
  32486. lodash.takeWhile = takeWhile;
  32487. lodash.tap = tap;
  32488. lodash.throttle = throttle;
  32489. lodash.thru = thru;
  32490. lodash.toArray = toArray;
  32491. lodash.toPairs = toPairs;
  32492. lodash.toPairsIn = toPairsIn;
  32493. lodash.toPath = toPath;
  32494. lodash.toPlainObject = toPlainObject;
  32495. lodash.transform = transform;
  32496. lodash.unary = unary;
  32497. lodash.union = union;
  32498. lodash.unionBy = unionBy;
  32499. lodash.unionWith = unionWith;
  32500. lodash.uniq = uniq;
  32501. lodash.uniqBy = uniqBy;
  32502. lodash.uniqWith = uniqWith;
  32503. lodash.unset = unset;
  32504. lodash.unzip = unzip;
  32505. lodash.unzipWith = unzipWith;
  32506. lodash.update = update;
  32507. lodash.updateWith = updateWith;
  32508. lodash.values = values;
  32509. lodash.valuesIn = valuesIn;
  32510. lodash.without = without;
  32511. lodash.words = words;
  32512. lodash.wrap = wrap;
  32513. lodash.xor = xor;
  32514. lodash.xorBy = xorBy;
  32515. lodash.xorWith = xorWith;
  32516. lodash.zip = zip;
  32517. lodash.zipObject = zipObject;
  32518. lodash.zipObjectDeep = zipObjectDeep;
  32519. lodash.zipWith = zipWith;
  32520. // Add aliases.
  32521. lodash.entries = toPairs;
  32522. lodash.entriesIn = toPairsIn;
  32523. lodash.extend = assignIn;
  32524. lodash.extendWith = assignInWith;
  32525. // Add methods to `lodash.prototype`.
  32526. mixin(lodash, lodash);
  32527. /*------------------------------------------------------------------------*/
  32528. // Add methods that return unwrapped values in chain sequences.
  32529. lodash.add = add;
  32530. lodash.attempt = attempt;
  32531. lodash.camelCase = camelCase;
  32532. lodash.capitalize = capitalize;
  32533. lodash.ceil = ceil;
  32534. lodash.clamp = clamp;
  32535. lodash.clone = clone;
  32536. lodash.cloneDeep = cloneDeep;
  32537. lodash.cloneDeepWith = cloneDeepWith;
  32538. lodash.cloneWith = cloneWith;
  32539. lodash.conformsTo = conformsTo;
  32540. lodash.deburr = deburr;
  32541. lodash.defaultTo = defaultTo;
  32542. lodash.divide = divide;
  32543. lodash.endsWith = endsWith;
  32544. lodash.eq = eq;
  32545. lodash.escape = escape;
  32546. lodash.escapeRegExp = escapeRegExp;
  32547. lodash.every = every;
  32548. lodash.find = find;
  32549. lodash.findIndex = findIndex;
  32550. lodash.findKey = findKey;
  32551. lodash.findLast = findLast;
  32552. lodash.findLastIndex = findLastIndex;
  32553. lodash.findLastKey = findLastKey;
  32554. lodash.floor = floor;
  32555. lodash.forEach = forEach;
  32556. lodash.forEachRight = forEachRight;
  32557. lodash.forIn = forIn;
  32558. lodash.forInRight = forInRight;
  32559. lodash.forOwn = forOwn;
  32560. lodash.forOwnRight = forOwnRight;
  32561. lodash.get = get;
  32562. lodash.gt = gt;
  32563. lodash.gte = gte;
  32564. lodash.has = has;
  32565. lodash.hasIn = hasIn;
  32566. lodash.head = head;
  32567. lodash.identity = identity;
  32568. lodash.includes = includes;
  32569. lodash.indexOf = indexOf;
  32570. lodash.inRange = inRange;
  32571. lodash.invoke = invoke;
  32572. lodash.isArguments = isArguments;
  32573. lodash.isArray = isArray;
  32574. lodash.isArrayBuffer = isArrayBuffer;
  32575. lodash.isArrayLike = isArrayLike;
  32576. lodash.isArrayLikeObject = isArrayLikeObject;
  32577. lodash.isBoolean = isBoolean;
  32578. lodash.isBuffer = isBuffer;
  32579. lodash.isDate = isDate;
  32580. lodash.isElement = isElement;
  32581. lodash.isEmpty = isEmpty;
  32582. lodash.isEqual = isEqual;
  32583. lodash.isEqualWith = isEqualWith;
  32584. lodash.isError = isError;
  32585. lodash.isFinite = isFinite;
  32586. lodash.isFunction = isFunction;
  32587. lodash.isInteger = isInteger;
  32588. lodash.isLength = isLength;
  32589. lodash.isMap = isMap;
  32590. lodash.isMatch = isMatch;
  32591. lodash.isMatchWith = isMatchWith;
  32592. lodash.isNaN = isNaN;
  32593. lodash.isNative = isNative;
  32594. lodash.isNil = isNil;
  32595. lodash.isNull = isNull;
  32596. lodash.isNumber = isNumber;
  32597. lodash.isObject = isObject;
  32598. lodash.isObjectLike = isObjectLike;
  32599. lodash.isPlainObject = isPlainObject;
  32600. lodash.isRegExp = isRegExp;
  32601. lodash.isSafeInteger = isSafeInteger;
  32602. lodash.isSet = isSet;
  32603. lodash.isString = isString;
  32604. lodash.isSymbol = isSymbol;
  32605. lodash.isTypedArray = isTypedArray;
  32606. lodash.isUndefined = isUndefined;
  32607. lodash.isWeakMap = isWeakMap;
  32608. lodash.isWeakSet = isWeakSet;
  32609. lodash.join = join;
  32610. lodash.kebabCase = kebabCase;
  32611. lodash.last = last;
  32612. lodash.lastIndexOf = lastIndexOf;
  32613. lodash.lowerCase = lowerCase;
  32614. lodash.lowerFirst = lowerFirst;
  32615. lodash.lt = lt;
  32616. lodash.lte = lte;
  32617. lodash.max = max;
  32618. lodash.maxBy = maxBy;
  32619. lodash.mean = mean;
  32620. lodash.meanBy = meanBy;
  32621. lodash.min = min;
  32622. lodash.minBy = minBy;
  32623. lodash.stubArray = stubArray;
  32624. lodash.stubFalse = stubFalse;
  32625. lodash.stubObject = stubObject;
  32626. lodash.stubString = stubString;
  32627. lodash.stubTrue = stubTrue;
  32628. lodash.multiply = multiply;
  32629. lodash.nth = nth;
  32630. lodash.noConflict = noConflict;
  32631. lodash.noop = noop;
  32632. lodash.now = now;
  32633. lodash.pad = pad;
  32634. lodash.padEnd = padEnd;
  32635. lodash.padStart = padStart;
  32636. lodash.parseInt = parseInt;
  32637. lodash.random = random;
  32638. lodash.reduce = reduce;
  32639. lodash.reduceRight = reduceRight;
  32640. lodash.repeat = repeat;
  32641. lodash.replace = replace;
  32642. lodash.result = result;
  32643. lodash.round = round;
  32644. lodash.runInContext = runInContext;
  32645. lodash.sample = sample;
  32646. lodash.size = size;
  32647. lodash.snakeCase = snakeCase;
  32648. lodash.some = some;
  32649. lodash.sortedIndex = sortedIndex;
  32650. lodash.sortedIndexBy = sortedIndexBy;
  32651. lodash.sortedIndexOf = sortedIndexOf;
  32652. lodash.sortedLastIndex = sortedLastIndex;
  32653. lodash.sortedLastIndexBy = sortedLastIndexBy;
  32654. lodash.sortedLastIndexOf = sortedLastIndexOf;
  32655. lodash.startCase = startCase;
  32656. lodash.startsWith = startsWith;
  32657. lodash.subtract = subtract;
  32658. lodash.sum = sum;
  32659. lodash.sumBy = sumBy;
  32660. lodash.template = template;
  32661. lodash.times = times;
  32662. lodash.toFinite = toFinite;
  32663. lodash.toInteger = toInteger;
  32664. lodash.toLength = toLength;
  32665. lodash.toLower = toLower;
  32666. lodash.toNumber = toNumber;
  32667. lodash.toSafeInteger = toSafeInteger;
  32668. lodash.toString = toString;
  32669. lodash.toUpper = toUpper;
  32670. lodash.trim = trim;
  32671. lodash.trimEnd = trimEnd;
  32672. lodash.trimStart = trimStart;
  32673. lodash.truncate = truncate;
  32674. lodash.unescape = unescape;
  32675. lodash.uniqueId = uniqueId;
  32676. lodash.upperCase = upperCase;
  32677. lodash.upperFirst = upperFirst;
  32678. // Add aliases.
  32679. lodash.each = forEach;
  32680. lodash.eachRight = forEachRight;
  32681. lodash.first = head;
  32682. mixin(lodash, (function() {
  32683. var source = {};
  32684. baseForOwn(lodash, function(func, methodName) {
  32685. if (!hasOwnProperty.call(lodash.prototype, methodName)) {
  32686. source[methodName] = func;
  32687. }
  32688. });
  32689. return source;
  32690. }()), { 'chain': false });
  32691. /*------------------------------------------------------------------------*/
  32692. /**
  32693. * The semantic version number.
  32694. *
  32695. * @static
  32696. * @memberOf _
  32697. * @type {string}
  32698. */
  32699. lodash.VERSION = VERSION;
  32700. // Assign default placeholders.
  32701. arrayEach(['bind', 'bindKey', 'curry', 'curryRight', 'partial', 'partialRight'], function(methodName) {
  32702. lodash[methodName].placeholder = lodash;
  32703. });
  32704. // Add `LazyWrapper` methods for `_.drop` and `_.take` variants.
  32705. arrayEach(['drop', 'take'], function(methodName, index) {
  32706. LazyWrapper.prototype[methodName] = function(n) {
  32707. n = n === undefined ? 1 : nativeMax(toInteger(n), 0);
  32708. var result = (this.__filtered__ && !index)
  32709. ? new LazyWrapper(this)
  32710. : this.clone();
  32711. if (result.__filtered__) {
  32712. result.__takeCount__ = nativeMin(n, result.__takeCount__);
  32713. } else {
  32714. result.__views__.push({
  32715. 'size': nativeMin(n, MAX_ARRAY_LENGTH),
  32716. 'type': methodName + (result.__dir__ < 0 ? 'Right' : '')
  32717. });
  32718. }
  32719. return result;
  32720. };
  32721. LazyWrapper.prototype[methodName + 'Right'] = function(n) {
  32722. return this.reverse()[methodName](n).reverse();
  32723. };
  32724. });
  32725. // Add `LazyWrapper` methods that accept an `iteratee` value.
  32726. arrayEach(['filter', 'map', 'takeWhile'], function(methodName, index) {
  32727. var type = index + 1,
  32728. isFilter = type == LAZY_FILTER_FLAG || type == LAZY_WHILE_FLAG;
  32729. LazyWrapper.prototype[methodName] = function(iteratee) {
  32730. var result = this.clone();
  32731. result.__iteratees__.push({
  32732. 'iteratee': getIteratee(iteratee, 3),
  32733. 'type': type
  32734. });
  32735. result.__filtered__ = result.__filtered__ || isFilter;
  32736. return result;
  32737. };
  32738. });
  32739. // Add `LazyWrapper` methods for `_.head` and `_.last`.
  32740. arrayEach(['head', 'last'], function(methodName, index) {
  32741. var takeName = 'take' + (index ? 'Right' : '');
  32742. LazyWrapper.prototype[methodName] = function() {
  32743. return this[takeName](1).value()[0];
  32744. };
  32745. });
  32746. // Add `LazyWrapper` methods for `_.initial` and `_.tail`.
  32747. arrayEach(['initial', 'tail'], function(methodName, index) {
  32748. var dropName = 'drop' + (index ? '' : 'Right');
  32749. LazyWrapper.prototype[methodName] = function() {
  32750. return this.__filtered__ ? new LazyWrapper(this) : this[dropName](1);
  32751. };
  32752. });
  32753. LazyWrapper.prototype.compact = function() {
  32754. return this.filter(identity);
  32755. };
  32756. LazyWrapper.prototype.find = function(predicate) {
  32757. return this.filter(predicate).head();
  32758. };
  32759. LazyWrapper.prototype.findLast = function(predicate) {
  32760. return this.reverse().find(predicate);
  32761. };
  32762. LazyWrapper.prototype.invokeMap = baseRest(function(path, args) {
  32763. if (typeof path == 'function') {
  32764. return new LazyWrapper(this);
  32765. }
  32766. return this.map(function(value) {
  32767. return baseInvoke(value, path, args);
  32768. });
  32769. });
  32770. LazyWrapper.prototype.reject = function(predicate) {
  32771. return this.filter(negate(getIteratee(predicate)));
  32772. };
  32773. LazyWrapper.prototype.slice = function(start, end) {
  32774. start = toInteger(start);
  32775. var result = this;
  32776. if (result.__filtered__ && (start > 0 || end < 0)) {
  32777. return new LazyWrapper(result);
  32778. }
  32779. if (start < 0) {
  32780. result = result.takeRight(-start);
  32781. } else if (start) {
  32782. result = result.drop(start);
  32783. }
  32784. if (end !== undefined) {
  32785. end = toInteger(end);
  32786. result = end < 0 ? result.dropRight(-end) : result.take(end - start);
  32787. }
  32788. return result;
  32789. };
  32790. LazyWrapper.prototype.takeRightWhile = function(predicate) {
  32791. return this.reverse().takeWhile(predicate).reverse();
  32792. };
  32793. LazyWrapper.prototype.toArray = function() {
  32794. return this.take(MAX_ARRAY_LENGTH);
  32795. };
  32796. // Add `LazyWrapper` methods to `lodash.prototype`.
  32797. baseForOwn(LazyWrapper.prototype, function(func, methodName) {
  32798. var checkIteratee = /^(?:filter|find|map|reject)|While$/.test(methodName),
  32799. isTaker = /^(?:head|last)$/.test(methodName),
  32800. lodashFunc = lodash[isTaker ? ('take' + (methodName == 'last' ? 'Right' : '')) : methodName],
  32801. retUnwrapped = isTaker || /^find/.test(methodName);
  32802. if (!lodashFunc) {
  32803. return;
  32804. }
  32805. lodash.prototype[methodName] = function() {
  32806. var value = this.__wrapped__,
  32807. args = isTaker ? [1] : arguments,
  32808. isLazy = value instanceof LazyWrapper,
  32809. iteratee = args[0],
  32810. useLazy = isLazy || isArray(value);
  32811. var interceptor = function(value) {
  32812. var result = lodashFunc.apply(lodash, arrayPush([value], args));
  32813. return (isTaker && chainAll) ? result[0] : result;
  32814. };
  32815. if (useLazy && checkIteratee && typeof iteratee == 'function' && iteratee.length != 1) {
  32816. // Avoid lazy use if the iteratee has a "length" value other than `1`.
  32817. isLazy = useLazy = false;
  32818. }
  32819. var chainAll = this.__chain__,
  32820. isHybrid = !!this.__actions__.length,
  32821. isUnwrapped = retUnwrapped && !chainAll,
  32822. onlyLazy = isLazy && !isHybrid;
  32823. if (!retUnwrapped && useLazy) {
  32824. value = onlyLazy ? value : new LazyWrapper(this);
  32825. var result = func.apply(value, args);
  32826. result.__actions__.push({ 'func': thru, 'args': [interceptor], 'thisArg': undefined });
  32827. return new LodashWrapper(result, chainAll);
  32828. }
  32829. if (isUnwrapped && onlyLazy) {
  32830. return func.apply(this, args);
  32831. }
  32832. result = this.thru(interceptor);
  32833. return isUnwrapped ? (isTaker ? result.value()[0] : result.value()) : result;
  32834. };
  32835. });
  32836. // Add `Array` methods to `lodash.prototype`.
  32837. arrayEach(['pop', 'push', 'shift', 'sort', 'splice', 'unshift'], function(methodName) {
  32838. var func = arrayProto[methodName],
  32839. chainName = /^(?:push|sort|unshift)$/.test(methodName) ? 'tap' : 'thru',
  32840. retUnwrapped = /^(?:pop|shift)$/.test(methodName);
  32841. lodash.prototype[methodName] = function() {
  32842. var args = arguments;
  32843. if (retUnwrapped && !this.__chain__) {
  32844. var value = this.value();
  32845. return func.apply(isArray(value) ? value : [], args);
  32846. }
  32847. return this[chainName](function(value) {
  32848. return func.apply(isArray(value) ? value : [], args);
  32849. });
  32850. };
  32851. });
  32852. // Map minified method names to their real names.
  32853. baseForOwn(LazyWrapper.prototype, function(func, methodName) {
  32854. var lodashFunc = lodash[methodName];
  32855. if (lodashFunc) {
  32856. var key = lodashFunc.name + '';
  32857. if (!hasOwnProperty.call(realNames, key)) {
  32858. realNames[key] = [];
  32859. }
  32860. realNames[key].push({ 'name': methodName, 'func': lodashFunc });
  32861. }
  32862. });
  32863. realNames[createHybrid(undefined, WRAP_BIND_KEY_FLAG).name] = [{
  32864. 'name': 'wrapper',
  32865. 'func': undefined
  32866. }];
  32867. // Add methods to `LazyWrapper`.
  32868. LazyWrapper.prototype.clone = lazyClone;
  32869. LazyWrapper.prototype.reverse = lazyReverse;
  32870. LazyWrapper.prototype.value = lazyValue;
  32871. // Add chain sequence methods to the `lodash` wrapper.
  32872. lodash.prototype.at = wrapperAt;
  32873. lodash.prototype.chain = wrapperChain;
  32874. lodash.prototype.commit = wrapperCommit;
  32875. lodash.prototype.next = wrapperNext;
  32876. lodash.prototype.plant = wrapperPlant;
  32877. lodash.prototype.reverse = wrapperReverse;
  32878. lodash.prototype.toJSON = lodash.prototype.valueOf = lodash.prototype.value = wrapperValue;
  32879. // Add lazy aliases.
  32880. lodash.prototype.first = lodash.prototype.head;
  32881. if (symIterator) {
  32882. lodash.prototype[symIterator] = wrapperToIterator;
  32883. }
  32884. return lodash;
  32885. });
  32886. /*--------------------------------------------------------------------------*/
  32887. // Export lodash.
  32888. var _ = runInContext();
  32889. // Some AMD build optimizers, like r.js, check for condition patterns like:
  32890. if (true) {
  32891. // Expose Lodash on the global object to prevent errors when Lodash is
  32892. // loaded by a script tag in the presence of an AMD loader.
  32893. // See http://requirejs.org/docs/errors.html#mismatch for more details.
  32894. // Use `_.noConflict` to remove Lodash from the global object.
  32895. root._ = _;
  32896. // Define as an anonymous module so, through path mapping, it can be
  32897. // referenced as the "underscore" module.
  32898. !(__WEBPACK_AMD_DEFINE_RESULT__ = (function() {
  32899. return _;
  32900. }).call(exports, __webpack_require__, exports, module),
  32901. __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
  32902. }
  32903. // Check for `exports` after `define` in case a build optimizer adds it.
  32904. else {}
  32905. }.call(this));
  32906. /* 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)))
  32907. /***/ }),
  32908. /***/ "./node_modules/popper.js/dist/esm/popper.js":
  32909. /*!***************************************************!*\
  32910. !*** ./node_modules/popper.js/dist/esm/popper.js ***!
  32911. \***************************************************/
  32912. /*! exports provided: default */
  32913. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  32914. "use strict";
  32915. __webpack_require__.r(__webpack_exports__);
  32916. /* WEBPACK VAR INJECTION */(function(global) {/**!
  32917. * @fileOverview Kickass library to create and place poppers near their reference elements.
  32918. * @version 1.16.1
  32919. * @license
  32920. * Copyright (c) 2016 Federico Zivolo and contributors
  32921. *
  32922. * Permission is hereby granted, free of charge, to any person obtaining a copy
  32923. * of this software and associated documentation files (the "Software"), to deal
  32924. * in the Software without restriction, including without limitation the rights
  32925. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  32926. * copies of the Software, and to permit persons to whom the Software is
  32927. * furnished to do so, subject to the following conditions:
  32928. *
  32929. * The above copyright notice and this permission notice shall be included in all
  32930. * copies or substantial portions of the Software.
  32931. *
  32932. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  32933. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  32934. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  32935. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  32936. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  32937. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  32938. * SOFTWARE.
  32939. */
  32940. var isBrowser = typeof window !== 'undefined' && typeof document !== 'undefined' && typeof navigator !== 'undefined';
  32941. var timeoutDuration = function () {
  32942. var longerTimeoutBrowsers = ['Edge', 'Trident', 'Firefox'];
  32943. for (var i = 0; i < longerTimeoutBrowsers.length; i += 1) {
  32944. if (isBrowser && navigator.userAgent.indexOf(longerTimeoutBrowsers[i]) >= 0) {
  32945. return 1;
  32946. }
  32947. }
  32948. return 0;
  32949. }();
  32950. function microtaskDebounce(fn) {
  32951. var called = false;
  32952. return function () {
  32953. if (called) {
  32954. return;
  32955. }
  32956. called = true;
  32957. window.Promise.resolve().then(function () {
  32958. called = false;
  32959. fn();
  32960. });
  32961. };
  32962. }
  32963. function taskDebounce(fn) {
  32964. var scheduled = false;
  32965. return function () {
  32966. if (!scheduled) {
  32967. scheduled = true;
  32968. setTimeout(function () {
  32969. scheduled = false;
  32970. fn();
  32971. }, timeoutDuration);
  32972. }
  32973. };
  32974. }
  32975. var supportsMicroTasks = isBrowser && window.Promise;
  32976. /**
  32977. * Create a debounced version of a method, that's asynchronously deferred
  32978. * but called in the minimum time possible.
  32979. *
  32980. * @method
  32981. * @memberof Popper.Utils
  32982. * @argument {Function} fn
  32983. * @returns {Function}
  32984. */
  32985. var debounce = supportsMicroTasks ? microtaskDebounce : taskDebounce;
  32986. /**
  32987. * Check if the given variable is a function
  32988. * @method
  32989. * @memberof Popper.Utils
  32990. * @argument {Any} functionToCheck - variable to check
  32991. * @returns {Boolean} answer to: is a function?
  32992. */
  32993. function isFunction(functionToCheck) {
  32994. var getType = {};
  32995. return functionToCheck && getType.toString.call(functionToCheck) === '[object Function]';
  32996. }
  32997. /**
  32998. * Get CSS computed property of the given element
  32999. * @method
  33000. * @memberof Popper.Utils
  33001. * @argument {Eement} element
  33002. * @argument {String} property
  33003. */
  33004. function getStyleComputedProperty(element, property) {
  33005. if (element.nodeType !== 1) {
  33006. return [];
  33007. }
  33008. // NOTE: 1 DOM access here
  33009. var window = element.ownerDocument.defaultView;
  33010. var css = window.getComputedStyle(element, null);
  33011. return property ? css[property] : css;
  33012. }
  33013. /**
  33014. * Returns the parentNode or the host of the element
  33015. * @method
  33016. * @memberof Popper.Utils
  33017. * @argument {Element} element
  33018. * @returns {Element} parent
  33019. */
  33020. function getParentNode(element) {
  33021. if (element.nodeName === 'HTML') {
  33022. return element;
  33023. }
  33024. return element.parentNode || element.host;
  33025. }
  33026. /**
  33027. * Returns the scrolling parent of the given element
  33028. * @method
  33029. * @memberof Popper.Utils
  33030. * @argument {Element} element
  33031. * @returns {Element} scroll parent
  33032. */
  33033. function getScrollParent(element) {
  33034. // Return body, `getScroll` will take care to get the correct `scrollTop` from it
  33035. if (!element) {
  33036. return document.body;
  33037. }
  33038. switch (element.nodeName) {
  33039. case 'HTML':
  33040. case 'BODY':
  33041. return element.ownerDocument.body;
  33042. case '#document':
  33043. return element.body;
  33044. }
  33045. // Firefox want us to check `-x` and `-y` variations as well
  33046. var _getStyleComputedProp = getStyleComputedProperty(element),
  33047. overflow = _getStyleComputedProp.overflow,
  33048. overflowX = _getStyleComputedProp.overflowX,
  33049. overflowY = _getStyleComputedProp.overflowY;
  33050. if (/(auto|scroll|overlay)/.test(overflow + overflowY + overflowX)) {
  33051. return element;
  33052. }
  33053. return getScrollParent(getParentNode(element));
  33054. }
  33055. /**
  33056. * Returns the reference node of the reference object, or the reference object itself.
  33057. * @method
  33058. * @memberof Popper.Utils
  33059. * @param {Element|Object} reference - the reference element (the popper will be relative to this)
  33060. * @returns {Element} parent
  33061. */
  33062. function getReferenceNode(reference) {
  33063. return reference && reference.referenceNode ? reference.referenceNode : reference;
  33064. }
  33065. var isIE11 = isBrowser && !!(window.MSInputMethodContext && document.documentMode);
  33066. var isIE10 = isBrowser && /MSIE 10/.test(navigator.userAgent);
  33067. /**
  33068. * Determines if the browser is Internet Explorer
  33069. * @method
  33070. * @memberof Popper.Utils
  33071. * @param {Number} version to check
  33072. * @returns {Boolean} isIE
  33073. */
  33074. function isIE(version) {
  33075. if (version === 11) {
  33076. return isIE11;
  33077. }
  33078. if (version === 10) {
  33079. return isIE10;
  33080. }
  33081. return isIE11 || isIE10;
  33082. }
  33083. /**
  33084. * Returns the offset parent of the given element
  33085. * @method
  33086. * @memberof Popper.Utils
  33087. * @argument {Element} element
  33088. * @returns {Element} offset parent
  33089. */
  33090. function getOffsetParent(element) {
  33091. if (!element) {
  33092. return document.documentElement;
  33093. }
  33094. var noOffsetParent = isIE(10) ? document.body : null;
  33095. // NOTE: 1 DOM access here
  33096. var offsetParent = element.offsetParent || null;
  33097. // Skip hidden elements which don't have an offsetParent
  33098. while (offsetParent === noOffsetParent && element.nextElementSibling) {
  33099. offsetParent = (element = element.nextElementSibling).offsetParent;
  33100. }
  33101. var nodeName = offsetParent && offsetParent.nodeName;
  33102. if (!nodeName || nodeName === 'BODY' || nodeName === 'HTML') {
  33103. return element ? element.ownerDocument.documentElement : document.documentElement;
  33104. }
  33105. // .offsetParent will return the closest TH, TD or TABLE in case
  33106. // no offsetParent is present, I hate this job...
  33107. if (['TH', 'TD', 'TABLE'].indexOf(offsetParent.nodeName) !== -1 && getStyleComputedProperty(offsetParent, 'position') === 'static') {
  33108. return getOffsetParent(offsetParent);
  33109. }
  33110. return offsetParent;
  33111. }
  33112. function isOffsetContainer(element) {
  33113. var nodeName = element.nodeName;
  33114. if (nodeName === 'BODY') {
  33115. return false;
  33116. }
  33117. return nodeName === 'HTML' || getOffsetParent(element.firstElementChild) === element;
  33118. }
  33119. /**
  33120. * Finds the root node (document, shadowDOM root) of the given element
  33121. * @method
  33122. * @memberof Popper.Utils
  33123. * @argument {Element} node
  33124. * @returns {Element} root node
  33125. */
  33126. function getRoot(node) {
  33127. if (node.parentNode !== null) {
  33128. return getRoot(node.parentNode);
  33129. }
  33130. return node;
  33131. }
  33132. /**
  33133. * Finds the offset parent common to the two provided nodes
  33134. * @method
  33135. * @memberof Popper.Utils
  33136. * @argument {Element} element1
  33137. * @argument {Element} element2
  33138. * @returns {Element} common offset parent
  33139. */
  33140. function findCommonOffsetParent(element1, element2) {
  33141. // This check is needed to avoid errors in case one of the elements isn't defined for any reason
  33142. if (!element1 || !element1.nodeType || !element2 || !element2.nodeType) {
  33143. return document.documentElement;
  33144. }
  33145. // Here we make sure to give as "start" the element that comes first in the DOM
  33146. var order = element1.compareDocumentPosition(element2) & Node.DOCUMENT_POSITION_FOLLOWING;
  33147. var start = order ? element1 : element2;
  33148. var end = order ? element2 : element1;
  33149. // Get common ancestor container
  33150. var range = document.createRange();
  33151. range.setStart(start, 0);
  33152. range.setEnd(end, 0);
  33153. var commonAncestorContainer = range.commonAncestorContainer;
  33154. // Both nodes are inside #document
  33155. if (element1 !== commonAncestorContainer && element2 !== commonAncestorContainer || start.contains(end)) {
  33156. if (isOffsetContainer(commonAncestorContainer)) {
  33157. return commonAncestorContainer;
  33158. }
  33159. return getOffsetParent(commonAncestorContainer);
  33160. }
  33161. // one of the nodes is inside shadowDOM, find which one
  33162. var element1root = getRoot(element1);
  33163. if (element1root.host) {
  33164. return findCommonOffsetParent(element1root.host, element2);
  33165. } else {
  33166. return findCommonOffsetParent(element1, getRoot(element2).host);
  33167. }
  33168. }
  33169. /**
  33170. * Gets the scroll value of the given element in the given side (top and left)
  33171. * @method
  33172. * @memberof Popper.Utils
  33173. * @argument {Element} element
  33174. * @argument {String} side `top` or `left`
  33175. * @returns {number} amount of scrolled pixels
  33176. */
  33177. function getScroll(element) {
  33178. var side = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'top';
  33179. var upperSide = side === 'top' ? 'scrollTop' : 'scrollLeft';
  33180. var nodeName = element.nodeName;
  33181. if (nodeName === 'BODY' || nodeName === 'HTML') {
  33182. var html = element.ownerDocument.documentElement;
  33183. var scrollingElement = element.ownerDocument.scrollingElement || html;
  33184. return scrollingElement[upperSide];
  33185. }
  33186. return element[upperSide];
  33187. }
  33188. /*
  33189. * Sum or subtract the element scroll values (left and top) from a given rect object
  33190. * @method
  33191. * @memberof Popper.Utils
  33192. * @param {Object} rect - Rect object you want to change
  33193. * @param {HTMLElement} element - The element from the function reads the scroll values
  33194. * @param {Boolean} subtract - set to true if you want to subtract the scroll values
  33195. * @return {Object} rect - The modifier rect object
  33196. */
  33197. function includeScroll(rect, element) {
  33198. var subtract = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  33199. var scrollTop = getScroll(element, 'top');
  33200. var scrollLeft = getScroll(element, 'left');
  33201. var modifier = subtract ? -1 : 1;
  33202. rect.top += scrollTop * modifier;
  33203. rect.bottom += scrollTop * modifier;
  33204. rect.left += scrollLeft * modifier;
  33205. rect.right += scrollLeft * modifier;
  33206. return rect;
  33207. }
  33208. /*
  33209. * Helper to detect borders of a given element
  33210. * @method
  33211. * @memberof Popper.Utils
  33212. * @param {CSSStyleDeclaration} styles
  33213. * Result of `getStyleComputedProperty` on the given element
  33214. * @param {String} axis - `x` or `y`
  33215. * @return {number} borders - The borders size of the given axis
  33216. */
  33217. function getBordersSize(styles, axis) {
  33218. var sideA = axis === 'x' ? 'Left' : 'Top';
  33219. var sideB = sideA === 'Left' ? 'Right' : 'Bottom';
  33220. return parseFloat(styles['border' + sideA + 'Width']) + parseFloat(styles['border' + sideB + 'Width']);
  33221. }
  33222. function getSize(axis, body, html, computedStyle) {
  33223. 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);
  33224. }
  33225. function getWindowSizes(document) {
  33226. var body = document.body;
  33227. var html = document.documentElement;
  33228. var computedStyle = isIE(10) && getComputedStyle(html);
  33229. return {
  33230. height: getSize('Height', body, html, computedStyle),
  33231. width: getSize('Width', body, html, computedStyle)
  33232. };
  33233. }
  33234. var classCallCheck = function (instance, Constructor) {
  33235. if (!(instance instanceof Constructor)) {
  33236. throw new TypeError("Cannot call a class as a function");
  33237. }
  33238. };
  33239. var createClass = function () {
  33240. function defineProperties(target, props) {
  33241. for (var i = 0; i < props.length; i++) {
  33242. var descriptor = props[i];
  33243. descriptor.enumerable = descriptor.enumerable || false;
  33244. descriptor.configurable = true;
  33245. if ("value" in descriptor) descriptor.writable = true;
  33246. Object.defineProperty(target, descriptor.key, descriptor);
  33247. }
  33248. }
  33249. return function (Constructor, protoProps, staticProps) {
  33250. if (protoProps) defineProperties(Constructor.prototype, protoProps);
  33251. if (staticProps) defineProperties(Constructor, staticProps);
  33252. return Constructor;
  33253. };
  33254. }();
  33255. var defineProperty = function (obj, key, value) {
  33256. if (key in obj) {
  33257. Object.defineProperty(obj, key, {
  33258. value: value,
  33259. enumerable: true,
  33260. configurable: true,
  33261. writable: true
  33262. });
  33263. } else {
  33264. obj[key] = value;
  33265. }
  33266. return obj;
  33267. };
  33268. var _extends = Object.assign || function (target) {
  33269. for (var i = 1; i < arguments.length; i++) {
  33270. var source = arguments[i];
  33271. for (var key in source) {
  33272. if (Object.prototype.hasOwnProperty.call(source, key)) {
  33273. target[key] = source[key];
  33274. }
  33275. }
  33276. }
  33277. return target;
  33278. };
  33279. /**
  33280. * Given element offsets, generate an output similar to getBoundingClientRect
  33281. * @method
  33282. * @memberof Popper.Utils
  33283. * @argument {Object} offsets
  33284. * @returns {Object} ClientRect like output
  33285. */
  33286. function getClientRect(offsets) {
  33287. return _extends({}, offsets, {
  33288. right: offsets.left + offsets.width,
  33289. bottom: offsets.top + offsets.height
  33290. });
  33291. }
  33292. /**
  33293. * Get bounding client rect of given element
  33294. * @method
  33295. * @memberof Popper.Utils
  33296. * @param {HTMLElement} element
  33297. * @return {Object} client rect
  33298. */
  33299. function getBoundingClientRect(element) {
  33300. var rect = {};
  33301. // IE10 10 FIX: Please, don't ask, the element isn't
  33302. // considered in DOM in some circumstances...
  33303. // This isn't reproducible in IE10 compatibility mode of IE11
  33304. try {
  33305. if (isIE(10)) {
  33306. rect = element.getBoundingClientRect();
  33307. var scrollTop = getScroll(element, 'top');
  33308. var scrollLeft = getScroll(element, 'left');
  33309. rect.top += scrollTop;
  33310. rect.left += scrollLeft;
  33311. rect.bottom += scrollTop;
  33312. rect.right += scrollLeft;
  33313. } else {
  33314. rect = element.getBoundingClientRect();
  33315. }
  33316. } catch (e) {}
  33317. var result = {
  33318. left: rect.left,
  33319. top: rect.top,
  33320. width: rect.right - rect.left,
  33321. height: rect.bottom - rect.top
  33322. };
  33323. // subtract scrollbar size from sizes
  33324. var sizes = element.nodeName === 'HTML' ? getWindowSizes(element.ownerDocument) : {};
  33325. var width = sizes.width || element.clientWidth || result.width;
  33326. var height = sizes.height || element.clientHeight || result.height;
  33327. var horizScrollbar = element.offsetWidth - width;
  33328. var vertScrollbar = element.offsetHeight - height;
  33329. // if an hypothetical scrollbar is detected, we must be sure it's not a `border`
  33330. // we make this check conditional for performance reasons
  33331. if (horizScrollbar || vertScrollbar) {
  33332. var styles = getStyleComputedProperty(element);
  33333. horizScrollbar -= getBordersSize(styles, 'x');
  33334. vertScrollbar -= getBordersSize(styles, 'y');
  33335. result.width -= horizScrollbar;
  33336. result.height -= vertScrollbar;
  33337. }
  33338. return getClientRect(result);
  33339. }
  33340. function getOffsetRectRelativeToArbitraryNode(children, parent) {
  33341. var fixedPosition = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  33342. var isIE10 = isIE(10);
  33343. var isHTML = parent.nodeName === 'HTML';
  33344. var childrenRect = getBoundingClientRect(children);
  33345. var parentRect = getBoundingClientRect(parent);
  33346. var scrollParent = getScrollParent(children);
  33347. var styles = getStyleComputedProperty(parent);
  33348. var borderTopWidth = parseFloat(styles.borderTopWidth);
  33349. var borderLeftWidth = parseFloat(styles.borderLeftWidth);
  33350. // In cases where the parent is fixed, we must ignore negative scroll in offset calc
  33351. if (fixedPosition && isHTML) {
  33352. parentRect.top = Math.max(parentRect.top, 0);
  33353. parentRect.left = Math.max(parentRect.left, 0);
  33354. }
  33355. var offsets = getClientRect({
  33356. top: childrenRect.top - parentRect.top - borderTopWidth,
  33357. left: childrenRect.left - parentRect.left - borderLeftWidth,
  33358. width: childrenRect.width,
  33359. height: childrenRect.height
  33360. });
  33361. offsets.marginTop = 0;
  33362. offsets.marginLeft = 0;
  33363. // Subtract margins of documentElement in case it's being used as parent
  33364. // we do this only on HTML because it's the only element that behaves
  33365. // differently when margins are applied to it. The margins are included in
  33366. // the box of the documentElement, in the other cases not.
  33367. if (!isIE10 && isHTML) {
  33368. var marginTop = parseFloat(styles.marginTop);
  33369. var marginLeft = parseFloat(styles.marginLeft);
  33370. offsets.top -= borderTopWidth - marginTop;
  33371. offsets.bottom -= borderTopWidth - marginTop;
  33372. offsets.left -= borderLeftWidth - marginLeft;
  33373. offsets.right -= borderLeftWidth - marginLeft;
  33374. // Attach marginTop and marginLeft because in some circumstances we may need them
  33375. offsets.marginTop = marginTop;
  33376. offsets.marginLeft = marginLeft;
  33377. }
  33378. if (isIE10 && !fixedPosition ? parent.contains(scrollParent) : parent === scrollParent && scrollParent.nodeName !== 'BODY') {
  33379. offsets = includeScroll(offsets, parent);
  33380. }
  33381. return offsets;
  33382. }
  33383. function getViewportOffsetRectRelativeToArtbitraryNode(element) {
  33384. var excludeScroll = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  33385. var html = element.ownerDocument.documentElement;
  33386. var relativeOffset = getOffsetRectRelativeToArbitraryNode(element, html);
  33387. var width = Math.max(html.clientWidth, window.innerWidth || 0);
  33388. var height = Math.max(html.clientHeight, window.innerHeight || 0);
  33389. var scrollTop = !excludeScroll ? getScroll(html) : 0;
  33390. var scrollLeft = !excludeScroll ? getScroll(html, 'left') : 0;
  33391. var offset = {
  33392. top: scrollTop - relativeOffset.top + relativeOffset.marginTop,
  33393. left: scrollLeft - relativeOffset.left + relativeOffset.marginLeft,
  33394. width: width,
  33395. height: height
  33396. };
  33397. return getClientRect(offset);
  33398. }
  33399. /**
  33400. * Check if the given element is fixed or is inside a fixed parent
  33401. * @method
  33402. * @memberof Popper.Utils
  33403. * @argument {Element} element
  33404. * @argument {Element} customContainer
  33405. * @returns {Boolean} answer to "isFixed?"
  33406. */
  33407. function isFixed(element) {
  33408. var nodeName = element.nodeName;
  33409. if (nodeName === 'BODY' || nodeName === 'HTML') {
  33410. return false;
  33411. }
  33412. if (getStyleComputedProperty(element, 'position') === 'fixed') {
  33413. return true;
  33414. }
  33415. var parentNode = getParentNode(element);
  33416. if (!parentNode) {
  33417. return false;
  33418. }
  33419. return isFixed(parentNode);
  33420. }
  33421. /**
  33422. * Finds the first parent of an element that has a transformed property defined
  33423. * @method
  33424. * @memberof Popper.Utils
  33425. * @argument {Element} element
  33426. * @returns {Element} first transformed parent or documentElement
  33427. */
  33428. function getFixedPositionOffsetParent(element) {
  33429. // This check is needed to avoid errors in case one of the elements isn't defined for any reason
  33430. if (!element || !element.parentElement || isIE()) {
  33431. return document.documentElement;
  33432. }
  33433. var el = element.parentElement;
  33434. while (el && getStyleComputedProperty(el, 'transform') === 'none') {
  33435. el = el.parentElement;
  33436. }
  33437. return el || document.documentElement;
  33438. }
  33439. /**
  33440. * Computed the boundaries limits and return them
  33441. * @method
  33442. * @memberof Popper.Utils
  33443. * @param {HTMLElement} popper
  33444. * @param {HTMLElement} reference
  33445. * @param {number} padding
  33446. * @param {HTMLElement} boundariesElement - Element used to define the boundaries
  33447. * @param {Boolean} fixedPosition - Is in fixed position mode
  33448. * @returns {Object} Coordinates of the boundaries
  33449. */
  33450. function getBoundaries(popper, reference, padding, boundariesElement) {
  33451. var fixedPosition = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
  33452. // NOTE: 1 DOM access here
  33453. var boundaries = { top: 0, left: 0 };
  33454. var offsetParent = fixedPosition ? getFixedPositionOffsetParent(popper) : findCommonOffsetParent(popper, getReferenceNode(reference));
  33455. // Handle viewport case
  33456. if (boundariesElement === 'viewport') {
  33457. boundaries = getViewportOffsetRectRelativeToArtbitraryNode(offsetParent, fixedPosition);
  33458. } else {
  33459. // Handle other cases based on DOM element used as boundaries
  33460. var boundariesNode = void 0;
  33461. if (boundariesElement === 'scrollParent') {
  33462. boundariesNode = getScrollParent(getParentNode(reference));
  33463. if (boundariesNode.nodeName === 'BODY') {
  33464. boundariesNode = popper.ownerDocument.documentElement;
  33465. }
  33466. } else if (boundariesElement === 'window') {
  33467. boundariesNode = popper.ownerDocument.documentElement;
  33468. } else {
  33469. boundariesNode = boundariesElement;
  33470. }
  33471. var offsets = getOffsetRectRelativeToArbitraryNode(boundariesNode, offsetParent, fixedPosition);
  33472. // In case of HTML, we need a different computation
  33473. if (boundariesNode.nodeName === 'HTML' && !isFixed(offsetParent)) {
  33474. var _getWindowSizes = getWindowSizes(popper.ownerDocument),
  33475. height = _getWindowSizes.height,
  33476. width = _getWindowSizes.width;
  33477. boundaries.top += offsets.top - offsets.marginTop;
  33478. boundaries.bottom = height + offsets.top;
  33479. boundaries.left += offsets.left - offsets.marginLeft;
  33480. boundaries.right = width + offsets.left;
  33481. } else {
  33482. // for all the other DOM elements, this one is good
  33483. boundaries = offsets;
  33484. }
  33485. }
  33486. // Add paddings
  33487. padding = padding || 0;
  33488. var isPaddingNumber = typeof padding === 'number';
  33489. boundaries.left += isPaddingNumber ? padding : padding.left || 0;
  33490. boundaries.top += isPaddingNumber ? padding : padding.top || 0;
  33491. boundaries.right -= isPaddingNumber ? padding : padding.right || 0;
  33492. boundaries.bottom -= isPaddingNumber ? padding : padding.bottom || 0;
  33493. return boundaries;
  33494. }
  33495. function getArea(_ref) {
  33496. var width = _ref.width,
  33497. height = _ref.height;
  33498. return width * height;
  33499. }
  33500. /**
  33501. * Utility used to transform the `auto` placement to the placement with more
  33502. * available space.
  33503. * @method
  33504. * @memberof Popper.Utils
  33505. * @argument {Object} data - The data object generated by update method
  33506. * @argument {Object} options - Modifiers configuration and options
  33507. * @returns {Object} The data object, properly modified
  33508. */
  33509. function computeAutoPlacement(placement, refRect, popper, reference, boundariesElement) {
  33510. var padding = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : 0;
  33511. if (placement.indexOf('auto') === -1) {
  33512. return placement;
  33513. }
  33514. var boundaries = getBoundaries(popper, reference, padding, boundariesElement);
  33515. var rects = {
  33516. top: {
  33517. width: boundaries.width,
  33518. height: refRect.top - boundaries.top
  33519. },
  33520. right: {
  33521. width: boundaries.right - refRect.right,
  33522. height: boundaries.height
  33523. },
  33524. bottom: {
  33525. width: boundaries.width,
  33526. height: boundaries.bottom - refRect.bottom
  33527. },
  33528. left: {
  33529. width: refRect.left - boundaries.left,
  33530. height: boundaries.height
  33531. }
  33532. };
  33533. var sortedAreas = Object.keys(rects).map(function (key) {
  33534. return _extends({
  33535. key: key
  33536. }, rects[key], {
  33537. area: getArea(rects[key])
  33538. });
  33539. }).sort(function (a, b) {
  33540. return b.area - a.area;
  33541. });
  33542. var filteredAreas = sortedAreas.filter(function (_ref2) {
  33543. var width = _ref2.width,
  33544. height = _ref2.height;
  33545. return width >= popper.clientWidth && height >= popper.clientHeight;
  33546. });
  33547. var computedPlacement = filteredAreas.length > 0 ? filteredAreas[0].key : sortedAreas[0].key;
  33548. var variation = placement.split('-')[1];
  33549. return computedPlacement + (variation ? '-' + variation : '');
  33550. }
  33551. /**
  33552. * Get offsets to the reference element
  33553. * @method
  33554. * @memberof Popper.Utils
  33555. * @param {Object} state
  33556. * @param {Element} popper - the popper element
  33557. * @param {Element} reference - the reference element (the popper will be relative to this)
  33558. * @param {Element} fixedPosition - is in fixed position mode
  33559. * @returns {Object} An object containing the offsets which will be applied to the popper
  33560. */
  33561. function getReferenceOffsets(state, popper, reference) {
  33562. var fixedPosition = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
  33563. var commonOffsetParent = fixedPosition ? getFixedPositionOffsetParent(popper) : findCommonOffsetParent(popper, getReferenceNode(reference));
  33564. return getOffsetRectRelativeToArbitraryNode(reference, commonOffsetParent, fixedPosition);
  33565. }
  33566. /**
  33567. * Get the outer sizes of the given element (offset size + margins)
  33568. * @method
  33569. * @memberof Popper.Utils
  33570. * @argument {Element} element
  33571. * @returns {Object} object containing width and height properties
  33572. */
  33573. function getOuterSizes(element) {
  33574. var window = element.ownerDocument.defaultView;
  33575. var styles = window.getComputedStyle(element);
  33576. var x = parseFloat(styles.marginTop || 0) + parseFloat(styles.marginBottom || 0);
  33577. var y = parseFloat(styles.marginLeft || 0) + parseFloat(styles.marginRight || 0);
  33578. var result = {
  33579. width: element.offsetWidth + y,
  33580. height: element.offsetHeight + x
  33581. };
  33582. return result;
  33583. }
  33584. /**
  33585. * Get the opposite placement of the given one
  33586. * @method
  33587. * @memberof Popper.Utils
  33588. * @argument {String} placement
  33589. * @returns {String} flipped placement
  33590. */
  33591. function getOppositePlacement(placement) {
  33592. var hash = { left: 'right', right: 'left', bottom: 'top', top: 'bottom' };
  33593. return placement.replace(/left|right|bottom|top/g, function (matched) {
  33594. return hash[matched];
  33595. });
  33596. }
  33597. /**
  33598. * Get offsets to the popper
  33599. * @method
  33600. * @memberof Popper.Utils
  33601. * @param {Object} position - CSS position the Popper will get applied
  33602. * @param {HTMLElement} popper - the popper element
  33603. * @param {Object} referenceOffsets - the reference offsets (the popper will be relative to this)
  33604. * @param {String} placement - one of the valid placement options
  33605. * @returns {Object} popperOffsets - An object containing the offsets which will be applied to the popper
  33606. */
  33607. function getPopperOffsets(popper, referenceOffsets, placement) {
  33608. placement = placement.split('-')[0];
  33609. // Get popper node sizes
  33610. var popperRect = getOuterSizes(popper);
  33611. // Add position, width and height to our offsets object
  33612. var popperOffsets = {
  33613. width: popperRect.width,
  33614. height: popperRect.height
  33615. };
  33616. // depending by the popper placement we have to compute its offsets slightly differently
  33617. var isHoriz = ['right', 'left'].indexOf(placement) !== -1;
  33618. var mainSide = isHoriz ? 'top' : 'left';
  33619. var secondarySide = isHoriz ? 'left' : 'top';
  33620. var measurement = isHoriz ? 'height' : 'width';
  33621. var secondaryMeasurement = !isHoriz ? 'height' : 'width';
  33622. popperOffsets[mainSide] = referenceOffsets[mainSide] + referenceOffsets[measurement] / 2 - popperRect[measurement] / 2;
  33623. if (placement === secondarySide) {
  33624. popperOffsets[secondarySide] = referenceOffsets[secondarySide] - popperRect[secondaryMeasurement];
  33625. } else {
  33626. popperOffsets[secondarySide] = referenceOffsets[getOppositePlacement(secondarySide)];
  33627. }
  33628. return popperOffsets;
  33629. }
  33630. /**
  33631. * Mimics the `find` method of Array
  33632. * @method
  33633. * @memberof Popper.Utils
  33634. * @argument {Array} arr
  33635. * @argument prop
  33636. * @argument value
  33637. * @returns index or -1
  33638. */
  33639. function find(arr, check) {
  33640. // use native find if supported
  33641. if (Array.prototype.find) {
  33642. return arr.find(check);
  33643. }
  33644. // use `filter` to obtain the same behavior of `find`
  33645. return arr.filter(check)[0];
  33646. }
  33647. /**
  33648. * Return the index of the matching object
  33649. * @method
  33650. * @memberof Popper.Utils
  33651. * @argument {Array} arr
  33652. * @argument prop
  33653. * @argument value
  33654. * @returns index or -1
  33655. */
  33656. function findIndex(arr, prop, value) {
  33657. // use native findIndex if supported
  33658. if (Array.prototype.findIndex) {
  33659. return arr.findIndex(function (cur) {
  33660. return cur[prop] === value;
  33661. });
  33662. }
  33663. // use `find` + `indexOf` if `findIndex` isn't supported
  33664. var match = find(arr, function (obj) {
  33665. return obj[prop] === value;
  33666. });
  33667. return arr.indexOf(match);
  33668. }
  33669. /**
  33670. * Loop trough the list of modifiers and run them in order,
  33671. * each of them will then edit the data object.
  33672. * @method
  33673. * @memberof Popper.Utils
  33674. * @param {dataObject} data
  33675. * @param {Array} modifiers
  33676. * @param {String} ends - Optional modifier name used as stopper
  33677. * @returns {dataObject}
  33678. */
  33679. function runModifiers(modifiers, data, ends) {
  33680. var modifiersToRun = ends === undefined ? modifiers : modifiers.slice(0, findIndex(modifiers, 'name', ends));
  33681. modifiersToRun.forEach(function (modifier) {
  33682. if (modifier['function']) {
  33683. // eslint-disable-line dot-notation
  33684. console.warn('`modifier.function` is deprecated, use `modifier.fn`!');
  33685. }
  33686. var fn = modifier['function'] || modifier.fn; // eslint-disable-line dot-notation
  33687. if (modifier.enabled && isFunction(fn)) {
  33688. // Add properties to offsets to make them a complete clientRect object
  33689. // we do this before each modifier to make sure the previous one doesn't
  33690. // mess with these values
  33691. data.offsets.popper = getClientRect(data.offsets.popper);
  33692. data.offsets.reference = getClientRect(data.offsets.reference);
  33693. data = fn(data, modifier);
  33694. }
  33695. });
  33696. return data;
  33697. }
  33698. /**
  33699. * Updates the position of the popper, computing the new offsets and applying
  33700. * the new style.<br />
  33701. * Prefer `scheduleUpdate` over `update` because of performance reasons.
  33702. * @method
  33703. * @memberof Popper
  33704. */
  33705. function update() {
  33706. // if popper is destroyed, don't perform any further update
  33707. if (this.state.isDestroyed) {
  33708. return;
  33709. }
  33710. var data = {
  33711. instance: this,
  33712. styles: {},
  33713. arrowStyles: {},
  33714. attributes: {},
  33715. flipped: false,
  33716. offsets: {}
  33717. };
  33718. // compute reference element offsets
  33719. data.offsets.reference = getReferenceOffsets(this.state, this.popper, this.reference, this.options.positionFixed);
  33720. // compute auto placement, store placement inside the data object,
  33721. // modifiers will be able to edit `placement` if needed
  33722. // and refer to originalPlacement to know the original value
  33723. data.placement = computeAutoPlacement(this.options.placement, data.offsets.reference, this.popper, this.reference, this.options.modifiers.flip.boundariesElement, this.options.modifiers.flip.padding);
  33724. // store the computed placement inside `originalPlacement`
  33725. data.originalPlacement = data.placement;
  33726. data.positionFixed = this.options.positionFixed;
  33727. // compute the popper offsets
  33728. data.offsets.popper = getPopperOffsets(this.popper, data.offsets.reference, data.placement);
  33729. data.offsets.popper.position = this.options.positionFixed ? 'fixed' : 'absolute';
  33730. // run the modifiers
  33731. data = runModifiers(this.modifiers, data);
  33732. // the first `update` will call `onCreate` callback
  33733. // the other ones will call `onUpdate` callback
  33734. if (!this.state.isCreated) {
  33735. this.state.isCreated = true;
  33736. this.options.onCreate(data);
  33737. } else {
  33738. this.options.onUpdate(data);
  33739. }
  33740. }
  33741. /**
  33742. * Helper used to know if the given modifier is enabled.
  33743. * @method
  33744. * @memberof Popper.Utils
  33745. * @returns {Boolean}
  33746. */
  33747. function isModifierEnabled(modifiers, modifierName) {
  33748. return modifiers.some(function (_ref) {
  33749. var name = _ref.name,
  33750. enabled = _ref.enabled;
  33751. return enabled && name === modifierName;
  33752. });
  33753. }
  33754. /**
  33755. * Get the prefixed supported property name
  33756. * @method
  33757. * @memberof Popper.Utils
  33758. * @argument {String} property (camelCase)
  33759. * @returns {String} prefixed property (camelCase or PascalCase, depending on the vendor prefix)
  33760. */
  33761. function getSupportedPropertyName(property) {
  33762. var prefixes = [false, 'ms', 'Webkit', 'Moz', 'O'];
  33763. var upperProp = property.charAt(0).toUpperCase() + property.slice(1);
  33764. for (var i = 0; i < prefixes.length; i++) {
  33765. var prefix = prefixes[i];
  33766. var toCheck = prefix ? '' + prefix + upperProp : property;
  33767. if (typeof document.body.style[toCheck] !== 'undefined') {
  33768. return toCheck;
  33769. }
  33770. }
  33771. return null;
  33772. }
  33773. /**
  33774. * Destroys the popper.
  33775. * @method
  33776. * @memberof Popper
  33777. */
  33778. function destroy() {
  33779. this.state.isDestroyed = true;
  33780. // touch DOM only if `applyStyle` modifier is enabled
  33781. if (isModifierEnabled(this.modifiers, 'applyStyle')) {
  33782. this.popper.removeAttribute('x-placement');
  33783. this.popper.style.position = '';
  33784. this.popper.style.top = '';
  33785. this.popper.style.left = '';
  33786. this.popper.style.right = '';
  33787. this.popper.style.bottom = '';
  33788. this.popper.style.willChange = '';
  33789. this.popper.style[getSupportedPropertyName('transform')] = '';
  33790. }
  33791. this.disableEventListeners();
  33792. // remove the popper if user explicitly asked for the deletion on destroy
  33793. // do not use `remove` because IE11 doesn't support it
  33794. if (this.options.removeOnDestroy) {
  33795. this.popper.parentNode.removeChild(this.popper);
  33796. }
  33797. return this;
  33798. }
  33799. /**
  33800. * Get the window associated with the element
  33801. * @argument {Element} element
  33802. * @returns {Window}
  33803. */
  33804. function getWindow(element) {
  33805. var ownerDocument = element.ownerDocument;
  33806. return ownerDocument ? ownerDocument.defaultView : window;
  33807. }
  33808. function attachToScrollParents(scrollParent, event, callback, scrollParents) {
  33809. var isBody = scrollParent.nodeName === 'BODY';
  33810. var target = isBody ? scrollParent.ownerDocument.defaultView : scrollParent;
  33811. target.addEventListener(event, callback, { passive: true });
  33812. if (!isBody) {
  33813. attachToScrollParents(getScrollParent(target.parentNode), event, callback, scrollParents);
  33814. }
  33815. scrollParents.push(target);
  33816. }
  33817. /**
  33818. * Setup needed event listeners used to update the popper position
  33819. * @method
  33820. * @memberof Popper.Utils
  33821. * @private
  33822. */
  33823. function setupEventListeners(reference, options, state, updateBound) {
  33824. // Resize event listener on window
  33825. state.updateBound = updateBound;
  33826. getWindow(reference).addEventListener('resize', state.updateBound, { passive: true });
  33827. // Scroll event listener on scroll parents
  33828. var scrollElement = getScrollParent(reference);
  33829. attachToScrollParents(scrollElement, 'scroll', state.updateBound, state.scrollParents);
  33830. state.scrollElement = scrollElement;
  33831. state.eventsEnabled = true;
  33832. return state;
  33833. }
  33834. /**
  33835. * It will add resize/scroll events and start recalculating
  33836. * position of the popper element when they are triggered.
  33837. * @method
  33838. * @memberof Popper
  33839. */
  33840. function enableEventListeners() {
  33841. if (!this.state.eventsEnabled) {
  33842. this.state = setupEventListeners(this.reference, this.options, this.state, this.scheduleUpdate);
  33843. }
  33844. }
  33845. /**
  33846. * Remove event listeners used to update the popper position
  33847. * @method
  33848. * @memberof Popper.Utils
  33849. * @private
  33850. */
  33851. function removeEventListeners(reference, state) {
  33852. // Remove resize event listener on window
  33853. getWindow(reference).removeEventListener('resize', state.updateBound);
  33854. // Remove scroll event listener on scroll parents
  33855. state.scrollParents.forEach(function (target) {
  33856. target.removeEventListener('scroll', state.updateBound);
  33857. });
  33858. // Reset state
  33859. state.updateBound = null;
  33860. state.scrollParents = [];
  33861. state.scrollElement = null;
  33862. state.eventsEnabled = false;
  33863. return state;
  33864. }
  33865. /**
  33866. * It will remove resize/scroll events and won't recalculate popper position
  33867. * when they are triggered. It also won't trigger `onUpdate` callback anymore,
  33868. * unless you call `update` method manually.
  33869. * @method
  33870. * @memberof Popper
  33871. */
  33872. function disableEventListeners() {
  33873. if (this.state.eventsEnabled) {
  33874. cancelAnimationFrame(this.scheduleUpdate);
  33875. this.state = removeEventListeners(this.reference, this.state);
  33876. }
  33877. }
  33878. /**
  33879. * Tells if a given input is a number
  33880. * @method
  33881. * @memberof Popper.Utils
  33882. * @param {*} input to check
  33883. * @return {Boolean}
  33884. */
  33885. function isNumeric(n) {
  33886. return n !== '' && !isNaN(parseFloat(n)) && isFinite(n);
  33887. }
  33888. /**
  33889. * Set the style to the given popper
  33890. * @method
  33891. * @memberof Popper.Utils
  33892. * @argument {Element} element - Element to apply the style to
  33893. * @argument {Object} styles
  33894. * Object with a list of properties and values which will be applied to the element
  33895. */
  33896. function setStyles(element, styles) {
  33897. Object.keys(styles).forEach(function (prop) {
  33898. var unit = '';
  33899. // add unit if the value is numeric and is one of the following
  33900. if (['width', 'height', 'top', 'right', 'bottom', 'left'].indexOf(prop) !== -1 && isNumeric(styles[prop])) {
  33901. unit = 'px';
  33902. }
  33903. element.style[prop] = styles[prop] + unit;
  33904. });
  33905. }
  33906. /**
  33907. * Set the attributes to the given popper
  33908. * @method
  33909. * @memberof Popper.Utils
  33910. * @argument {Element} element - Element to apply the attributes to
  33911. * @argument {Object} styles
  33912. * Object with a list of properties and values which will be applied to the element
  33913. */
  33914. function setAttributes(element, attributes) {
  33915. Object.keys(attributes).forEach(function (prop) {
  33916. var value = attributes[prop];
  33917. if (value !== false) {
  33918. element.setAttribute(prop, attributes[prop]);
  33919. } else {
  33920. element.removeAttribute(prop);
  33921. }
  33922. });
  33923. }
  33924. /**
  33925. * @function
  33926. * @memberof Modifiers
  33927. * @argument {Object} data - The data object generated by `update` method
  33928. * @argument {Object} data.styles - List of style properties - values to apply to popper element
  33929. * @argument {Object} data.attributes - List of attribute properties - values to apply to popper element
  33930. * @argument {Object} options - Modifiers configuration and options
  33931. * @returns {Object} The same data object
  33932. */
  33933. function applyStyle(data) {
  33934. // any property present in `data.styles` will be applied to the popper,
  33935. // in this way we can make the 3rd party modifiers add custom styles to it
  33936. // Be aware, modifiers could override the properties defined in the previous
  33937. // lines of this modifier!
  33938. setStyles(data.instance.popper, data.styles);
  33939. // any property present in `data.attributes` will be applied to the popper,
  33940. // they will be set as HTML attributes of the element
  33941. setAttributes(data.instance.popper, data.attributes);
  33942. // if arrowElement is defined and arrowStyles has some properties
  33943. if (data.arrowElement && Object.keys(data.arrowStyles).length) {
  33944. setStyles(data.arrowElement, data.arrowStyles);
  33945. }
  33946. return data;
  33947. }
  33948. /**
  33949. * Set the x-placement attribute before everything else because it could be used
  33950. * to add margins to the popper margins needs to be calculated to get the
  33951. * correct popper offsets.
  33952. * @method
  33953. * @memberof Popper.modifiers
  33954. * @param {HTMLElement} reference - The reference element used to position the popper
  33955. * @param {HTMLElement} popper - The HTML element used as popper
  33956. * @param {Object} options - Popper.js options
  33957. */
  33958. function applyStyleOnLoad(reference, popper, options, modifierOptions, state) {
  33959. // compute reference element offsets
  33960. var referenceOffsets = getReferenceOffsets(state, popper, reference, options.positionFixed);
  33961. // compute auto placement, store placement inside the data object,
  33962. // modifiers will be able to edit `placement` if needed
  33963. // and refer to originalPlacement to know the original value
  33964. var placement = computeAutoPlacement(options.placement, referenceOffsets, popper, reference, options.modifiers.flip.boundariesElement, options.modifiers.flip.padding);
  33965. popper.setAttribute('x-placement', placement);
  33966. // Apply `position` to popper before anything else because
  33967. // without the position applied we can't guarantee correct computations
  33968. setStyles(popper, { position: options.positionFixed ? 'fixed' : 'absolute' });
  33969. return options;
  33970. }
  33971. /**
  33972. * @function
  33973. * @memberof Popper.Utils
  33974. * @argument {Object} data - The data object generated by `update` method
  33975. * @argument {Boolean} shouldRound - If the offsets should be rounded at all
  33976. * @returns {Object} The popper's position offsets rounded
  33977. *
  33978. * The tale of pixel-perfect positioning. It's still not 100% perfect, but as
  33979. * good as it can be within reason.
  33980. * Discussion here: https://github.com/FezVrasta/popper.js/pull/715
  33981. *
  33982. * Low DPI screens cause a popper to be blurry if not using full pixels (Safari
  33983. * as well on High DPI screens).
  33984. *
  33985. * Firefox prefers no rounding for positioning and does not have blurriness on
  33986. * high DPI screens.
  33987. *
  33988. * Only horizontal placement and left/right values need to be considered.
  33989. */
  33990. function getRoundedOffsets(data, shouldRound) {
  33991. var _data$offsets = data.offsets,
  33992. popper = _data$offsets.popper,
  33993. reference = _data$offsets.reference;
  33994. var round = Math.round,
  33995. floor = Math.floor;
  33996. var noRound = function noRound(v) {
  33997. return v;
  33998. };
  33999. var referenceWidth = round(reference.width);
  34000. var popperWidth = round(popper.width);
  34001. var isVertical = ['left', 'right'].indexOf(data.placement) !== -1;
  34002. var isVariation = data.placement.indexOf('-') !== -1;
  34003. var sameWidthParity = referenceWidth % 2 === popperWidth % 2;
  34004. var bothOddWidth = referenceWidth % 2 === 1 && popperWidth % 2 === 1;
  34005. var horizontalToInteger = !shouldRound ? noRound : isVertical || isVariation || sameWidthParity ? round : floor;
  34006. var verticalToInteger = !shouldRound ? noRound : round;
  34007. return {
  34008. left: horizontalToInteger(bothOddWidth && !isVariation && shouldRound ? popper.left - 1 : popper.left),
  34009. top: verticalToInteger(popper.top),
  34010. bottom: verticalToInteger(popper.bottom),
  34011. right: horizontalToInteger(popper.right)
  34012. };
  34013. }
  34014. var isFirefox = isBrowser && /Firefox/i.test(navigator.userAgent);
  34015. /**
  34016. * @function
  34017. * @memberof Modifiers
  34018. * @argument {Object} data - The data object generated by `update` method
  34019. * @argument {Object} options - Modifiers configuration and options
  34020. * @returns {Object} The data object, properly modified
  34021. */
  34022. function computeStyle(data, options) {
  34023. var x = options.x,
  34024. y = options.y;
  34025. var popper = data.offsets.popper;
  34026. // Remove this legacy support in Popper.js v2
  34027. var legacyGpuAccelerationOption = find(data.instance.modifiers, function (modifier) {
  34028. return modifier.name === 'applyStyle';
  34029. }).gpuAcceleration;
  34030. if (legacyGpuAccelerationOption !== undefined) {
  34031. console.warn('WARNING: `gpuAcceleration` option moved to `computeStyle` modifier and will not be supported in future versions of Popper.js!');
  34032. }
  34033. var gpuAcceleration = legacyGpuAccelerationOption !== undefined ? legacyGpuAccelerationOption : options.gpuAcceleration;
  34034. var offsetParent = getOffsetParent(data.instance.popper);
  34035. var offsetParentRect = getBoundingClientRect(offsetParent);
  34036. // Styles
  34037. var styles = {
  34038. position: popper.position
  34039. };
  34040. var offsets = getRoundedOffsets(data, window.devicePixelRatio < 2 || !isFirefox);
  34041. var sideA = x === 'bottom' ? 'top' : 'bottom';
  34042. var sideB = y === 'right' ? 'left' : 'right';
  34043. // if gpuAcceleration is set to `true` and transform is supported,
  34044. // we use `translate3d` to apply the position to the popper we
  34045. // automatically use the supported prefixed version if needed
  34046. var prefixedProperty = getSupportedPropertyName('transform');
  34047. // now, let's make a step back and look at this code closely (wtf?)
  34048. // If the content of the popper grows once it's been positioned, it
  34049. // may happen that the popper gets misplaced because of the new content
  34050. // overflowing its reference element
  34051. // To avoid this problem, we provide two options (x and y), which allow
  34052. // the consumer to define the offset origin.
  34053. // If we position a popper on top of a reference element, we can set
  34054. // `x` to `top` to make the popper grow towards its top instead of
  34055. // its bottom.
  34056. var left = void 0,
  34057. top = void 0;
  34058. if (sideA === 'bottom') {
  34059. // when offsetParent is <html> the positioning is relative to the bottom of the screen (excluding the scrollbar)
  34060. // and not the bottom of the html element
  34061. if (offsetParent.nodeName === 'HTML') {
  34062. top = -offsetParent.clientHeight + offsets.bottom;
  34063. } else {
  34064. top = -offsetParentRect.height + offsets.bottom;
  34065. }
  34066. } else {
  34067. top = offsets.top;
  34068. }
  34069. if (sideB === 'right') {
  34070. if (offsetParent.nodeName === 'HTML') {
  34071. left = -offsetParent.clientWidth + offsets.right;
  34072. } else {
  34073. left = -offsetParentRect.width + offsets.right;
  34074. }
  34075. } else {
  34076. left = offsets.left;
  34077. }
  34078. if (gpuAcceleration && prefixedProperty) {
  34079. styles[prefixedProperty] = 'translate3d(' + left + 'px, ' + top + 'px, 0)';
  34080. styles[sideA] = 0;
  34081. styles[sideB] = 0;
  34082. styles.willChange = 'transform';
  34083. } else {
  34084. // othwerise, we use the standard `top`, `left`, `bottom` and `right` properties
  34085. var invertTop = sideA === 'bottom' ? -1 : 1;
  34086. var invertLeft = sideB === 'right' ? -1 : 1;
  34087. styles[sideA] = top * invertTop;
  34088. styles[sideB] = left * invertLeft;
  34089. styles.willChange = sideA + ', ' + sideB;
  34090. }
  34091. // Attributes
  34092. var attributes = {
  34093. 'x-placement': data.placement
  34094. };
  34095. // Update `data` attributes, styles and arrowStyles
  34096. data.attributes = _extends({}, attributes, data.attributes);
  34097. data.styles = _extends({}, styles, data.styles);
  34098. data.arrowStyles = _extends({}, data.offsets.arrow, data.arrowStyles);
  34099. return data;
  34100. }
  34101. /**
  34102. * Helper used to know if the given modifier depends from another one.<br />
  34103. * It checks if the needed modifier is listed and enabled.
  34104. * @method
  34105. * @memberof Popper.Utils
  34106. * @param {Array} modifiers - list of modifiers
  34107. * @param {String} requestingName - name of requesting modifier
  34108. * @param {String} requestedName - name of requested modifier
  34109. * @returns {Boolean}
  34110. */
  34111. function isModifierRequired(modifiers, requestingName, requestedName) {
  34112. var requesting = find(modifiers, function (_ref) {
  34113. var name = _ref.name;
  34114. return name === requestingName;
  34115. });
  34116. var isRequired = !!requesting && modifiers.some(function (modifier) {
  34117. return modifier.name === requestedName && modifier.enabled && modifier.order < requesting.order;
  34118. });
  34119. if (!isRequired) {
  34120. var _requesting = '`' + requestingName + '`';
  34121. var requested = '`' + requestedName + '`';
  34122. console.warn(requested + ' modifier is required by ' + _requesting + ' modifier in order to work, be sure to include it before ' + _requesting + '!');
  34123. }
  34124. return isRequired;
  34125. }
  34126. /**
  34127. * @function
  34128. * @memberof Modifiers
  34129. * @argument {Object} data - The data object generated by update method
  34130. * @argument {Object} options - Modifiers configuration and options
  34131. * @returns {Object} The data object, properly modified
  34132. */
  34133. function arrow(data, options) {
  34134. var _data$offsets$arrow;
  34135. // arrow depends on keepTogether in order to work
  34136. if (!isModifierRequired(data.instance.modifiers, 'arrow', 'keepTogether')) {
  34137. return data;
  34138. }
  34139. var arrowElement = options.element;
  34140. // if arrowElement is a string, suppose it's a CSS selector
  34141. if (typeof arrowElement === 'string') {
  34142. arrowElement = data.instance.popper.querySelector(arrowElement);
  34143. // if arrowElement is not found, don't run the modifier
  34144. if (!arrowElement) {
  34145. return data;
  34146. }
  34147. } else {
  34148. // if the arrowElement isn't a query selector we must check that the
  34149. // provided DOM node is child of its popper node
  34150. if (!data.instance.popper.contains(arrowElement)) {
  34151. console.warn('WARNING: `arrow.element` must be child of its popper element!');
  34152. return data;
  34153. }
  34154. }
  34155. var placement = data.placement.split('-')[0];
  34156. var _data$offsets = data.offsets,
  34157. popper = _data$offsets.popper,
  34158. reference = _data$offsets.reference;
  34159. var isVertical = ['left', 'right'].indexOf(placement) !== -1;
  34160. var len = isVertical ? 'height' : 'width';
  34161. var sideCapitalized = isVertical ? 'Top' : 'Left';
  34162. var side = sideCapitalized.toLowerCase();
  34163. var altSide = isVertical ? 'left' : 'top';
  34164. var opSide = isVertical ? 'bottom' : 'right';
  34165. var arrowElementSize = getOuterSizes(arrowElement)[len];
  34166. //
  34167. // extends keepTogether behavior making sure the popper and its
  34168. // reference have enough pixels in conjunction
  34169. //
  34170. // top/left side
  34171. if (reference[opSide] - arrowElementSize < popper[side]) {
  34172. data.offsets.popper[side] -= popper[side] - (reference[opSide] - arrowElementSize);
  34173. }
  34174. // bottom/right side
  34175. if (reference[side] + arrowElementSize > popper[opSide]) {
  34176. data.offsets.popper[side] += reference[side] + arrowElementSize - popper[opSide];
  34177. }
  34178. data.offsets.popper = getClientRect(data.offsets.popper);
  34179. // compute center of the popper
  34180. var center = reference[side] + reference[len] / 2 - arrowElementSize / 2;
  34181. // Compute the sideValue using the updated popper offsets
  34182. // take popper margin in account because we don't have this info available
  34183. var css = getStyleComputedProperty(data.instance.popper);
  34184. var popperMarginSide = parseFloat(css['margin' + sideCapitalized]);
  34185. var popperBorderSide = parseFloat(css['border' + sideCapitalized + 'Width']);
  34186. var sideValue = center - data.offsets.popper[side] - popperMarginSide - popperBorderSide;
  34187. // prevent arrowElement from being placed not contiguously to its popper
  34188. sideValue = Math.max(Math.min(popper[len] - arrowElementSize, sideValue), 0);
  34189. data.arrowElement = arrowElement;
  34190. data.offsets.arrow = (_data$offsets$arrow = {}, defineProperty(_data$offsets$arrow, side, Math.round(sideValue)), defineProperty(_data$offsets$arrow, altSide, ''), _data$offsets$arrow);
  34191. return data;
  34192. }
  34193. /**
  34194. * Get the opposite placement variation of the given one
  34195. * @method
  34196. * @memberof Popper.Utils
  34197. * @argument {String} placement variation
  34198. * @returns {String} flipped placement variation
  34199. */
  34200. function getOppositeVariation(variation) {
  34201. if (variation === 'end') {
  34202. return 'start';
  34203. } else if (variation === 'start') {
  34204. return 'end';
  34205. }
  34206. return variation;
  34207. }
  34208. /**
  34209. * List of accepted placements to use as values of the `placement` option.<br />
  34210. * Valid placements are:
  34211. * - `auto`
  34212. * - `top`
  34213. * - `right`
  34214. * - `bottom`
  34215. * - `left`
  34216. *
  34217. * Each placement can have a variation from this list:
  34218. * - `-start`
  34219. * - `-end`
  34220. *
  34221. * Variations are interpreted easily if you think of them as the left to right
  34222. * written languages. Horizontally (`top` and `bottom`), `start` is left and `end`
  34223. * is right.<br />
  34224. * Vertically (`left` and `right`), `start` is top and `end` is bottom.
  34225. *
  34226. * Some valid examples are:
  34227. * - `top-end` (on top of reference, right aligned)
  34228. * - `right-start` (on right of reference, top aligned)
  34229. * - `bottom` (on bottom, centered)
  34230. * - `auto-end` (on the side with more space available, alignment depends by placement)
  34231. *
  34232. * @static
  34233. * @type {Array}
  34234. * @enum {String}
  34235. * @readonly
  34236. * @method placements
  34237. * @memberof Popper
  34238. */
  34239. 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'];
  34240. // Get rid of `auto` `auto-start` and `auto-end`
  34241. var validPlacements = placements.slice(3);
  34242. /**
  34243. * Given an initial placement, returns all the subsequent placements
  34244. * clockwise (or counter-clockwise).
  34245. *
  34246. * @method
  34247. * @memberof Popper.Utils
  34248. * @argument {String} placement - A valid placement (it accepts variations)
  34249. * @argument {Boolean} counter - Set to true to walk the placements counterclockwise
  34250. * @returns {Array} placements including their variations
  34251. */
  34252. function clockwise(placement) {
  34253. var counter = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  34254. var index = validPlacements.indexOf(placement);
  34255. var arr = validPlacements.slice(index + 1).concat(validPlacements.slice(0, index));
  34256. return counter ? arr.reverse() : arr;
  34257. }
  34258. var BEHAVIORS = {
  34259. FLIP: 'flip',
  34260. CLOCKWISE: 'clockwise',
  34261. COUNTERCLOCKWISE: 'counterclockwise'
  34262. };
  34263. /**
  34264. * @function
  34265. * @memberof Modifiers
  34266. * @argument {Object} data - The data object generated by update method
  34267. * @argument {Object} options - Modifiers configuration and options
  34268. * @returns {Object} The data object, properly modified
  34269. */
  34270. function flip(data, options) {
  34271. // if `inner` modifier is enabled, we can't use the `flip` modifier
  34272. if (isModifierEnabled(data.instance.modifiers, 'inner')) {
  34273. return data;
  34274. }
  34275. if (data.flipped && data.placement === data.originalPlacement) {
  34276. // seems like flip is trying to loop, probably there's not enough space on any of the flippable sides
  34277. return data;
  34278. }
  34279. var boundaries = getBoundaries(data.instance.popper, data.instance.reference, options.padding, options.boundariesElement, data.positionFixed);
  34280. var placement = data.placement.split('-')[0];
  34281. var placementOpposite = getOppositePlacement(placement);
  34282. var variation = data.placement.split('-')[1] || '';
  34283. var flipOrder = [];
  34284. switch (options.behavior) {
  34285. case BEHAVIORS.FLIP:
  34286. flipOrder = [placement, placementOpposite];
  34287. break;
  34288. case BEHAVIORS.CLOCKWISE:
  34289. flipOrder = clockwise(placement);
  34290. break;
  34291. case BEHAVIORS.COUNTERCLOCKWISE:
  34292. flipOrder = clockwise(placement, true);
  34293. break;
  34294. default:
  34295. flipOrder = options.behavior;
  34296. }
  34297. flipOrder.forEach(function (step, index) {
  34298. if (placement !== step || flipOrder.length === index + 1) {
  34299. return data;
  34300. }
  34301. placement = data.placement.split('-')[0];
  34302. placementOpposite = getOppositePlacement(placement);
  34303. var popperOffsets = data.offsets.popper;
  34304. var refOffsets = data.offsets.reference;
  34305. // using floor because the reference offsets may contain decimals we are not going to consider here
  34306. var floor = Math.floor;
  34307. 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);
  34308. var overflowsLeft = floor(popperOffsets.left) < floor(boundaries.left);
  34309. var overflowsRight = floor(popperOffsets.right) > floor(boundaries.right);
  34310. var overflowsTop = floor(popperOffsets.top) < floor(boundaries.top);
  34311. var overflowsBottom = floor(popperOffsets.bottom) > floor(boundaries.bottom);
  34312. var overflowsBoundaries = placement === 'left' && overflowsLeft || placement === 'right' && overflowsRight || placement === 'top' && overflowsTop || placement === 'bottom' && overflowsBottom;
  34313. // flip the variation if required
  34314. var isVertical = ['top', 'bottom'].indexOf(placement) !== -1;
  34315. // flips variation if reference element overflows boundaries
  34316. var flippedVariationByRef = !!options.flipVariations && (isVertical && variation === 'start' && overflowsLeft || isVertical && variation === 'end' && overflowsRight || !isVertical && variation === 'start' && overflowsTop || !isVertical && variation === 'end' && overflowsBottom);
  34317. // flips variation if popper content overflows boundaries
  34318. var flippedVariationByContent = !!options.flipVariationsByContent && (isVertical && variation === 'start' && overflowsRight || isVertical && variation === 'end' && overflowsLeft || !isVertical && variation === 'start' && overflowsBottom || !isVertical && variation === 'end' && overflowsTop);
  34319. var flippedVariation = flippedVariationByRef || flippedVariationByContent;
  34320. if (overlapsRef || overflowsBoundaries || flippedVariation) {
  34321. // this boolean to detect any flip loop
  34322. data.flipped = true;
  34323. if (overlapsRef || overflowsBoundaries) {
  34324. placement = flipOrder[index + 1];
  34325. }
  34326. if (flippedVariation) {
  34327. variation = getOppositeVariation(variation);
  34328. }
  34329. data.placement = placement + (variation ? '-' + variation : '');
  34330. // this object contains `position`, we want to preserve it along with
  34331. // any additional property we may add in the future
  34332. data.offsets.popper = _extends({}, data.offsets.popper, getPopperOffsets(data.instance.popper, data.offsets.reference, data.placement));
  34333. data = runModifiers(data.instance.modifiers, data, 'flip');
  34334. }
  34335. });
  34336. return data;
  34337. }
  34338. /**
  34339. * @function
  34340. * @memberof Modifiers
  34341. * @argument {Object} data - The data object generated by update method
  34342. * @argument {Object} options - Modifiers configuration and options
  34343. * @returns {Object} The data object, properly modified
  34344. */
  34345. function keepTogether(data) {
  34346. var _data$offsets = data.offsets,
  34347. popper = _data$offsets.popper,
  34348. reference = _data$offsets.reference;
  34349. var placement = data.placement.split('-')[0];
  34350. var floor = Math.floor;
  34351. var isVertical = ['top', 'bottom'].indexOf(placement) !== -1;
  34352. var side = isVertical ? 'right' : 'bottom';
  34353. var opSide = isVertical ? 'left' : 'top';
  34354. var measurement = isVertical ? 'width' : 'height';
  34355. if (popper[side] < floor(reference[opSide])) {
  34356. data.offsets.popper[opSide] = floor(reference[opSide]) - popper[measurement];
  34357. }
  34358. if (popper[opSide] > floor(reference[side])) {
  34359. data.offsets.popper[opSide] = floor(reference[side]);
  34360. }
  34361. return data;
  34362. }
  34363. /**
  34364. * Converts a string containing value + unit into a px value number
  34365. * @function
  34366. * @memberof {modifiers~offset}
  34367. * @private
  34368. * @argument {String} str - Value + unit string
  34369. * @argument {String} measurement - `height` or `width`
  34370. * @argument {Object} popperOffsets
  34371. * @argument {Object} referenceOffsets
  34372. * @returns {Number|String}
  34373. * Value in pixels, or original string if no values were extracted
  34374. */
  34375. function toValue(str, measurement, popperOffsets, referenceOffsets) {
  34376. // separate value from unit
  34377. var split = str.match(/((?:\-|\+)?\d*\.?\d*)(.*)/);
  34378. var value = +split[1];
  34379. var unit = split[2];
  34380. // If it's not a number it's an operator, I guess
  34381. if (!value) {
  34382. return str;
  34383. }
  34384. if (unit.indexOf('%') === 0) {
  34385. var element = void 0;
  34386. switch (unit) {
  34387. case '%p':
  34388. element = popperOffsets;
  34389. break;
  34390. case '%':
  34391. case '%r':
  34392. default:
  34393. element = referenceOffsets;
  34394. }
  34395. var rect = getClientRect(element);
  34396. return rect[measurement] / 100 * value;
  34397. } else if (unit === 'vh' || unit === 'vw') {
  34398. // if is a vh or vw, we calculate the size based on the viewport
  34399. var size = void 0;
  34400. if (unit === 'vh') {
  34401. size = Math.max(document.documentElement.clientHeight, window.innerHeight || 0);
  34402. } else {
  34403. size = Math.max(document.documentElement.clientWidth, window.innerWidth || 0);
  34404. }
  34405. return size / 100 * value;
  34406. } else {
  34407. // if is an explicit pixel unit, we get rid of the unit and keep the value
  34408. // if is an implicit unit, it's px, and we return just the value
  34409. return value;
  34410. }
  34411. }
  34412. /**
  34413. * Parse an `offset` string to extrapolate `x` and `y` numeric offsets.
  34414. * @function
  34415. * @memberof {modifiers~offset}
  34416. * @private
  34417. * @argument {String} offset
  34418. * @argument {Object} popperOffsets
  34419. * @argument {Object} referenceOffsets
  34420. * @argument {String} basePlacement
  34421. * @returns {Array} a two cells array with x and y offsets in numbers
  34422. */
  34423. function parseOffset(offset, popperOffsets, referenceOffsets, basePlacement) {
  34424. var offsets = [0, 0];
  34425. // Use height if placement is left or right and index is 0 otherwise use width
  34426. // in this way the first offset will use an axis and the second one
  34427. // will use the other one
  34428. var useHeight = ['right', 'left'].indexOf(basePlacement) !== -1;
  34429. // Split the offset string to obtain a list of values and operands
  34430. // The regex addresses values with the plus or minus sign in front (+10, -20, etc)
  34431. var fragments = offset.split(/(\+|\-)/).map(function (frag) {
  34432. return frag.trim();
  34433. });
  34434. // Detect if the offset string contains a pair of values or a single one
  34435. // they could be separated by comma or space
  34436. var divider = fragments.indexOf(find(fragments, function (frag) {
  34437. return frag.search(/,|\s/) !== -1;
  34438. }));
  34439. if (fragments[divider] && fragments[divider].indexOf(',') === -1) {
  34440. console.warn('Offsets separated by white space(s) are deprecated, use a comma (,) instead.');
  34441. }
  34442. // If divider is found, we divide the list of values and operands to divide
  34443. // them by ofset X and Y.
  34444. var splitRegex = /\s*,\s*|\s+/;
  34445. 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];
  34446. // Convert the values with units to absolute pixels to allow our computations
  34447. ops = ops.map(function (op, index) {
  34448. // Most of the units rely on the orientation of the popper
  34449. var measurement = (index === 1 ? !useHeight : useHeight) ? 'height' : 'width';
  34450. var mergeWithPrevious = false;
  34451. return op
  34452. // This aggregates any `+` or `-` sign that aren't considered operators
  34453. // e.g.: 10 + +5 => [10, +, +5]
  34454. .reduce(function (a, b) {
  34455. if (a[a.length - 1] === '' && ['+', '-'].indexOf(b) !== -1) {
  34456. a[a.length - 1] = b;
  34457. mergeWithPrevious = true;
  34458. return a;
  34459. } else if (mergeWithPrevious) {
  34460. a[a.length - 1] += b;
  34461. mergeWithPrevious = false;
  34462. return a;
  34463. } else {
  34464. return a.concat(b);
  34465. }
  34466. }, [])
  34467. // Here we convert the string values into number values (in px)
  34468. .map(function (str) {
  34469. return toValue(str, measurement, popperOffsets, referenceOffsets);
  34470. });
  34471. });
  34472. // Loop trough the offsets arrays and execute the operations
  34473. ops.forEach(function (op, index) {
  34474. op.forEach(function (frag, index2) {
  34475. if (isNumeric(frag)) {
  34476. offsets[index] += frag * (op[index2 - 1] === '-' ? -1 : 1);
  34477. }
  34478. });
  34479. });
  34480. return offsets;
  34481. }
  34482. /**
  34483. * @function
  34484. * @memberof Modifiers
  34485. * @argument {Object} data - The data object generated by update method
  34486. * @argument {Object} options - Modifiers configuration and options
  34487. * @argument {Number|String} options.offset=0
  34488. * The offset value as described in the modifier description
  34489. * @returns {Object} The data object, properly modified
  34490. */
  34491. function offset(data, _ref) {
  34492. var offset = _ref.offset;
  34493. var placement = data.placement,
  34494. _data$offsets = data.offsets,
  34495. popper = _data$offsets.popper,
  34496. reference = _data$offsets.reference;
  34497. var basePlacement = placement.split('-')[0];
  34498. var offsets = void 0;
  34499. if (isNumeric(+offset)) {
  34500. offsets = [+offset, 0];
  34501. } else {
  34502. offsets = parseOffset(offset, popper, reference, basePlacement);
  34503. }
  34504. if (basePlacement === 'left') {
  34505. popper.top += offsets[0];
  34506. popper.left -= offsets[1];
  34507. } else if (basePlacement === 'right') {
  34508. popper.top += offsets[0];
  34509. popper.left += offsets[1];
  34510. } else if (basePlacement === 'top') {
  34511. popper.left += offsets[0];
  34512. popper.top -= offsets[1];
  34513. } else if (basePlacement === 'bottom') {
  34514. popper.left += offsets[0];
  34515. popper.top += offsets[1];
  34516. }
  34517. data.popper = popper;
  34518. return data;
  34519. }
  34520. /**
  34521. * @function
  34522. * @memberof Modifiers
  34523. * @argument {Object} data - The data object generated by `update` method
  34524. * @argument {Object} options - Modifiers configuration and options
  34525. * @returns {Object} The data object, properly modified
  34526. */
  34527. function preventOverflow(data, options) {
  34528. var boundariesElement = options.boundariesElement || getOffsetParent(data.instance.popper);
  34529. // If offsetParent is the reference element, we really want to
  34530. // go one step up and use the next offsetParent as reference to
  34531. // avoid to make this modifier completely useless and look like broken
  34532. if (data.instance.reference === boundariesElement) {
  34533. boundariesElement = getOffsetParent(boundariesElement);
  34534. }
  34535. // NOTE: DOM access here
  34536. // resets the popper's position so that the document size can be calculated excluding
  34537. // the size of the popper element itself
  34538. var transformProp = getSupportedPropertyName('transform');
  34539. var popperStyles = data.instance.popper.style; // assignment to help minification
  34540. var top = popperStyles.top,
  34541. left = popperStyles.left,
  34542. transform = popperStyles[transformProp];
  34543. popperStyles.top = '';
  34544. popperStyles.left = '';
  34545. popperStyles[transformProp] = '';
  34546. var boundaries = getBoundaries(data.instance.popper, data.instance.reference, options.padding, boundariesElement, data.positionFixed);
  34547. // NOTE: DOM access here
  34548. // restores the original style properties after the offsets have been computed
  34549. popperStyles.top = top;
  34550. popperStyles.left = left;
  34551. popperStyles[transformProp] = transform;
  34552. options.boundaries = boundaries;
  34553. var order = options.priority;
  34554. var popper = data.offsets.popper;
  34555. var check = {
  34556. primary: function primary(placement) {
  34557. var value = popper[placement];
  34558. if (popper[placement] < boundaries[placement] && !options.escapeWithReference) {
  34559. value = Math.max(popper[placement], boundaries[placement]);
  34560. }
  34561. return defineProperty({}, placement, value);
  34562. },
  34563. secondary: function secondary(placement) {
  34564. var mainSide = placement === 'right' ? 'left' : 'top';
  34565. var value = popper[mainSide];
  34566. if (popper[placement] > boundaries[placement] && !options.escapeWithReference) {
  34567. value = Math.min(popper[mainSide], boundaries[placement] - (placement === 'right' ? popper.width : popper.height));
  34568. }
  34569. return defineProperty({}, mainSide, value);
  34570. }
  34571. };
  34572. order.forEach(function (placement) {
  34573. var side = ['left', 'top'].indexOf(placement) !== -1 ? 'primary' : 'secondary';
  34574. popper = _extends({}, popper, check[side](placement));
  34575. });
  34576. data.offsets.popper = popper;
  34577. return data;
  34578. }
  34579. /**
  34580. * @function
  34581. * @memberof Modifiers
  34582. * @argument {Object} data - The data object generated by `update` method
  34583. * @argument {Object} options - Modifiers configuration and options
  34584. * @returns {Object} The data object, properly modified
  34585. */
  34586. function shift(data) {
  34587. var placement = data.placement;
  34588. var basePlacement = placement.split('-')[0];
  34589. var shiftvariation = placement.split('-')[1];
  34590. // if shift shiftvariation is specified, run the modifier
  34591. if (shiftvariation) {
  34592. var _data$offsets = data.offsets,
  34593. reference = _data$offsets.reference,
  34594. popper = _data$offsets.popper;
  34595. var isVertical = ['bottom', 'top'].indexOf(basePlacement) !== -1;
  34596. var side = isVertical ? 'left' : 'top';
  34597. var measurement = isVertical ? 'width' : 'height';
  34598. var shiftOffsets = {
  34599. start: defineProperty({}, side, reference[side]),
  34600. end: defineProperty({}, side, reference[side] + reference[measurement] - popper[measurement])
  34601. };
  34602. data.offsets.popper = _extends({}, popper, shiftOffsets[shiftvariation]);
  34603. }
  34604. return data;
  34605. }
  34606. /**
  34607. * @function
  34608. * @memberof Modifiers
  34609. * @argument {Object} data - The data object generated by update method
  34610. * @argument {Object} options - Modifiers configuration and options
  34611. * @returns {Object} The data object, properly modified
  34612. */
  34613. function hide(data) {
  34614. if (!isModifierRequired(data.instance.modifiers, 'hide', 'preventOverflow')) {
  34615. return data;
  34616. }
  34617. var refRect = data.offsets.reference;
  34618. var bound = find(data.instance.modifiers, function (modifier) {
  34619. return modifier.name === 'preventOverflow';
  34620. }).boundaries;
  34621. if (refRect.bottom < bound.top || refRect.left > bound.right || refRect.top > bound.bottom || refRect.right < bound.left) {
  34622. // Avoid unnecessary DOM access if visibility hasn't changed
  34623. if (data.hide === true) {
  34624. return data;
  34625. }
  34626. data.hide = true;
  34627. data.attributes['x-out-of-boundaries'] = '';
  34628. } else {
  34629. // Avoid unnecessary DOM access if visibility hasn't changed
  34630. if (data.hide === false) {
  34631. return data;
  34632. }
  34633. data.hide = false;
  34634. data.attributes['x-out-of-boundaries'] = false;
  34635. }
  34636. return data;
  34637. }
  34638. /**
  34639. * @function
  34640. * @memberof Modifiers
  34641. * @argument {Object} data - The data object generated by `update` method
  34642. * @argument {Object} options - Modifiers configuration and options
  34643. * @returns {Object} The data object, properly modified
  34644. */
  34645. function inner(data) {
  34646. var placement = data.placement;
  34647. var basePlacement = placement.split('-')[0];
  34648. var _data$offsets = data.offsets,
  34649. popper = _data$offsets.popper,
  34650. reference = _data$offsets.reference;
  34651. var isHoriz = ['left', 'right'].indexOf(basePlacement) !== -1;
  34652. var subtractLength = ['top', 'left'].indexOf(basePlacement) === -1;
  34653. popper[isHoriz ? 'left' : 'top'] = reference[basePlacement] - (subtractLength ? popper[isHoriz ? 'width' : 'height'] : 0);
  34654. data.placement = getOppositePlacement(placement);
  34655. data.offsets.popper = getClientRect(popper);
  34656. return data;
  34657. }
  34658. /**
  34659. * Modifier function, each modifier can have a function of this type assigned
  34660. * to its `fn` property.<br />
  34661. * These functions will be called on each update, this means that you must
  34662. * make sure they are performant enough to avoid performance bottlenecks.
  34663. *
  34664. * @function ModifierFn
  34665. * @argument {dataObject} data - The data object generated by `update` method
  34666. * @argument {Object} options - Modifiers configuration and options
  34667. * @returns {dataObject} The data object, properly modified
  34668. */
  34669. /**
  34670. * Modifiers are plugins used to alter the behavior of your poppers.<br />
  34671. * Popper.js uses a set of 9 modifiers to provide all the basic functionalities
  34672. * needed by the library.
  34673. *
  34674. * Usually you don't want to override the `order`, `fn` and `onLoad` props.
  34675. * All the other properties are configurations that could be tweaked.
  34676. * @namespace modifiers
  34677. */
  34678. var modifiers = {
  34679. /**
  34680. * Modifier used to shift the popper on the start or end of its reference
  34681. * element.<br />
  34682. * It will read the variation of the `placement` property.<br />
  34683. * It can be one either `-end` or `-start`.
  34684. * @memberof modifiers
  34685. * @inner
  34686. */
  34687. shift: {
  34688. /** @prop {number} order=100 - Index used to define the order of execution */
  34689. order: 100,
  34690. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  34691. enabled: true,
  34692. /** @prop {ModifierFn} */
  34693. fn: shift
  34694. },
  34695. /**
  34696. * The `offset` modifier can shift your popper on both its axis.
  34697. *
  34698. * It accepts the following units:
  34699. * - `px` or unit-less, interpreted as pixels
  34700. * - `%` or `%r`, percentage relative to the length of the reference element
  34701. * - `%p`, percentage relative to the length of the popper element
  34702. * - `vw`, CSS viewport width unit
  34703. * - `vh`, CSS viewport height unit
  34704. *
  34705. * For length is intended the main axis relative to the placement of the popper.<br />
  34706. * This means that if the placement is `top` or `bottom`, the length will be the
  34707. * `width`. In case of `left` or `right`, it will be the `height`.
  34708. *
  34709. * You can provide a single value (as `Number` or `String`), or a pair of values
  34710. * as `String` divided by a comma or one (or more) white spaces.<br />
  34711. * The latter is a deprecated method because it leads to confusion and will be
  34712. * removed in v2.<br />
  34713. * Additionally, it accepts additions and subtractions between different units.
  34714. * Note that multiplications and divisions aren't supported.
  34715. *
  34716. * Valid examples are:
  34717. * ```
  34718. * 10
  34719. * '10%'
  34720. * '10, 10'
  34721. * '10%, 10'
  34722. * '10 + 10%'
  34723. * '10 - 5vh + 3%'
  34724. * '-10px + 5vh, 5px - 6%'
  34725. * ```
  34726. * > **NB**: If you desire to apply offsets to your poppers in a way that may make them overlap
  34727. * > with their reference element, unfortunately, you will have to disable the `flip` modifier.
  34728. * > You can read more on this at this [issue](https://github.com/FezVrasta/popper.js/issues/373).
  34729. *
  34730. * @memberof modifiers
  34731. * @inner
  34732. */
  34733. offset: {
  34734. /** @prop {number} order=200 - Index used to define the order of execution */
  34735. order: 200,
  34736. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  34737. enabled: true,
  34738. /** @prop {ModifierFn} */
  34739. fn: offset,
  34740. /** @prop {Number|String} offset=0
  34741. * The offset value as described in the modifier description
  34742. */
  34743. offset: 0
  34744. },
  34745. /**
  34746. * Modifier used to prevent the popper from being positioned outside the boundary.
  34747. *
  34748. * A scenario exists where the reference itself is not within the boundaries.<br />
  34749. * We can say it has "escaped the boundaries" — or just "escaped".<br />
  34750. * In this case we need to decide whether the popper should either:
  34751. *
  34752. * - detach from the reference and remain "trapped" in the boundaries, or
  34753. * - if it should ignore the boundary and "escape with its reference"
  34754. *
  34755. * When `escapeWithReference` is set to`true` and reference is completely
  34756. * outside its boundaries, the popper will overflow (or completely leave)
  34757. * the boundaries in order to remain attached to the edge of the reference.
  34758. *
  34759. * @memberof modifiers
  34760. * @inner
  34761. */
  34762. preventOverflow: {
  34763. /** @prop {number} order=300 - Index used to define the order of execution */
  34764. order: 300,
  34765. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  34766. enabled: true,
  34767. /** @prop {ModifierFn} */
  34768. fn: preventOverflow,
  34769. /**
  34770. * @prop {Array} [priority=['left','right','top','bottom']]
  34771. * Popper will try to prevent overflow following these priorities by default,
  34772. * then, it could overflow on the left and on top of the `boundariesElement`
  34773. */
  34774. priority: ['left', 'right', 'top', 'bottom'],
  34775. /**
  34776. * @prop {number} padding=5
  34777. * Amount of pixel used to define a minimum distance between the boundaries
  34778. * and the popper. This makes sure the popper always has a little padding
  34779. * between the edges of its container
  34780. */
  34781. padding: 5,
  34782. /**
  34783. * @prop {String|HTMLElement} boundariesElement='scrollParent'
  34784. * Boundaries used by the modifier. Can be `scrollParent`, `window`,
  34785. * `viewport` or any DOM element.
  34786. */
  34787. boundariesElement: 'scrollParent'
  34788. },
  34789. /**
  34790. * Modifier used to make sure the reference and its popper stay near each other
  34791. * without leaving any gap between the two. Especially useful when the arrow is
  34792. * enabled and you want to ensure that it points to its reference element.
  34793. * It cares only about the first axis. You can still have poppers with margin
  34794. * between the popper and its reference element.
  34795. * @memberof modifiers
  34796. * @inner
  34797. */
  34798. keepTogether: {
  34799. /** @prop {number} order=400 - Index used to define the order of execution */
  34800. order: 400,
  34801. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  34802. enabled: true,
  34803. /** @prop {ModifierFn} */
  34804. fn: keepTogether
  34805. },
  34806. /**
  34807. * This modifier is used to move the `arrowElement` of the popper to make
  34808. * sure it is positioned between the reference element and its popper element.
  34809. * It will read the outer size of the `arrowElement` node to detect how many
  34810. * pixels of conjunction are needed.
  34811. *
  34812. * It has no effect if no `arrowElement` is provided.
  34813. * @memberof modifiers
  34814. * @inner
  34815. */
  34816. arrow: {
  34817. /** @prop {number} order=500 - Index used to define the order of execution */
  34818. order: 500,
  34819. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  34820. enabled: true,
  34821. /** @prop {ModifierFn} */
  34822. fn: arrow,
  34823. /** @prop {String|HTMLElement} element='[x-arrow]' - Selector or node used as arrow */
  34824. element: '[x-arrow]'
  34825. },
  34826. /**
  34827. * Modifier used to flip the popper's placement when it starts to overlap its
  34828. * reference element.
  34829. *
  34830. * Requires the `preventOverflow` modifier before it in order to work.
  34831. *
  34832. * **NOTE:** this modifier will interrupt the current update cycle and will
  34833. * restart it if it detects the need to flip the placement.
  34834. * @memberof modifiers
  34835. * @inner
  34836. */
  34837. flip: {
  34838. /** @prop {number} order=600 - Index used to define the order of execution */
  34839. order: 600,
  34840. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  34841. enabled: true,
  34842. /** @prop {ModifierFn} */
  34843. fn: flip,
  34844. /**
  34845. * @prop {String|Array} behavior='flip'
  34846. * The behavior used to change the popper's placement. It can be one of
  34847. * `flip`, `clockwise`, `counterclockwise` or an array with a list of valid
  34848. * placements (with optional variations)
  34849. */
  34850. behavior: 'flip',
  34851. /**
  34852. * @prop {number} padding=5
  34853. * The popper will flip if it hits the edges of the `boundariesElement`
  34854. */
  34855. padding: 5,
  34856. /**
  34857. * @prop {String|HTMLElement} boundariesElement='viewport'
  34858. * The element which will define the boundaries of the popper position.
  34859. * The popper will never be placed outside of the defined boundaries
  34860. * (except if `keepTogether` is enabled)
  34861. */
  34862. boundariesElement: 'viewport',
  34863. /**
  34864. * @prop {Boolean} flipVariations=false
  34865. * The popper will switch placement variation between `-start` and `-end` when
  34866. * the reference element overlaps its boundaries.
  34867. *
  34868. * The original placement should have a set variation.
  34869. */
  34870. flipVariations: false,
  34871. /**
  34872. * @prop {Boolean} flipVariationsByContent=false
  34873. * The popper will switch placement variation between `-start` and `-end` when
  34874. * the popper element overlaps its reference boundaries.
  34875. *
  34876. * The original placement should have a set variation.
  34877. */
  34878. flipVariationsByContent: false
  34879. },
  34880. /**
  34881. * Modifier used to make the popper flow toward the inner of the reference element.
  34882. * By default, when this modifier is disabled, the popper will be placed outside
  34883. * the reference element.
  34884. * @memberof modifiers
  34885. * @inner
  34886. */
  34887. inner: {
  34888. /** @prop {number} order=700 - Index used to define the order of execution */
  34889. order: 700,
  34890. /** @prop {Boolean} enabled=false - Whether the modifier is enabled or not */
  34891. enabled: false,
  34892. /** @prop {ModifierFn} */
  34893. fn: inner
  34894. },
  34895. /**
  34896. * Modifier used to hide the popper when its reference element is outside of the
  34897. * popper boundaries. It will set a `x-out-of-boundaries` attribute which can
  34898. * be used to hide with a CSS selector the popper when its reference is
  34899. * out of boundaries.
  34900. *
  34901. * Requires the `preventOverflow` modifier before it in order to work.
  34902. * @memberof modifiers
  34903. * @inner
  34904. */
  34905. hide: {
  34906. /** @prop {number} order=800 - Index used to define the order of execution */
  34907. order: 800,
  34908. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  34909. enabled: true,
  34910. /** @prop {ModifierFn} */
  34911. fn: hide
  34912. },
  34913. /**
  34914. * Computes the style that will be applied to the popper element to gets
  34915. * properly positioned.
  34916. *
  34917. * Note that this modifier will not touch the DOM, it just prepares the styles
  34918. * so that `applyStyle` modifier can apply it. This separation is useful
  34919. * in case you need to replace `applyStyle` with a custom implementation.
  34920. *
  34921. * This modifier has `850` as `order` value to maintain backward compatibility
  34922. * with previous versions of Popper.js. Expect the modifiers ordering method
  34923. * to change in future major versions of the library.
  34924. *
  34925. * @memberof modifiers
  34926. * @inner
  34927. */
  34928. computeStyle: {
  34929. /** @prop {number} order=850 - Index used to define the order of execution */
  34930. order: 850,
  34931. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  34932. enabled: true,
  34933. /** @prop {ModifierFn} */
  34934. fn: computeStyle,
  34935. /**
  34936. * @prop {Boolean} gpuAcceleration=true
  34937. * If true, it uses the CSS 3D transformation to position the popper.
  34938. * Otherwise, it will use the `top` and `left` properties
  34939. */
  34940. gpuAcceleration: true,
  34941. /**
  34942. * @prop {string} [x='bottom']
  34943. * Where to anchor the X axis (`bottom` or `top`). AKA X offset origin.
  34944. * Change this if your popper should grow in a direction different from `bottom`
  34945. */
  34946. x: 'bottom',
  34947. /**
  34948. * @prop {string} [x='left']
  34949. * Where to anchor the Y axis (`left` or `right`). AKA Y offset origin.
  34950. * Change this if your popper should grow in a direction different from `right`
  34951. */
  34952. y: 'right'
  34953. },
  34954. /**
  34955. * Applies the computed styles to the popper element.
  34956. *
  34957. * All the DOM manipulations are limited to this modifier. This is useful in case
  34958. * you want to integrate Popper.js inside a framework or view library and you
  34959. * want to delegate all the DOM manipulations to it.
  34960. *
  34961. * Note that if you disable this modifier, you must make sure the popper element
  34962. * has its position set to `absolute` before Popper.js can do its work!
  34963. *
  34964. * Just disable this modifier and define your own to achieve the desired effect.
  34965. *
  34966. * @memberof modifiers
  34967. * @inner
  34968. */
  34969. applyStyle: {
  34970. /** @prop {number} order=900 - Index used to define the order of execution */
  34971. order: 900,
  34972. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  34973. enabled: true,
  34974. /** @prop {ModifierFn} */
  34975. fn: applyStyle,
  34976. /** @prop {Function} */
  34977. onLoad: applyStyleOnLoad,
  34978. /**
  34979. * @deprecated since version 1.10.0, the property moved to `computeStyle` modifier
  34980. * @prop {Boolean} gpuAcceleration=true
  34981. * If true, it uses the CSS 3D transformation to position the popper.
  34982. * Otherwise, it will use the `top` and `left` properties
  34983. */
  34984. gpuAcceleration: undefined
  34985. }
  34986. };
  34987. /**
  34988. * The `dataObject` is an object containing all the information used by Popper.js.
  34989. * This object is passed to modifiers and to the `onCreate` and `onUpdate` callbacks.
  34990. * @name dataObject
  34991. * @property {Object} data.instance The Popper.js instance
  34992. * @property {String} data.placement Placement applied to popper
  34993. * @property {String} data.originalPlacement Placement originally defined on init
  34994. * @property {Boolean} data.flipped True if popper has been flipped by flip modifier
  34995. * @property {Boolean} data.hide True if the reference element is out of boundaries, useful to know when to hide the popper
  34996. * @property {HTMLElement} data.arrowElement Node used as arrow by arrow modifier
  34997. * @property {Object} data.styles Any CSS property defined here will be applied to the popper. It expects the JavaScript nomenclature (eg. `marginBottom`)
  34998. * @property {Object} data.arrowStyles Any CSS property defined here will be applied to the popper arrow. It expects the JavaScript nomenclature (eg. `marginBottom`)
  34999. * @property {Object} data.boundaries Offsets of the popper boundaries
  35000. * @property {Object} data.offsets The measurements of popper, reference and arrow elements
  35001. * @property {Object} data.offsets.popper `top`, `left`, `width`, `height` values
  35002. * @property {Object} data.offsets.reference `top`, `left`, `width`, `height` values
  35003. * @property {Object} data.offsets.arrow] `top` and `left` offsets, only one of them will be different from 0
  35004. */
  35005. /**
  35006. * Default options provided to Popper.js constructor.<br />
  35007. * These can be overridden using the `options` argument of Popper.js.<br />
  35008. * To override an option, simply pass an object with the same
  35009. * structure of the `options` object, as the 3rd argument. For example:
  35010. * ```
  35011. * new Popper(ref, pop, {
  35012. * modifiers: {
  35013. * preventOverflow: { enabled: false }
  35014. * }
  35015. * })
  35016. * ```
  35017. * @type {Object}
  35018. * @static
  35019. * @memberof Popper
  35020. */
  35021. var Defaults = {
  35022. /**
  35023. * Popper's placement.
  35024. * @prop {Popper.placements} placement='bottom'
  35025. */
  35026. placement: 'bottom',
  35027. /**
  35028. * Set this to true if you want popper to position it self in 'fixed' mode
  35029. * @prop {Boolean} positionFixed=false
  35030. */
  35031. positionFixed: false,
  35032. /**
  35033. * Whether events (resize, scroll) are initially enabled.
  35034. * @prop {Boolean} eventsEnabled=true
  35035. */
  35036. eventsEnabled: true,
  35037. /**
  35038. * Set to true if you want to automatically remove the popper when
  35039. * you call the `destroy` method.
  35040. * @prop {Boolean} removeOnDestroy=false
  35041. */
  35042. removeOnDestroy: false,
  35043. /**
  35044. * Callback called when the popper is created.<br />
  35045. * By default, it is set to no-op.<br />
  35046. * Access Popper.js instance with `data.instance`.
  35047. * @prop {onCreate}
  35048. */
  35049. onCreate: function onCreate() {},
  35050. /**
  35051. * Callback called when the popper is updated. This callback is not called
  35052. * on the initialization/creation of the popper, but only on subsequent
  35053. * updates.<br />
  35054. * By default, it is set to no-op.<br />
  35055. * Access Popper.js instance with `data.instance`.
  35056. * @prop {onUpdate}
  35057. */
  35058. onUpdate: function onUpdate() {},
  35059. /**
  35060. * List of modifiers used to modify the offsets before they are applied to the popper.
  35061. * They provide most of the functionalities of Popper.js.
  35062. * @prop {modifiers}
  35063. */
  35064. modifiers: modifiers
  35065. };
  35066. /**
  35067. * @callback onCreate
  35068. * @param {dataObject} data
  35069. */
  35070. /**
  35071. * @callback onUpdate
  35072. * @param {dataObject} data
  35073. */
  35074. // Utils
  35075. // Methods
  35076. var Popper = function () {
  35077. /**
  35078. * Creates a new Popper.js instance.
  35079. * @class Popper
  35080. * @param {Element|referenceObject} reference - The reference element used to position the popper
  35081. * @param {Element} popper - The HTML / XML element used as the popper
  35082. * @param {Object} options - Your custom options to override the ones defined in [Defaults](#defaults)
  35083. * @return {Object} instance - The generated Popper.js instance
  35084. */
  35085. function Popper(reference, popper) {
  35086. var _this = this;
  35087. var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
  35088. classCallCheck(this, Popper);
  35089. this.scheduleUpdate = function () {
  35090. return requestAnimationFrame(_this.update);
  35091. };
  35092. // make update() debounced, so that it only runs at most once-per-tick
  35093. this.update = debounce(this.update.bind(this));
  35094. // with {} we create a new object with the options inside it
  35095. this.options = _extends({}, Popper.Defaults, options);
  35096. // init state
  35097. this.state = {
  35098. isDestroyed: false,
  35099. isCreated: false,
  35100. scrollParents: []
  35101. };
  35102. // get reference and popper elements (allow jQuery wrappers)
  35103. this.reference = reference && reference.jquery ? reference[0] : reference;
  35104. this.popper = popper && popper.jquery ? popper[0] : popper;
  35105. // Deep merge modifiers options
  35106. this.options.modifiers = {};
  35107. Object.keys(_extends({}, Popper.Defaults.modifiers, options.modifiers)).forEach(function (name) {
  35108. _this.options.modifiers[name] = _extends({}, Popper.Defaults.modifiers[name] || {}, options.modifiers ? options.modifiers[name] : {});
  35109. });
  35110. // Refactoring modifiers' list (Object => Array)
  35111. this.modifiers = Object.keys(this.options.modifiers).map(function (name) {
  35112. return _extends({
  35113. name: name
  35114. }, _this.options.modifiers[name]);
  35115. })
  35116. // sort the modifiers by order
  35117. .sort(function (a, b) {
  35118. return a.order - b.order;
  35119. });
  35120. // modifiers have the ability to execute arbitrary code when Popper.js get inited
  35121. // such code is executed in the same order of its modifier
  35122. // they could add new properties to their options configuration
  35123. // BE AWARE: don't add options to `options.modifiers.name` but to `modifierOptions`!
  35124. this.modifiers.forEach(function (modifierOptions) {
  35125. if (modifierOptions.enabled && isFunction(modifierOptions.onLoad)) {
  35126. modifierOptions.onLoad(_this.reference, _this.popper, _this.options, modifierOptions, _this.state);
  35127. }
  35128. });
  35129. // fire the first update to position the popper in the right place
  35130. this.update();
  35131. var eventsEnabled = this.options.eventsEnabled;
  35132. if (eventsEnabled) {
  35133. // setup event listeners, they will take care of update the position in specific situations
  35134. this.enableEventListeners();
  35135. }
  35136. this.state.eventsEnabled = eventsEnabled;
  35137. }
  35138. // We can't use class properties because they don't get listed in the
  35139. // class prototype and break stuff like Sinon stubs
  35140. createClass(Popper, [{
  35141. key: 'update',
  35142. value: function update$$1() {
  35143. return update.call(this);
  35144. }
  35145. }, {
  35146. key: 'destroy',
  35147. value: function destroy$$1() {
  35148. return destroy.call(this);
  35149. }
  35150. }, {
  35151. key: 'enableEventListeners',
  35152. value: function enableEventListeners$$1() {
  35153. return enableEventListeners.call(this);
  35154. }
  35155. }, {
  35156. key: 'disableEventListeners',
  35157. value: function disableEventListeners$$1() {
  35158. return disableEventListeners.call(this);
  35159. }
  35160. /**
  35161. * Schedules an update. It will run on the next UI update available.
  35162. * @method scheduleUpdate
  35163. * @memberof Popper
  35164. */
  35165. /**
  35166. * Collection of utilities useful when writing custom modifiers.
  35167. * Starting from version 1.7, this method is available only if you
  35168. * include `popper-utils.js` before `popper.js`.
  35169. *
  35170. * **DEPRECATION**: This way to access PopperUtils is deprecated
  35171. * and will be removed in v2! Use the PopperUtils module directly instead.
  35172. * Due to the high instability of the methods contained in Utils, we can't
  35173. * guarantee them to follow semver. Use them at your own risk!
  35174. * @static
  35175. * @private
  35176. * @type {Object}
  35177. * @deprecated since version 1.8
  35178. * @member Utils
  35179. * @memberof Popper
  35180. */
  35181. }]);
  35182. return Popper;
  35183. }();
  35184. /**
  35185. * The `referenceObject` is an object that provides an interface compatible with Popper.js
  35186. * and lets you use it as replacement of a real DOM node.<br />
  35187. * You can use this method to position a popper relatively to a set of coordinates
  35188. * in case you don't have a DOM node to use as reference.
  35189. *
  35190. * ```
  35191. * new Popper(referenceObject, popperNode);
  35192. * ```
  35193. *
  35194. * NB: This feature isn't supported in Internet Explorer 10.
  35195. * @name referenceObject
  35196. * @property {Function} data.getBoundingClientRect
  35197. * A function that returns a set of coordinates compatible with the native `getBoundingClientRect` method.
  35198. * @property {number} data.clientWidth
  35199. * An ES6 getter that will return the width of the virtual reference element.
  35200. * @property {number} data.clientHeight
  35201. * An ES6 getter that will return the height of the virtual reference element.
  35202. */
  35203. Popper.Utils = (typeof window !== 'undefined' ? window : global).PopperUtils;
  35204. Popper.placements = placements;
  35205. Popper.Defaults = Defaults;
  35206. /* harmony default export */ __webpack_exports__["default"] = (Popper);
  35207. //# sourceMappingURL=popper.js.map
  35208. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../../webpack/buildin/global.js */ "./node_modules/webpack/buildin/global.js")))
  35209. /***/ }),
  35210. /***/ "./node_modules/process/browser.js":
  35211. /*!*****************************************!*\
  35212. !*** ./node_modules/process/browser.js ***!
  35213. \*****************************************/
  35214. /*! no static exports found */
  35215. /***/ (function(module, exports) {
  35216. // shim for using process in browser
  35217. var process = module.exports = {};
  35218. // cached from whatever global is present so that test runners that stub it
  35219. // don't break things. But we need to wrap it in a try catch in case it is
  35220. // wrapped in strict mode code which doesn't define any globals. It's inside a
  35221. // function because try/catches deoptimize in certain engines.
  35222. var cachedSetTimeout;
  35223. var cachedClearTimeout;
  35224. function defaultSetTimout() {
  35225. throw new Error('setTimeout has not been defined');
  35226. }
  35227. function defaultClearTimeout () {
  35228. throw new Error('clearTimeout has not been defined');
  35229. }
  35230. (function () {
  35231. try {
  35232. if (typeof setTimeout === 'function') {
  35233. cachedSetTimeout = setTimeout;
  35234. } else {
  35235. cachedSetTimeout = defaultSetTimout;
  35236. }
  35237. } catch (e) {
  35238. cachedSetTimeout = defaultSetTimout;
  35239. }
  35240. try {
  35241. if (typeof clearTimeout === 'function') {
  35242. cachedClearTimeout = clearTimeout;
  35243. } else {
  35244. cachedClearTimeout = defaultClearTimeout;
  35245. }
  35246. } catch (e) {
  35247. cachedClearTimeout = defaultClearTimeout;
  35248. }
  35249. } ())
  35250. function runTimeout(fun) {
  35251. if (cachedSetTimeout === setTimeout) {
  35252. //normal enviroments in sane situations
  35253. return setTimeout(fun, 0);
  35254. }
  35255. // if setTimeout wasn't available but was latter defined
  35256. if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
  35257. cachedSetTimeout = setTimeout;
  35258. return setTimeout(fun, 0);
  35259. }
  35260. try {
  35261. // when when somebody has screwed with setTimeout but no I.E. maddness
  35262. return cachedSetTimeout(fun, 0);
  35263. } catch(e){
  35264. try {
  35265. // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
  35266. return cachedSetTimeout.call(null, fun, 0);
  35267. } catch(e){
  35268. // 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
  35269. return cachedSetTimeout.call(this, fun, 0);
  35270. }
  35271. }
  35272. }
  35273. function runClearTimeout(marker) {
  35274. if (cachedClearTimeout === clearTimeout) {
  35275. //normal enviroments in sane situations
  35276. return clearTimeout(marker);
  35277. }
  35278. // if clearTimeout wasn't available but was latter defined
  35279. if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
  35280. cachedClearTimeout = clearTimeout;
  35281. return clearTimeout(marker);
  35282. }
  35283. try {
  35284. // when when somebody has screwed with setTimeout but no I.E. maddness
  35285. return cachedClearTimeout(marker);
  35286. } catch (e){
  35287. try {
  35288. // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
  35289. return cachedClearTimeout.call(null, marker);
  35290. } catch (e){
  35291. // 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.
  35292. // Some versions of I.E. have different rules for clearTimeout vs setTimeout
  35293. return cachedClearTimeout.call(this, marker);
  35294. }
  35295. }
  35296. }
  35297. var queue = [];
  35298. var draining = false;
  35299. var currentQueue;
  35300. var queueIndex = -1;
  35301. function cleanUpNextTick() {
  35302. if (!draining || !currentQueue) {
  35303. return;
  35304. }
  35305. draining = false;
  35306. if (currentQueue.length) {
  35307. queue = currentQueue.concat(queue);
  35308. } else {
  35309. queueIndex = -1;
  35310. }
  35311. if (queue.length) {
  35312. drainQueue();
  35313. }
  35314. }
  35315. function drainQueue() {
  35316. if (draining) {
  35317. return;
  35318. }
  35319. var timeout = runTimeout(cleanUpNextTick);
  35320. draining = true;
  35321. var len = queue.length;
  35322. while(len) {
  35323. currentQueue = queue;
  35324. queue = [];
  35325. while (++queueIndex < len) {
  35326. if (currentQueue) {
  35327. currentQueue[queueIndex].run();
  35328. }
  35329. }
  35330. queueIndex = -1;
  35331. len = queue.length;
  35332. }
  35333. currentQueue = null;
  35334. draining = false;
  35335. runClearTimeout(timeout);
  35336. }
  35337. process.nextTick = function (fun) {
  35338. var args = new Array(arguments.length - 1);
  35339. if (arguments.length > 1) {
  35340. for (var i = 1; i < arguments.length; i++) {
  35341. args[i - 1] = arguments[i];
  35342. }
  35343. }
  35344. queue.push(new Item(fun, args));
  35345. if (queue.length === 1 && !draining) {
  35346. runTimeout(drainQueue);
  35347. }
  35348. };
  35349. // v8 likes predictible objects
  35350. function Item(fun, array) {
  35351. this.fun = fun;
  35352. this.array = array;
  35353. }
  35354. Item.prototype.run = function () {
  35355. this.fun.apply(null, this.array);
  35356. };
  35357. process.title = 'browser';
  35358. process.browser = true;
  35359. process.env = {};
  35360. process.argv = [];
  35361. process.version = ''; // empty string to avoid regexp issues
  35362. process.versions = {};
  35363. function noop() {}
  35364. process.on = noop;
  35365. process.addListener = noop;
  35366. process.once = noop;
  35367. process.off = noop;
  35368. process.removeListener = noop;
  35369. process.removeAllListeners = noop;
  35370. process.emit = noop;
  35371. process.prependListener = noop;
  35372. process.prependOnceListener = noop;
  35373. process.listeners = function (name) { return [] }
  35374. process.binding = function (name) {
  35375. throw new Error('process.binding is not supported');
  35376. };
  35377. process.cwd = function () { return '/' };
  35378. process.chdir = function (dir) {
  35379. throw new Error('process.chdir is not supported');
  35380. };
  35381. process.umask = function() { return 0; };
  35382. /***/ }),
  35383. /***/ "./node_modules/pusher-js/dist/web/pusher.js":
  35384. /*!***************************************************!*\
  35385. !*** ./node_modules/pusher-js/dist/web/pusher.js ***!
  35386. \***************************************************/
  35387. /*! no static exports found */
  35388. /***/ (function(module, exports, __webpack_require__) {
  35389. /* WEBPACK VAR INJECTION */(function(Buffer) {/*!
  35390. * Pusher JavaScript Library v5.0.3
  35391. * https://pusher.com/
  35392. *
  35393. * Copyright 2017, Pusher
  35394. * Released under the MIT licence.
  35395. */
  35396. (function webpackUniversalModuleDefinition(root, factory) {
  35397. if(true)
  35398. module.exports = factory();
  35399. else {}
  35400. })(window, function() {
  35401. return /******/ (function(modules) { // webpackBootstrap
  35402. /******/ // The module cache
  35403. /******/ var installedModules = {};
  35404. /******/
  35405. /******/ // The require function
  35406. /******/ function __webpack_require__(moduleId) {
  35407. /******/
  35408. /******/ // Check if module is in cache
  35409. /******/ if(installedModules[moduleId]) {
  35410. /******/ return installedModules[moduleId].exports;
  35411. /******/ }
  35412. /******/ // Create a new module (and put it into the cache)
  35413. /******/ var module = installedModules[moduleId] = {
  35414. /******/ i: moduleId,
  35415. /******/ l: false,
  35416. /******/ exports: {}
  35417. /******/ };
  35418. /******/
  35419. /******/ // Execute the module function
  35420. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  35421. /******/
  35422. /******/ // Flag the module as loaded
  35423. /******/ module.l = true;
  35424. /******/
  35425. /******/ // Return the exports of the module
  35426. /******/ return module.exports;
  35427. /******/ }
  35428. /******/
  35429. /******/
  35430. /******/ // expose the modules object (__webpack_modules__)
  35431. /******/ __webpack_require__.m = modules;
  35432. /******/
  35433. /******/ // expose the module cache
  35434. /******/ __webpack_require__.c = installedModules;
  35435. /******/
  35436. /******/ // define getter function for harmony exports
  35437. /******/ __webpack_require__.d = function(exports, name, getter) {
  35438. /******/ if(!__webpack_require__.o(exports, name)) {
  35439. /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
  35440. /******/ }
  35441. /******/ };
  35442. /******/
  35443. /******/ // define __esModule on exports
  35444. /******/ __webpack_require__.r = function(exports) {
  35445. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  35446. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  35447. /******/ }
  35448. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  35449. /******/ };
  35450. /******/
  35451. /******/ // create a fake namespace object
  35452. /******/ // mode & 1: value is a module id, require it
  35453. /******/ // mode & 2: merge all properties of value into the ns
  35454. /******/ // mode & 4: return value when already ns object
  35455. /******/ // mode & 8|1: behave like require
  35456. /******/ __webpack_require__.t = function(value, mode) {
  35457. /******/ if(mode & 1) value = __webpack_require__(value);
  35458. /******/ if(mode & 8) return value;
  35459. /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
  35460. /******/ var ns = Object.create(null);
  35461. /******/ __webpack_require__.r(ns);
  35462. /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
  35463. /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
  35464. /******/ return ns;
  35465. /******/ };
  35466. /******/
  35467. /******/ // getDefaultExport function for compatibility with non-harmony modules
  35468. /******/ __webpack_require__.n = function(module) {
  35469. /******/ var getter = module && module.__esModule ?
  35470. /******/ function getDefault() { return module['default']; } :
  35471. /******/ function getModuleExports() { return module; };
  35472. /******/ __webpack_require__.d(getter, 'a', getter);
  35473. /******/ return getter;
  35474. /******/ };
  35475. /******/
  35476. /******/ // Object.prototype.hasOwnProperty.call
  35477. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  35478. /******/
  35479. /******/ // __webpack_public_path__
  35480. /******/ __webpack_require__.p = "";
  35481. /******/
  35482. /******/
  35483. /******/ // Load entry module and return exports
  35484. /******/ return __webpack_require__(__webpack_require__.s = 2);
  35485. /******/ })
  35486. /************************************************************************/
  35487. /******/ ([
  35488. /* 0 */
  35489. /***/ (function(module, exports, __webpack_require__) {
  35490. (function(nacl) {
  35491. 'use strict';
  35492. // Ported in 2014 by Dmitry Chestnykh and Devi Mandiri.
  35493. // Public domain.
  35494. //
  35495. // Implementation derived from TweetNaCl version 20140427.
  35496. // See for details: http://tweetnacl.cr.yp.to/
  35497. var gf = function(init) {
  35498. var i, r = new Float64Array(16);
  35499. if (init) for (i = 0; i < init.length; i++) r[i] = init[i];
  35500. return r;
  35501. };
  35502. // Pluggable, initialized in high-level API below.
  35503. var randombytes = function(/* x, n */) { throw new Error('no PRNG'); };
  35504. var _0 = new Uint8Array(16);
  35505. var _9 = new Uint8Array(32); _9[0] = 9;
  35506. var gf0 = gf(),
  35507. gf1 = gf([1]),
  35508. _121665 = gf([0xdb41, 1]),
  35509. D = gf([0x78a3, 0x1359, 0x4dca, 0x75eb, 0xd8ab, 0x4141, 0x0a4d, 0x0070, 0xe898, 0x7779, 0x4079, 0x8cc7, 0xfe73, 0x2b6f, 0x6cee, 0x5203]),
  35510. D2 = gf([0xf159, 0x26b2, 0x9b94, 0xebd6, 0xb156, 0x8283, 0x149a, 0x00e0, 0xd130, 0xeef3, 0x80f2, 0x198e, 0xfce7, 0x56df, 0xd9dc, 0x2406]),
  35511. X = gf([0xd51a, 0x8f25, 0x2d60, 0xc956, 0xa7b2, 0x9525, 0xc760, 0x692c, 0xdc5c, 0xfdd6, 0xe231, 0xc0a4, 0x53fe, 0xcd6e, 0x36d3, 0x2169]),
  35512. Y = gf([0x6658, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666]),
  35513. I = gf([0xa0b0, 0x4a0e, 0x1b27, 0xc4ee, 0xe478, 0xad2f, 0x1806, 0x2f43, 0xd7a7, 0x3dfb, 0x0099, 0x2b4d, 0xdf0b, 0x4fc1, 0x2480, 0x2b83]);
  35514. function ts64(x, i, h, l) {
  35515. x[i] = (h >> 24) & 0xff;
  35516. x[i+1] = (h >> 16) & 0xff;
  35517. x[i+2] = (h >> 8) & 0xff;
  35518. x[i+3] = h & 0xff;
  35519. x[i+4] = (l >> 24) & 0xff;
  35520. x[i+5] = (l >> 16) & 0xff;
  35521. x[i+6] = (l >> 8) & 0xff;
  35522. x[i+7] = l & 0xff;
  35523. }
  35524. function vn(x, xi, y, yi, n) {
  35525. var i,d = 0;
  35526. for (i = 0; i < n; i++) d |= x[xi+i]^y[yi+i];
  35527. return (1 & ((d - 1) >>> 8)) - 1;
  35528. }
  35529. function crypto_verify_16(x, xi, y, yi) {
  35530. return vn(x,xi,y,yi,16);
  35531. }
  35532. function crypto_verify_32(x, xi, y, yi) {
  35533. return vn(x,xi,y,yi,32);
  35534. }
  35535. function core_salsa20(o, p, k, c) {
  35536. var j0 = c[ 0] & 0xff | (c[ 1] & 0xff)<<8 | (c[ 2] & 0xff)<<16 | (c[ 3] & 0xff)<<24,
  35537. j1 = k[ 0] & 0xff | (k[ 1] & 0xff)<<8 | (k[ 2] & 0xff)<<16 | (k[ 3] & 0xff)<<24,
  35538. j2 = k[ 4] & 0xff | (k[ 5] & 0xff)<<8 | (k[ 6] & 0xff)<<16 | (k[ 7] & 0xff)<<24,
  35539. j3 = k[ 8] & 0xff | (k[ 9] & 0xff)<<8 | (k[10] & 0xff)<<16 | (k[11] & 0xff)<<24,
  35540. j4 = k[12] & 0xff | (k[13] & 0xff)<<8 | (k[14] & 0xff)<<16 | (k[15] & 0xff)<<24,
  35541. j5 = c[ 4] & 0xff | (c[ 5] & 0xff)<<8 | (c[ 6] & 0xff)<<16 | (c[ 7] & 0xff)<<24,
  35542. j6 = p[ 0] & 0xff | (p[ 1] & 0xff)<<8 | (p[ 2] & 0xff)<<16 | (p[ 3] & 0xff)<<24,
  35543. j7 = p[ 4] & 0xff | (p[ 5] & 0xff)<<8 | (p[ 6] & 0xff)<<16 | (p[ 7] & 0xff)<<24,
  35544. j8 = p[ 8] & 0xff | (p[ 9] & 0xff)<<8 | (p[10] & 0xff)<<16 | (p[11] & 0xff)<<24,
  35545. j9 = p[12] & 0xff | (p[13] & 0xff)<<8 | (p[14] & 0xff)<<16 | (p[15] & 0xff)<<24,
  35546. j10 = c[ 8] & 0xff | (c[ 9] & 0xff)<<8 | (c[10] & 0xff)<<16 | (c[11] & 0xff)<<24,
  35547. j11 = k[16] & 0xff | (k[17] & 0xff)<<8 | (k[18] & 0xff)<<16 | (k[19] & 0xff)<<24,
  35548. j12 = k[20] & 0xff | (k[21] & 0xff)<<8 | (k[22] & 0xff)<<16 | (k[23] & 0xff)<<24,
  35549. j13 = k[24] & 0xff | (k[25] & 0xff)<<8 | (k[26] & 0xff)<<16 | (k[27] & 0xff)<<24,
  35550. j14 = k[28] & 0xff | (k[29] & 0xff)<<8 | (k[30] & 0xff)<<16 | (k[31] & 0xff)<<24,
  35551. j15 = c[12] & 0xff | (c[13] & 0xff)<<8 | (c[14] & 0xff)<<16 | (c[15] & 0xff)<<24;
  35552. var x0 = j0, x1 = j1, x2 = j2, x3 = j3, x4 = j4, x5 = j5, x6 = j6, x7 = j7,
  35553. x8 = j8, x9 = j9, x10 = j10, x11 = j11, x12 = j12, x13 = j13, x14 = j14,
  35554. x15 = j15, u;
  35555. for (var i = 0; i < 20; i += 2) {
  35556. u = x0 + x12 | 0;
  35557. x4 ^= u<<7 | u>>>(32-7);
  35558. u = x4 + x0 | 0;
  35559. x8 ^= u<<9 | u>>>(32-9);
  35560. u = x8 + x4 | 0;
  35561. x12 ^= u<<13 | u>>>(32-13);
  35562. u = x12 + x8 | 0;
  35563. x0 ^= u<<18 | u>>>(32-18);
  35564. u = x5 + x1 | 0;
  35565. x9 ^= u<<7 | u>>>(32-7);
  35566. u = x9 + x5 | 0;
  35567. x13 ^= u<<9 | u>>>(32-9);
  35568. u = x13 + x9 | 0;
  35569. x1 ^= u<<13 | u>>>(32-13);
  35570. u = x1 + x13 | 0;
  35571. x5 ^= u<<18 | u>>>(32-18);
  35572. u = x10 + x6 | 0;
  35573. x14 ^= u<<7 | u>>>(32-7);
  35574. u = x14 + x10 | 0;
  35575. x2 ^= u<<9 | u>>>(32-9);
  35576. u = x2 + x14 | 0;
  35577. x6 ^= u<<13 | u>>>(32-13);
  35578. u = x6 + x2 | 0;
  35579. x10 ^= u<<18 | u>>>(32-18);
  35580. u = x15 + x11 | 0;
  35581. x3 ^= u<<7 | u>>>(32-7);
  35582. u = x3 + x15 | 0;
  35583. x7 ^= u<<9 | u>>>(32-9);
  35584. u = x7 + x3 | 0;
  35585. x11 ^= u<<13 | u>>>(32-13);
  35586. u = x11 + x7 | 0;
  35587. x15 ^= u<<18 | u>>>(32-18);
  35588. u = x0 + x3 | 0;
  35589. x1 ^= u<<7 | u>>>(32-7);
  35590. u = x1 + x0 | 0;
  35591. x2 ^= u<<9 | u>>>(32-9);
  35592. u = x2 + x1 | 0;
  35593. x3 ^= u<<13 | u>>>(32-13);
  35594. u = x3 + x2 | 0;
  35595. x0 ^= u<<18 | u>>>(32-18);
  35596. u = x5 + x4 | 0;
  35597. x6 ^= u<<7 | u>>>(32-7);
  35598. u = x6 + x5 | 0;
  35599. x7 ^= u<<9 | u>>>(32-9);
  35600. u = x7 + x6 | 0;
  35601. x4 ^= u<<13 | u>>>(32-13);
  35602. u = x4 + x7 | 0;
  35603. x5 ^= u<<18 | u>>>(32-18);
  35604. u = x10 + x9 | 0;
  35605. x11 ^= u<<7 | u>>>(32-7);
  35606. u = x11 + x10 | 0;
  35607. x8 ^= u<<9 | u>>>(32-9);
  35608. u = x8 + x11 | 0;
  35609. x9 ^= u<<13 | u>>>(32-13);
  35610. u = x9 + x8 | 0;
  35611. x10 ^= u<<18 | u>>>(32-18);
  35612. u = x15 + x14 | 0;
  35613. x12 ^= u<<7 | u>>>(32-7);
  35614. u = x12 + x15 | 0;
  35615. x13 ^= u<<9 | u>>>(32-9);
  35616. u = x13 + x12 | 0;
  35617. x14 ^= u<<13 | u>>>(32-13);
  35618. u = x14 + x13 | 0;
  35619. x15 ^= u<<18 | u>>>(32-18);
  35620. }
  35621. x0 = x0 + j0 | 0;
  35622. x1 = x1 + j1 | 0;
  35623. x2 = x2 + j2 | 0;
  35624. x3 = x3 + j3 | 0;
  35625. x4 = x4 + j4 | 0;
  35626. x5 = x5 + j5 | 0;
  35627. x6 = x6 + j6 | 0;
  35628. x7 = x7 + j7 | 0;
  35629. x8 = x8 + j8 | 0;
  35630. x9 = x9 + j9 | 0;
  35631. x10 = x10 + j10 | 0;
  35632. x11 = x11 + j11 | 0;
  35633. x12 = x12 + j12 | 0;
  35634. x13 = x13 + j13 | 0;
  35635. x14 = x14 + j14 | 0;
  35636. x15 = x15 + j15 | 0;
  35637. o[ 0] = x0 >>> 0 & 0xff;
  35638. o[ 1] = x0 >>> 8 & 0xff;
  35639. o[ 2] = x0 >>> 16 & 0xff;
  35640. o[ 3] = x0 >>> 24 & 0xff;
  35641. o[ 4] = x1 >>> 0 & 0xff;
  35642. o[ 5] = x1 >>> 8 & 0xff;
  35643. o[ 6] = x1 >>> 16 & 0xff;
  35644. o[ 7] = x1 >>> 24 & 0xff;
  35645. o[ 8] = x2 >>> 0 & 0xff;
  35646. o[ 9] = x2 >>> 8 & 0xff;
  35647. o[10] = x2 >>> 16 & 0xff;
  35648. o[11] = x2 >>> 24 & 0xff;
  35649. o[12] = x3 >>> 0 & 0xff;
  35650. o[13] = x3 >>> 8 & 0xff;
  35651. o[14] = x3 >>> 16 & 0xff;
  35652. o[15] = x3 >>> 24 & 0xff;
  35653. o[16] = x4 >>> 0 & 0xff;
  35654. o[17] = x4 >>> 8 & 0xff;
  35655. o[18] = x4 >>> 16 & 0xff;
  35656. o[19] = x4 >>> 24 & 0xff;
  35657. o[20] = x5 >>> 0 & 0xff;
  35658. o[21] = x5 >>> 8 & 0xff;
  35659. o[22] = x5 >>> 16 & 0xff;
  35660. o[23] = x5 >>> 24 & 0xff;
  35661. o[24] = x6 >>> 0 & 0xff;
  35662. o[25] = x6 >>> 8 & 0xff;
  35663. o[26] = x6 >>> 16 & 0xff;
  35664. o[27] = x6 >>> 24 & 0xff;
  35665. o[28] = x7 >>> 0 & 0xff;
  35666. o[29] = x7 >>> 8 & 0xff;
  35667. o[30] = x7 >>> 16 & 0xff;
  35668. o[31] = x7 >>> 24 & 0xff;
  35669. o[32] = x8 >>> 0 & 0xff;
  35670. o[33] = x8 >>> 8 & 0xff;
  35671. o[34] = x8 >>> 16 & 0xff;
  35672. o[35] = x8 >>> 24 & 0xff;
  35673. o[36] = x9 >>> 0 & 0xff;
  35674. o[37] = x9 >>> 8 & 0xff;
  35675. o[38] = x9 >>> 16 & 0xff;
  35676. o[39] = x9 >>> 24 & 0xff;
  35677. o[40] = x10 >>> 0 & 0xff;
  35678. o[41] = x10 >>> 8 & 0xff;
  35679. o[42] = x10 >>> 16 & 0xff;
  35680. o[43] = x10 >>> 24 & 0xff;
  35681. o[44] = x11 >>> 0 & 0xff;
  35682. o[45] = x11 >>> 8 & 0xff;
  35683. o[46] = x11 >>> 16 & 0xff;
  35684. o[47] = x11 >>> 24 & 0xff;
  35685. o[48] = x12 >>> 0 & 0xff;
  35686. o[49] = x12 >>> 8 & 0xff;
  35687. o[50] = x12 >>> 16 & 0xff;
  35688. o[51] = x12 >>> 24 & 0xff;
  35689. o[52] = x13 >>> 0 & 0xff;
  35690. o[53] = x13 >>> 8 & 0xff;
  35691. o[54] = x13 >>> 16 & 0xff;
  35692. o[55] = x13 >>> 24 & 0xff;
  35693. o[56] = x14 >>> 0 & 0xff;
  35694. o[57] = x14 >>> 8 & 0xff;
  35695. o[58] = x14 >>> 16 & 0xff;
  35696. o[59] = x14 >>> 24 & 0xff;
  35697. o[60] = x15 >>> 0 & 0xff;
  35698. o[61] = x15 >>> 8 & 0xff;
  35699. o[62] = x15 >>> 16 & 0xff;
  35700. o[63] = x15 >>> 24 & 0xff;
  35701. }
  35702. function core_hsalsa20(o,p,k,c) {
  35703. var j0 = c[ 0] & 0xff | (c[ 1] & 0xff)<<8 | (c[ 2] & 0xff)<<16 | (c[ 3] & 0xff)<<24,
  35704. j1 = k[ 0] & 0xff | (k[ 1] & 0xff)<<8 | (k[ 2] & 0xff)<<16 | (k[ 3] & 0xff)<<24,
  35705. j2 = k[ 4] & 0xff | (k[ 5] & 0xff)<<8 | (k[ 6] & 0xff)<<16 | (k[ 7] & 0xff)<<24,
  35706. j3 = k[ 8] & 0xff | (k[ 9] & 0xff)<<8 | (k[10] & 0xff)<<16 | (k[11] & 0xff)<<24,
  35707. j4 = k[12] & 0xff | (k[13] & 0xff)<<8 | (k[14] & 0xff)<<16 | (k[15] & 0xff)<<24,
  35708. j5 = c[ 4] & 0xff | (c[ 5] & 0xff)<<8 | (c[ 6] & 0xff)<<16 | (c[ 7] & 0xff)<<24,
  35709. j6 = p[ 0] & 0xff | (p[ 1] & 0xff)<<8 | (p[ 2] & 0xff)<<16 | (p[ 3] & 0xff)<<24,
  35710. j7 = p[ 4] & 0xff | (p[ 5] & 0xff)<<8 | (p[ 6] & 0xff)<<16 | (p[ 7] & 0xff)<<24,
  35711. j8 = p[ 8] & 0xff | (p[ 9] & 0xff)<<8 | (p[10] & 0xff)<<16 | (p[11] & 0xff)<<24,
  35712. j9 = p[12] & 0xff | (p[13] & 0xff)<<8 | (p[14] & 0xff)<<16 | (p[15] & 0xff)<<24,
  35713. j10 = c[ 8] & 0xff | (c[ 9] & 0xff)<<8 | (c[10] & 0xff)<<16 | (c[11] & 0xff)<<24,
  35714. j11 = k[16] & 0xff | (k[17] & 0xff)<<8 | (k[18] & 0xff)<<16 | (k[19] & 0xff)<<24,
  35715. j12 = k[20] & 0xff | (k[21] & 0xff)<<8 | (k[22] & 0xff)<<16 | (k[23] & 0xff)<<24,
  35716. j13 = k[24] & 0xff | (k[25] & 0xff)<<8 | (k[26] & 0xff)<<16 | (k[27] & 0xff)<<24,
  35717. j14 = k[28] & 0xff | (k[29] & 0xff)<<8 | (k[30] & 0xff)<<16 | (k[31] & 0xff)<<24,
  35718. j15 = c[12] & 0xff | (c[13] & 0xff)<<8 | (c[14] & 0xff)<<16 | (c[15] & 0xff)<<24;
  35719. var x0 = j0, x1 = j1, x2 = j2, x3 = j3, x4 = j4, x5 = j5, x6 = j6, x7 = j7,
  35720. x8 = j8, x9 = j9, x10 = j10, x11 = j11, x12 = j12, x13 = j13, x14 = j14,
  35721. x15 = j15, u;
  35722. for (var i = 0; i < 20; i += 2) {
  35723. u = x0 + x12 | 0;
  35724. x4 ^= u<<7 | u>>>(32-7);
  35725. u = x4 + x0 | 0;
  35726. x8 ^= u<<9 | u>>>(32-9);
  35727. u = x8 + x4 | 0;
  35728. x12 ^= u<<13 | u>>>(32-13);
  35729. u = x12 + x8 | 0;
  35730. x0 ^= u<<18 | u>>>(32-18);
  35731. u = x5 + x1 | 0;
  35732. x9 ^= u<<7 | u>>>(32-7);
  35733. u = x9 + x5 | 0;
  35734. x13 ^= u<<9 | u>>>(32-9);
  35735. u = x13 + x9 | 0;
  35736. x1 ^= u<<13 | u>>>(32-13);
  35737. u = x1 + x13 | 0;
  35738. x5 ^= u<<18 | u>>>(32-18);
  35739. u = x10 + x6 | 0;
  35740. x14 ^= u<<7 | u>>>(32-7);
  35741. u = x14 + x10 | 0;
  35742. x2 ^= u<<9 | u>>>(32-9);
  35743. u = x2 + x14 | 0;
  35744. x6 ^= u<<13 | u>>>(32-13);
  35745. u = x6 + x2 | 0;
  35746. x10 ^= u<<18 | u>>>(32-18);
  35747. u = x15 + x11 | 0;
  35748. x3 ^= u<<7 | u>>>(32-7);
  35749. u = x3 + x15 | 0;
  35750. x7 ^= u<<9 | u>>>(32-9);
  35751. u = x7 + x3 | 0;
  35752. x11 ^= u<<13 | u>>>(32-13);
  35753. u = x11 + x7 | 0;
  35754. x15 ^= u<<18 | u>>>(32-18);
  35755. u = x0 + x3 | 0;
  35756. x1 ^= u<<7 | u>>>(32-7);
  35757. u = x1 + x0 | 0;
  35758. x2 ^= u<<9 | u>>>(32-9);
  35759. u = x2 + x1 | 0;
  35760. x3 ^= u<<13 | u>>>(32-13);
  35761. u = x3 + x2 | 0;
  35762. x0 ^= u<<18 | u>>>(32-18);
  35763. u = x5 + x4 | 0;
  35764. x6 ^= u<<7 | u>>>(32-7);
  35765. u = x6 + x5 | 0;
  35766. x7 ^= u<<9 | u>>>(32-9);
  35767. u = x7 + x6 | 0;
  35768. x4 ^= u<<13 | u>>>(32-13);
  35769. u = x4 + x7 | 0;
  35770. x5 ^= u<<18 | u>>>(32-18);
  35771. u = x10 + x9 | 0;
  35772. x11 ^= u<<7 | u>>>(32-7);
  35773. u = x11 + x10 | 0;
  35774. x8 ^= u<<9 | u>>>(32-9);
  35775. u = x8 + x11 | 0;
  35776. x9 ^= u<<13 | u>>>(32-13);
  35777. u = x9 + x8 | 0;
  35778. x10 ^= u<<18 | u>>>(32-18);
  35779. u = x15 + x14 | 0;
  35780. x12 ^= u<<7 | u>>>(32-7);
  35781. u = x12 + x15 | 0;
  35782. x13 ^= u<<9 | u>>>(32-9);
  35783. u = x13 + x12 | 0;
  35784. x14 ^= u<<13 | u>>>(32-13);
  35785. u = x14 + x13 | 0;
  35786. x15 ^= u<<18 | u>>>(32-18);
  35787. }
  35788. o[ 0] = x0 >>> 0 & 0xff;
  35789. o[ 1] = x0 >>> 8 & 0xff;
  35790. o[ 2] = x0 >>> 16 & 0xff;
  35791. o[ 3] = x0 >>> 24 & 0xff;
  35792. o[ 4] = x5 >>> 0 & 0xff;
  35793. o[ 5] = x5 >>> 8 & 0xff;
  35794. o[ 6] = x5 >>> 16 & 0xff;
  35795. o[ 7] = x5 >>> 24 & 0xff;
  35796. o[ 8] = x10 >>> 0 & 0xff;
  35797. o[ 9] = x10 >>> 8 & 0xff;
  35798. o[10] = x10 >>> 16 & 0xff;
  35799. o[11] = x10 >>> 24 & 0xff;
  35800. o[12] = x15 >>> 0 & 0xff;
  35801. o[13] = x15 >>> 8 & 0xff;
  35802. o[14] = x15 >>> 16 & 0xff;
  35803. o[15] = x15 >>> 24 & 0xff;
  35804. o[16] = x6 >>> 0 & 0xff;
  35805. o[17] = x6 >>> 8 & 0xff;
  35806. o[18] = x6 >>> 16 & 0xff;
  35807. o[19] = x6 >>> 24 & 0xff;
  35808. o[20] = x7 >>> 0 & 0xff;
  35809. o[21] = x7 >>> 8 & 0xff;
  35810. o[22] = x7 >>> 16 & 0xff;
  35811. o[23] = x7 >>> 24 & 0xff;
  35812. o[24] = x8 >>> 0 & 0xff;
  35813. o[25] = x8 >>> 8 & 0xff;
  35814. o[26] = x8 >>> 16 & 0xff;
  35815. o[27] = x8 >>> 24 & 0xff;
  35816. o[28] = x9 >>> 0 & 0xff;
  35817. o[29] = x9 >>> 8 & 0xff;
  35818. o[30] = x9 >>> 16 & 0xff;
  35819. o[31] = x9 >>> 24 & 0xff;
  35820. }
  35821. function crypto_core_salsa20(out,inp,k,c) {
  35822. core_salsa20(out,inp,k,c);
  35823. }
  35824. function crypto_core_hsalsa20(out,inp,k,c) {
  35825. core_hsalsa20(out,inp,k,c);
  35826. }
  35827. var sigma = new Uint8Array([101, 120, 112, 97, 110, 100, 32, 51, 50, 45, 98, 121, 116, 101, 32, 107]);
  35828. // "expand 32-byte k"
  35829. function crypto_stream_salsa20_xor(c,cpos,m,mpos,b,n,k) {
  35830. var z = new Uint8Array(16), x = new Uint8Array(64);
  35831. var u, i;
  35832. for (i = 0; i < 16; i++) z[i] = 0;
  35833. for (i = 0; i < 8; i++) z[i] = n[i];
  35834. while (b >= 64) {
  35835. crypto_core_salsa20(x,z,k,sigma);
  35836. for (i = 0; i < 64; i++) c[cpos+i] = m[mpos+i] ^ x[i];
  35837. u = 1;
  35838. for (i = 8; i < 16; i++) {
  35839. u = u + (z[i] & 0xff) | 0;
  35840. z[i] = u & 0xff;
  35841. u >>>= 8;
  35842. }
  35843. b -= 64;
  35844. cpos += 64;
  35845. mpos += 64;
  35846. }
  35847. if (b > 0) {
  35848. crypto_core_salsa20(x,z,k,sigma);
  35849. for (i = 0; i < b; i++) c[cpos+i] = m[mpos+i] ^ x[i];
  35850. }
  35851. return 0;
  35852. }
  35853. function crypto_stream_salsa20(c,cpos,b,n,k) {
  35854. var z = new Uint8Array(16), x = new Uint8Array(64);
  35855. var u, i;
  35856. for (i = 0; i < 16; i++) z[i] = 0;
  35857. for (i = 0; i < 8; i++) z[i] = n[i];
  35858. while (b >= 64) {
  35859. crypto_core_salsa20(x,z,k,sigma);
  35860. for (i = 0; i < 64; i++) c[cpos+i] = x[i];
  35861. u = 1;
  35862. for (i = 8; i < 16; i++) {
  35863. u = u + (z[i] & 0xff) | 0;
  35864. z[i] = u & 0xff;
  35865. u >>>= 8;
  35866. }
  35867. b -= 64;
  35868. cpos += 64;
  35869. }
  35870. if (b > 0) {
  35871. crypto_core_salsa20(x,z,k,sigma);
  35872. for (i = 0; i < b; i++) c[cpos+i] = x[i];
  35873. }
  35874. return 0;
  35875. }
  35876. function crypto_stream(c,cpos,d,n,k) {
  35877. var s = new Uint8Array(32);
  35878. crypto_core_hsalsa20(s,n,k,sigma);
  35879. var sn = new Uint8Array(8);
  35880. for (var i = 0; i < 8; i++) sn[i] = n[i+16];
  35881. return crypto_stream_salsa20(c,cpos,d,sn,s);
  35882. }
  35883. function crypto_stream_xor(c,cpos,m,mpos,d,n,k) {
  35884. var s = new Uint8Array(32);
  35885. crypto_core_hsalsa20(s,n,k,sigma);
  35886. var sn = new Uint8Array(8);
  35887. for (var i = 0; i < 8; i++) sn[i] = n[i+16];
  35888. return crypto_stream_salsa20_xor(c,cpos,m,mpos,d,sn,s);
  35889. }
  35890. /*
  35891. * Port of Andrew Moon's Poly1305-donna-16. Public domain.
  35892. * https://github.com/floodyberry/poly1305-donna
  35893. */
  35894. var poly1305 = function(key) {
  35895. this.buffer = new Uint8Array(16);
  35896. this.r = new Uint16Array(10);
  35897. this.h = new Uint16Array(10);
  35898. this.pad = new Uint16Array(8);
  35899. this.leftover = 0;
  35900. this.fin = 0;
  35901. var t0, t1, t2, t3, t4, t5, t6, t7;
  35902. t0 = key[ 0] & 0xff | (key[ 1] & 0xff) << 8; this.r[0] = ( t0 ) & 0x1fff;
  35903. t1 = key[ 2] & 0xff | (key[ 3] & 0xff) << 8; this.r[1] = ((t0 >>> 13) | (t1 << 3)) & 0x1fff;
  35904. t2 = key[ 4] & 0xff | (key[ 5] & 0xff) << 8; this.r[2] = ((t1 >>> 10) | (t2 << 6)) & 0x1f03;
  35905. t3 = key[ 6] & 0xff | (key[ 7] & 0xff) << 8; this.r[3] = ((t2 >>> 7) | (t3 << 9)) & 0x1fff;
  35906. t4 = key[ 8] & 0xff | (key[ 9] & 0xff) << 8; this.r[4] = ((t3 >>> 4) | (t4 << 12)) & 0x00ff;
  35907. this.r[5] = ((t4 >>> 1)) & 0x1ffe;
  35908. t5 = key[10] & 0xff | (key[11] & 0xff) << 8; this.r[6] = ((t4 >>> 14) | (t5 << 2)) & 0x1fff;
  35909. t6 = key[12] & 0xff | (key[13] & 0xff) << 8; this.r[7] = ((t5 >>> 11) | (t6 << 5)) & 0x1f81;
  35910. t7 = key[14] & 0xff | (key[15] & 0xff) << 8; this.r[8] = ((t6 >>> 8) | (t7 << 8)) & 0x1fff;
  35911. this.r[9] = ((t7 >>> 5)) & 0x007f;
  35912. this.pad[0] = key[16] & 0xff | (key[17] & 0xff) << 8;
  35913. this.pad[1] = key[18] & 0xff | (key[19] & 0xff) << 8;
  35914. this.pad[2] = key[20] & 0xff | (key[21] & 0xff) << 8;
  35915. this.pad[3] = key[22] & 0xff | (key[23] & 0xff) << 8;
  35916. this.pad[4] = key[24] & 0xff | (key[25] & 0xff) << 8;
  35917. this.pad[5] = key[26] & 0xff | (key[27] & 0xff) << 8;
  35918. this.pad[6] = key[28] & 0xff | (key[29] & 0xff) << 8;
  35919. this.pad[7] = key[30] & 0xff | (key[31] & 0xff) << 8;
  35920. };
  35921. poly1305.prototype.blocks = function(m, mpos, bytes) {
  35922. var hibit = this.fin ? 0 : (1 << 11);
  35923. var t0, t1, t2, t3, t4, t5, t6, t7, c;
  35924. var d0, d1, d2, d3, d4, d5, d6, d7, d8, d9;
  35925. var h0 = this.h[0],
  35926. h1 = this.h[1],
  35927. h2 = this.h[2],
  35928. h3 = this.h[3],
  35929. h4 = this.h[4],
  35930. h5 = this.h[5],
  35931. h6 = this.h[6],
  35932. h7 = this.h[7],
  35933. h8 = this.h[8],
  35934. h9 = this.h[9];
  35935. var r0 = this.r[0],
  35936. r1 = this.r[1],
  35937. r2 = this.r[2],
  35938. r3 = this.r[3],
  35939. r4 = this.r[4],
  35940. r5 = this.r[5],
  35941. r6 = this.r[6],
  35942. r7 = this.r[7],
  35943. r8 = this.r[8],
  35944. r9 = this.r[9];
  35945. while (bytes >= 16) {
  35946. t0 = m[mpos+ 0] & 0xff | (m[mpos+ 1] & 0xff) << 8; h0 += ( t0 ) & 0x1fff;
  35947. t1 = m[mpos+ 2] & 0xff | (m[mpos+ 3] & 0xff) << 8; h1 += ((t0 >>> 13) | (t1 << 3)) & 0x1fff;
  35948. t2 = m[mpos+ 4] & 0xff | (m[mpos+ 5] & 0xff) << 8; h2 += ((t1 >>> 10) | (t2 << 6)) & 0x1fff;
  35949. t3 = m[mpos+ 6] & 0xff | (m[mpos+ 7] & 0xff) << 8; h3 += ((t2 >>> 7) | (t3 << 9)) & 0x1fff;
  35950. t4 = m[mpos+ 8] & 0xff | (m[mpos+ 9] & 0xff) << 8; h4 += ((t3 >>> 4) | (t4 << 12)) & 0x1fff;
  35951. h5 += ((t4 >>> 1)) & 0x1fff;
  35952. t5 = m[mpos+10] & 0xff | (m[mpos+11] & 0xff) << 8; h6 += ((t4 >>> 14) | (t5 << 2)) & 0x1fff;
  35953. t6 = m[mpos+12] & 0xff | (m[mpos+13] & 0xff) << 8; h7 += ((t5 >>> 11) | (t6 << 5)) & 0x1fff;
  35954. t7 = m[mpos+14] & 0xff | (m[mpos+15] & 0xff) << 8; h8 += ((t6 >>> 8) | (t7 << 8)) & 0x1fff;
  35955. h9 += ((t7 >>> 5)) | hibit;
  35956. c = 0;
  35957. d0 = c;
  35958. d0 += h0 * r0;
  35959. d0 += h1 * (5 * r9);
  35960. d0 += h2 * (5 * r8);
  35961. d0 += h3 * (5 * r7);
  35962. d0 += h4 * (5 * r6);
  35963. c = (d0 >>> 13); d0 &= 0x1fff;
  35964. d0 += h5 * (5 * r5);
  35965. d0 += h6 * (5 * r4);
  35966. d0 += h7 * (5 * r3);
  35967. d0 += h8 * (5 * r2);
  35968. d0 += h9 * (5 * r1);
  35969. c += (d0 >>> 13); d0 &= 0x1fff;
  35970. d1 = c;
  35971. d1 += h0 * r1;
  35972. d1 += h1 * r0;
  35973. d1 += h2 * (5 * r9);
  35974. d1 += h3 * (5 * r8);
  35975. d1 += h4 * (5 * r7);
  35976. c = (d1 >>> 13); d1 &= 0x1fff;
  35977. d1 += h5 * (5 * r6);
  35978. d1 += h6 * (5 * r5);
  35979. d1 += h7 * (5 * r4);
  35980. d1 += h8 * (5 * r3);
  35981. d1 += h9 * (5 * r2);
  35982. c += (d1 >>> 13); d1 &= 0x1fff;
  35983. d2 = c;
  35984. d2 += h0 * r2;
  35985. d2 += h1 * r1;
  35986. d2 += h2 * r0;
  35987. d2 += h3 * (5 * r9);
  35988. d2 += h4 * (5 * r8);
  35989. c = (d2 >>> 13); d2 &= 0x1fff;
  35990. d2 += h5 * (5 * r7);
  35991. d2 += h6 * (5 * r6);
  35992. d2 += h7 * (5 * r5);
  35993. d2 += h8 * (5 * r4);
  35994. d2 += h9 * (5 * r3);
  35995. c += (d2 >>> 13); d2 &= 0x1fff;
  35996. d3 = c;
  35997. d3 += h0 * r3;
  35998. d3 += h1 * r2;
  35999. d3 += h2 * r1;
  36000. d3 += h3 * r0;
  36001. d3 += h4 * (5 * r9);
  36002. c = (d3 >>> 13); d3 &= 0x1fff;
  36003. d3 += h5 * (5 * r8);
  36004. d3 += h6 * (5 * r7);
  36005. d3 += h7 * (5 * r6);
  36006. d3 += h8 * (5 * r5);
  36007. d3 += h9 * (5 * r4);
  36008. c += (d3 >>> 13); d3 &= 0x1fff;
  36009. d4 = c;
  36010. d4 += h0 * r4;
  36011. d4 += h1 * r3;
  36012. d4 += h2 * r2;
  36013. d4 += h3 * r1;
  36014. d4 += h4 * r0;
  36015. c = (d4 >>> 13); d4 &= 0x1fff;
  36016. d4 += h5 * (5 * r9);
  36017. d4 += h6 * (5 * r8);
  36018. d4 += h7 * (5 * r7);
  36019. d4 += h8 * (5 * r6);
  36020. d4 += h9 * (5 * r5);
  36021. c += (d4 >>> 13); d4 &= 0x1fff;
  36022. d5 = c;
  36023. d5 += h0 * r5;
  36024. d5 += h1 * r4;
  36025. d5 += h2 * r3;
  36026. d5 += h3 * r2;
  36027. d5 += h4 * r1;
  36028. c = (d5 >>> 13); d5 &= 0x1fff;
  36029. d5 += h5 * r0;
  36030. d5 += h6 * (5 * r9);
  36031. d5 += h7 * (5 * r8);
  36032. d5 += h8 * (5 * r7);
  36033. d5 += h9 * (5 * r6);
  36034. c += (d5 >>> 13); d5 &= 0x1fff;
  36035. d6 = c;
  36036. d6 += h0 * r6;
  36037. d6 += h1 * r5;
  36038. d6 += h2 * r4;
  36039. d6 += h3 * r3;
  36040. d6 += h4 * r2;
  36041. c = (d6 >>> 13); d6 &= 0x1fff;
  36042. d6 += h5 * r1;
  36043. d6 += h6 * r0;
  36044. d6 += h7 * (5 * r9);
  36045. d6 += h8 * (5 * r8);
  36046. d6 += h9 * (5 * r7);
  36047. c += (d6 >>> 13); d6 &= 0x1fff;
  36048. d7 = c;
  36049. d7 += h0 * r7;
  36050. d7 += h1 * r6;
  36051. d7 += h2 * r5;
  36052. d7 += h3 * r4;
  36053. d7 += h4 * r3;
  36054. c = (d7 >>> 13); d7 &= 0x1fff;
  36055. d7 += h5 * r2;
  36056. d7 += h6 * r1;
  36057. d7 += h7 * r0;
  36058. d7 += h8 * (5 * r9);
  36059. d7 += h9 * (5 * r8);
  36060. c += (d7 >>> 13); d7 &= 0x1fff;
  36061. d8 = c;
  36062. d8 += h0 * r8;
  36063. d8 += h1 * r7;
  36064. d8 += h2 * r6;
  36065. d8 += h3 * r5;
  36066. d8 += h4 * r4;
  36067. c = (d8 >>> 13); d8 &= 0x1fff;
  36068. d8 += h5 * r3;
  36069. d8 += h6 * r2;
  36070. d8 += h7 * r1;
  36071. d8 += h8 * r0;
  36072. d8 += h9 * (5 * r9);
  36073. c += (d8 >>> 13); d8 &= 0x1fff;
  36074. d9 = c;
  36075. d9 += h0 * r9;
  36076. d9 += h1 * r8;
  36077. d9 += h2 * r7;
  36078. d9 += h3 * r6;
  36079. d9 += h4 * r5;
  36080. c = (d9 >>> 13); d9 &= 0x1fff;
  36081. d9 += h5 * r4;
  36082. d9 += h6 * r3;
  36083. d9 += h7 * r2;
  36084. d9 += h8 * r1;
  36085. d9 += h9 * r0;
  36086. c += (d9 >>> 13); d9 &= 0x1fff;
  36087. c = (((c << 2) + c)) | 0;
  36088. c = (c + d0) | 0;
  36089. d0 = c & 0x1fff;
  36090. c = (c >>> 13);
  36091. d1 += c;
  36092. h0 = d0;
  36093. h1 = d1;
  36094. h2 = d2;
  36095. h3 = d3;
  36096. h4 = d4;
  36097. h5 = d5;
  36098. h6 = d6;
  36099. h7 = d7;
  36100. h8 = d8;
  36101. h9 = d9;
  36102. mpos += 16;
  36103. bytes -= 16;
  36104. }
  36105. this.h[0] = h0;
  36106. this.h[1] = h1;
  36107. this.h[2] = h2;
  36108. this.h[3] = h3;
  36109. this.h[4] = h4;
  36110. this.h[5] = h5;
  36111. this.h[6] = h6;
  36112. this.h[7] = h7;
  36113. this.h[8] = h8;
  36114. this.h[9] = h9;
  36115. };
  36116. poly1305.prototype.finish = function(mac, macpos) {
  36117. var g = new Uint16Array(10);
  36118. var c, mask, f, i;
  36119. if (this.leftover) {
  36120. i = this.leftover;
  36121. this.buffer[i++] = 1;
  36122. for (; i < 16; i++) this.buffer[i] = 0;
  36123. this.fin = 1;
  36124. this.blocks(this.buffer, 0, 16);
  36125. }
  36126. c = this.h[1] >>> 13;
  36127. this.h[1] &= 0x1fff;
  36128. for (i = 2; i < 10; i++) {
  36129. this.h[i] += c;
  36130. c = this.h[i] >>> 13;
  36131. this.h[i] &= 0x1fff;
  36132. }
  36133. this.h[0] += (c * 5);
  36134. c = this.h[0] >>> 13;
  36135. this.h[0] &= 0x1fff;
  36136. this.h[1] += c;
  36137. c = this.h[1] >>> 13;
  36138. this.h[1] &= 0x1fff;
  36139. this.h[2] += c;
  36140. g[0] = this.h[0] + 5;
  36141. c = g[0] >>> 13;
  36142. g[0] &= 0x1fff;
  36143. for (i = 1; i < 10; i++) {
  36144. g[i] = this.h[i] + c;
  36145. c = g[i] >>> 13;
  36146. g[i] &= 0x1fff;
  36147. }
  36148. g[9] -= (1 << 13);
  36149. mask = (c ^ 1) - 1;
  36150. for (i = 0; i < 10; i++) g[i] &= mask;
  36151. mask = ~mask;
  36152. for (i = 0; i < 10; i++) this.h[i] = (this.h[i] & mask) | g[i];
  36153. this.h[0] = ((this.h[0] ) | (this.h[1] << 13) ) & 0xffff;
  36154. this.h[1] = ((this.h[1] >>> 3) | (this.h[2] << 10) ) & 0xffff;
  36155. this.h[2] = ((this.h[2] >>> 6) | (this.h[3] << 7) ) & 0xffff;
  36156. this.h[3] = ((this.h[3] >>> 9) | (this.h[4] << 4) ) & 0xffff;
  36157. this.h[4] = ((this.h[4] >>> 12) | (this.h[5] << 1) | (this.h[6] << 14)) & 0xffff;
  36158. this.h[5] = ((this.h[6] >>> 2) | (this.h[7] << 11) ) & 0xffff;
  36159. this.h[6] = ((this.h[7] >>> 5) | (this.h[8] << 8) ) & 0xffff;
  36160. this.h[7] = ((this.h[8] >>> 8) | (this.h[9] << 5) ) & 0xffff;
  36161. f = this.h[0] + this.pad[0];
  36162. this.h[0] = f & 0xffff;
  36163. for (i = 1; i < 8; i++) {
  36164. f = (((this.h[i] + this.pad[i]) | 0) + (f >>> 16)) | 0;
  36165. this.h[i] = f & 0xffff;
  36166. }
  36167. mac[macpos+ 0] = (this.h[0] >>> 0) & 0xff;
  36168. mac[macpos+ 1] = (this.h[0] >>> 8) & 0xff;
  36169. mac[macpos+ 2] = (this.h[1] >>> 0) & 0xff;
  36170. mac[macpos+ 3] = (this.h[1] >>> 8) & 0xff;
  36171. mac[macpos+ 4] = (this.h[2] >>> 0) & 0xff;
  36172. mac[macpos+ 5] = (this.h[2] >>> 8) & 0xff;
  36173. mac[macpos+ 6] = (this.h[3] >>> 0) & 0xff;
  36174. mac[macpos+ 7] = (this.h[3] >>> 8) & 0xff;
  36175. mac[macpos+ 8] = (this.h[4] >>> 0) & 0xff;
  36176. mac[macpos+ 9] = (this.h[4] >>> 8) & 0xff;
  36177. mac[macpos+10] = (this.h[5] >>> 0) & 0xff;
  36178. mac[macpos+11] = (this.h[5] >>> 8) & 0xff;
  36179. mac[macpos+12] = (this.h[6] >>> 0) & 0xff;
  36180. mac[macpos+13] = (this.h[6] >>> 8) & 0xff;
  36181. mac[macpos+14] = (this.h[7] >>> 0) & 0xff;
  36182. mac[macpos+15] = (this.h[7] >>> 8) & 0xff;
  36183. };
  36184. poly1305.prototype.update = function(m, mpos, bytes) {
  36185. var i, want;
  36186. if (this.leftover) {
  36187. want = (16 - this.leftover);
  36188. if (want > bytes)
  36189. want = bytes;
  36190. for (i = 0; i < want; i++)
  36191. this.buffer[this.leftover + i] = m[mpos+i];
  36192. bytes -= want;
  36193. mpos += want;
  36194. this.leftover += want;
  36195. if (this.leftover < 16)
  36196. return;
  36197. this.blocks(this.buffer, 0, 16);
  36198. this.leftover = 0;
  36199. }
  36200. if (bytes >= 16) {
  36201. want = bytes - (bytes % 16);
  36202. this.blocks(m, mpos, want);
  36203. mpos += want;
  36204. bytes -= want;
  36205. }
  36206. if (bytes) {
  36207. for (i = 0; i < bytes; i++)
  36208. this.buffer[this.leftover + i] = m[mpos+i];
  36209. this.leftover += bytes;
  36210. }
  36211. };
  36212. function crypto_onetimeauth(out, outpos, m, mpos, n, k) {
  36213. var s = new poly1305(k);
  36214. s.update(m, mpos, n);
  36215. s.finish(out, outpos);
  36216. return 0;
  36217. }
  36218. function crypto_onetimeauth_verify(h, hpos, m, mpos, n, k) {
  36219. var x = new Uint8Array(16);
  36220. crypto_onetimeauth(x,0,m,mpos,n,k);
  36221. return crypto_verify_16(h,hpos,x,0);
  36222. }
  36223. function crypto_secretbox(c,m,d,n,k) {
  36224. var i;
  36225. if (d < 32) return -1;
  36226. crypto_stream_xor(c,0,m,0,d,n,k);
  36227. crypto_onetimeauth(c, 16, c, 32, d - 32, c);
  36228. for (i = 0; i < 16; i++) c[i] = 0;
  36229. return 0;
  36230. }
  36231. function crypto_secretbox_open(m,c,d,n,k) {
  36232. var i;
  36233. var x = new Uint8Array(32);
  36234. if (d < 32) return -1;
  36235. crypto_stream(x,0,32,n,k);
  36236. if (crypto_onetimeauth_verify(c, 16,c, 32,d - 32,x) !== 0) return -1;
  36237. crypto_stream_xor(m,0,c,0,d,n,k);
  36238. for (i = 0; i < 32; i++) m[i] = 0;
  36239. return 0;
  36240. }
  36241. function set25519(r, a) {
  36242. var i;
  36243. for (i = 0; i < 16; i++) r[i] = a[i]|0;
  36244. }
  36245. function car25519(o) {
  36246. var i, v, c = 1;
  36247. for (i = 0; i < 16; i++) {
  36248. v = o[i] + c + 65535;
  36249. c = Math.floor(v / 65536);
  36250. o[i] = v - c * 65536;
  36251. }
  36252. o[0] += c-1 + 37 * (c-1);
  36253. }
  36254. function sel25519(p, q, b) {
  36255. var t, c = ~(b-1);
  36256. for (var i = 0; i < 16; i++) {
  36257. t = c & (p[i] ^ q[i]);
  36258. p[i] ^= t;
  36259. q[i] ^= t;
  36260. }
  36261. }
  36262. function pack25519(o, n) {
  36263. var i, j, b;
  36264. var m = gf(), t = gf();
  36265. for (i = 0; i < 16; i++) t[i] = n[i];
  36266. car25519(t);
  36267. car25519(t);
  36268. car25519(t);
  36269. for (j = 0; j < 2; j++) {
  36270. m[0] = t[0] - 0xffed;
  36271. for (i = 1; i < 15; i++) {
  36272. m[i] = t[i] - 0xffff - ((m[i-1]>>16) & 1);
  36273. m[i-1] &= 0xffff;
  36274. }
  36275. m[15] = t[15] - 0x7fff - ((m[14]>>16) & 1);
  36276. b = (m[15]>>16) & 1;
  36277. m[14] &= 0xffff;
  36278. sel25519(t, m, 1-b);
  36279. }
  36280. for (i = 0; i < 16; i++) {
  36281. o[2*i] = t[i] & 0xff;
  36282. o[2*i+1] = t[i]>>8;
  36283. }
  36284. }
  36285. function neq25519(a, b) {
  36286. var c = new Uint8Array(32), d = new Uint8Array(32);
  36287. pack25519(c, a);
  36288. pack25519(d, b);
  36289. return crypto_verify_32(c, 0, d, 0);
  36290. }
  36291. function par25519(a) {
  36292. var d = new Uint8Array(32);
  36293. pack25519(d, a);
  36294. return d[0] & 1;
  36295. }
  36296. function unpack25519(o, n) {
  36297. var i;
  36298. for (i = 0; i < 16; i++) o[i] = n[2*i] + (n[2*i+1] << 8);
  36299. o[15] &= 0x7fff;
  36300. }
  36301. function A(o, a, b) {
  36302. for (var i = 0; i < 16; i++) o[i] = a[i] + b[i];
  36303. }
  36304. function Z(o, a, b) {
  36305. for (var i = 0; i < 16; i++) o[i] = a[i] - b[i];
  36306. }
  36307. function M(o, a, b) {
  36308. var v, c,
  36309. t0 = 0, t1 = 0, t2 = 0, t3 = 0, t4 = 0, t5 = 0, t6 = 0, t7 = 0,
  36310. t8 = 0, t9 = 0, t10 = 0, t11 = 0, t12 = 0, t13 = 0, t14 = 0, t15 = 0,
  36311. t16 = 0, t17 = 0, t18 = 0, t19 = 0, t20 = 0, t21 = 0, t22 = 0, t23 = 0,
  36312. t24 = 0, t25 = 0, t26 = 0, t27 = 0, t28 = 0, t29 = 0, t30 = 0,
  36313. b0 = b[0],
  36314. b1 = b[1],
  36315. b2 = b[2],
  36316. b3 = b[3],
  36317. b4 = b[4],
  36318. b5 = b[5],
  36319. b6 = b[6],
  36320. b7 = b[7],
  36321. b8 = b[8],
  36322. b9 = b[9],
  36323. b10 = b[10],
  36324. b11 = b[11],
  36325. b12 = b[12],
  36326. b13 = b[13],
  36327. b14 = b[14],
  36328. b15 = b[15];
  36329. v = a[0];
  36330. t0 += v * b0;
  36331. t1 += v * b1;
  36332. t2 += v * b2;
  36333. t3 += v * b3;
  36334. t4 += v * b4;
  36335. t5 += v * b5;
  36336. t6 += v * b6;
  36337. t7 += v * b7;
  36338. t8 += v * b8;
  36339. t9 += v * b9;
  36340. t10 += v * b10;
  36341. t11 += v * b11;
  36342. t12 += v * b12;
  36343. t13 += v * b13;
  36344. t14 += v * b14;
  36345. t15 += v * b15;
  36346. v = a[1];
  36347. t1 += v * b0;
  36348. t2 += v * b1;
  36349. t3 += v * b2;
  36350. t4 += v * b3;
  36351. t5 += v * b4;
  36352. t6 += v * b5;
  36353. t7 += v * b6;
  36354. t8 += v * b7;
  36355. t9 += v * b8;
  36356. t10 += v * b9;
  36357. t11 += v * b10;
  36358. t12 += v * b11;
  36359. t13 += v * b12;
  36360. t14 += v * b13;
  36361. t15 += v * b14;
  36362. t16 += v * b15;
  36363. v = a[2];
  36364. t2 += v * b0;
  36365. t3 += v * b1;
  36366. t4 += v * b2;
  36367. t5 += v * b3;
  36368. t6 += v * b4;
  36369. t7 += v * b5;
  36370. t8 += v * b6;
  36371. t9 += v * b7;
  36372. t10 += v * b8;
  36373. t11 += v * b9;
  36374. t12 += v * b10;
  36375. t13 += v * b11;
  36376. t14 += v * b12;
  36377. t15 += v * b13;
  36378. t16 += v * b14;
  36379. t17 += v * b15;
  36380. v = a[3];
  36381. t3 += v * b0;
  36382. t4 += v * b1;
  36383. t5 += v * b2;
  36384. t6 += v * b3;
  36385. t7 += v * b4;
  36386. t8 += v * b5;
  36387. t9 += v * b6;
  36388. t10 += v * b7;
  36389. t11 += v * b8;
  36390. t12 += v * b9;
  36391. t13 += v * b10;
  36392. t14 += v * b11;
  36393. t15 += v * b12;
  36394. t16 += v * b13;
  36395. t17 += v * b14;
  36396. t18 += v * b15;
  36397. v = a[4];
  36398. t4 += v * b0;
  36399. t5 += v * b1;
  36400. t6 += v * b2;
  36401. t7 += v * b3;
  36402. t8 += v * b4;
  36403. t9 += v * b5;
  36404. t10 += v * b6;
  36405. t11 += v * b7;
  36406. t12 += v * b8;
  36407. t13 += v * b9;
  36408. t14 += v * b10;
  36409. t15 += v * b11;
  36410. t16 += v * b12;
  36411. t17 += v * b13;
  36412. t18 += v * b14;
  36413. t19 += v * b15;
  36414. v = a[5];
  36415. t5 += v * b0;
  36416. t6 += v * b1;
  36417. t7 += v * b2;
  36418. t8 += v * b3;
  36419. t9 += v * b4;
  36420. t10 += v * b5;
  36421. t11 += v * b6;
  36422. t12 += v * b7;
  36423. t13 += v * b8;
  36424. t14 += v * b9;
  36425. t15 += v * b10;
  36426. t16 += v * b11;
  36427. t17 += v * b12;
  36428. t18 += v * b13;
  36429. t19 += v * b14;
  36430. t20 += v * b15;
  36431. v = a[6];
  36432. t6 += v * b0;
  36433. t7 += v * b1;
  36434. t8 += v * b2;
  36435. t9 += v * b3;
  36436. t10 += v * b4;
  36437. t11 += v * b5;
  36438. t12 += v * b6;
  36439. t13 += v * b7;
  36440. t14 += v * b8;
  36441. t15 += v * b9;
  36442. t16 += v * b10;
  36443. t17 += v * b11;
  36444. t18 += v * b12;
  36445. t19 += v * b13;
  36446. t20 += v * b14;
  36447. t21 += v * b15;
  36448. v = a[7];
  36449. t7 += v * b0;
  36450. t8 += v * b1;
  36451. t9 += v * b2;
  36452. t10 += v * b3;
  36453. t11 += v * b4;
  36454. t12 += v * b5;
  36455. t13 += v * b6;
  36456. t14 += v * b7;
  36457. t15 += v * b8;
  36458. t16 += v * b9;
  36459. t17 += v * b10;
  36460. t18 += v * b11;
  36461. t19 += v * b12;
  36462. t20 += v * b13;
  36463. t21 += v * b14;
  36464. t22 += v * b15;
  36465. v = a[8];
  36466. t8 += v * b0;
  36467. t9 += v * b1;
  36468. t10 += v * b2;
  36469. t11 += v * b3;
  36470. t12 += v * b4;
  36471. t13 += v * b5;
  36472. t14 += v * b6;
  36473. t15 += v * b7;
  36474. t16 += v * b8;
  36475. t17 += v * b9;
  36476. t18 += v * b10;
  36477. t19 += v * b11;
  36478. t20 += v * b12;
  36479. t21 += v * b13;
  36480. t22 += v * b14;
  36481. t23 += v * b15;
  36482. v = a[9];
  36483. t9 += v * b0;
  36484. t10 += v * b1;
  36485. t11 += v * b2;
  36486. t12 += v * b3;
  36487. t13 += v * b4;
  36488. t14 += v * b5;
  36489. t15 += v * b6;
  36490. t16 += v * b7;
  36491. t17 += v * b8;
  36492. t18 += v * b9;
  36493. t19 += v * b10;
  36494. t20 += v * b11;
  36495. t21 += v * b12;
  36496. t22 += v * b13;
  36497. t23 += v * b14;
  36498. t24 += v * b15;
  36499. v = a[10];
  36500. t10 += v * b0;
  36501. t11 += v * b1;
  36502. t12 += v * b2;
  36503. t13 += v * b3;
  36504. t14 += v * b4;
  36505. t15 += v * b5;
  36506. t16 += v * b6;
  36507. t17 += v * b7;
  36508. t18 += v * b8;
  36509. t19 += v * b9;
  36510. t20 += v * b10;
  36511. t21 += v * b11;
  36512. t22 += v * b12;
  36513. t23 += v * b13;
  36514. t24 += v * b14;
  36515. t25 += v * b15;
  36516. v = a[11];
  36517. t11 += v * b0;
  36518. t12 += v * b1;
  36519. t13 += v * b2;
  36520. t14 += v * b3;
  36521. t15 += v * b4;
  36522. t16 += v * b5;
  36523. t17 += v * b6;
  36524. t18 += v * b7;
  36525. t19 += v * b8;
  36526. t20 += v * b9;
  36527. t21 += v * b10;
  36528. t22 += v * b11;
  36529. t23 += v * b12;
  36530. t24 += v * b13;
  36531. t25 += v * b14;
  36532. t26 += v * b15;
  36533. v = a[12];
  36534. t12 += v * b0;
  36535. t13 += v * b1;
  36536. t14 += v * b2;
  36537. t15 += v * b3;
  36538. t16 += v * b4;
  36539. t17 += v * b5;
  36540. t18 += v * b6;
  36541. t19 += v * b7;
  36542. t20 += v * b8;
  36543. t21 += v * b9;
  36544. t22 += v * b10;
  36545. t23 += v * b11;
  36546. t24 += v * b12;
  36547. t25 += v * b13;
  36548. t26 += v * b14;
  36549. t27 += v * b15;
  36550. v = a[13];
  36551. t13 += v * b0;
  36552. t14 += v * b1;
  36553. t15 += v * b2;
  36554. t16 += v * b3;
  36555. t17 += v * b4;
  36556. t18 += v * b5;
  36557. t19 += v * b6;
  36558. t20 += v * b7;
  36559. t21 += v * b8;
  36560. t22 += v * b9;
  36561. t23 += v * b10;
  36562. t24 += v * b11;
  36563. t25 += v * b12;
  36564. t26 += v * b13;
  36565. t27 += v * b14;
  36566. t28 += v * b15;
  36567. v = a[14];
  36568. t14 += v * b0;
  36569. t15 += v * b1;
  36570. t16 += v * b2;
  36571. t17 += v * b3;
  36572. t18 += v * b4;
  36573. t19 += v * b5;
  36574. t20 += v * b6;
  36575. t21 += v * b7;
  36576. t22 += v * b8;
  36577. t23 += v * b9;
  36578. t24 += v * b10;
  36579. t25 += v * b11;
  36580. t26 += v * b12;
  36581. t27 += v * b13;
  36582. t28 += v * b14;
  36583. t29 += v * b15;
  36584. v = a[15];
  36585. t15 += v * b0;
  36586. t16 += v * b1;
  36587. t17 += v * b2;
  36588. t18 += v * b3;
  36589. t19 += v * b4;
  36590. t20 += v * b5;
  36591. t21 += v * b6;
  36592. t22 += v * b7;
  36593. t23 += v * b8;
  36594. t24 += v * b9;
  36595. t25 += v * b10;
  36596. t26 += v * b11;
  36597. t27 += v * b12;
  36598. t28 += v * b13;
  36599. t29 += v * b14;
  36600. t30 += v * b15;
  36601. t0 += 38 * t16;
  36602. t1 += 38 * t17;
  36603. t2 += 38 * t18;
  36604. t3 += 38 * t19;
  36605. t4 += 38 * t20;
  36606. t5 += 38 * t21;
  36607. t6 += 38 * t22;
  36608. t7 += 38 * t23;
  36609. t8 += 38 * t24;
  36610. t9 += 38 * t25;
  36611. t10 += 38 * t26;
  36612. t11 += 38 * t27;
  36613. t12 += 38 * t28;
  36614. t13 += 38 * t29;
  36615. t14 += 38 * t30;
  36616. // t15 left as is
  36617. // first car
  36618. c = 1;
  36619. v = t0 + c + 65535; c = Math.floor(v / 65536); t0 = v - c * 65536;
  36620. v = t1 + c + 65535; c = Math.floor(v / 65536); t1 = v - c * 65536;
  36621. v = t2 + c + 65535; c = Math.floor(v / 65536); t2 = v - c * 65536;
  36622. v = t3 + c + 65535; c = Math.floor(v / 65536); t3 = v - c * 65536;
  36623. v = t4 + c + 65535; c = Math.floor(v / 65536); t4 = v - c * 65536;
  36624. v = t5 + c + 65535; c = Math.floor(v / 65536); t5 = v - c * 65536;
  36625. v = t6 + c + 65535; c = Math.floor(v / 65536); t6 = v - c * 65536;
  36626. v = t7 + c + 65535; c = Math.floor(v / 65536); t7 = v - c * 65536;
  36627. v = t8 + c + 65535; c = Math.floor(v / 65536); t8 = v - c * 65536;
  36628. v = t9 + c + 65535; c = Math.floor(v / 65536); t9 = v - c * 65536;
  36629. v = t10 + c + 65535; c = Math.floor(v / 65536); t10 = v - c * 65536;
  36630. v = t11 + c + 65535; c = Math.floor(v / 65536); t11 = v - c * 65536;
  36631. v = t12 + c + 65535; c = Math.floor(v / 65536); t12 = v - c * 65536;
  36632. v = t13 + c + 65535; c = Math.floor(v / 65536); t13 = v - c * 65536;
  36633. v = t14 + c + 65535; c = Math.floor(v / 65536); t14 = v - c * 65536;
  36634. v = t15 + c + 65535; c = Math.floor(v / 65536); t15 = v - c * 65536;
  36635. t0 += c-1 + 37 * (c-1);
  36636. // second car
  36637. c = 1;
  36638. v = t0 + c + 65535; c = Math.floor(v / 65536); t0 = v - c * 65536;
  36639. v = t1 + c + 65535; c = Math.floor(v / 65536); t1 = v - c * 65536;
  36640. v = t2 + c + 65535; c = Math.floor(v / 65536); t2 = v - c * 65536;
  36641. v = t3 + c + 65535; c = Math.floor(v / 65536); t3 = v - c * 65536;
  36642. v = t4 + c + 65535; c = Math.floor(v / 65536); t4 = v - c * 65536;
  36643. v = t5 + c + 65535; c = Math.floor(v / 65536); t5 = v - c * 65536;
  36644. v = t6 + c + 65535; c = Math.floor(v / 65536); t6 = v - c * 65536;
  36645. v = t7 + c + 65535; c = Math.floor(v / 65536); t7 = v - c * 65536;
  36646. v = t8 + c + 65535; c = Math.floor(v / 65536); t8 = v - c * 65536;
  36647. v = t9 + c + 65535; c = Math.floor(v / 65536); t9 = v - c * 65536;
  36648. v = t10 + c + 65535; c = Math.floor(v / 65536); t10 = v - c * 65536;
  36649. v = t11 + c + 65535; c = Math.floor(v / 65536); t11 = v - c * 65536;
  36650. v = t12 + c + 65535; c = Math.floor(v / 65536); t12 = v - c * 65536;
  36651. v = t13 + c + 65535; c = Math.floor(v / 65536); t13 = v - c * 65536;
  36652. v = t14 + c + 65535; c = Math.floor(v / 65536); t14 = v - c * 65536;
  36653. v = t15 + c + 65535; c = Math.floor(v / 65536); t15 = v - c * 65536;
  36654. t0 += c-1 + 37 * (c-1);
  36655. o[ 0] = t0;
  36656. o[ 1] = t1;
  36657. o[ 2] = t2;
  36658. o[ 3] = t3;
  36659. o[ 4] = t4;
  36660. o[ 5] = t5;
  36661. o[ 6] = t6;
  36662. o[ 7] = t7;
  36663. o[ 8] = t8;
  36664. o[ 9] = t9;
  36665. o[10] = t10;
  36666. o[11] = t11;
  36667. o[12] = t12;
  36668. o[13] = t13;
  36669. o[14] = t14;
  36670. o[15] = t15;
  36671. }
  36672. function S(o, a) {
  36673. M(o, a, a);
  36674. }
  36675. function inv25519(o, i) {
  36676. var c = gf();
  36677. var a;
  36678. for (a = 0; a < 16; a++) c[a] = i[a];
  36679. for (a = 253; a >= 0; a--) {
  36680. S(c, c);
  36681. if(a !== 2 && a !== 4) M(c, c, i);
  36682. }
  36683. for (a = 0; a < 16; a++) o[a] = c[a];
  36684. }
  36685. function pow2523(o, i) {
  36686. var c = gf();
  36687. var a;
  36688. for (a = 0; a < 16; a++) c[a] = i[a];
  36689. for (a = 250; a >= 0; a--) {
  36690. S(c, c);
  36691. if(a !== 1) M(c, c, i);
  36692. }
  36693. for (a = 0; a < 16; a++) o[a] = c[a];
  36694. }
  36695. function crypto_scalarmult(q, n, p) {
  36696. var z = new Uint8Array(32);
  36697. var x = new Float64Array(80), r, i;
  36698. var a = gf(), b = gf(), c = gf(),
  36699. d = gf(), e = gf(), f = gf();
  36700. for (i = 0; i < 31; i++) z[i] = n[i];
  36701. z[31]=(n[31]&127)|64;
  36702. z[0]&=248;
  36703. unpack25519(x,p);
  36704. for (i = 0; i < 16; i++) {
  36705. b[i]=x[i];
  36706. d[i]=a[i]=c[i]=0;
  36707. }
  36708. a[0]=d[0]=1;
  36709. for (i=254; i>=0; --i) {
  36710. r=(z[i>>>3]>>>(i&7))&1;
  36711. sel25519(a,b,r);
  36712. sel25519(c,d,r);
  36713. A(e,a,c);
  36714. Z(a,a,c);
  36715. A(c,b,d);
  36716. Z(b,b,d);
  36717. S(d,e);
  36718. S(f,a);
  36719. M(a,c,a);
  36720. M(c,b,e);
  36721. A(e,a,c);
  36722. Z(a,a,c);
  36723. S(b,a);
  36724. Z(c,d,f);
  36725. M(a,c,_121665);
  36726. A(a,a,d);
  36727. M(c,c,a);
  36728. M(a,d,f);
  36729. M(d,b,x);
  36730. S(b,e);
  36731. sel25519(a,b,r);
  36732. sel25519(c,d,r);
  36733. }
  36734. for (i = 0; i < 16; i++) {
  36735. x[i+16]=a[i];
  36736. x[i+32]=c[i];
  36737. x[i+48]=b[i];
  36738. x[i+64]=d[i];
  36739. }
  36740. var x32 = x.subarray(32);
  36741. var x16 = x.subarray(16);
  36742. inv25519(x32,x32);
  36743. M(x16,x16,x32);
  36744. pack25519(q,x16);
  36745. return 0;
  36746. }
  36747. function crypto_scalarmult_base(q, n) {
  36748. return crypto_scalarmult(q, n, _9);
  36749. }
  36750. function crypto_box_keypair(y, x) {
  36751. randombytes(x, 32);
  36752. return crypto_scalarmult_base(y, x);
  36753. }
  36754. function crypto_box_beforenm(k, y, x) {
  36755. var s = new Uint8Array(32);
  36756. crypto_scalarmult(s, x, y);
  36757. return crypto_core_hsalsa20(k, _0, s, sigma);
  36758. }
  36759. var crypto_box_afternm = crypto_secretbox;
  36760. var crypto_box_open_afternm = crypto_secretbox_open;
  36761. function crypto_box(c, m, d, n, y, x) {
  36762. var k = new Uint8Array(32);
  36763. crypto_box_beforenm(k, y, x);
  36764. return crypto_box_afternm(c, m, d, n, k);
  36765. }
  36766. function crypto_box_open(m, c, d, n, y, x) {
  36767. var k = new Uint8Array(32);
  36768. crypto_box_beforenm(k, y, x);
  36769. return crypto_box_open_afternm(m, c, d, n, k);
  36770. }
  36771. var K = [
  36772. 0x428a2f98, 0xd728ae22, 0x71374491, 0x23ef65cd,
  36773. 0xb5c0fbcf, 0xec4d3b2f, 0xe9b5dba5, 0x8189dbbc,
  36774. 0x3956c25b, 0xf348b538, 0x59f111f1, 0xb605d019,
  36775. 0x923f82a4, 0xaf194f9b, 0xab1c5ed5, 0xda6d8118,
  36776. 0xd807aa98, 0xa3030242, 0x12835b01, 0x45706fbe,
  36777. 0x243185be, 0x4ee4b28c, 0x550c7dc3, 0xd5ffb4e2,
  36778. 0x72be5d74, 0xf27b896f, 0x80deb1fe, 0x3b1696b1,
  36779. 0x9bdc06a7, 0x25c71235, 0xc19bf174, 0xcf692694,
  36780. 0xe49b69c1, 0x9ef14ad2, 0xefbe4786, 0x384f25e3,
  36781. 0x0fc19dc6, 0x8b8cd5b5, 0x240ca1cc, 0x77ac9c65,
  36782. 0x2de92c6f, 0x592b0275, 0x4a7484aa, 0x6ea6e483,
  36783. 0x5cb0a9dc, 0xbd41fbd4, 0x76f988da, 0x831153b5,
  36784. 0x983e5152, 0xee66dfab, 0xa831c66d, 0x2db43210,
  36785. 0xb00327c8, 0x98fb213f, 0xbf597fc7, 0xbeef0ee4,
  36786. 0xc6e00bf3, 0x3da88fc2, 0xd5a79147, 0x930aa725,
  36787. 0x06ca6351, 0xe003826f, 0x14292967, 0x0a0e6e70,
  36788. 0x27b70a85, 0x46d22ffc, 0x2e1b2138, 0x5c26c926,
  36789. 0x4d2c6dfc, 0x5ac42aed, 0x53380d13, 0x9d95b3df,
  36790. 0x650a7354, 0x8baf63de, 0x766a0abb, 0x3c77b2a8,
  36791. 0x81c2c92e, 0x47edaee6, 0x92722c85, 0x1482353b,
  36792. 0xa2bfe8a1, 0x4cf10364, 0xa81a664b, 0xbc423001,
  36793. 0xc24b8b70, 0xd0f89791, 0xc76c51a3, 0x0654be30,
  36794. 0xd192e819, 0xd6ef5218, 0xd6990624, 0x5565a910,
  36795. 0xf40e3585, 0x5771202a, 0x106aa070, 0x32bbd1b8,
  36796. 0x19a4c116, 0xb8d2d0c8, 0x1e376c08, 0x5141ab53,
  36797. 0x2748774c, 0xdf8eeb99, 0x34b0bcb5, 0xe19b48a8,
  36798. 0x391c0cb3, 0xc5c95a63, 0x4ed8aa4a, 0xe3418acb,
  36799. 0x5b9cca4f, 0x7763e373, 0x682e6ff3, 0xd6b2b8a3,
  36800. 0x748f82ee, 0x5defb2fc, 0x78a5636f, 0x43172f60,
  36801. 0x84c87814, 0xa1f0ab72, 0x8cc70208, 0x1a6439ec,
  36802. 0x90befffa, 0x23631e28, 0xa4506ceb, 0xde82bde9,
  36803. 0xbef9a3f7, 0xb2c67915, 0xc67178f2, 0xe372532b,
  36804. 0xca273ece, 0xea26619c, 0xd186b8c7, 0x21c0c207,
  36805. 0xeada7dd6, 0xcde0eb1e, 0xf57d4f7f, 0xee6ed178,
  36806. 0x06f067aa, 0x72176fba, 0x0a637dc5, 0xa2c898a6,
  36807. 0x113f9804, 0xbef90dae, 0x1b710b35, 0x131c471b,
  36808. 0x28db77f5, 0x23047d84, 0x32caab7b, 0x40c72493,
  36809. 0x3c9ebe0a, 0x15c9bebc, 0x431d67c4, 0x9c100d4c,
  36810. 0x4cc5d4be, 0xcb3e42b6, 0x597f299c, 0xfc657e2a,
  36811. 0x5fcb6fab, 0x3ad6faec, 0x6c44198c, 0x4a475817
  36812. ];
  36813. function crypto_hashblocks_hl(hh, hl, m, n) {
  36814. var wh = new Int32Array(16), wl = new Int32Array(16),
  36815. bh0, bh1, bh2, bh3, bh4, bh5, bh6, bh7,
  36816. bl0, bl1, bl2, bl3, bl4, bl5, bl6, bl7,
  36817. th, tl, i, j, h, l, a, b, c, d;
  36818. var ah0 = hh[0],
  36819. ah1 = hh[1],
  36820. ah2 = hh[2],
  36821. ah3 = hh[3],
  36822. ah4 = hh[4],
  36823. ah5 = hh[5],
  36824. ah6 = hh[6],
  36825. ah7 = hh[7],
  36826. al0 = hl[0],
  36827. al1 = hl[1],
  36828. al2 = hl[2],
  36829. al3 = hl[3],
  36830. al4 = hl[4],
  36831. al5 = hl[5],
  36832. al6 = hl[6],
  36833. al7 = hl[7];
  36834. var pos = 0;
  36835. while (n >= 128) {
  36836. for (i = 0; i < 16; i++) {
  36837. j = 8 * i + pos;
  36838. wh[i] = (m[j+0] << 24) | (m[j+1] << 16) | (m[j+2] << 8) | m[j+3];
  36839. wl[i] = (m[j+4] << 24) | (m[j+5] << 16) | (m[j+6] << 8) | m[j+7];
  36840. }
  36841. for (i = 0; i < 80; i++) {
  36842. bh0 = ah0;
  36843. bh1 = ah1;
  36844. bh2 = ah2;
  36845. bh3 = ah3;
  36846. bh4 = ah4;
  36847. bh5 = ah5;
  36848. bh6 = ah6;
  36849. bh7 = ah7;
  36850. bl0 = al0;
  36851. bl1 = al1;
  36852. bl2 = al2;
  36853. bl3 = al3;
  36854. bl4 = al4;
  36855. bl5 = al5;
  36856. bl6 = al6;
  36857. bl7 = al7;
  36858. // add
  36859. h = ah7;
  36860. l = al7;
  36861. a = l & 0xffff; b = l >>> 16;
  36862. c = h & 0xffff; d = h >>> 16;
  36863. // Sigma1
  36864. h = ((ah4 >>> 14) | (al4 << (32-14))) ^ ((ah4 >>> 18) | (al4 << (32-18))) ^ ((al4 >>> (41-32)) | (ah4 << (32-(41-32))));
  36865. l = ((al4 >>> 14) | (ah4 << (32-14))) ^ ((al4 >>> 18) | (ah4 << (32-18))) ^ ((ah4 >>> (41-32)) | (al4 << (32-(41-32))));
  36866. a += l & 0xffff; b += l >>> 16;
  36867. c += h & 0xffff; d += h >>> 16;
  36868. // Ch
  36869. h = (ah4 & ah5) ^ (~ah4 & ah6);
  36870. l = (al4 & al5) ^ (~al4 & al6);
  36871. a += l & 0xffff; b += l >>> 16;
  36872. c += h & 0xffff; d += h >>> 16;
  36873. // K
  36874. h = K[i*2];
  36875. l = K[i*2+1];
  36876. a += l & 0xffff; b += l >>> 16;
  36877. c += h & 0xffff; d += h >>> 16;
  36878. // w
  36879. h = wh[i%16];
  36880. l = wl[i%16];
  36881. a += l & 0xffff; b += l >>> 16;
  36882. c += h & 0xffff; d += h >>> 16;
  36883. b += a >>> 16;
  36884. c += b >>> 16;
  36885. d += c >>> 16;
  36886. th = c & 0xffff | d << 16;
  36887. tl = a & 0xffff | b << 16;
  36888. // add
  36889. h = th;
  36890. l = tl;
  36891. a = l & 0xffff; b = l >>> 16;
  36892. c = h & 0xffff; d = h >>> 16;
  36893. // Sigma0
  36894. h = ((ah0 >>> 28) | (al0 << (32-28))) ^ ((al0 >>> (34-32)) | (ah0 << (32-(34-32)))) ^ ((al0 >>> (39-32)) | (ah0 << (32-(39-32))));
  36895. l = ((al0 >>> 28) | (ah0 << (32-28))) ^ ((ah0 >>> (34-32)) | (al0 << (32-(34-32)))) ^ ((ah0 >>> (39-32)) | (al0 << (32-(39-32))));
  36896. a += l & 0xffff; b += l >>> 16;
  36897. c += h & 0xffff; d += h >>> 16;
  36898. // Maj
  36899. h = (ah0 & ah1) ^ (ah0 & ah2) ^ (ah1 & ah2);
  36900. l = (al0 & al1) ^ (al0 & al2) ^ (al1 & al2);
  36901. a += l & 0xffff; b += l >>> 16;
  36902. c += h & 0xffff; d += h >>> 16;
  36903. b += a >>> 16;
  36904. c += b >>> 16;
  36905. d += c >>> 16;
  36906. bh7 = (c & 0xffff) | (d << 16);
  36907. bl7 = (a & 0xffff) | (b << 16);
  36908. // add
  36909. h = bh3;
  36910. l = bl3;
  36911. a = l & 0xffff; b = l >>> 16;
  36912. c = h & 0xffff; d = h >>> 16;
  36913. h = th;
  36914. l = tl;
  36915. a += l & 0xffff; b += l >>> 16;
  36916. c += h & 0xffff; d += h >>> 16;
  36917. b += a >>> 16;
  36918. c += b >>> 16;
  36919. d += c >>> 16;
  36920. bh3 = (c & 0xffff) | (d << 16);
  36921. bl3 = (a & 0xffff) | (b << 16);
  36922. ah1 = bh0;
  36923. ah2 = bh1;
  36924. ah3 = bh2;
  36925. ah4 = bh3;
  36926. ah5 = bh4;
  36927. ah6 = bh5;
  36928. ah7 = bh6;
  36929. ah0 = bh7;
  36930. al1 = bl0;
  36931. al2 = bl1;
  36932. al3 = bl2;
  36933. al4 = bl3;
  36934. al5 = bl4;
  36935. al6 = bl5;
  36936. al7 = bl6;
  36937. al0 = bl7;
  36938. if (i%16 === 15) {
  36939. for (j = 0; j < 16; j++) {
  36940. // add
  36941. h = wh[j];
  36942. l = wl[j];
  36943. a = l & 0xffff; b = l >>> 16;
  36944. c = h & 0xffff; d = h >>> 16;
  36945. h = wh[(j+9)%16];
  36946. l = wl[(j+9)%16];
  36947. a += l & 0xffff; b += l >>> 16;
  36948. c += h & 0xffff; d += h >>> 16;
  36949. // sigma0
  36950. th = wh[(j+1)%16];
  36951. tl = wl[(j+1)%16];
  36952. h = ((th >>> 1) | (tl << (32-1))) ^ ((th >>> 8) | (tl << (32-8))) ^ (th >>> 7);
  36953. l = ((tl >>> 1) | (th << (32-1))) ^ ((tl >>> 8) | (th << (32-8))) ^ ((tl >>> 7) | (th << (32-7)));
  36954. a += l & 0xffff; b += l >>> 16;
  36955. c += h & 0xffff; d += h >>> 16;
  36956. // sigma1
  36957. th = wh[(j+14)%16];
  36958. tl = wl[(j+14)%16];
  36959. h = ((th >>> 19) | (tl << (32-19))) ^ ((tl >>> (61-32)) | (th << (32-(61-32)))) ^ (th >>> 6);
  36960. l = ((tl >>> 19) | (th << (32-19))) ^ ((th >>> (61-32)) | (tl << (32-(61-32)))) ^ ((tl >>> 6) | (th << (32-6)));
  36961. a += l & 0xffff; b += l >>> 16;
  36962. c += h & 0xffff; d += h >>> 16;
  36963. b += a >>> 16;
  36964. c += b >>> 16;
  36965. d += c >>> 16;
  36966. wh[j] = (c & 0xffff) | (d << 16);
  36967. wl[j] = (a & 0xffff) | (b << 16);
  36968. }
  36969. }
  36970. }
  36971. // add
  36972. h = ah0;
  36973. l = al0;
  36974. a = l & 0xffff; b = l >>> 16;
  36975. c = h & 0xffff; d = h >>> 16;
  36976. h = hh[0];
  36977. l = hl[0];
  36978. a += l & 0xffff; b += l >>> 16;
  36979. c += h & 0xffff; d += h >>> 16;
  36980. b += a >>> 16;
  36981. c += b >>> 16;
  36982. d += c >>> 16;
  36983. hh[0] = ah0 = (c & 0xffff) | (d << 16);
  36984. hl[0] = al0 = (a & 0xffff) | (b << 16);
  36985. h = ah1;
  36986. l = al1;
  36987. a = l & 0xffff; b = l >>> 16;
  36988. c = h & 0xffff; d = h >>> 16;
  36989. h = hh[1];
  36990. l = hl[1];
  36991. a += l & 0xffff; b += l >>> 16;
  36992. c += h & 0xffff; d += h >>> 16;
  36993. b += a >>> 16;
  36994. c += b >>> 16;
  36995. d += c >>> 16;
  36996. hh[1] = ah1 = (c & 0xffff) | (d << 16);
  36997. hl[1] = al1 = (a & 0xffff) | (b << 16);
  36998. h = ah2;
  36999. l = al2;
  37000. a = l & 0xffff; b = l >>> 16;
  37001. c = h & 0xffff; d = h >>> 16;
  37002. h = hh[2];
  37003. l = hl[2];
  37004. a += l & 0xffff; b += l >>> 16;
  37005. c += h & 0xffff; d += h >>> 16;
  37006. b += a >>> 16;
  37007. c += b >>> 16;
  37008. d += c >>> 16;
  37009. hh[2] = ah2 = (c & 0xffff) | (d << 16);
  37010. hl[2] = al2 = (a & 0xffff) | (b << 16);
  37011. h = ah3;
  37012. l = al3;
  37013. a = l & 0xffff; b = l >>> 16;
  37014. c = h & 0xffff; d = h >>> 16;
  37015. h = hh[3];
  37016. l = hl[3];
  37017. a += l & 0xffff; b += l >>> 16;
  37018. c += h & 0xffff; d += h >>> 16;
  37019. b += a >>> 16;
  37020. c += b >>> 16;
  37021. d += c >>> 16;
  37022. hh[3] = ah3 = (c & 0xffff) | (d << 16);
  37023. hl[3] = al3 = (a & 0xffff) | (b << 16);
  37024. h = ah4;
  37025. l = al4;
  37026. a = l & 0xffff; b = l >>> 16;
  37027. c = h & 0xffff; d = h >>> 16;
  37028. h = hh[4];
  37029. l = hl[4];
  37030. a += l & 0xffff; b += l >>> 16;
  37031. c += h & 0xffff; d += h >>> 16;
  37032. b += a >>> 16;
  37033. c += b >>> 16;
  37034. d += c >>> 16;
  37035. hh[4] = ah4 = (c & 0xffff) | (d << 16);
  37036. hl[4] = al4 = (a & 0xffff) | (b << 16);
  37037. h = ah5;
  37038. l = al5;
  37039. a = l & 0xffff; b = l >>> 16;
  37040. c = h & 0xffff; d = h >>> 16;
  37041. h = hh[5];
  37042. l = hl[5];
  37043. a += l & 0xffff; b += l >>> 16;
  37044. c += h & 0xffff; d += h >>> 16;
  37045. b += a >>> 16;
  37046. c += b >>> 16;
  37047. d += c >>> 16;
  37048. hh[5] = ah5 = (c & 0xffff) | (d << 16);
  37049. hl[5] = al5 = (a & 0xffff) | (b << 16);
  37050. h = ah6;
  37051. l = al6;
  37052. a = l & 0xffff; b = l >>> 16;
  37053. c = h & 0xffff; d = h >>> 16;
  37054. h = hh[6];
  37055. l = hl[6];
  37056. a += l & 0xffff; b += l >>> 16;
  37057. c += h & 0xffff; d += h >>> 16;
  37058. b += a >>> 16;
  37059. c += b >>> 16;
  37060. d += c >>> 16;
  37061. hh[6] = ah6 = (c & 0xffff) | (d << 16);
  37062. hl[6] = al6 = (a & 0xffff) | (b << 16);
  37063. h = ah7;
  37064. l = al7;
  37065. a = l & 0xffff; b = l >>> 16;
  37066. c = h & 0xffff; d = h >>> 16;
  37067. h = hh[7];
  37068. l = hl[7];
  37069. a += l & 0xffff; b += l >>> 16;
  37070. c += h & 0xffff; d += h >>> 16;
  37071. b += a >>> 16;
  37072. c += b >>> 16;
  37073. d += c >>> 16;
  37074. hh[7] = ah7 = (c & 0xffff) | (d << 16);
  37075. hl[7] = al7 = (a & 0xffff) | (b << 16);
  37076. pos += 128;
  37077. n -= 128;
  37078. }
  37079. return n;
  37080. }
  37081. function crypto_hash(out, m, n) {
  37082. var hh = new Int32Array(8),
  37083. hl = new Int32Array(8),
  37084. x = new Uint8Array(256),
  37085. i, b = n;
  37086. hh[0] = 0x6a09e667;
  37087. hh[1] = 0xbb67ae85;
  37088. hh[2] = 0x3c6ef372;
  37089. hh[3] = 0xa54ff53a;
  37090. hh[4] = 0x510e527f;
  37091. hh[5] = 0x9b05688c;
  37092. hh[6] = 0x1f83d9ab;
  37093. hh[7] = 0x5be0cd19;
  37094. hl[0] = 0xf3bcc908;
  37095. hl[1] = 0x84caa73b;
  37096. hl[2] = 0xfe94f82b;
  37097. hl[3] = 0x5f1d36f1;
  37098. hl[4] = 0xade682d1;
  37099. hl[5] = 0x2b3e6c1f;
  37100. hl[6] = 0xfb41bd6b;
  37101. hl[7] = 0x137e2179;
  37102. crypto_hashblocks_hl(hh, hl, m, n);
  37103. n %= 128;
  37104. for (i = 0; i < n; i++) x[i] = m[b-n+i];
  37105. x[n] = 128;
  37106. n = 256-128*(n<112?1:0);
  37107. x[n-9] = 0;
  37108. ts64(x, n-8, (b / 0x20000000) | 0, b << 3);
  37109. crypto_hashblocks_hl(hh, hl, x, n);
  37110. for (i = 0; i < 8; i++) ts64(out, 8*i, hh[i], hl[i]);
  37111. return 0;
  37112. }
  37113. function add(p, q) {
  37114. var a = gf(), b = gf(), c = gf(),
  37115. d = gf(), e = gf(), f = gf(),
  37116. g = gf(), h = gf(), t = gf();
  37117. Z(a, p[1], p[0]);
  37118. Z(t, q[1], q[0]);
  37119. M(a, a, t);
  37120. A(b, p[0], p[1]);
  37121. A(t, q[0], q[1]);
  37122. M(b, b, t);
  37123. M(c, p[3], q[3]);
  37124. M(c, c, D2);
  37125. M(d, p[2], q[2]);
  37126. A(d, d, d);
  37127. Z(e, b, a);
  37128. Z(f, d, c);
  37129. A(g, d, c);
  37130. A(h, b, a);
  37131. M(p[0], e, f);
  37132. M(p[1], h, g);
  37133. M(p[2], g, f);
  37134. M(p[3], e, h);
  37135. }
  37136. function cswap(p, q, b) {
  37137. var i;
  37138. for (i = 0; i < 4; i++) {
  37139. sel25519(p[i], q[i], b);
  37140. }
  37141. }
  37142. function pack(r, p) {
  37143. var tx = gf(), ty = gf(), zi = gf();
  37144. inv25519(zi, p[2]);
  37145. M(tx, p[0], zi);
  37146. M(ty, p[1], zi);
  37147. pack25519(r, ty);
  37148. r[31] ^= par25519(tx) << 7;
  37149. }
  37150. function scalarmult(p, q, s) {
  37151. var b, i;
  37152. set25519(p[0], gf0);
  37153. set25519(p[1], gf1);
  37154. set25519(p[2], gf1);
  37155. set25519(p[3], gf0);
  37156. for (i = 255; i >= 0; --i) {
  37157. b = (s[(i/8)|0] >> (i&7)) & 1;
  37158. cswap(p, q, b);
  37159. add(q, p);
  37160. add(p, p);
  37161. cswap(p, q, b);
  37162. }
  37163. }
  37164. function scalarbase(p, s) {
  37165. var q = [gf(), gf(), gf(), gf()];
  37166. set25519(q[0], X);
  37167. set25519(q[1], Y);
  37168. set25519(q[2], gf1);
  37169. M(q[3], X, Y);
  37170. scalarmult(p, q, s);
  37171. }
  37172. function crypto_sign_keypair(pk, sk, seeded) {
  37173. var d = new Uint8Array(64);
  37174. var p = [gf(), gf(), gf(), gf()];
  37175. var i;
  37176. if (!seeded) randombytes(sk, 32);
  37177. crypto_hash(d, sk, 32);
  37178. d[0] &= 248;
  37179. d[31] &= 127;
  37180. d[31] |= 64;
  37181. scalarbase(p, d);
  37182. pack(pk, p);
  37183. for (i = 0; i < 32; i++) sk[i+32] = pk[i];
  37184. return 0;
  37185. }
  37186. 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]);
  37187. function modL(r, x) {
  37188. var carry, i, j, k;
  37189. for (i = 63; i >= 32; --i) {
  37190. carry = 0;
  37191. for (j = i - 32, k = i - 12; j < k; ++j) {
  37192. x[j] += carry - 16 * x[i] * L[j - (i - 32)];
  37193. carry = (x[j] + 128) >> 8;
  37194. x[j] -= carry * 256;
  37195. }
  37196. x[j] += carry;
  37197. x[i] = 0;
  37198. }
  37199. carry = 0;
  37200. for (j = 0; j < 32; j++) {
  37201. x[j] += carry - (x[31] >> 4) * L[j];
  37202. carry = x[j] >> 8;
  37203. x[j] &= 255;
  37204. }
  37205. for (j = 0; j < 32; j++) x[j] -= carry * L[j];
  37206. for (i = 0; i < 32; i++) {
  37207. x[i+1] += x[i] >> 8;
  37208. r[i] = x[i] & 255;
  37209. }
  37210. }
  37211. function reduce(r) {
  37212. var x = new Float64Array(64), i;
  37213. for (i = 0; i < 64; i++) x[i] = r[i];
  37214. for (i = 0; i < 64; i++) r[i] = 0;
  37215. modL(r, x);
  37216. }
  37217. // Note: difference from C - smlen returned, not passed as argument.
  37218. function crypto_sign(sm, m, n, sk) {
  37219. var d = new Uint8Array(64), h = new Uint8Array(64), r = new Uint8Array(64);
  37220. var i, j, x = new Float64Array(64);
  37221. var p = [gf(), gf(), gf(), gf()];
  37222. crypto_hash(d, sk, 32);
  37223. d[0] &= 248;
  37224. d[31] &= 127;
  37225. d[31] |= 64;
  37226. var smlen = n + 64;
  37227. for (i = 0; i < n; i++) sm[64 + i] = m[i];
  37228. for (i = 0; i < 32; i++) sm[32 + i] = d[32 + i];
  37229. crypto_hash(r, sm.subarray(32), n+32);
  37230. reduce(r);
  37231. scalarbase(p, r);
  37232. pack(sm, p);
  37233. for (i = 32; i < 64; i++) sm[i] = sk[i];
  37234. crypto_hash(h, sm, n + 64);
  37235. reduce(h);
  37236. for (i = 0; i < 64; i++) x[i] = 0;
  37237. for (i = 0; i < 32; i++) x[i] = r[i];
  37238. for (i = 0; i < 32; i++) {
  37239. for (j = 0; j < 32; j++) {
  37240. x[i+j] += h[i] * d[j];
  37241. }
  37242. }
  37243. modL(sm.subarray(32), x);
  37244. return smlen;
  37245. }
  37246. function unpackneg(r, p) {
  37247. var t = gf(), chk = gf(), num = gf(),
  37248. den = gf(), den2 = gf(), den4 = gf(),
  37249. den6 = gf();
  37250. set25519(r[2], gf1);
  37251. unpack25519(r[1], p);
  37252. S(num, r[1]);
  37253. M(den, num, D);
  37254. Z(num, num, r[2]);
  37255. A(den, r[2], den);
  37256. S(den2, den);
  37257. S(den4, den2);
  37258. M(den6, den4, den2);
  37259. M(t, den6, num);
  37260. M(t, t, den);
  37261. pow2523(t, t);
  37262. M(t, t, num);
  37263. M(t, t, den);
  37264. M(t, t, den);
  37265. M(r[0], t, den);
  37266. S(chk, r[0]);
  37267. M(chk, chk, den);
  37268. if (neq25519(chk, num)) M(r[0], r[0], I);
  37269. S(chk, r[0]);
  37270. M(chk, chk, den);
  37271. if (neq25519(chk, num)) return -1;
  37272. if (par25519(r[0]) === (p[31]>>7)) Z(r[0], gf0, r[0]);
  37273. M(r[3], r[0], r[1]);
  37274. return 0;
  37275. }
  37276. function crypto_sign_open(m, sm, n, pk) {
  37277. var i, mlen;
  37278. var t = new Uint8Array(32), h = new Uint8Array(64);
  37279. var p = [gf(), gf(), gf(), gf()],
  37280. q = [gf(), gf(), gf(), gf()];
  37281. mlen = -1;
  37282. if (n < 64) return -1;
  37283. if (unpackneg(q, pk)) return -1;
  37284. for (i = 0; i < n; i++) m[i] = sm[i];
  37285. for (i = 0; i < 32; i++) m[i+32] = pk[i];
  37286. crypto_hash(h, m, n);
  37287. reduce(h);
  37288. scalarmult(p, q, h);
  37289. scalarbase(q, sm.subarray(32));
  37290. add(p, q);
  37291. pack(t, p);
  37292. n -= 64;
  37293. if (crypto_verify_32(sm, 0, t, 0)) {
  37294. for (i = 0; i < n; i++) m[i] = 0;
  37295. return -1;
  37296. }
  37297. for (i = 0; i < n; i++) m[i] = sm[i + 64];
  37298. mlen = n;
  37299. return mlen;
  37300. }
  37301. var crypto_secretbox_KEYBYTES = 32,
  37302. crypto_secretbox_NONCEBYTES = 24,
  37303. crypto_secretbox_ZEROBYTES = 32,
  37304. crypto_secretbox_BOXZEROBYTES = 16,
  37305. crypto_scalarmult_BYTES = 32,
  37306. crypto_scalarmult_SCALARBYTES = 32,
  37307. crypto_box_PUBLICKEYBYTES = 32,
  37308. crypto_box_SECRETKEYBYTES = 32,
  37309. crypto_box_BEFORENMBYTES = 32,
  37310. crypto_box_NONCEBYTES = crypto_secretbox_NONCEBYTES,
  37311. crypto_box_ZEROBYTES = crypto_secretbox_ZEROBYTES,
  37312. crypto_box_BOXZEROBYTES = crypto_secretbox_BOXZEROBYTES,
  37313. crypto_sign_BYTES = 64,
  37314. crypto_sign_PUBLICKEYBYTES = 32,
  37315. crypto_sign_SECRETKEYBYTES = 64,
  37316. crypto_sign_SEEDBYTES = 32,
  37317. crypto_hash_BYTES = 64;
  37318. nacl.lowlevel = {
  37319. crypto_core_hsalsa20: crypto_core_hsalsa20,
  37320. crypto_stream_xor: crypto_stream_xor,
  37321. crypto_stream: crypto_stream,
  37322. crypto_stream_salsa20_xor: crypto_stream_salsa20_xor,
  37323. crypto_stream_salsa20: crypto_stream_salsa20,
  37324. crypto_onetimeauth: crypto_onetimeauth,
  37325. crypto_onetimeauth_verify: crypto_onetimeauth_verify,
  37326. crypto_verify_16: crypto_verify_16,
  37327. crypto_verify_32: crypto_verify_32,
  37328. crypto_secretbox: crypto_secretbox,
  37329. crypto_secretbox_open: crypto_secretbox_open,
  37330. crypto_scalarmult: crypto_scalarmult,
  37331. crypto_scalarmult_base: crypto_scalarmult_base,
  37332. crypto_box_beforenm: crypto_box_beforenm,
  37333. crypto_box_afternm: crypto_box_afternm,
  37334. crypto_box: crypto_box,
  37335. crypto_box_open: crypto_box_open,
  37336. crypto_box_keypair: crypto_box_keypair,
  37337. crypto_hash: crypto_hash,
  37338. crypto_sign: crypto_sign,
  37339. crypto_sign_keypair: crypto_sign_keypair,
  37340. crypto_sign_open: crypto_sign_open,
  37341. crypto_secretbox_KEYBYTES: crypto_secretbox_KEYBYTES,
  37342. crypto_secretbox_NONCEBYTES: crypto_secretbox_NONCEBYTES,
  37343. crypto_secretbox_ZEROBYTES: crypto_secretbox_ZEROBYTES,
  37344. crypto_secretbox_BOXZEROBYTES: crypto_secretbox_BOXZEROBYTES,
  37345. crypto_scalarmult_BYTES: crypto_scalarmult_BYTES,
  37346. crypto_scalarmult_SCALARBYTES: crypto_scalarmult_SCALARBYTES,
  37347. crypto_box_PUBLICKEYBYTES: crypto_box_PUBLICKEYBYTES,
  37348. crypto_box_SECRETKEYBYTES: crypto_box_SECRETKEYBYTES,
  37349. crypto_box_BEFORENMBYTES: crypto_box_BEFORENMBYTES,
  37350. crypto_box_NONCEBYTES: crypto_box_NONCEBYTES,
  37351. crypto_box_ZEROBYTES: crypto_box_ZEROBYTES,
  37352. crypto_box_BOXZEROBYTES: crypto_box_BOXZEROBYTES,
  37353. crypto_sign_BYTES: crypto_sign_BYTES,
  37354. crypto_sign_PUBLICKEYBYTES: crypto_sign_PUBLICKEYBYTES,
  37355. crypto_sign_SECRETKEYBYTES: crypto_sign_SECRETKEYBYTES,
  37356. crypto_sign_SEEDBYTES: crypto_sign_SEEDBYTES,
  37357. crypto_hash_BYTES: crypto_hash_BYTES
  37358. };
  37359. /* High-level API */
  37360. function checkLengths(k, n) {
  37361. if (k.length !== crypto_secretbox_KEYBYTES) throw new Error('bad key size');
  37362. if (n.length !== crypto_secretbox_NONCEBYTES) throw new Error('bad nonce size');
  37363. }
  37364. function checkBoxLengths(pk, sk) {
  37365. if (pk.length !== crypto_box_PUBLICKEYBYTES) throw new Error('bad public key size');
  37366. if (sk.length !== crypto_box_SECRETKEYBYTES) throw new Error('bad secret key size');
  37367. }
  37368. function checkArrayTypes() {
  37369. for (var i = 0; i < arguments.length; i++) {
  37370. if (!(arguments[i] instanceof Uint8Array))
  37371. throw new TypeError('unexpected type, use Uint8Array');
  37372. }
  37373. }
  37374. function cleanup(arr) {
  37375. for (var i = 0; i < arr.length; i++) arr[i] = 0;
  37376. }
  37377. nacl.randomBytes = function(n) {
  37378. var b = new Uint8Array(n);
  37379. randombytes(b, n);
  37380. return b;
  37381. };
  37382. nacl.secretbox = function(msg, nonce, key) {
  37383. checkArrayTypes(msg, nonce, key);
  37384. checkLengths(key, nonce);
  37385. var m = new Uint8Array(crypto_secretbox_ZEROBYTES + msg.length);
  37386. var c = new Uint8Array(m.length);
  37387. for (var i = 0; i < msg.length; i++) m[i+crypto_secretbox_ZEROBYTES] = msg[i];
  37388. crypto_secretbox(c, m, m.length, nonce, key);
  37389. return c.subarray(crypto_secretbox_BOXZEROBYTES);
  37390. };
  37391. nacl.secretbox.open = function(box, nonce, key) {
  37392. checkArrayTypes(box, nonce, key);
  37393. checkLengths(key, nonce);
  37394. var c = new Uint8Array(crypto_secretbox_BOXZEROBYTES + box.length);
  37395. var m = new Uint8Array(c.length);
  37396. for (var i = 0; i < box.length; i++) c[i+crypto_secretbox_BOXZEROBYTES] = box[i];
  37397. if (c.length < 32) return null;
  37398. if (crypto_secretbox_open(m, c, c.length, nonce, key) !== 0) return null;
  37399. return m.subarray(crypto_secretbox_ZEROBYTES);
  37400. };
  37401. nacl.secretbox.keyLength = crypto_secretbox_KEYBYTES;
  37402. nacl.secretbox.nonceLength = crypto_secretbox_NONCEBYTES;
  37403. nacl.secretbox.overheadLength = crypto_secretbox_BOXZEROBYTES;
  37404. nacl.scalarMult = function(n, p) {
  37405. checkArrayTypes(n, p);
  37406. if (n.length !== crypto_scalarmult_SCALARBYTES) throw new Error('bad n size');
  37407. if (p.length !== crypto_scalarmult_BYTES) throw new Error('bad p size');
  37408. var q = new Uint8Array(crypto_scalarmult_BYTES);
  37409. crypto_scalarmult(q, n, p);
  37410. return q;
  37411. };
  37412. nacl.scalarMult.base = function(n) {
  37413. checkArrayTypes(n);
  37414. if (n.length !== crypto_scalarmult_SCALARBYTES) throw new Error('bad n size');
  37415. var q = new Uint8Array(crypto_scalarmult_BYTES);
  37416. crypto_scalarmult_base(q, n);
  37417. return q;
  37418. };
  37419. nacl.scalarMult.scalarLength = crypto_scalarmult_SCALARBYTES;
  37420. nacl.scalarMult.groupElementLength = crypto_scalarmult_BYTES;
  37421. nacl.box = function(msg, nonce, publicKey, secretKey) {
  37422. var k = nacl.box.before(publicKey, secretKey);
  37423. return nacl.secretbox(msg, nonce, k);
  37424. };
  37425. nacl.box.before = function(publicKey, secretKey) {
  37426. checkArrayTypes(publicKey, secretKey);
  37427. checkBoxLengths(publicKey, secretKey);
  37428. var k = new Uint8Array(crypto_box_BEFORENMBYTES);
  37429. crypto_box_beforenm(k, publicKey, secretKey);
  37430. return k;
  37431. };
  37432. nacl.box.after = nacl.secretbox;
  37433. nacl.box.open = function(msg, nonce, publicKey, secretKey) {
  37434. var k = nacl.box.before(publicKey, secretKey);
  37435. return nacl.secretbox.open(msg, nonce, k);
  37436. };
  37437. nacl.box.open.after = nacl.secretbox.open;
  37438. nacl.box.keyPair = function() {
  37439. var pk = new Uint8Array(crypto_box_PUBLICKEYBYTES);
  37440. var sk = new Uint8Array(crypto_box_SECRETKEYBYTES);
  37441. crypto_box_keypair(pk, sk);
  37442. return {publicKey: pk, secretKey: sk};
  37443. };
  37444. nacl.box.keyPair.fromSecretKey = function(secretKey) {
  37445. checkArrayTypes(secretKey);
  37446. if (secretKey.length !== crypto_box_SECRETKEYBYTES)
  37447. throw new Error('bad secret key size');
  37448. var pk = new Uint8Array(crypto_box_PUBLICKEYBYTES);
  37449. crypto_scalarmult_base(pk, secretKey);
  37450. return {publicKey: pk, secretKey: new Uint8Array(secretKey)};
  37451. };
  37452. nacl.box.publicKeyLength = crypto_box_PUBLICKEYBYTES;
  37453. nacl.box.secretKeyLength = crypto_box_SECRETKEYBYTES;
  37454. nacl.box.sharedKeyLength = crypto_box_BEFORENMBYTES;
  37455. nacl.box.nonceLength = crypto_box_NONCEBYTES;
  37456. nacl.box.overheadLength = nacl.secretbox.overheadLength;
  37457. nacl.sign = function(msg, secretKey) {
  37458. checkArrayTypes(msg, secretKey);
  37459. if (secretKey.length !== crypto_sign_SECRETKEYBYTES)
  37460. throw new Error('bad secret key size');
  37461. var signedMsg = new Uint8Array(crypto_sign_BYTES+msg.length);
  37462. crypto_sign(signedMsg, msg, msg.length, secretKey);
  37463. return signedMsg;
  37464. };
  37465. nacl.sign.open = function(signedMsg, publicKey) {
  37466. checkArrayTypes(signedMsg, publicKey);
  37467. if (publicKey.length !== crypto_sign_PUBLICKEYBYTES)
  37468. throw new Error('bad public key size');
  37469. var tmp = new Uint8Array(signedMsg.length);
  37470. var mlen = crypto_sign_open(tmp, signedMsg, signedMsg.length, publicKey);
  37471. if (mlen < 0) return null;
  37472. var m = new Uint8Array(mlen);
  37473. for (var i = 0; i < m.length; i++) m[i] = tmp[i];
  37474. return m;
  37475. };
  37476. nacl.sign.detached = function(msg, secretKey) {
  37477. var signedMsg = nacl.sign(msg, secretKey);
  37478. var sig = new Uint8Array(crypto_sign_BYTES);
  37479. for (var i = 0; i < sig.length; i++) sig[i] = signedMsg[i];
  37480. return sig;
  37481. };
  37482. nacl.sign.detached.verify = function(msg, sig, publicKey) {
  37483. checkArrayTypes(msg, sig, publicKey);
  37484. if (sig.length !== crypto_sign_BYTES)
  37485. throw new Error('bad signature size');
  37486. if (publicKey.length !== crypto_sign_PUBLICKEYBYTES)
  37487. throw new Error('bad public key size');
  37488. var sm = new Uint8Array(crypto_sign_BYTES + msg.length);
  37489. var m = new Uint8Array(crypto_sign_BYTES + msg.length);
  37490. var i;
  37491. for (i = 0; i < crypto_sign_BYTES; i++) sm[i] = sig[i];
  37492. for (i = 0; i < msg.length; i++) sm[i+crypto_sign_BYTES] = msg[i];
  37493. return (crypto_sign_open(m, sm, sm.length, publicKey) >= 0);
  37494. };
  37495. nacl.sign.keyPair = function() {
  37496. var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);
  37497. var sk = new Uint8Array(crypto_sign_SECRETKEYBYTES);
  37498. crypto_sign_keypair(pk, sk);
  37499. return {publicKey: pk, secretKey: sk};
  37500. };
  37501. nacl.sign.keyPair.fromSecretKey = function(secretKey) {
  37502. checkArrayTypes(secretKey);
  37503. if (secretKey.length !== crypto_sign_SECRETKEYBYTES)
  37504. throw new Error('bad secret key size');
  37505. var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);
  37506. for (var i = 0; i < pk.length; i++) pk[i] = secretKey[32+i];
  37507. return {publicKey: pk, secretKey: new Uint8Array(secretKey)};
  37508. };
  37509. nacl.sign.keyPair.fromSeed = function(seed) {
  37510. checkArrayTypes(seed);
  37511. if (seed.length !== crypto_sign_SEEDBYTES)
  37512. throw new Error('bad seed size');
  37513. var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);
  37514. var sk = new Uint8Array(crypto_sign_SECRETKEYBYTES);
  37515. for (var i = 0; i < 32; i++) sk[i] = seed[i];
  37516. crypto_sign_keypair(pk, sk, true);
  37517. return {publicKey: pk, secretKey: sk};
  37518. };
  37519. nacl.sign.publicKeyLength = crypto_sign_PUBLICKEYBYTES;
  37520. nacl.sign.secretKeyLength = crypto_sign_SECRETKEYBYTES;
  37521. nacl.sign.seedLength = crypto_sign_SEEDBYTES;
  37522. nacl.sign.signatureLength = crypto_sign_BYTES;
  37523. nacl.hash = function(msg) {
  37524. checkArrayTypes(msg);
  37525. var h = new Uint8Array(crypto_hash_BYTES);
  37526. crypto_hash(h, msg, msg.length);
  37527. return h;
  37528. };
  37529. nacl.hash.hashLength = crypto_hash_BYTES;
  37530. nacl.verify = function(x, y) {
  37531. checkArrayTypes(x, y);
  37532. // Zero length arguments are considered not equal.
  37533. if (x.length === 0 || y.length === 0) return false;
  37534. if (x.length !== y.length) return false;
  37535. return (vn(x, 0, y, 0, x.length) === 0) ? true : false;
  37536. };
  37537. nacl.setPRNG = function(fn) {
  37538. randombytes = fn;
  37539. };
  37540. (function() {
  37541. // Initialize PRNG if environment provides CSPRNG.
  37542. // If not, methods calling randombytes will throw.
  37543. var crypto = typeof self !== 'undefined' ? (self.crypto || self.msCrypto) : null;
  37544. if (crypto && crypto.getRandomValues) {
  37545. // Browsers.
  37546. var QUOTA = 65536;
  37547. nacl.setPRNG(function(x, n) {
  37548. var i, v = new Uint8Array(n);
  37549. for (i = 0; i < n; i += QUOTA) {
  37550. crypto.getRandomValues(v.subarray(i, i + Math.min(n - i, QUOTA)));
  37551. }
  37552. for (i = 0; i < n; i++) x[i] = v[i];
  37553. cleanup(v);
  37554. });
  37555. } else if (true) {
  37556. // Node.js.
  37557. crypto = __webpack_require__(3);
  37558. if (crypto && crypto.randomBytes) {
  37559. nacl.setPRNG(function(x, n) {
  37560. var i, v = crypto.randomBytes(n);
  37561. for (i = 0; i < n; i++) x[i] = v[i];
  37562. cleanup(v);
  37563. });
  37564. }
  37565. }
  37566. })();
  37567. })( true && module.exports ? module.exports : (self.nacl = self.nacl || {}));
  37568. /***/ }),
  37569. /* 1 */
  37570. /***/ (function(module, exports, __webpack_require__) {
  37571. // Written in 2014-2016 by Dmitry Chestnykh and Devi Mandiri.
  37572. // Public domain.
  37573. (function(root, f) {
  37574. 'use strict';
  37575. if ( true && module.exports) module.exports = f();
  37576. else if (root.nacl) root.nacl.util = f();
  37577. else {
  37578. root.nacl = {};
  37579. root.nacl.util = f();
  37580. }
  37581. }(this, function() {
  37582. 'use strict';
  37583. var util = {};
  37584. function validateBase64(s) {
  37585. if (!(/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(s))) {
  37586. throw new TypeError('invalid encoding');
  37587. }
  37588. }
  37589. util.decodeUTF8 = function(s) {
  37590. if (typeof s !== 'string') throw new TypeError('expected string');
  37591. var i, d = unescape(encodeURIComponent(s)), b = new Uint8Array(d.length);
  37592. for (i = 0; i < d.length; i++) b[i] = d.charCodeAt(i);
  37593. return b;
  37594. };
  37595. util.encodeUTF8 = function(arr) {
  37596. var i, s = [];
  37597. for (i = 0; i < arr.length; i++) s.push(String.fromCharCode(arr[i]));
  37598. return decodeURIComponent(escape(s.join('')));
  37599. };
  37600. if (typeof atob === 'undefined') {
  37601. // Node.js
  37602. if (typeof Buffer.from !== 'undefined') {
  37603. // Node v6 and later
  37604. util.encodeBase64 = function (arr) { // v6 and later
  37605. return Buffer.from(arr).toString('base64');
  37606. };
  37607. util.decodeBase64 = function (s) {
  37608. validateBase64(s);
  37609. return new Uint8Array(Array.prototype.slice.call(Buffer.from(s, 'base64'), 0));
  37610. };
  37611. } else {
  37612. // Node earlier than v6
  37613. util.encodeBase64 = function (arr) { // v6 and later
  37614. return (new Buffer(arr)).toString('base64');
  37615. };
  37616. util.decodeBase64 = function(s) {
  37617. validateBase64(s);
  37618. return new Uint8Array(Array.prototype.slice.call(new Buffer(s, 'base64'), 0));
  37619. };
  37620. }
  37621. } else {
  37622. // Browsers
  37623. util.encodeBase64 = function(arr) {
  37624. var i, s = [], len = arr.length;
  37625. for (i = 0; i < len; i++) s.push(String.fromCharCode(arr[i]));
  37626. return btoa(s.join(''));
  37627. };
  37628. util.decodeBase64 = function(s) {
  37629. validateBase64(s);
  37630. var i, d = atob(s), b = new Uint8Array(d.length);
  37631. for (i = 0; i < d.length; i++) b[i] = d.charCodeAt(i);
  37632. return b;
  37633. };
  37634. }
  37635. return util;
  37636. }));
  37637. /***/ }),
  37638. /* 2 */
  37639. /***/ (function(module, exports, __webpack_require__) {
  37640. // required so we don't have to do require('pusher').default etc.
  37641. module.exports = __webpack_require__(4).default;
  37642. /***/ }),
  37643. /* 3 */
  37644. /***/ (function(module, exports) {
  37645. /* (ignored) */
  37646. /***/ }),
  37647. /* 4 */
  37648. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  37649. "use strict";
  37650. __webpack_require__.r(__webpack_exports__);
  37651. // CONCATENATED MODULE: ./src/runtimes/web/dom/script_receiver_factory.ts
  37652. var ScriptReceiverFactory = (function () {
  37653. function ScriptReceiverFactory(prefix, name) {
  37654. this.lastId = 0;
  37655. this.prefix = prefix;
  37656. this.name = name;
  37657. }
  37658. ScriptReceiverFactory.prototype.create = function (callback) {
  37659. this.lastId++;
  37660. var number = this.lastId;
  37661. var id = this.prefix + number;
  37662. var name = this.name + "[" + number + "]";
  37663. var called = false;
  37664. var callbackWrapper = function () {
  37665. if (!called) {
  37666. callback.apply(null, arguments);
  37667. called = true;
  37668. }
  37669. };
  37670. this[number] = callbackWrapper;
  37671. return { number: number, id: id, name: name, callback: callbackWrapper };
  37672. };
  37673. ScriptReceiverFactory.prototype.remove = function (receiver) {
  37674. delete this[receiver.number];
  37675. };
  37676. return ScriptReceiverFactory;
  37677. }());
  37678. var ScriptReceivers = new ScriptReceiverFactory("_pusher_script_", "Pusher.ScriptReceivers");
  37679. // CONCATENATED MODULE: ./src/core/defaults.ts
  37680. var Defaults = {
  37681. VERSION: "5.0.3",
  37682. PROTOCOL: 7,
  37683. host: 'ws.pusherapp.com',
  37684. ws_port: 80,
  37685. wss_port: 443,
  37686. ws_path: '',
  37687. sockjs_host: 'sockjs.pusher.com',
  37688. sockjs_http_port: 80,
  37689. sockjs_https_port: 443,
  37690. sockjs_path: '/pusher',
  37691. stats_host: 'stats.pusher.com',
  37692. channel_auth_endpoint: '/pusher/auth',
  37693. channel_auth_transport: 'ajax',
  37694. activity_timeout: 120000,
  37695. pong_timeout: 30000,
  37696. unavailable_timeout: 10000,
  37697. cdn_http: "http://js.pusher.com",
  37698. cdn_https: "https://js.pusher.com",
  37699. dependency_suffix: ""
  37700. };
  37701. /* harmony default export */ var defaults = (Defaults);
  37702. // CONCATENATED MODULE: ./src/runtimes/web/dom/dependency_loader.ts
  37703. var dependency_loader_DependencyLoader = (function () {
  37704. function DependencyLoader(options) {
  37705. this.options = options;
  37706. this.receivers = options.receivers || ScriptReceivers;
  37707. this.loading = {};
  37708. }
  37709. DependencyLoader.prototype.load = function (name, options, callback) {
  37710. var self = this;
  37711. if (self.loading[name] && self.loading[name].length > 0) {
  37712. self.loading[name].push(callback);
  37713. }
  37714. else {
  37715. self.loading[name] = [callback];
  37716. var request = runtime.createScriptRequest(self.getPath(name, options));
  37717. var receiver = self.receivers.create(function (error) {
  37718. self.receivers.remove(receiver);
  37719. if (self.loading[name]) {
  37720. var callbacks = self.loading[name];
  37721. delete self.loading[name];
  37722. var successCallback = function (wasSuccessful) {
  37723. if (!wasSuccessful) {
  37724. request.cleanup();
  37725. }
  37726. };
  37727. for (var i = 0; i < callbacks.length; i++) {
  37728. callbacks[i](error, successCallback);
  37729. }
  37730. }
  37731. });
  37732. request.send(receiver);
  37733. }
  37734. };
  37735. DependencyLoader.prototype.getRoot = function (options) {
  37736. var cdn;
  37737. var protocol = runtime.getDocument().location.protocol;
  37738. if ((options && options.useTLS) || protocol === "https:") {
  37739. cdn = this.options.cdn_https;
  37740. }
  37741. else {
  37742. cdn = this.options.cdn_http;
  37743. }
  37744. return cdn.replace(/\/*$/, "") + "/" + this.options.version;
  37745. };
  37746. DependencyLoader.prototype.getPath = function (name, options) {
  37747. return this.getRoot(options) + '/' + name + this.options.suffix + '.js';
  37748. };
  37749. ;
  37750. return DependencyLoader;
  37751. }());
  37752. /* harmony default export */ var dependency_loader = (dependency_loader_DependencyLoader);
  37753. // CONCATENATED MODULE: ./src/runtimes/web/dom/dependencies.ts
  37754. var DependenciesReceivers = new ScriptReceiverFactory("_pusher_dependencies", "Pusher.DependenciesReceivers");
  37755. var Dependencies = new dependency_loader({
  37756. cdn_http: defaults.cdn_http,
  37757. cdn_https: defaults.cdn_https,
  37758. version: defaults.VERSION,
  37759. suffix: defaults.dependency_suffix,
  37760. receivers: DependenciesReceivers
  37761. });
  37762. // CONCATENATED MODULE: ./src/core/base64.ts
  37763. function encode(s) {
  37764. return btoa(utob(s));
  37765. }
  37766. var fromCharCode = String.fromCharCode;
  37767. var b64chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
  37768. var b64tab = {};
  37769. for (var base64_i = 0, l = b64chars.length; base64_i < l; base64_i++) {
  37770. b64tab[b64chars.charAt(base64_i)] = base64_i;
  37771. }
  37772. var cb_utob = function (c) {
  37773. var cc = c.charCodeAt(0);
  37774. return cc < 0x80
  37775. ? c
  37776. : cc < 0x800
  37777. ? fromCharCode(0xc0 | (cc >>> 6)) + fromCharCode(0x80 | (cc & 0x3f))
  37778. : fromCharCode(0xe0 | ((cc >>> 12) & 0x0f)) +
  37779. fromCharCode(0x80 | ((cc >>> 6) & 0x3f)) +
  37780. fromCharCode(0x80 | (cc & 0x3f));
  37781. };
  37782. var utob = function (u) {
  37783. return u.replace(/[^\x00-\x7F]/g, cb_utob);
  37784. };
  37785. var cb_encode = function (ccc) {
  37786. var padlen = [0, 2, 1][ccc.length % 3];
  37787. var ord = (ccc.charCodeAt(0) << 16) |
  37788. ((ccc.length > 1 ? ccc.charCodeAt(1) : 0) << 8) |
  37789. (ccc.length > 2 ? ccc.charCodeAt(2) : 0);
  37790. var chars = [
  37791. b64chars.charAt(ord >>> 18),
  37792. b64chars.charAt((ord >>> 12) & 63),
  37793. padlen >= 2 ? '=' : b64chars.charAt((ord >>> 6) & 63),
  37794. padlen >= 1 ? '=' : b64chars.charAt(ord & 63)
  37795. ];
  37796. return chars.join('');
  37797. };
  37798. var btoa = window.btoa ||
  37799. function (b) {
  37800. return b.replace(/[\s\S]{1,3}/g, cb_encode);
  37801. };
  37802. // CONCATENATED MODULE: ./src/core/utils/timers/abstract_timer.ts
  37803. var Timer = (function () {
  37804. function Timer(set, clear, delay, callback) {
  37805. var _this = this;
  37806. this.clear = clear;
  37807. this.timer = set(function () {
  37808. if (_this.timer) {
  37809. _this.timer = callback(_this.timer);
  37810. }
  37811. }, delay);
  37812. }
  37813. Timer.prototype.isRunning = function () {
  37814. return this.timer !== null;
  37815. };
  37816. Timer.prototype.ensureAborted = function () {
  37817. if (this.timer) {
  37818. this.clear(this.timer);
  37819. this.timer = null;
  37820. }
  37821. };
  37822. return Timer;
  37823. }());
  37824. /* harmony default export */ var abstract_timer = (Timer);
  37825. // CONCATENATED MODULE: ./src/core/utils/timers/index.ts
  37826. var __extends = (undefined && undefined.__extends) || (function () {
  37827. var extendStatics = function (d, b) {
  37828. extendStatics = Object.setPrototypeOf ||
  37829. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  37830. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  37831. return extendStatics(d, b);
  37832. };
  37833. return function (d, b) {
  37834. extendStatics(d, b);
  37835. function __() { this.constructor = d; }
  37836. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  37837. };
  37838. })();
  37839. function timers_clearTimeout(timer) {
  37840. window.clearTimeout(timer);
  37841. }
  37842. function timers_clearInterval(timer) {
  37843. window.clearInterval(timer);
  37844. }
  37845. var OneOffTimer = (function (_super) {
  37846. __extends(OneOffTimer, _super);
  37847. function OneOffTimer(delay, callback) {
  37848. return _super.call(this, setTimeout, timers_clearTimeout, delay, function (timer) {
  37849. callback();
  37850. return null;
  37851. }) || this;
  37852. }
  37853. return OneOffTimer;
  37854. }(abstract_timer));
  37855. var PeriodicTimer = (function (_super) {
  37856. __extends(PeriodicTimer, _super);
  37857. function PeriodicTimer(delay, callback) {
  37858. return _super.call(this, setInterval, timers_clearInterval, delay, function (timer) {
  37859. callback();
  37860. return timer;
  37861. }) || this;
  37862. }
  37863. return PeriodicTimer;
  37864. }(abstract_timer));
  37865. // CONCATENATED MODULE: ./src/core/util.ts
  37866. var Util = {
  37867. now: function () {
  37868. if (Date.now) {
  37869. return Date.now();
  37870. }
  37871. else {
  37872. return new Date().valueOf();
  37873. }
  37874. },
  37875. defer: function (callback) {
  37876. return new OneOffTimer(0, callback);
  37877. },
  37878. method: function (name) {
  37879. var args = [];
  37880. for (var _i = 1; _i < arguments.length; _i++) {
  37881. args[_i - 1] = arguments[_i];
  37882. }
  37883. var boundArguments = Array.prototype.slice.call(arguments, 1);
  37884. return function (object) {
  37885. return object[name].apply(object, boundArguments.concat(arguments));
  37886. };
  37887. }
  37888. };
  37889. /* harmony default export */ var util = (Util);
  37890. // CONCATENATED MODULE: ./src/core/utils/collections.ts
  37891. function extend(target) {
  37892. var sources = [];
  37893. for (var _i = 1; _i < arguments.length; _i++) {
  37894. sources[_i - 1] = arguments[_i];
  37895. }
  37896. for (var i = 0; i < sources.length; i++) {
  37897. var extensions = sources[i];
  37898. for (var property in extensions) {
  37899. if (extensions[property] && extensions[property].constructor &&
  37900. extensions[property].constructor === Object) {
  37901. target[property] = extend(target[property] || {}, extensions[property]);
  37902. }
  37903. else {
  37904. target[property] = extensions[property];
  37905. }
  37906. }
  37907. }
  37908. return target;
  37909. }
  37910. function stringify() {
  37911. var m = ["Pusher"];
  37912. for (var i = 0; i < arguments.length; i++) {
  37913. if (typeof arguments[i] === "string") {
  37914. m.push(arguments[i]);
  37915. }
  37916. else {
  37917. m.push(safeJSONStringify(arguments[i]));
  37918. }
  37919. }
  37920. return m.join(" : ");
  37921. }
  37922. function arrayIndexOf(array, item) {
  37923. var nativeIndexOf = Array.prototype.indexOf;
  37924. if (array === null) {
  37925. return -1;
  37926. }
  37927. if (nativeIndexOf && array.indexOf === nativeIndexOf) {
  37928. return array.indexOf(item);
  37929. }
  37930. for (var i = 0, l = array.length; i < l; i++) {
  37931. if (array[i] === item) {
  37932. return i;
  37933. }
  37934. }
  37935. return -1;
  37936. }
  37937. function objectApply(object, f) {
  37938. for (var key in object) {
  37939. if (Object.prototype.hasOwnProperty.call(object, key)) {
  37940. f(object[key], key, object);
  37941. }
  37942. }
  37943. }
  37944. function keys(object) {
  37945. var keys = [];
  37946. objectApply(object, function (_, key) {
  37947. keys.push(key);
  37948. });
  37949. return keys;
  37950. }
  37951. function values(object) {
  37952. var values = [];
  37953. objectApply(object, function (value) {
  37954. values.push(value);
  37955. });
  37956. return values;
  37957. }
  37958. function apply(array, f, context) {
  37959. for (var i = 0; i < array.length; i++) {
  37960. f.call(context || window, array[i], i, array);
  37961. }
  37962. }
  37963. function map(array, f) {
  37964. var result = [];
  37965. for (var i = 0; i < array.length; i++) {
  37966. result.push(f(array[i], i, array, result));
  37967. }
  37968. return result;
  37969. }
  37970. function mapObject(object, f) {
  37971. var result = {};
  37972. objectApply(object, function (value, key) {
  37973. result[key] = f(value);
  37974. });
  37975. return result;
  37976. }
  37977. function filter(array, test) {
  37978. test = test || function (value) { return !!value; };
  37979. var result = [];
  37980. for (var i = 0; i < array.length; i++) {
  37981. if (test(array[i], i, array, result)) {
  37982. result.push(array[i]);
  37983. }
  37984. }
  37985. return result;
  37986. }
  37987. function filterObject(object, test) {
  37988. var result = {};
  37989. objectApply(object, function (value, key) {
  37990. if ((test && test(value, key, object, result)) || Boolean(value)) {
  37991. result[key] = value;
  37992. }
  37993. });
  37994. return result;
  37995. }
  37996. function flatten(object) {
  37997. var result = [];
  37998. objectApply(object, function (value, key) {
  37999. result.push([key, value]);
  38000. });
  38001. return result;
  38002. }
  38003. function any(array, test) {
  38004. for (var i = 0; i < array.length; i++) {
  38005. if (test(array[i], i, array)) {
  38006. return true;
  38007. }
  38008. }
  38009. return false;
  38010. }
  38011. function collections_all(array, test) {
  38012. for (var i = 0; i < array.length; i++) {
  38013. if (!test(array[i], i, array)) {
  38014. return false;
  38015. }
  38016. }
  38017. return true;
  38018. }
  38019. function encodeParamsObject(data) {
  38020. return mapObject(data, function (value) {
  38021. if (typeof value === "object") {
  38022. value = safeJSONStringify(value);
  38023. }
  38024. return encodeURIComponent(encode(value.toString()));
  38025. });
  38026. }
  38027. function buildQueryString(data) {
  38028. var params = filterObject(data, function (value) {
  38029. return value !== undefined;
  38030. });
  38031. var query = map(flatten(encodeParamsObject(params)), util.method("join", "=")).join("&");
  38032. return query;
  38033. }
  38034. function decycleObject(object) {
  38035. var objects = [], paths = [];
  38036. return (function derez(value, path) {
  38037. var i, name, nu;
  38038. switch (typeof value) {
  38039. case 'object':
  38040. if (!value) {
  38041. return null;
  38042. }
  38043. for (i = 0; i < objects.length; i += 1) {
  38044. if (objects[i] === value) {
  38045. return { $ref: paths[i] };
  38046. }
  38047. }
  38048. objects.push(value);
  38049. paths.push(path);
  38050. if (Object.prototype.toString.apply(value) === '[object Array]') {
  38051. nu = [];
  38052. for (i = 0; i < value.length; i += 1) {
  38053. nu[i] = derez(value[i], path + '[' + i + ']');
  38054. }
  38055. }
  38056. else {
  38057. nu = {};
  38058. for (name in value) {
  38059. if (Object.prototype.hasOwnProperty.call(value, name)) {
  38060. nu[name] = derez(value[name], path + '[' + JSON.stringify(name) + ']');
  38061. }
  38062. }
  38063. }
  38064. return nu;
  38065. case 'number':
  38066. case 'string':
  38067. case 'boolean':
  38068. return value;
  38069. }
  38070. }(object, '$'));
  38071. }
  38072. function safeJSONStringify(source) {
  38073. try {
  38074. return JSON.stringify(source);
  38075. }
  38076. catch (e) {
  38077. return JSON.stringify(decycleObject(source));
  38078. }
  38079. }
  38080. // CONCATENATED MODULE: ./src/core/logger.ts
  38081. var logger_Logger = (function () {
  38082. function Logger() {
  38083. this.globalLog = function (message) {
  38084. if (window.console && window.console.log) {
  38085. window.console.log(message);
  38086. }
  38087. };
  38088. }
  38089. Logger.prototype.debug = function () {
  38090. var args = [];
  38091. for (var _i = 0; _i < arguments.length; _i++) {
  38092. args[_i] = arguments[_i];
  38093. }
  38094. this.log(this.globalLog, args);
  38095. };
  38096. Logger.prototype.warn = function () {
  38097. var args = [];
  38098. for (var _i = 0; _i < arguments.length; _i++) {
  38099. args[_i] = arguments[_i];
  38100. }
  38101. this.log(this.globalLogWarn, args);
  38102. };
  38103. Logger.prototype.error = function () {
  38104. var args = [];
  38105. for (var _i = 0; _i < arguments.length; _i++) {
  38106. args[_i] = arguments[_i];
  38107. }
  38108. this.log(this.globalLogError, args);
  38109. };
  38110. Logger.prototype.globalLogWarn = function (message) {
  38111. if (window.console && window.console.warn) {
  38112. window.console.warn(message);
  38113. }
  38114. else {
  38115. this.globalLog(message);
  38116. }
  38117. };
  38118. Logger.prototype.globalLogError = function (message) {
  38119. if (window.console && window.console.error) {
  38120. window.console.error(message);
  38121. }
  38122. else {
  38123. this.globalLogWarn(message);
  38124. }
  38125. };
  38126. Logger.prototype.log = function (defaultLoggingFunction) {
  38127. var args = [];
  38128. for (var _i = 1; _i < arguments.length; _i++) {
  38129. args[_i - 1] = arguments[_i];
  38130. }
  38131. var message = stringify.apply(this, arguments);
  38132. if (core_pusher.log) {
  38133. core_pusher.log(message);
  38134. }
  38135. else if (core_pusher.logToConsole) {
  38136. var log = defaultLoggingFunction.bind(this);
  38137. log(message);
  38138. }
  38139. };
  38140. return Logger;
  38141. }());
  38142. /* harmony default export */ var logger = (new logger_Logger());
  38143. // CONCATENATED MODULE: ./src/core/utils/url_store.ts
  38144. var urlStore = {
  38145. baseUrl: "https://pusher.com",
  38146. urls: {
  38147. authenticationEndpoint: {
  38148. path: "/docs/authenticating_users",
  38149. },
  38150. javascriptQuickStart: {
  38151. path: "/docs/javascript_quick_start"
  38152. },
  38153. triggeringClientEvents: {
  38154. path: "/docs/client_api_guide/client_events#trigger-events"
  38155. }
  38156. }
  38157. };
  38158. var buildLogSuffix = function (key) {
  38159. var urlPrefix = "See:";
  38160. var urlObj = urlStore.urls[key];
  38161. if (!urlObj)
  38162. return "";
  38163. var url;
  38164. if (urlObj.fullUrl) {
  38165. url = urlObj.fullUrl;
  38166. }
  38167. else if (urlObj.path) {
  38168. url = urlStore.baseUrl + urlObj.path;
  38169. }
  38170. if (!url)
  38171. return "";
  38172. return urlPrefix + " " + url;
  38173. };
  38174. /* harmony default export */ var url_store = ({ buildLogSuffix: buildLogSuffix });
  38175. // CONCATENATED MODULE: ./src/runtimes/isomorphic/auth/xhr_auth.ts
  38176. var ajax = function (context, socketId, callback) {
  38177. var self = this, xhr;
  38178. xhr = runtime.createXHR();
  38179. xhr.open("POST", self.options.authEndpoint, true);
  38180. xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
  38181. for (var headerName in this.authOptions.headers) {
  38182. xhr.setRequestHeader(headerName, this.authOptions.headers[headerName]);
  38183. }
  38184. xhr.onreadystatechange = function () {
  38185. if (xhr.readyState === 4) {
  38186. if (xhr.status === 200) {
  38187. var data, parsed = false;
  38188. try {
  38189. data = JSON.parse(xhr.responseText);
  38190. parsed = true;
  38191. }
  38192. catch (e) {
  38193. callback(true, 'JSON returned from auth endpoint was invalid, yet status code was 200. Data was: ' + xhr.responseText);
  38194. }
  38195. if (parsed) {
  38196. callback(false, data);
  38197. }
  38198. }
  38199. else {
  38200. var suffix = url_store.buildLogSuffix("authenticationEndpoint");
  38201. logger.error('Unable to retrieve auth string from auth endpoint - ' +
  38202. ("received status " + xhr.status + " from " + self.options.authEndpoint + ". ") +
  38203. ("Clients must be authenticated to join private or presence channels. " + suffix));
  38204. callback(true, xhr.status);
  38205. }
  38206. }
  38207. };
  38208. xhr.send(this.composeQuery(socketId));
  38209. return xhr;
  38210. };
  38211. /* harmony default export */ var xhr_auth = (ajax);
  38212. // CONCATENATED MODULE: ./src/runtimes/web/auth/jsonp_auth.ts
  38213. var jsonp = function (context, socketId, callback) {
  38214. if (this.authOptions.headers !== undefined) {
  38215. logger.warn('To send headers with the auth request, you must use AJAX, rather than JSONP.');
  38216. }
  38217. var callbackName = context.nextAuthCallbackID.toString();
  38218. context.nextAuthCallbackID++;
  38219. var document = context.getDocument();
  38220. var script = document.createElement("script");
  38221. context.auth_callbacks[callbackName] = function (data) {
  38222. callback(false, data);
  38223. };
  38224. var callback_name = "Pusher.auth_callbacks['" + callbackName + "']";
  38225. script.src = this.options.authEndpoint +
  38226. '?callback=' +
  38227. encodeURIComponent(callback_name) +
  38228. '&' +
  38229. this.composeQuery(socketId);
  38230. var head = document.getElementsByTagName("head")[0] || document.documentElement;
  38231. head.insertBefore(script, head.firstChild);
  38232. };
  38233. /* harmony default export */ var jsonp_auth = (jsonp);
  38234. // CONCATENATED MODULE: ./src/runtimes/web/dom/script_request.ts
  38235. var ScriptRequest = (function () {
  38236. function ScriptRequest(src) {
  38237. this.src = src;
  38238. }
  38239. ScriptRequest.prototype.send = function (receiver) {
  38240. var self = this;
  38241. var errorString = "Error loading " + self.src;
  38242. self.script = document.createElement("script");
  38243. self.script.id = receiver.id;
  38244. self.script.src = self.src;
  38245. self.script.type = "text/javascript";
  38246. self.script.charset = "UTF-8";
  38247. if (self.script.addEventListener) {
  38248. self.script.onerror = function () {
  38249. receiver.callback(errorString);
  38250. };
  38251. self.script.onload = function () {
  38252. receiver.callback(null);
  38253. };
  38254. }
  38255. else {
  38256. self.script.onreadystatechange = function () {
  38257. if (self.script.readyState === 'loaded' ||
  38258. self.script.readyState === 'complete') {
  38259. receiver.callback(null);
  38260. }
  38261. };
  38262. }
  38263. if (self.script.async === undefined && document.attachEvent &&
  38264. /opera/i.test(navigator.userAgent)) {
  38265. self.errorScript = document.createElement("script");
  38266. self.errorScript.id = receiver.id + "_error";
  38267. self.errorScript.text = receiver.name + "('" + errorString + "');";
  38268. self.script.async = self.errorScript.async = false;
  38269. }
  38270. else {
  38271. self.script.async = true;
  38272. }
  38273. var head = document.getElementsByTagName('head')[0];
  38274. head.insertBefore(self.script, head.firstChild);
  38275. if (self.errorScript) {
  38276. head.insertBefore(self.errorScript, self.script.nextSibling);
  38277. }
  38278. };
  38279. ScriptRequest.prototype.cleanup = function () {
  38280. if (this.script) {
  38281. this.script.onload = this.script.onerror = null;
  38282. this.script.onreadystatechange = null;
  38283. }
  38284. if (this.script && this.script.parentNode) {
  38285. this.script.parentNode.removeChild(this.script);
  38286. }
  38287. if (this.errorScript && this.errorScript.parentNode) {
  38288. this.errorScript.parentNode.removeChild(this.errorScript);
  38289. }
  38290. this.script = null;
  38291. this.errorScript = null;
  38292. };
  38293. return ScriptRequest;
  38294. }());
  38295. /* harmony default export */ var script_request = (ScriptRequest);
  38296. // CONCATENATED MODULE: ./src/runtimes/web/dom/jsonp_request.ts
  38297. var jsonp_request_JSONPRequest = (function () {
  38298. function JSONPRequest(url, data) {
  38299. this.url = url;
  38300. this.data = data;
  38301. }
  38302. JSONPRequest.prototype.send = function (receiver) {
  38303. if (this.request) {
  38304. return;
  38305. }
  38306. var query = buildQueryString(this.data);
  38307. var url = this.url + "/" + receiver.number + "?" + query;
  38308. this.request = runtime.createScriptRequest(url);
  38309. this.request.send(receiver);
  38310. };
  38311. JSONPRequest.prototype.cleanup = function () {
  38312. if (this.request) {
  38313. this.request.cleanup();
  38314. }
  38315. };
  38316. return JSONPRequest;
  38317. }());
  38318. /* harmony default export */ var jsonp_request = (jsonp_request_JSONPRequest);
  38319. // CONCATENATED MODULE: ./src/runtimes/web/timeline/jsonp_timeline.ts
  38320. var getAgent = function (sender, useTLS) {
  38321. return function (data, callback) {
  38322. var scheme = "http" + (useTLS ? "s" : "") + "://";
  38323. var url = scheme + (sender.host || sender.options.host) + sender.options.path;
  38324. var request = runtime.createJSONPRequest(url, data);
  38325. var receiver = runtime.ScriptReceivers.create(function (error, result) {
  38326. ScriptReceivers.remove(receiver);
  38327. request.cleanup();
  38328. if (result && result.host) {
  38329. sender.host = result.host;
  38330. }
  38331. if (callback) {
  38332. callback(error, result);
  38333. }
  38334. });
  38335. request.send(receiver);
  38336. };
  38337. };
  38338. var jsonp_timeline_jsonp = {
  38339. name: 'jsonp',
  38340. getAgent: getAgent
  38341. };
  38342. /* harmony default export */ var jsonp_timeline = (jsonp_timeline_jsonp);
  38343. // CONCATENATED MODULE: ./src/core/transports/url_schemes.ts
  38344. function getGenericURL(baseScheme, params, path) {
  38345. var scheme = baseScheme + (params.useTLS ? "s" : "");
  38346. var host = params.useTLS ? params.hostTLS : params.hostNonTLS;
  38347. return scheme + "://" + host + path;
  38348. }
  38349. function getGenericPath(key, queryString) {
  38350. var path = "/app/" + key;
  38351. var query = "?protocol=" + defaults.PROTOCOL +
  38352. "&client=js" +
  38353. "&version=" + defaults.VERSION +
  38354. (queryString ? ("&" + queryString) : "");
  38355. return path + query;
  38356. }
  38357. var ws = {
  38358. getInitial: function (key, params) {
  38359. var path = (params.httpPath || "") + getGenericPath(key, "flash=false");
  38360. return getGenericURL("ws", params, path);
  38361. }
  38362. };
  38363. var http = {
  38364. getInitial: function (key, params) {
  38365. var path = (params.httpPath || "/pusher") + getGenericPath(key);
  38366. return getGenericURL("http", params, path);
  38367. }
  38368. };
  38369. var sockjs = {
  38370. getInitial: function (key, params) {
  38371. return getGenericURL("http", params, params.httpPath || "/pusher");
  38372. },
  38373. getPath: function (key, params) {
  38374. return getGenericPath(key);
  38375. }
  38376. };
  38377. // CONCATENATED MODULE: ./src/core/events/callback_registry.ts
  38378. var callback_registry_CallbackRegistry = (function () {
  38379. function CallbackRegistry() {
  38380. this._callbacks = {};
  38381. }
  38382. CallbackRegistry.prototype.get = function (name) {
  38383. return this._callbacks[prefix(name)];
  38384. };
  38385. CallbackRegistry.prototype.add = function (name, callback, context) {
  38386. var prefixedEventName = prefix(name);
  38387. this._callbacks[prefixedEventName] = this._callbacks[prefixedEventName] || [];
  38388. this._callbacks[prefixedEventName].push({
  38389. fn: callback,
  38390. context: context
  38391. });
  38392. };
  38393. CallbackRegistry.prototype.remove = function (name, callback, context) {
  38394. if (!name && !callback && !context) {
  38395. this._callbacks = {};
  38396. return;
  38397. }
  38398. var names = name ? [prefix(name)] : keys(this._callbacks);
  38399. if (callback || context) {
  38400. this.removeCallback(names, callback, context);
  38401. }
  38402. else {
  38403. this.removeAllCallbacks(names);
  38404. }
  38405. };
  38406. CallbackRegistry.prototype.removeCallback = function (names, callback, context) {
  38407. apply(names, function (name) {
  38408. this._callbacks[name] = filter(this._callbacks[name] || [], function (binding) {
  38409. return (callback && callback !== binding.fn) ||
  38410. (context && context !== binding.context);
  38411. });
  38412. if (this._callbacks[name].length === 0) {
  38413. delete this._callbacks[name];
  38414. }
  38415. }, this);
  38416. };
  38417. CallbackRegistry.prototype.removeAllCallbacks = function (names) {
  38418. apply(names, function (name) {
  38419. delete this._callbacks[name];
  38420. }, this);
  38421. };
  38422. return CallbackRegistry;
  38423. }());
  38424. /* harmony default export */ var callback_registry = (callback_registry_CallbackRegistry);
  38425. function prefix(name) {
  38426. return "_" + name;
  38427. }
  38428. // CONCATENATED MODULE: ./src/core/events/dispatcher.ts
  38429. var dispatcher_Dispatcher = (function () {
  38430. function Dispatcher(failThrough) {
  38431. this.callbacks = new callback_registry();
  38432. this.global_callbacks = [];
  38433. this.failThrough = failThrough;
  38434. }
  38435. Dispatcher.prototype.bind = function (eventName, callback, context) {
  38436. this.callbacks.add(eventName, callback, context);
  38437. return this;
  38438. };
  38439. Dispatcher.prototype.bind_global = function (callback) {
  38440. this.global_callbacks.push(callback);
  38441. return this;
  38442. };
  38443. Dispatcher.prototype.unbind = function (eventName, callback, context) {
  38444. this.callbacks.remove(eventName, callback, context);
  38445. return this;
  38446. };
  38447. Dispatcher.prototype.unbind_global = function (callback) {
  38448. if (!callback) {
  38449. this.global_callbacks = [];
  38450. return this;
  38451. }
  38452. this.global_callbacks = filter(this.global_callbacks || [], function (c) { return c !== callback; });
  38453. return this;
  38454. };
  38455. Dispatcher.prototype.unbind_all = function () {
  38456. this.unbind();
  38457. this.unbind_global();
  38458. return this;
  38459. };
  38460. Dispatcher.prototype.emit = function (eventName, data, metadata) {
  38461. for (var i = 0; i < this.global_callbacks.length; i++) {
  38462. this.global_callbacks[i](eventName, data);
  38463. }
  38464. var callbacks = this.callbacks.get(eventName);
  38465. var args = [];
  38466. if (metadata) {
  38467. args.push(data, metadata);
  38468. }
  38469. else if (data) {
  38470. args.push(data);
  38471. }
  38472. if (callbacks && callbacks.length > 0) {
  38473. for (var i = 0; i < callbacks.length; i++) {
  38474. callbacks[i].fn.apply(callbacks[i].context || window, args);
  38475. }
  38476. }
  38477. else if (this.failThrough) {
  38478. this.failThrough(eventName, data);
  38479. }
  38480. return this;
  38481. };
  38482. return Dispatcher;
  38483. }());
  38484. /* harmony default export */ var dispatcher = (dispatcher_Dispatcher);
  38485. // CONCATENATED MODULE: ./src/core/transports/transport_connection.ts
  38486. var transport_connection_extends = (undefined && undefined.__extends) || (function () {
  38487. var extendStatics = function (d, b) {
  38488. extendStatics = Object.setPrototypeOf ||
  38489. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  38490. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  38491. return extendStatics(d, b);
  38492. };
  38493. return function (d, b) {
  38494. extendStatics(d, b);
  38495. function __() { this.constructor = d; }
  38496. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  38497. };
  38498. })();
  38499. var transport_connection_TransportConnection = (function (_super) {
  38500. transport_connection_extends(TransportConnection, _super);
  38501. function TransportConnection(hooks, name, priority, key, options) {
  38502. var _this = _super.call(this) || this;
  38503. _this.initialize = runtime.transportConnectionInitializer;
  38504. _this.hooks = hooks;
  38505. _this.name = name;
  38506. _this.priority = priority;
  38507. _this.key = key;
  38508. _this.options = options;
  38509. _this.state = "new";
  38510. _this.timeline = options.timeline;
  38511. _this.activityTimeout = options.activityTimeout;
  38512. _this.id = _this.timeline.generateUniqueID();
  38513. return _this;
  38514. }
  38515. TransportConnection.prototype.handlesActivityChecks = function () {
  38516. return Boolean(this.hooks.handlesActivityChecks);
  38517. };
  38518. TransportConnection.prototype.supportsPing = function () {
  38519. return Boolean(this.hooks.supportsPing);
  38520. };
  38521. TransportConnection.prototype.connect = function () {
  38522. var _this = this;
  38523. if (this.socket || this.state !== "initialized") {
  38524. return false;
  38525. }
  38526. var url = this.hooks.urls.getInitial(this.key, this.options);
  38527. try {
  38528. this.socket = this.hooks.getSocket(url, this.options);
  38529. }
  38530. catch (e) {
  38531. util.defer(function () {
  38532. _this.onError(e);
  38533. _this.changeState("closed");
  38534. });
  38535. return false;
  38536. }
  38537. this.bindListeners();
  38538. logger.debug("Connecting", { transport: this.name, url: url });
  38539. this.changeState("connecting");
  38540. return true;
  38541. };
  38542. TransportConnection.prototype.close = function () {
  38543. if (this.socket) {
  38544. this.socket.close();
  38545. return true;
  38546. }
  38547. else {
  38548. return false;
  38549. }
  38550. };
  38551. TransportConnection.prototype.send = function (data) {
  38552. var _this = this;
  38553. if (this.state === "open") {
  38554. util.defer(function () {
  38555. if (_this.socket) {
  38556. _this.socket.send(data);
  38557. }
  38558. });
  38559. return true;
  38560. }
  38561. else {
  38562. return false;
  38563. }
  38564. };
  38565. TransportConnection.prototype.ping = function () {
  38566. if (this.state === "open" && this.supportsPing()) {
  38567. this.socket.ping();
  38568. }
  38569. };
  38570. TransportConnection.prototype.onOpen = function () {
  38571. if (this.hooks.beforeOpen) {
  38572. this.hooks.beforeOpen(this.socket, this.hooks.urls.getPath(this.key, this.options));
  38573. }
  38574. this.changeState("open");
  38575. this.socket.onopen = undefined;
  38576. };
  38577. TransportConnection.prototype.onError = function (error) {
  38578. this.emit("error", { type: 'WebSocketError', error: error });
  38579. this.timeline.error(this.buildTimelineMessage({ error: error.toString() }));
  38580. };
  38581. TransportConnection.prototype.onClose = function (closeEvent) {
  38582. if (closeEvent) {
  38583. this.changeState("closed", {
  38584. code: closeEvent.code,
  38585. reason: closeEvent.reason,
  38586. wasClean: closeEvent.wasClean
  38587. });
  38588. }
  38589. else {
  38590. this.changeState("closed");
  38591. }
  38592. this.unbindListeners();
  38593. this.socket = undefined;
  38594. };
  38595. TransportConnection.prototype.onMessage = function (message) {
  38596. this.emit("message", message);
  38597. };
  38598. TransportConnection.prototype.onActivity = function () {
  38599. this.emit("activity");
  38600. };
  38601. TransportConnection.prototype.bindListeners = function () {
  38602. var _this = this;
  38603. this.socket.onopen = function () {
  38604. _this.onOpen();
  38605. };
  38606. this.socket.onerror = function (error) {
  38607. _this.onError(error);
  38608. };
  38609. this.socket.onclose = function (closeEvent) {
  38610. _this.onClose(closeEvent);
  38611. };
  38612. this.socket.onmessage = function (message) {
  38613. _this.onMessage(message);
  38614. };
  38615. if (this.supportsPing()) {
  38616. this.socket.onactivity = function () { _this.onActivity(); };
  38617. }
  38618. };
  38619. TransportConnection.prototype.unbindListeners = function () {
  38620. if (this.socket) {
  38621. this.socket.onopen = undefined;
  38622. this.socket.onerror = undefined;
  38623. this.socket.onclose = undefined;
  38624. this.socket.onmessage = undefined;
  38625. if (this.supportsPing()) {
  38626. this.socket.onactivity = undefined;
  38627. }
  38628. }
  38629. };
  38630. TransportConnection.prototype.changeState = function (state, params) {
  38631. this.state = state;
  38632. this.timeline.info(this.buildTimelineMessage({
  38633. state: state,
  38634. params: params
  38635. }));
  38636. this.emit(state, params);
  38637. };
  38638. TransportConnection.prototype.buildTimelineMessage = function (message) {
  38639. return extend({ cid: this.id }, message);
  38640. };
  38641. return TransportConnection;
  38642. }(dispatcher));
  38643. /* harmony default export */ var transport_connection = (transport_connection_TransportConnection);
  38644. // CONCATENATED MODULE: ./src/core/transports/transport.ts
  38645. var transport_Transport = (function () {
  38646. function Transport(hooks) {
  38647. this.hooks = hooks;
  38648. }
  38649. Transport.prototype.isSupported = function (environment) {
  38650. return this.hooks.isSupported(environment);
  38651. };
  38652. Transport.prototype.createConnection = function (name, priority, key, options) {
  38653. return new transport_connection(this.hooks, name, priority, key, options);
  38654. };
  38655. return Transport;
  38656. }());
  38657. /* harmony default export */ var transports_transport = (transport_Transport);
  38658. // CONCATENATED MODULE: ./src/runtimes/isomorphic/transports/transports.ts
  38659. var WSTransport = new transports_transport({
  38660. urls: ws,
  38661. handlesActivityChecks: false,
  38662. supportsPing: false,
  38663. isInitialized: function () {
  38664. return Boolean(runtime.getWebSocketAPI());
  38665. },
  38666. isSupported: function () {
  38667. return Boolean(runtime.getWebSocketAPI());
  38668. },
  38669. getSocket: function (url) {
  38670. return runtime.createWebSocket(url);
  38671. }
  38672. });
  38673. var httpConfiguration = {
  38674. urls: http,
  38675. handlesActivityChecks: false,
  38676. supportsPing: true,
  38677. isInitialized: function () {
  38678. return true;
  38679. }
  38680. };
  38681. var streamingConfiguration = extend({ getSocket: function (url) {
  38682. return runtime.HTTPFactory.createStreamingSocket(url);
  38683. }
  38684. }, httpConfiguration);
  38685. var pollingConfiguration = extend({ getSocket: function (url) {
  38686. return runtime.HTTPFactory.createPollingSocket(url);
  38687. }
  38688. }, httpConfiguration);
  38689. var xhrConfiguration = {
  38690. isSupported: function () {
  38691. return runtime.isXHRSupported();
  38692. }
  38693. };
  38694. var XHRStreamingTransport = new transports_transport(extend({}, streamingConfiguration, xhrConfiguration));
  38695. var XHRPollingTransport = new transports_transport(extend({}, pollingConfiguration, xhrConfiguration));
  38696. var Transports = {
  38697. ws: WSTransport,
  38698. xhr_streaming: XHRStreamingTransport,
  38699. xhr_polling: XHRPollingTransport
  38700. };
  38701. /* harmony default export */ var transports = (Transports);
  38702. // CONCATENATED MODULE: ./src/runtimes/web/transports/transports.ts
  38703. var SockJSTransport = new transports_transport({
  38704. file: "sockjs",
  38705. urls: sockjs,
  38706. handlesActivityChecks: true,
  38707. supportsPing: false,
  38708. isSupported: function () {
  38709. return true;
  38710. },
  38711. isInitialized: function () {
  38712. return window.SockJS !== undefined;
  38713. },
  38714. getSocket: function (url, options) {
  38715. return new window.SockJS(url, null, {
  38716. js_path: Dependencies.getPath("sockjs", {
  38717. useTLS: options.useTLS
  38718. }),
  38719. ignore_null_origin: options.ignoreNullOrigin
  38720. });
  38721. },
  38722. beforeOpen: function (socket, path) {
  38723. socket.send(JSON.stringify({
  38724. path: path
  38725. }));
  38726. }
  38727. });
  38728. var xdrConfiguration = {
  38729. isSupported: function (environment) {
  38730. var yes = runtime.isXDRSupported(environment.useTLS);
  38731. return yes;
  38732. }
  38733. };
  38734. var XDRStreamingTransport = new transports_transport(extend({}, streamingConfiguration, xdrConfiguration));
  38735. var XDRPollingTransport = new transports_transport(extend({}, pollingConfiguration, xdrConfiguration));
  38736. transports.xdr_streaming = XDRStreamingTransport;
  38737. transports.xdr_polling = XDRPollingTransport;
  38738. transports.sockjs = SockJSTransport;
  38739. /* harmony default export */ var transports_transports = (transports);
  38740. // CONCATENATED MODULE: ./src/runtimes/web/net_info.ts
  38741. var net_info_extends = (undefined && undefined.__extends) || (function () {
  38742. var extendStatics = function (d, b) {
  38743. extendStatics = Object.setPrototypeOf ||
  38744. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  38745. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  38746. return extendStatics(d, b);
  38747. };
  38748. return function (d, b) {
  38749. extendStatics(d, b);
  38750. function __() { this.constructor = d; }
  38751. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  38752. };
  38753. })();
  38754. var NetInfo = (function (_super) {
  38755. net_info_extends(NetInfo, _super);
  38756. function NetInfo() {
  38757. var _this = _super.call(this) || this;
  38758. var self = _this;
  38759. if (window.addEventListener !== undefined) {
  38760. window.addEventListener("online", function () {
  38761. self.emit('online');
  38762. }, false);
  38763. window.addEventListener("offline", function () {
  38764. self.emit('offline');
  38765. }, false);
  38766. }
  38767. return _this;
  38768. }
  38769. NetInfo.prototype.isOnline = function () {
  38770. if (window.navigator.onLine === undefined) {
  38771. return true;
  38772. }
  38773. else {
  38774. return window.navigator.onLine;
  38775. }
  38776. };
  38777. return NetInfo;
  38778. }(dispatcher));
  38779. var net_info_Network = new NetInfo();
  38780. // CONCATENATED MODULE: ./src/core/transports/assistant_to_the_transport_manager.ts
  38781. var assistant_to_the_transport_manager_AssistantToTheTransportManager = (function () {
  38782. function AssistantToTheTransportManager(manager, transport, options) {
  38783. this.manager = manager;
  38784. this.transport = transport;
  38785. this.minPingDelay = options.minPingDelay;
  38786. this.maxPingDelay = options.maxPingDelay;
  38787. this.pingDelay = undefined;
  38788. }
  38789. AssistantToTheTransportManager.prototype.createConnection = function (name, priority, key, options) {
  38790. var _this = this;
  38791. options = extend({}, options, {
  38792. activityTimeout: this.pingDelay
  38793. });
  38794. var connection = this.transport.createConnection(name, priority, key, options);
  38795. var openTimestamp = null;
  38796. var onOpen = function () {
  38797. connection.unbind("open", onOpen);
  38798. connection.bind("closed", onClosed);
  38799. openTimestamp = util.now();
  38800. };
  38801. var onClosed = function (closeEvent) {
  38802. connection.unbind("closed", onClosed);
  38803. if (closeEvent.code === 1002 || closeEvent.code === 1003) {
  38804. _this.manager.reportDeath();
  38805. }
  38806. else if (!closeEvent.wasClean && openTimestamp) {
  38807. var lifespan = util.now() - openTimestamp;
  38808. if (lifespan < 2 * _this.maxPingDelay) {
  38809. _this.manager.reportDeath();
  38810. _this.pingDelay = Math.max(lifespan / 2, _this.minPingDelay);
  38811. }
  38812. }
  38813. };
  38814. connection.bind("open", onOpen);
  38815. return connection;
  38816. };
  38817. AssistantToTheTransportManager.prototype.isSupported = function (environment) {
  38818. return this.manager.isAlive() && this.transport.isSupported(environment);
  38819. };
  38820. return AssistantToTheTransportManager;
  38821. }());
  38822. /* harmony default export */ var assistant_to_the_transport_manager = (assistant_to_the_transport_manager_AssistantToTheTransportManager);
  38823. // CONCATENATED MODULE: ./src/core/connection/protocol/protocol.ts
  38824. var Protocol = {
  38825. decodeMessage: function (messageEvent) {
  38826. try {
  38827. var messageData = JSON.parse(messageEvent.data);
  38828. var pusherEventData = messageData.data;
  38829. if (typeof pusherEventData === 'string') {
  38830. try {
  38831. pusherEventData = JSON.parse(messageData.data);
  38832. }
  38833. catch (e) { }
  38834. }
  38835. var pusherEvent = {
  38836. event: messageData.event,
  38837. channel: messageData.channel,
  38838. data: pusherEventData,
  38839. };
  38840. if (messageData.user_id) {
  38841. pusherEvent.user_id = messageData.user_id;
  38842. }
  38843. return pusherEvent;
  38844. }
  38845. catch (e) {
  38846. throw { type: 'MessageParseError', error: e, data: messageEvent.data };
  38847. }
  38848. },
  38849. encodeMessage: function (event) {
  38850. return JSON.stringify(event);
  38851. },
  38852. processHandshake: function (messageEvent) {
  38853. var message = Protocol.decodeMessage(messageEvent);
  38854. if (message.event === "pusher:connection_established") {
  38855. if (!message.data.activity_timeout) {
  38856. throw "No activity timeout specified in handshake";
  38857. }
  38858. return {
  38859. action: "connected",
  38860. id: message.data.socket_id,
  38861. activityTimeout: message.data.activity_timeout * 1000
  38862. };
  38863. }
  38864. else if (message.event === "pusher:error") {
  38865. return {
  38866. action: this.getCloseAction(message.data),
  38867. error: this.getCloseError(message.data)
  38868. };
  38869. }
  38870. else {
  38871. throw "Invalid handshake";
  38872. }
  38873. },
  38874. getCloseAction: function (closeEvent) {
  38875. if (closeEvent.code < 4000) {
  38876. if (closeEvent.code >= 1002 && closeEvent.code <= 1004) {
  38877. return "backoff";
  38878. }
  38879. else {
  38880. return null;
  38881. }
  38882. }
  38883. else if (closeEvent.code === 4000) {
  38884. return "tls_only";
  38885. }
  38886. else if (closeEvent.code < 4100) {
  38887. return "refused";
  38888. }
  38889. else if (closeEvent.code < 4200) {
  38890. return "backoff";
  38891. }
  38892. else if (closeEvent.code < 4300) {
  38893. return "retry";
  38894. }
  38895. else {
  38896. return "refused";
  38897. }
  38898. },
  38899. getCloseError: function (closeEvent) {
  38900. if (closeEvent.code !== 1000 && closeEvent.code !== 1001) {
  38901. return {
  38902. type: 'PusherError',
  38903. data: {
  38904. code: closeEvent.code,
  38905. message: closeEvent.reason || closeEvent.message
  38906. }
  38907. };
  38908. }
  38909. else {
  38910. return null;
  38911. }
  38912. }
  38913. };
  38914. /* harmony default export */ var protocol_protocol = (Protocol);
  38915. // CONCATENATED MODULE: ./src/core/connection/connection.ts
  38916. var connection_extends = (undefined && undefined.__extends) || (function () {
  38917. var extendStatics = function (d, b) {
  38918. extendStatics = Object.setPrototypeOf ||
  38919. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  38920. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  38921. return extendStatics(d, b);
  38922. };
  38923. return function (d, b) {
  38924. extendStatics(d, b);
  38925. function __() { this.constructor = d; }
  38926. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  38927. };
  38928. })();
  38929. var connection_Connection = (function (_super) {
  38930. connection_extends(Connection, _super);
  38931. function Connection(id, transport) {
  38932. var _this = _super.call(this) || this;
  38933. _this.id = id;
  38934. _this.transport = transport;
  38935. _this.activityTimeout = transport.activityTimeout;
  38936. _this.bindListeners();
  38937. return _this;
  38938. }
  38939. Connection.prototype.handlesActivityChecks = function () {
  38940. return this.transport.handlesActivityChecks();
  38941. };
  38942. Connection.prototype.send = function (data) {
  38943. return this.transport.send(data);
  38944. };
  38945. Connection.prototype.send_event = function (name, data, channel) {
  38946. var event = { event: name, data: data };
  38947. if (channel) {
  38948. event.channel = channel;
  38949. }
  38950. logger.debug('Event sent', event);
  38951. return this.send(protocol_protocol.encodeMessage(event));
  38952. };
  38953. Connection.prototype.ping = function () {
  38954. if (this.transport.supportsPing()) {
  38955. this.transport.ping();
  38956. }
  38957. else {
  38958. this.send_event('pusher:ping', {});
  38959. }
  38960. };
  38961. Connection.prototype.close = function () {
  38962. this.transport.close();
  38963. };
  38964. Connection.prototype.bindListeners = function () {
  38965. var _this = this;
  38966. var listeners = {
  38967. message: function (messageEvent) {
  38968. var pusherEvent;
  38969. try {
  38970. pusherEvent = protocol_protocol.decodeMessage(messageEvent);
  38971. }
  38972. catch (e) {
  38973. _this.emit('error', {
  38974. type: 'MessageParseError',
  38975. error: e,
  38976. data: messageEvent.data
  38977. });
  38978. }
  38979. if (pusherEvent !== undefined) {
  38980. logger.debug('Event recd', pusherEvent);
  38981. switch (pusherEvent.event) {
  38982. case 'pusher:error':
  38983. _this.emit('error', { type: 'PusherError', data: pusherEvent.data });
  38984. break;
  38985. case 'pusher:ping':
  38986. _this.emit("ping");
  38987. break;
  38988. case 'pusher:pong':
  38989. _this.emit("pong");
  38990. break;
  38991. }
  38992. _this.emit('message', pusherEvent);
  38993. }
  38994. },
  38995. activity: function () {
  38996. _this.emit("activity");
  38997. },
  38998. error: function (error) {
  38999. _this.emit("error", { type: "WebSocketError", error: error });
  39000. },
  39001. closed: function (closeEvent) {
  39002. unbindListeners();
  39003. if (closeEvent && closeEvent.code) {
  39004. _this.handleCloseEvent(closeEvent);
  39005. }
  39006. _this.transport = null;
  39007. _this.emit("closed");
  39008. }
  39009. };
  39010. var unbindListeners = function () {
  39011. objectApply(listeners, function (listener, event) {
  39012. _this.transport.unbind(event, listener);
  39013. });
  39014. };
  39015. objectApply(listeners, function (listener, event) {
  39016. _this.transport.bind(event, listener);
  39017. });
  39018. };
  39019. Connection.prototype.handleCloseEvent = function (closeEvent) {
  39020. var action = protocol_protocol.getCloseAction(closeEvent);
  39021. var error = protocol_protocol.getCloseError(closeEvent);
  39022. if (error) {
  39023. this.emit('error', error);
  39024. }
  39025. if (action) {
  39026. this.emit(action, { action: action, error: error });
  39027. }
  39028. };
  39029. return Connection;
  39030. }(dispatcher));
  39031. /* harmony default export */ var connection_connection = (connection_Connection);
  39032. // CONCATENATED MODULE: ./src/core/connection/handshake/index.ts
  39033. var handshake_Handshake = (function () {
  39034. function Handshake(transport, callback) {
  39035. this.transport = transport;
  39036. this.callback = callback;
  39037. this.bindListeners();
  39038. }
  39039. Handshake.prototype.close = function () {
  39040. this.unbindListeners();
  39041. this.transport.close();
  39042. };
  39043. Handshake.prototype.bindListeners = function () {
  39044. var _this = this;
  39045. this.onMessage = function (m) {
  39046. _this.unbindListeners();
  39047. var result;
  39048. try {
  39049. result = protocol_protocol.processHandshake(m);
  39050. }
  39051. catch (e) {
  39052. _this.finish("error", { error: e });
  39053. _this.transport.close();
  39054. return;
  39055. }
  39056. if (result.action === "connected") {
  39057. _this.finish("connected", {
  39058. connection: new connection_connection(result.id, _this.transport),
  39059. activityTimeout: result.activityTimeout
  39060. });
  39061. }
  39062. else {
  39063. _this.finish(result.action, { error: result.error });
  39064. _this.transport.close();
  39065. }
  39066. };
  39067. this.onClosed = function (closeEvent) {
  39068. _this.unbindListeners();
  39069. var action = protocol_protocol.getCloseAction(closeEvent) || "backoff";
  39070. var error = protocol_protocol.getCloseError(closeEvent);
  39071. _this.finish(action, { error: error });
  39072. };
  39073. this.transport.bind("message", this.onMessage);
  39074. this.transport.bind("closed", this.onClosed);
  39075. };
  39076. Handshake.prototype.unbindListeners = function () {
  39077. this.transport.unbind("message", this.onMessage);
  39078. this.transport.unbind("closed", this.onClosed);
  39079. };
  39080. Handshake.prototype.finish = function (action, params) {
  39081. this.callback(extend({ transport: this.transport, action: action }, params));
  39082. };
  39083. return Handshake;
  39084. }());
  39085. /* harmony default export */ var connection_handshake = (handshake_Handshake);
  39086. // CONCATENATED MODULE: ./src/core/auth/pusher_authorizer.ts
  39087. var pusher_authorizer_PusherAuthorizer = (function () {
  39088. function PusherAuthorizer(channel, options) {
  39089. this.channel = channel;
  39090. var authTransport = options.authTransport;
  39091. if (typeof runtime.getAuthorizers()[authTransport] === "undefined") {
  39092. throw "'" + authTransport + "' is not a recognized auth transport";
  39093. }
  39094. this.type = authTransport;
  39095. this.options = options;
  39096. this.authOptions = (options || {}).auth || {};
  39097. }
  39098. PusherAuthorizer.prototype.composeQuery = function (socketId) {
  39099. var query = 'socket_id=' + encodeURIComponent(socketId) +
  39100. '&channel_name=' + encodeURIComponent(this.channel.name);
  39101. for (var i in this.authOptions.params) {
  39102. query += "&" + encodeURIComponent(i) + "=" + encodeURIComponent(this.authOptions.params[i]);
  39103. }
  39104. return query;
  39105. };
  39106. PusherAuthorizer.prototype.authorize = function (socketId, callback) {
  39107. PusherAuthorizer.authorizers = PusherAuthorizer.authorizers || runtime.getAuthorizers();
  39108. return PusherAuthorizer.authorizers[this.type].call(this, runtime, socketId, callback);
  39109. };
  39110. return PusherAuthorizer;
  39111. }());
  39112. /* harmony default export */ var pusher_authorizer = (pusher_authorizer_PusherAuthorizer);
  39113. // CONCATENATED MODULE: ./src/core/timeline/timeline_sender.ts
  39114. var timeline_sender_TimelineSender = (function () {
  39115. function TimelineSender(timeline, options) {
  39116. this.timeline = timeline;
  39117. this.options = options || {};
  39118. }
  39119. TimelineSender.prototype.send = function (useTLS, callback) {
  39120. if (this.timeline.isEmpty()) {
  39121. return;
  39122. }
  39123. this.timeline.send(runtime.TimelineTransport.getAgent(this, useTLS), callback);
  39124. };
  39125. return TimelineSender;
  39126. }());
  39127. /* harmony default export */ var timeline_sender = (timeline_sender_TimelineSender);
  39128. // CONCATENATED MODULE: ./src/core/errors.ts
  39129. var errors_extends = (undefined && undefined.__extends) || (function () {
  39130. var extendStatics = function (d, b) {
  39131. extendStatics = Object.setPrototypeOf ||
  39132. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  39133. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  39134. return extendStatics(d, b);
  39135. };
  39136. return function (d, b) {
  39137. extendStatics(d, b);
  39138. function __() { this.constructor = d; }
  39139. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  39140. };
  39141. })();
  39142. var BadEventName = (function (_super) {
  39143. errors_extends(BadEventName, _super);
  39144. function BadEventName(msg) {
  39145. var _newTarget = this.constructor;
  39146. var _this = _super.call(this, msg) || this;
  39147. Object.setPrototypeOf(_this, _newTarget.prototype);
  39148. return _this;
  39149. }
  39150. return BadEventName;
  39151. }(Error));
  39152. var RequestTimedOut = (function (_super) {
  39153. errors_extends(RequestTimedOut, _super);
  39154. function RequestTimedOut(msg) {
  39155. var _newTarget = this.constructor;
  39156. var _this = _super.call(this, msg) || this;
  39157. Object.setPrototypeOf(_this, _newTarget.prototype);
  39158. return _this;
  39159. }
  39160. return RequestTimedOut;
  39161. }(Error));
  39162. var TransportPriorityTooLow = (function (_super) {
  39163. errors_extends(TransportPriorityTooLow, _super);
  39164. function TransportPriorityTooLow(msg) {
  39165. var _newTarget = this.constructor;
  39166. var _this = _super.call(this, msg) || this;
  39167. Object.setPrototypeOf(_this, _newTarget.prototype);
  39168. return _this;
  39169. }
  39170. return TransportPriorityTooLow;
  39171. }(Error));
  39172. var TransportClosed = (function (_super) {
  39173. errors_extends(TransportClosed, _super);
  39174. function TransportClosed(msg) {
  39175. var _newTarget = this.constructor;
  39176. var _this = _super.call(this, msg) || this;
  39177. Object.setPrototypeOf(_this, _newTarget.prototype);
  39178. return _this;
  39179. }
  39180. return TransportClosed;
  39181. }(Error));
  39182. var UnsupportedFeature = (function (_super) {
  39183. errors_extends(UnsupportedFeature, _super);
  39184. function UnsupportedFeature(msg) {
  39185. var _newTarget = this.constructor;
  39186. var _this = _super.call(this, msg) || this;
  39187. Object.setPrototypeOf(_this, _newTarget.prototype);
  39188. return _this;
  39189. }
  39190. return UnsupportedFeature;
  39191. }(Error));
  39192. var UnsupportedTransport = (function (_super) {
  39193. errors_extends(UnsupportedTransport, _super);
  39194. function UnsupportedTransport(msg) {
  39195. var _newTarget = this.constructor;
  39196. var _this = _super.call(this, msg) || this;
  39197. Object.setPrototypeOf(_this, _newTarget.prototype);
  39198. return _this;
  39199. }
  39200. return UnsupportedTransport;
  39201. }(Error));
  39202. var UnsupportedStrategy = (function (_super) {
  39203. errors_extends(UnsupportedStrategy, _super);
  39204. function UnsupportedStrategy(msg) {
  39205. var _newTarget = this.constructor;
  39206. var _this = _super.call(this, msg) || this;
  39207. Object.setPrototypeOf(_this, _newTarget.prototype);
  39208. return _this;
  39209. }
  39210. return UnsupportedStrategy;
  39211. }(Error));
  39212. // CONCATENATED MODULE: ./src/core/channels/channel.ts
  39213. var channel_extends = (undefined && undefined.__extends) || (function () {
  39214. var extendStatics = function (d, b) {
  39215. extendStatics = Object.setPrototypeOf ||
  39216. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  39217. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  39218. return extendStatics(d, b);
  39219. };
  39220. return function (d, b) {
  39221. extendStatics(d, b);
  39222. function __() { this.constructor = d; }
  39223. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  39224. };
  39225. })();
  39226. var channel_Channel = (function (_super) {
  39227. channel_extends(Channel, _super);
  39228. function Channel(name, pusher) {
  39229. var _this = _super.call(this, function (event, data) {
  39230. logger.debug('No callbacks on ' + name + ' for ' + event);
  39231. }) || this;
  39232. _this.name = name;
  39233. _this.pusher = pusher;
  39234. _this.subscribed = false;
  39235. _this.subscriptionPending = false;
  39236. _this.subscriptionCancelled = false;
  39237. return _this;
  39238. }
  39239. Channel.prototype.authorize = function (socketId, callback) {
  39240. return callback(false, {});
  39241. };
  39242. Channel.prototype.trigger = function (event, data) {
  39243. if (event.indexOf("client-") !== 0) {
  39244. throw new BadEventName("Event '" + event + "' does not start with 'client-'");
  39245. }
  39246. if (!this.subscribed) {
  39247. var suffix = url_store.buildLogSuffix("triggeringClientEvents");
  39248. logger.warn("Client event triggered before channel 'subscription_succeeded' event . " + suffix);
  39249. }
  39250. return this.pusher.send_event(event, data, this.name);
  39251. };
  39252. Channel.prototype.disconnect = function () {
  39253. this.subscribed = false;
  39254. this.subscriptionPending = false;
  39255. };
  39256. Channel.prototype.handleEvent = function (event) {
  39257. var eventName = event.event;
  39258. var data = event.data;
  39259. if (eventName === "pusher_internal:subscription_succeeded") {
  39260. this.handleSubscriptionSucceededEvent(event);
  39261. }
  39262. else if (eventName.indexOf("pusher_internal:") !== 0) {
  39263. var metadata = {};
  39264. this.emit(eventName, data, metadata);
  39265. }
  39266. };
  39267. Channel.prototype.handleSubscriptionSucceededEvent = function (event) {
  39268. this.subscriptionPending = false;
  39269. this.subscribed = true;
  39270. if (this.subscriptionCancelled) {
  39271. this.pusher.unsubscribe(this.name);
  39272. }
  39273. else {
  39274. this.emit("pusher:subscription_succeeded", event.data);
  39275. }
  39276. };
  39277. Channel.prototype.subscribe = function () {
  39278. var _this = this;
  39279. if (this.subscribed) {
  39280. return;
  39281. }
  39282. this.subscriptionPending = true;
  39283. this.subscriptionCancelled = false;
  39284. this.authorize(this.pusher.connection.socket_id, function (error, data) {
  39285. if (error) {
  39286. logger.error(data);
  39287. _this.emit('pusher:subscription_error', data);
  39288. }
  39289. else {
  39290. _this.pusher.send_event('pusher:subscribe', {
  39291. auth: data.auth,
  39292. channel_data: data.channel_data,
  39293. channel: _this.name
  39294. });
  39295. }
  39296. });
  39297. };
  39298. Channel.prototype.unsubscribe = function () {
  39299. this.subscribed = false;
  39300. this.pusher.send_event('pusher:unsubscribe', {
  39301. channel: this.name
  39302. });
  39303. };
  39304. Channel.prototype.cancelSubscription = function () {
  39305. this.subscriptionCancelled = true;
  39306. };
  39307. Channel.prototype.reinstateSubscription = function () {
  39308. this.subscriptionCancelled = false;
  39309. };
  39310. return Channel;
  39311. }(dispatcher));
  39312. /* harmony default export */ var channels_channel = (channel_Channel);
  39313. // CONCATENATED MODULE: ./src/core/channels/private_channel.ts
  39314. var private_channel_extends = (undefined && undefined.__extends) || (function () {
  39315. var extendStatics = function (d, b) {
  39316. extendStatics = Object.setPrototypeOf ||
  39317. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  39318. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  39319. return extendStatics(d, b);
  39320. };
  39321. return function (d, b) {
  39322. extendStatics(d, b);
  39323. function __() { this.constructor = d; }
  39324. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  39325. };
  39326. })();
  39327. var private_channel_PrivateChannel = (function (_super) {
  39328. private_channel_extends(PrivateChannel, _super);
  39329. function PrivateChannel() {
  39330. return _super !== null && _super.apply(this, arguments) || this;
  39331. }
  39332. PrivateChannel.prototype.authorize = function (socketId, callback) {
  39333. var authorizer = factory.createAuthorizer(this, this.pusher.config);
  39334. return authorizer.authorize(socketId, callback);
  39335. };
  39336. return PrivateChannel;
  39337. }(channels_channel));
  39338. /* harmony default export */ var private_channel = (private_channel_PrivateChannel);
  39339. // CONCATENATED MODULE: ./src/core/channels/members.ts
  39340. var members_Members = (function () {
  39341. function Members() {
  39342. this.reset();
  39343. }
  39344. Members.prototype.get = function (id) {
  39345. if (Object.prototype.hasOwnProperty.call(this.members, id)) {
  39346. return {
  39347. id: id,
  39348. info: this.members[id]
  39349. };
  39350. }
  39351. else {
  39352. return null;
  39353. }
  39354. };
  39355. Members.prototype.each = function (callback) {
  39356. var _this = this;
  39357. objectApply(this.members, function (member, id) {
  39358. callback(_this.get(id));
  39359. });
  39360. };
  39361. Members.prototype.setMyID = function (id) {
  39362. this.myID = id;
  39363. };
  39364. Members.prototype.onSubscription = function (subscriptionData) {
  39365. this.members = subscriptionData.presence.hash;
  39366. this.count = subscriptionData.presence.count;
  39367. this.me = this.get(this.myID);
  39368. };
  39369. Members.prototype.addMember = function (memberData) {
  39370. if (this.get(memberData.user_id) === null) {
  39371. this.count++;
  39372. }
  39373. this.members[memberData.user_id] = memberData.user_info;
  39374. return this.get(memberData.user_id);
  39375. };
  39376. Members.prototype.removeMember = function (memberData) {
  39377. var member = this.get(memberData.user_id);
  39378. if (member) {
  39379. delete this.members[memberData.user_id];
  39380. this.count--;
  39381. }
  39382. return member;
  39383. };
  39384. Members.prototype.reset = function () {
  39385. this.members = {};
  39386. this.count = 0;
  39387. this.myID = null;
  39388. this.me = null;
  39389. };
  39390. return Members;
  39391. }());
  39392. /* harmony default export */ var members = (members_Members);
  39393. // CONCATENATED MODULE: ./src/core/channels/presence_channel.ts
  39394. var presence_channel_extends = (undefined && undefined.__extends) || (function () {
  39395. var extendStatics = function (d, b) {
  39396. extendStatics = Object.setPrototypeOf ||
  39397. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  39398. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  39399. return extendStatics(d, b);
  39400. };
  39401. return function (d, b) {
  39402. extendStatics(d, b);
  39403. function __() { this.constructor = d; }
  39404. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  39405. };
  39406. })();
  39407. var presence_channel_PresenceChannel = (function (_super) {
  39408. presence_channel_extends(PresenceChannel, _super);
  39409. function PresenceChannel(name, pusher) {
  39410. var _this = _super.call(this, name, pusher) || this;
  39411. _this.members = new members();
  39412. return _this;
  39413. }
  39414. PresenceChannel.prototype.authorize = function (socketId, callback) {
  39415. var _this = this;
  39416. _super.prototype.authorize.call(this, socketId, function (error, authData) {
  39417. if (!error) {
  39418. if (authData.channel_data === undefined) {
  39419. var suffix = url_store.buildLogSuffix("authenticationEndpoint");
  39420. logger.error("Invalid auth response for channel '" + _this.name + "'," +
  39421. ("expected 'channel_data' field. " + suffix));
  39422. callback("Invalid auth response");
  39423. return;
  39424. }
  39425. var channelData = JSON.parse(authData.channel_data);
  39426. _this.members.setMyID(channelData.user_id);
  39427. }
  39428. callback(error, authData);
  39429. });
  39430. };
  39431. PresenceChannel.prototype.handleEvent = function (event) {
  39432. var eventName = event.event;
  39433. if (eventName.indexOf("pusher_internal:") === 0) {
  39434. this.handleInternalEvent(event);
  39435. }
  39436. else {
  39437. var data = event.data;
  39438. var metadata = {};
  39439. if (event.user_id) {
  39440. metadata.user_id = event.user_id;
  39441. }
  39442. this.emit(eventName, data, metadata);
  39443. }
  39444. };
  39445. PresenceChannel.prototype.handleInternalEvent = function (event) {
  39446. var eventName = event.event;
  39447. var data = event.data;
  39448. switch (eventName) {
  39449. case "pusher_internal:subscription_succeeded":
  39450. this.handleSubscriptionSucceededEvent(event);
  39451. break;
  39452. case "pusher_internal:member_added":
  39453. var addedMember = this.members.addMember(data);
  39454. this.emit('pusher:member_added', addedMember);
  39455. break;
  39456. case "pusher_internal:member_removed":
  39457. var removedMember = this.members.removeMember(data);
  39458. if (removedMember) {
  39459. this.emit('pusher:member_removed', removedMember);
  39460. }
  39461. break;
  39462. }
  39463. };
  39464. PresenceChannel.prototype.handleSubscriptionSucceededEvent = function (event) {
  39465. this.subscriptionPending = false;
  39466. this.subscribed = true;
  39467. if (this.subscriptionCancelled) {
  39468. this.pusher.unsubscribe(this.name);
  39469. }
  39470. else {
  39471. this.members.onSubscription(event.data);
  39472. this.emit("pusher:subscription_succeeded", this.members);
  39473. }
  39474. };
  39475. PresenceChannel.prototype.disconnect = function () {
  39476. this.members.reset();
  39477. _super.prototype.disconnect.call(this);
  39478. };
  39479. return PresenceChannel;
  39480. }(private_channel));
  39481. /* harmony default export */ var presence_channel = (presence_channel_PresenceChannel);
  39482. // EXTERNAL MODULE: ./node_modules/tweetnacl/nacl-fast.js
  39483. var nacl_fast = __webpack_require__(0);
  39484. // EXTERNAL MODULE: ./node_modules/tweetnacl-util/nacl-util.js
  39485. var nacl_util = __webpack_require__(1);
  39486. // CONCATENATED MODULE: ./src/core/channels/encrypted_channel.ts
  39487. var encrypted_channel_extends = (undefined && undefined.__extends) || (function () {
  39488. var extendStatics = function (d, b) {
  39489. extendStatics = Object.setPrototypeOf ||
  39490. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  39491. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  39492. return extendStatics(d, b);
  39493. };
  39494. return function (d, b) {
  39495. extendStatics(d, b);
  39496. function __() { this.constructor = d; }
  39497. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  39498. };
  39499. })();
  39500. var encrypted_channel_EncryptedChannel = (function (_super) {
  39501. encrypted_channel_extends(EncryptedChannel, _super);
  39502. function EncryptedChannel() {
  39503. var _this = _super !== null && _super.apply(this, arguments) || this;
  39504. _this.key = null;
  39505. return _this;
  39506. }
  39507. EncryptedChannel.prototype.authorize = function (socketId, callback) {
  39508. var _this = this;
  39509. _super.prototype.authorize.call(this, socketId, function (error, authData) {
  39510. if (error) {
  39511. callback(true, authData);
  39512. return;
  39513. }
  39514. var sharedSecret = authData["shared_secret"];
  39515. if (!sharedSecret) {
  39516. var errorMsg = "No shared_secret key in auth payload for encrypted channel: " + _this.name;
  39517. callback(true, errorMsg);
  39518. return;
  39519. }
  39520. _this.key = Object(nacl_util["decodeBase64"])(sharedSecret);
  39521. delete authData["shared_secret"];
  39522. callback(false, authData);
  39523. });
  39524. };
  39525. EncryptedChannel.prototype.trigger = function (event, data) {
  39526. throw new UnsupportedFeature('Client events are not currently supported for encrypted channels');
  39527. };
  39528. EncryptedChannel.prototype.handleEvent = function (event) {
  39529. var eventName = event.event;
  39530. var data = event.data;
  39531. if (eventName.indexOf("pusher_internal:") === 0 || eventName.indexOf("pusher:") === 0) {
  39532. _super.prototype.handleEvent.call(this, event);
  39533. return;
  39534. }
  39535. this.handleEncryptedEvent(eventName, data);
  39536. };
  39537. EncryptedChannel.prototype.handleEncryptedEvent = function (event, data) {
  39538. var _this = this;
  39539. if (!this.key) {
  39540. logger.debug('Received encrypted event before key has been retrieved from the authEndpoint');
  39541. return;
  39542. }
  39543. if (!data.ciphertext || !data.nonce) {
  39544. logger.error('Unexpected format for encrypted event, expected object with `ciphertext` and `nonce` fields, got: ' + data);
  39545. return;
  39546. }
  39547. var cipherText = Object(nacl_util["decodeBase64"])(data.ciphertext);
  39548. if (cipherText.length < nacl_fast["secretbox"].overheadLength) {
  39549. logger.error("Expected encrypted event ciphertext length to be " + nacl_fast["secretbox"].overheadLength + ", got: " + cipherText.length);
  39550. return;
  39551. }
  39552. var nonce = Object(nacl_util["decodeBase64"])(data.nonce);
  39553. if (nonce.length < nacl_fast["secretbox"].nonceLength) {
  39554. logger.error("Expected encrypted event nonce length to be " + nacl_fast["secretbox"].nonceLength + ", got: " + nonce.length);
  39555. return;
  39556. }
  39557. var bytes = nacl_fast["secretbox"].open(cipherText, nonce, this.key);
  39558. if (bytes === null) {
  39559. logger.debug('Failed to decrypt an event, probably because it was encrypted with a different key. Fetching a new key from the authEndpoint...');
  39560. this.authorize(this.pusher.connection.socket_id, function (error, authData) {
  39561. if (error) {
  39562. logger.error("Failed to make a request to the authEndpoint: " + authData + ". Unable to fetch new key, so dropping encrypted event");
  39563. return;
  39564. }
  39565. bytes = nacl_fast["secretbox"].open(cipherText, nonce, _this.key);
  39566. if (bytes === null) {
  39567. logger.error("Failed to decrypt event with new key. Dropping encrypted event");
  39568. return;
  39569. }
  39570. _this.emitJSON(event, Object(nacl_util["encodeUTF8"])(bytes));
  39571. return;
  39572. });
  39573. return;
  39574. }
  39575. this.emitJSON(event, Object(nacl_util["encodeUTF8"])(bytes));
  39576. };
  39577. EncryptedChannel.prototype.emitJSON = function (eventName, data) {
  39578. try {
  39579. this.emit(eventName, JSON.parse(data));
  39580. }
  39581. catch (e) {
  39582. this.emit(eventName, data);
  39583. }
  39584. return this;
  39585. };
  39586. return EncryptedChannel;
  39587. }(private_channel));
  39588. /* harmony default export */ var encrypted_channel = (encrypted_channel_EncryptedChannel);
  39589. // CONCATENATED MODULE: ./src/core/connection/connection_manager.ts
  39590. var connection_manager_extends = (undefined && undefined.__extends) || (function () {
  39591. var extendStatics = function (d, b) {
  39592. extendStatics = Object.setPrototypeOf ||
  39593. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  39594. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  39595. return extendStatics(d, b);
  39596. };
  39597. return function (d, b) {
  39598. extendStatics(d, b);
  39599. function __() { this.constructor = d; }
  39600. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  39601. };
  39602. })();
  39603. var connection_manager_ConnectionManager = (function (_super) {
  39604. connection_manager_extends(ConnectionManager, _super);
  39605. function ConnectionManager(key, options) {
  39606. var _this = _super.call(this) || this;
  39607. _this.key = key;
  39608. _this.options = options || {};
  39609. _this.state = "initialized";
  39610. _this.connection = null;
  39611. _this.usingTLS = !!options.useTLS;
  39612. _this.timeline = _this.options.timeline;
  39613. _this.errorCallbacks = _this.buildErrorCallbacks();
  39614. _this.connectionCallbacks = _this.buildConnectionCallbacks(_this.errorCallbacks);
  39615. _this.handshakeCallbacks = _this.buildHandshakeCallbacks(_this.errorCallbacks);
  39616. var Network = runtime.getNetwork();
  39617. Network.bind("online", function () {
  39618. _this.timeline.info({ netinfo: "online" });
  39619. if (_this.state === "connecting" || _this.state === "unavailable") {
  39620. _this.retryIn(0);
  39621. }
  39622. });
  39623. Network.bind("offline", function () {
  39624. _this.timeline.info({ netinfo: "offline" });
  39625. if (_this.connection) {
  39626. _this.sendActivityCheck();
  39627. }
  39628. });
  39629. _this.updateStrategy();
  39630. return _this;
  39631. }
  39632. ConnectionManager.prototype.connect = function () {
  39633. if (this.connection || this.runner) {
  39634. return;
  39635. }
  39636. if (!this.strategy.isSupported()) {
  39637. this.updateState("failed");
  39638. return;
  39639. }
  39640. this.updateState("connecting");
  39641. this.startConnecting();
  39642. this.setUnavailableTimer();
  39643. };
  39644. ;
  39645. ConnectionManager.prototype.send = function (data) {
  39646. if (this.connection) {
  39647. return this.connection.send(data);
  39648. }
  39649. else {
  39650. return false;
  39651. }
  39652. };
  39653. ;
  39654. ConnectionManager.prototype.send_event = function (name, data, channel) {
  39655. if (this.connection) {
  39656. return this.connection.send_event(name, data, channel);
  39657. }
  39658. else {
  39659. return false;
  39660. }
  39661. };
  39662. ;
  39663. ConnectionManager.prototype.disconnect = function () {
  39664. this.disconnectInternally();
  39665. this.updateState("disconnected");
  39666. };
  39667. ;
  39668. ConnectionManager.prototype.isUsingTLS = function () {
  39669. return this.usingTLS;
  39670. };
  39671. ;
  39672. ConnectionManager.prototype.startConnecting = function () {
  39673. var _this = this;
  39674. var callback = function (error, handshake) {
  39675. if (error) {
  39676. _this.runner = _this.strategy.connect(0, callback);
  39677. }
  39678. else {
  39679. if (handshake.action === "error") {
  39680. _this.emit("error", { type: "HandshakeError", error: handshake.error });
  39681. _this.timeline.error({ handshakeError: handshake.error });
  39682. }
  39683. else {
  39684. _this.abortConnecting();
  39685. _this.handshakeCallbacks[handshake.action](handshake);
  39686. }
  39687. }
  39688. };
  39689. this.runner = this.strategy.connect(0, callback);
  39690. };
  39691. ;
  39692. ConnectionManager.prototype.abortConnecting = function () {
  39693. if (this.runner) {
  39694. this.runner.abort();
  39695. this.runner = null;
  39696. }
  39697. };
  39698. ;
  39699. ConnectionManager.prototype.disconnectInternally = function () {
  39700. this.abortConnecting();
  39701. this.clearRetryTimer();
  39702. this.clearUnavailableTimer();
  39703. if (this.connection) {
  39704. var connection = this.abandonConnection();
  39705. connection.close();
  39706. }
  39707. };
  39708. ;
  39709. ConnectionManager.prototype.updateStrategy = function () {
  39710. this.strategy = this.options.getStrategy({
  39711. key: this.key,
  39712. timeline: this.timeline,
  39713. useTLS: this.usingTLS
  39714. });
  39715. };
  39716. ;
  39717. ConnectionManager.prototype.retryIn = function (delay) {
  39718. var _this = this;
  39719. this.timeline.info({ action: "retry", delay: delay });
  39720. if (delay > 0) {
  39721. this.emit("connecting_in", Math.round(delay / 1000));
  39722. }
  39723. this.retryTimer = new OneOffTimer(delay || 0, function () {
  39724. _this.disconnectInternally();
  39725. _this.connect();
  39726. });
  39727. };
  39728. ;
  39729. ConnectionManager.prototype.clearRetryTimer = function () {
  39730. if (this.retryTimer) {
  39731. this.retryTimer.ensureAborted();
  39732. this.retryTimer = null;
  39733. }
  39734. };
  39735. ;
  39736. ConnectionManager.prototype.setUnavailableTimer = function () {
  39737. var _this = this;
  39738. this.unavailableTimer = new OneOffTimer(this.options.unavailableTimeout, function () {
  39739. _this.updateState("unavailable");
  39740. });
  39741. };
  39742. ;
  39743. ConnectionManager.prototype.clearUnavailableTimer = function () {
  39744. if (this.unavailableTimer) {
  39745. this.unavailableTimer.ensureAborted();
  39746. }
  39747. };
  39748. ;
  39749. ConnectionManager.prototype.sendActivityCheck = function () {
  39750. var _this = this;
  39751. this.stopActivityCheck();
  39752. this.connection.ping();
  39753. this.activityTimer = new OneOffTimer(this.options.pongTimeout, function () {
  39754. _this.timeline.error({ pong_timed_out: _this.options.pongTimeout });
  39755. _this.retryIn(0);
  39756. });
  39757. };
  39758. ;
  39759. ConnectionManager.prototype.resetActivityCheck = function () {
  39760. var _this = this;
  39761. this.stopActivityCheck();
  39762. if (this.connection && !this.connection.handlesActivityChecks()) {
  39763. this.activityTimer = new OneOffTimer(this.activityTimeout, function () {
  39764. _this.sendActivityCheck();
  39765. });
  39766. }
  39767. };
  39768. ;
  39769. ConnectionManager.prototype.stopActivityCheck = function () {
  39770. if (this.activityTimer) {
  39771. this.activityTimer.ensureAborted();
  39772. }
  39773. };
  39774. ;
  39775. ConnectionManager.prototype.buildConnectionCallbacks = function (errorCallbacks) {
  39776. var _this = this;
  39777. return extend({}, errorCallbacks, {
  39778. message: function (message) {
  39779. _this.resetActivityCheck();
  39780. _this.emit('message', message);
  39781. },
  39782. ping: function () {
  39783. _this.send_event('pusher:pong', {});
  39784. },
  39785. activity: function () {
  39786. _this.resetActivityCheck();
  39787. },
  39788. error: function (error) {
  39789. _this.emit("error", { type: "WebSocketError", error: error });
  39790. },
  39791. closed: function () {
  39792. _this.abandonConnection();
  39793. if (_this.shouldRetry()) {
  39794. _this.retryIn(1000);
  39795. }
  39796. }
  39797. });
  39798. };
  39799. ;
  39800. ConnectionManager.prototype.buildHandshakeCallbacks = function (errorCallbacks) {
  39801. var _this = this;
  39802. return extend({}, errorCallbacks, {
  39803. connected: function (handshake) {
  39804. _this.activityTimeout = Math.min(_this.options.activityTimeout, handshake.activityTimeout, handshake.connection.activityTimeout || Infinity);
  39805. _this.clearUnavailableTimer();
  39806. _this.setConnection(handshake.connection);
  39807. _this.socket_id = _this.connection.id;
  39808. _this.updateState("connected", { socket_id: _this.socket_id });
  39809. }
  39810. });
  39811. };
  39812. ;
  39813. ConnectionManager.prototype.buildErrorCallbacks = function () {
  39814. var _this = this;
  39815. var withErrorEmitted = function (callback) {
  39816. return function (result) {
  39817. if (result.error) {
  39818. _this.emit("error", { type: "WebSocketError", error: result.error });
  39819. }
  39820. callback(result);
  39821. };
  39822. };
  39823. return {
  39824. tls_only: withErrorEmitted(function () {
  39825. _this.usingTLS = true;
  39826. _this.updateStrategy();
  39827. _this.retryIn(0);
  39828. }),
  39829. refused: withErrorEmitted(function () {
  39830. _this.disconnect();
  39831. }),
  39832. backoff: withErrorEmitted(function () {
  39833. _this.retryIn(1000);
  39834. }),
  39835. retry: withErrorEmitted(function () {
  39836. _this.retryIn(0);
  39837. })
  39838. };
  39839. };
  39840. ;
  39841. ConnectionManager.prototype.setConnection = function (connection) {
  39842. this.connection = connection;
  39843. for (var event in this.connectionCallbacks) {
  39844. this.connection.bind(event, this.connectionCallbacks[event]);
  39845. }
  39846. this.resetActivityCheck();
  39847. };
  39848. ;
  39849. ConnectionManager.prototype.abandonConnection = function () {
  39850. if (!this.connection) {
  39851. return;
  39852. }
  39853. this.stopActivityCheck();
  39854. for (var event in this.connectionCallbacks) {
  39855. this.connection.unbind(event, this.connectionCallbacks[event]);
  39856. }
  39857. var connection = this.connection;
  39858. this.connection = null;
  39859. return connection;
  39860. };
  39861. ConnectionManager.prototype.updateState = function (newState, data) {
  39862. var previousState = this.state;
  39863. this.state = newState;
  39864. if (previousState !== newState) {
  39865. var newStateDescription = newState;
  39866. if (newStateDescription === "connected") {
  39867. newStateDescription += " with new socket ID " + data.socket_id;
  39868. }
  39869. logger.debug('State changed', previousState + ' -> ' + newStateDescription);
  39870. this.timeline.info({ state: newState, params: data });
  39871. this.emit('state_change', { previous: previousState, current: newState });
  39872. this.emit(newState, data);
  39873. }
  39874. };
  39875. ConnectionManager.prototype.shouldRetry = function () {
  39876. return this.state === "connecting" || this.state === "connected";
  39877. };
  39878. return ConnectionManager;
  39879. }(dispatcher));
  39880. /* harmony default export */ var connection_manager = (connection_manager_ConnectionManager);
  39881. // CONCATENATED MODULE: ./src/core/channels/channels.ts
  39882. var channels_Channels = (function () {
  39883. function Channels() {
  39884. this.channels = {};
  39885. }
  39886. Channels.prototype.add = function (name, pusher) {
  39887. if (!this.channels[name]) {
  39888. this.channels[name] = createChannel(name, pusher);
  39889. }
  39890. return this.channels[name];
  39891. };
  39892. Channels.prototype.all = function () {
  39893. return values(this.channels);
  39894. };
  39895. Channels.prototype.find = function (name) {
  39896. return this.channels[name];
  39897. };
  39898. Channels.prototype.remove = function (name) {
  39899. var channel = this.channels[name];
  39900. delete this.channels[name];
  39901. return channel;
  39902. };
  39903. Channels.prototype.disconnect = function () {
  39904. objectApply(this.channels, function (channel) {
  39905. channel.disconnect();
  39906. });
  39907. };
  39908. return Channels;
  39909. }());
  39910. /* harmony default export */ var channels = (channels_Channels);
  39911. function createChannel(name, pusher) {
  39912. if (name.indexOf('private-encrypted-') === 0) {
  39913. if (false) { var errorMsg; }
  39914. return factory.createEncryptedChannel(name, pusher);
  39915. }
  39916. else if (name.indexOf('private-') === 0) {
  39917. return factory.createPrivateChannel(name, pusher);
  39918. }
  39919. else if (name.indexOf('presence-') === 0) {
  39920. return factory.createPresenceChannel(name, pusher);
  39921. }
  39922. else {
  39923. return factory.createChannel(name, pusher);
  39924. }
  39925. }
  39926. // CONCATENATED MODULE: ./src/core/utils/factory.ts
  39927. var Factory = {
  39928. createChannels: function () {
  39929. return new channels();
  39930. },
  39931. createConnectionManager: function (key, options) {
  39932. return new connection_manager(key, options);
  39933. },
  39934. createChannel: function (name, pusher) {
  39935. return new channels_channel(name, pusher);
  39936. },
  39937. createPrivateChannel: function (name, pusher) {
  39938. return new private_channel(name, pusher);
  39939. },
  39940. createPresenceChannel: function (name, pusher) {
  39941. return new presence_channel(name, pusher);
  39942. },
  39943. createEncryptedChannel: function (name, pusher) {
  39944. return new encrypted_channel(name, pusher);
  39945. },
  39946. createTimelineSender: function (timeline, options) {
  39947. return new timeline_sender(timeline, options);
  39948. },
  39949. createAuthorizer: function (channel, options) {
  39950. if (options.authorizer) {
  39951. return options.authorizer(channel, options);
  39952. }
  39953. return new pusher_authorizer(channel, options);
  39954. },
  39955. createHandshake: function (transport, callback) {
  39956. return new connection_handshake(transport, callback);
  39957. },
  39958. createAssistantToTheTransportManager: function (manager, transport, options) {
  39959. return new assistant_to_the_transport_manager(manager, transport, options);
  39960. }
  39961. };
  39962. /* harmony default export */ var factory = (Factory);
  39963. // CONCATENATED MODULE: ./src/core/transports/transport_manager.ts
  39964. var transport_manager_TransportManager = (function () {
  39965. function TransportManager(options) {
  39966. this.options = options || {};
  39967. this.livesLeft = this.options.lives || Infinity;
  39968. }
  39969. TransportManager.prototype.getAssistant = function (transport) {
  39970. return factory.createAssistantToTheTransportManager(this, transport, {
  39971. minPingDelay: this.options.minPingDelay,
  39972. maxPingDelay: this.options.maxPingDelay
  39973. });
  39974. };
  39975. TransportManager.prototype.isAlive = function () {
  39976. return this.livesLeft > 0;
  39977. };
  39978. TransportManager.prototype.reportDeath = function () {
  39979. this.livesLeft -= 1;
  39980. };
  39981. return TransportManager;
  39982. }());
  39983. /* harmony default export */ var transport_manager = (transport_manager_TransportManager);
  39984. // CONCATENATED MODULE: ./src/core/strategies/sequential_strategy.ts
  39985. var sequential_strategy_SequentialStrategy = (function () {
  39986. function SequentialStrategy(strategies, options) {
  39987. this.strategies = strategies;
  39988. this.loop = Boolean(options.loop);
  39989. this.failFast = Boolean(options.failFast);
  39990. this.timeout = options.timeout;
  39991. this.timeoutLimit = options.timeoutLimit;
  39992. }
  39993. SequentialStrategy.prototype.isSupported = function () {
  39994. return any(this.strategies, util.method("isSupported"));
  39995. };
  39996. SequentialStrategy.prototype.connect = function (minPriority, callback) {
  39997. var _this = this;
  39998. var strategies = this.strategies;
  39999. var current = 0;
  40000. var timeout = this.timeout;
  40001. var runner = null;
  40002. var tryNextStrategy = function (error, handshake) {
  40003. if (handshake) {
  40004. callback(null, handshake);
  40005. }
  40006. else {
  40007. current = current + 1;
  40008. if (_this.loop) {
  40009. current = current % strategies.length;
  40010. }
  40011. if (current < strategies.length) {
  40012. if (timeout) {
  40013. timeout = timeout * 2;
  40014. if (_this.timeoutLimit) {
  40015. timeout = Math.min(timeout, _this.timeoutLimit);
  40016. }
  40017. }
  40018. runner = _this.tryStrategy(strategies[current], minPriority, { timeout: timeout, failFast: _this.failFast }, tryNextStrategy);
  40019. }
  40020. else {
  40021. callback(true);
  40022. }
  40023. }
  40024. };
  40025. runner = this.tryStrategy(strategies[current], minPriority, { timeout: timeout, failFast: this.failFast }, tryNextStrategy);
  40026. return {
  40027. abort: function () {
  40028. runner.abort();
  40029. },
  40030. forceMinPriority: function (p) {
  40031. minPriority = p;
  40032. if (runner) {
  40033. runner.forceMinPriority(p);
  40034. }
  40035. }
  40036. };
  40037. };
  40038. SequentialStrategy.prototype.tryStrategy = function (strategy, minPriority, options, callback) {
  40039. var timer = null;
  40040. var runner = null;
  40041. if (options.timeout > 0) {
  40042. timer = new OneOffTimer(options.timeout, function () {
  40043. runner.abort();
  40044. callback(true);
  40045. });
  40046. }
  40047. runner = strategy.connect(minPriority, function (error, handshake) {
  40048. if (error && timer && timer.isRunning() && !options.failFast) {
  40049. return;
  40050. }
  40051. if (timer) {
  40052. timer.ensureAborted();
  40053. }
  40054. callback(error, handshake);
  40055. });
  40056. return {
  40057. abort: function () {
  40058. if (timer) {
  40059. timer.ensureAborted();
  40060. }
  40061. runner.abort();
  40062. },
  40063. forceMinPriority: function (p) {
  40064. runner.forceMinPriority(p);
  40065. }
  40066. };
  40067. };
  40068. return SequentialStrategy;
  40069. }());
  40070. /* harmony default export */ var sequential_strategy = (sequential_strategy_SequentialStrategy);
  40071. // CONCATENATED MODULE: ./src/core/strategies/best_connected_ever_strategy.ts
  40072. var best_connected_ever_strategy_BestConnectedEverStrategy = (function () {
  40073. function BestConnectedEverStrategy(strategies) {
  40074. this.strategies = strategies;
  40075. }
  40076. BestConnectedEverStrategy.prototype.isSupported = function () {
  40077. return any(this.strategies, util.method("isSupported"));
  40078. };
  40079. BestConnectedEverStrategy.prototype.connect = function (minPriority, callback) {
  40080. return connect(this.strategies, minPriority, function (i, runners) {
  40081. return function (error, handshake) {
  40082. runners[i].error = error;
  40083. if (error) {
  40084. if (allRunnersFailed(runners)) {
  40085. callback(true);
  40086. }
  40087. return;
  40088. }
  40089. apply(runners, function (runner) {
  40090. runner.forceMinPriority(handshake.transport.priority);
  40091. });
  40092. callback(null, handshake);
  40093. };
  40094. });
  40095. };
  40096. return BestConnectedEverStrategy;
  40097. }());
  40098. /* harmony default export */ var best_connected_ever_strategy = (best_connected_ever_strategy_BestConnectedEverStrategy);
  40099. function connect(strategies, minPriority, callbackBuilder) {
  40100. var runners = map(strategies, function (strategy, i, _, rs) {
  40101. return strategy.connect(minPriority, callbackBuilder(i, rs));
  40102. });
  40103. return {
  40104. abort: function () {
  40105. apply(runners, abortRunner);
  40106. },
  40107. forceMinPriority: function (p) {
  40108. apply(runners, function (runner) {
  40109. runner.forceMinPriority(p);
  40110. });
  40111. }
  40112. };
  40113. }
  40114. function allRunnersFailed(runners) {
  40115. return collections_all(runners, function (runner) {
  40116. return Boolean(runner.error);
  40117. });
  40118. }
  40119. function abortRunner(runner) {
  40120. if (!runner.error && !runner.aborted) {
  40121. runner.abort();
  40122. runner.aborted = true;
  40123. }
  40124. }
  40125. // CONCATENATED MODULE: ./src/core/strategies/cached_strategy.ts
  40126. var cached_strategy_CachedStrategy = (function () {
  40127. function CachedStrategy(strategy, transports, options) {
  40128. this.strategy = strategy;
  40129. this.transports = transports;
  40130. this.ttl = options.ttl || 1800 * 1000;
  40131. this.usingTLS = options.useTLS;
  40132. this.timeline = options.timeline;
  40133. }
  40134. CachedStrategy.prototype.isSupported = function () {
  40135. return this.strategy.isSupported();
  40136. };
  40137. CachedStrategy.prototype.connect = function (minPriority, callback) {
  40138. var usingTLS = this.usingTLS;
  40139. var info = fetchTransportCache(usingTLS);
  40140. var strategies = [this.strategy];
  40141. if (info && info.timestamp + this.ttl >= util.now()) {
  40142. var transport = this.transports[info.transport];
  40143. if (transport) {
  40144. this.timeline.info({
  40145. cached: true,
  40146. transport: info.transport,
  40147. latency: info.latency
  40148. });
  40149. strategies.push(new sequential_strategy([transport], {
  40150. timeout: info.latency * 2 + 1000,
  40151. failFast: true
  40152. }));
  40153. }
  40154. }
  40155. var startTimestamp = util.now();
  40156. var runner = strategies.pop().connect(minPriority, function cb(error, handshake) {
  40157. if (error) {
  40158. flushTransportCache(usingTLS);
  40159. if (strategies.length > 0) {
  40160. startTimestamp = util.now();
  40161. runner = strategies.pop().connect(minPriority, cb);
  40162. }
  40163. else {
  40164. callback(error);
  40165. }
  40166. }
  40167. else {
  40168. storeTransportCache(usingTLS, handshake.transport.name, util.now() - startTimestamp);
  40169. callback(null, handshake);
  40170. }
  40171. });
  40172. return {
  40173. abort: function () {
  40174. runner.abort();
  40175. },
  40176. forceMinPriority: function (p) {
  40177. minPriority = p;
  40178. if (runner) {
  40179. runner.forceMinPriority(p);
  40180. }
  40181. }
  40182. };
  40183. };
  40184. return CachedStrategy;
  40185. }());
  40186. /* harmony default export */ var cached_strategy = (cached_strategy_CachedStrategy);
  40187. function getTransportCacheKey(usingTLS) {
  40188. return "pusherTransport" + (usingTLS ? "TLS" : "NonTLS");
  40189. }
  40190. function fetchTransportCache(usingTLS) {
  40191. var storage = runtime.getLocalStorage();
  40192. if (storage) {
  40193. try {
  40194. var serializedCache = storage[getTransportCacheKey(usingTLS)];
  40195. if (serializedCache) {
  40196. return JSON.parse(serializedCache);
  40197. }
  40198. }
  40199. catch (e) {
  40200. flushTransportCache(usingTLS);
  40201. }
  40202. }
  40203. return null;
  40204. }
  40205. function storeTransportCache(usingTLS, transport, latency) {
  40206. var storage = runtime.getLocalStorage();
  40207. if (storage) {
  40208. try {
  40209. storage[getTransportCacheKey(usingTLS)] = safeJSONStringify({
  40210. timestamp: util.now(),
  40211. transport: transport,
  40212. latency: latency
  40213. });
  40214. }
  40215. catch (e) {
  40216. }
  40217. }
  40218. }
  40219. function flushTransportCache(usingTLS) {
  40220. var storage = runtime.getLocalStorage();
  40221. if (storage) {
  40222. try {
  40223. delete storage[getTransportCacheKey(usingTLS)];
  40224. }
  40225. catch (e) {
  40226. }
  40227. }
  40228. }
  40229. // CONCATENATED MODULE: ./src/core/strategies/delayed_strategy.ts
  40230. var delayed_strategy_DelayedStrategy = (function () {
  40231. function DelayedStrategy(strategy, _a) {
  40232. var number = _a.delay;
  40233. this.strategy = strategy;
  40234. this.options = { delay: number };
  40235. }
  40236. DelayedStrategy.prototype.isSupported = function () {
  40237. return this.strategy.isSupported();
  40238. };
  40239. DelayedStrategy.prototype.connect = function (minPriority, callback) {
  40240. var strategy = this.strategy;
  40241. var runner;
  40242. var timer = new OneOffTimer(this.options.delay, function () {
  40243. runner = strategy.connect(minPriority, callback);
  40244. });
  40245. return {
  40246. abort: function () {
  40247. timer.ensureAborted();
  40248. if (runner) {
  40249. runner.abort();
  40250. }
  40251. },
  40252. forceMinPriority: function (p) {
  40253. minPriority = p;
  40254. if (runner) {
  40255. runner.forceMinPriority(p);
  40256. }
  40257. }
  40258. };
  40259. };
  40260. return DelayedStrategy;
  40261. }());
  40262. /* harmony default export */ var delayed_strategy = (delayed_strategy_DelayedStrategy);
  40263. // CONCATENATED MODULE: ./src/core/strategies/if_strategy.ts
  40264. var IfStrategy = (function () {
  40265. function IfStrategy(test, trueBranch, falseBranch) {
  40266. this.test = test;
  40267. this.trueBranch = trueBranch;
  40268. this.falseBranch = falseBranch;
  40269. }
  40270. IfStrategy.prototype.isSupported = function () {
  40271. var branch = this.test() ? this.trueBranch : this.falseBranch;
  40272. return branch.isSupported();
  40273. };
  40274. IfStrategy.prototype.connect = function (minPriority, callback) {
  40275. var branch = this.test() ? this.trueBranch : this.falseBranch;
  40276. return branch.connect(minPriority, callback);
  40277. };
  40278. return IfStrategy;
  40279. }());
  40280. /* harmony default export */ var if_strategy = (IfStrategy);
  40281. // CONCATENATED MODULE: ./src/core/strategies/first_connected_strategy.ts
  40282. var FirstConnectedStrategy = (function () {
  40283. function FirstConnectedStrategy(strategy) {
  40284. this.strategy = strategy;
  40285. }
  40286. FirstConnectedStrategy.prototype.isSupported = function () {
  40287. return this.strategy.isSupported();
  40288. };
  40289. FirstConnectedStrategy.prototype.connect = function (minPriority, callback) {
  40290. var runner = this.strategy.connect(minPriority, function (error, handshake) {
  40291. if (handshake) {
  40292. runner.abort();
  40293. }
  40294. callback(error, handshake);
  40295. });
  40296. return runner;
  40297. };
  40298. return FirstConnectedStrategy;
  40299. }());
  40300. /* harmony default export */ var first_connected_strategy = (FirstConnectedStrategy);
  40301. // CONCATENATED MODULE: ./src/runtimes/web/default_strategy.ts
  40302. function testSupportsStrategy(strategy) {
  40303. return function () {
  40304. return strategy.isSupported();
  40305. };
  40306. }
  40307. var getDefaultStrategy = function (config, defineTransport) {
  40308. var definedTransports = {};
  40309. function defineTransportStrategy(name, type, priority, options, manager) {
  40310. var transport = defineTransport(config, name, type, priority, options, manager);
  40311. definedTransports[name] = transport;
  40312. return transport;
  40313. }
  40314. var ws_options = {
  40315. hostNonTLS: config.wsHost + ":" + config.wsPort,
  40316. hostTLS: config.wsHost + ":" + config.wssPort,
  40317. httpPath: config.wsPath
  40318. };
  40319. var wss_options = extend({}, ws_options, {
  40320. useTLS: true
  40321. });
  40322. var sockjs_options = {
  40323. hostNonTLS: config.httpHost + ":" + config.httpPort,
  40324. hostTLS: config.httpHost + ":" + config.httpsPort,
  40325. httpPath: config.httpPath
  40326. };
  40327. var timeouts = {
  40328. loop: true,
  40329. timeout: 15000,
  40330. timeoutLimit: 60000
  40331. };
  40332. var ws_manager = new transport_manager({
  40333. lives: 2,
  40334. minPingDelay: 10000,
  40335. maxPingDelay: config.activity_timeout
  40336. });
  40337. var streaming_manager = new transport_manager({
  40338. lives: 2,
  40339. minPingDelay: 10000,
  40340. maxPingDelay: config.activity_timeout
  40341. });
  40342. var ws_transport = defineTransportStrategy("ws", "ws", 3, ws_options, ws_manager);
  40343. var wss_transport = defineTransportStrategy("wss", "ws", 3, wss_options, ws_manager);
  40344. var sockjs_transport = defineTransportStrategy("sockjs", "sockjs", 1, sockjs_options);
  40345. var xhr_streaming_transport = defineTransportStrategy("xhr_streaming", "xhr_streaming", 1, sockjs_options, streaming_manager);
  40346. var xdr_streaming_transport = defineTransportStrategy("xdr_streaming", "xdr_streaming", 1, sockjs_options, streaming_manager);
  40347. var xhr_polling_transport = defineTransportStrategy("xhr_polling", "xhr_polling", 1, sockjs_options);
  40348. var xdr_polling_transport = defineTransportStrategy("xdr_polling", "xdr_polling", 1, sockjs_options);
  40349. var ws_loop = new sequential_strategy([ws_transport], timeouts);
  40350. var wss_loop = new sequential_strategy([wss_transport], timeouts);
  40351. var sockjs_loop = new sequential_strategy([sockjs_transport], timeouts);
  40352. var streaming_loop = new sequential_strategy([new if_strategy(testSupportsStrategy(xhr_streaming_transport), xhr_streaming_transport, xdr_streaming_transport)], timeouts);
  40353. var polling_loop = new sequential_strategy([new if_strategy(testSupportsStrategy(xhr_polling_transport), xhr_polling_transport, xdr_polling_transport)], timeouts);
  40354. 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);
  40355. var http_fallback_loop = new if_strategy(testSupportsStrategy(http_loop), http_loop, sockjs_loop);
  40356. var wsStrategy;
  40357. if (config.useTLS) {
  40358. wsStrategy = new best_connected_ever_strategy([ws_loop, new delayed_strategy(http_fallback_loop, { delay: 2000 })]);
  40359. }
  40360. else {
  40361. wsStrategy = new best_connected_ever_strategy([
  40362. ws_loop,
  40363. new delayed_strategy(wss_loop, { delay: 2000 }),
  40364. new delayed_strategy(http_fallback_loop, { delay: 5000 })
  40365. ]);
  40366. }
  40367. return new cached_strategy(new first_connected_strategy(new if_strategy(testSupportsStrategy(ws_transport), wsStrategy, http_fallback_loop)), definedTransports, {
  40368. ttl: 1800000,
  40369. timeline: config.timeline,
  40370. useTLS: config.useTLS
  40371. });
  40372. };
  40373. /* harmony default export */ var default_strategy = (getDefaultStrategy);
  40374. // CONCATENATED MODULE: ./src/runtimes/web/transports/transport_connection_initializer.ts
  40375. /* harmony default export */ var transport_connection_initializer = (function () {
  40376. var self = this;
  40377. self.timeline.info(self.buildTimelineMessage({
  40378. transport: self.name + (self.options.useTLS ? "s" : "")
  40379. }));
  40380. if (self.hooks.isInitialized()) {
  40381. self.changeState("initialized");
  40382. }
  40383. else if (self.hooks.file) {
  40384. self.changeState("initializing");
  40385. Dependencies.load(self.hooks.file, { useTLS: self.options.useTLS }, function (error, callback) {
  40386. if (self.hooks.isInitialized()) {
  40387. self.changeState("initialized");
  40388. callback(true);
  40389. }
  40390. else {
  40391. if (error) {
  40392. self.onError(error);
  40393. }
  40394. self.onClose();
  40395. callback(false);
  40396. }
  40397. });
  40398. }
  40399. else {
  40400. self.onClose();
  40401. }
  40402. });
  40403. // CONCATENATED MODULE: ./src/runtimes/web/http/http_xdomain_request.ts
  40404. var http_xdomain_request_hooks = {
  40405. getRequest: function (socket) {
  40406. var xdr = new window.XDomainRequest();
  40407. xdr.ontimeout = function () {
  40408. socket.emit("error", new RequestTimedOut());
  40409. socket.close();
  40410. };
  40411. xdr.onerror = function (e) {
  40412. socket.emit("error", e);
  40413. socket.close();
  40414. };
  40415. xdr.onprogress = function () {
  40416. if (xdr.responseText && xdr.responseText.length > 0) {
  40417. socket.onChunk(200, xdr.responseText);
  40418. }
  40419. };
  40420. xdr.onload = function () {
  40421. if (xdr.responseText && xdr.responseText.length > 0) {
  40422. socket.onChunk(200, xdr.responseText);
  40423. }
  40424. socket.emit("finished", 200);
  40425. socket.close();
  40426. };
  40427. return xdr;
  40428. },
  40429. abortRequest: function (xdr) {
  40430. xdr.ontimeout = xdr.onerror = xdr.onprogress = xdr.onload = null;
  40431. xdr.abort();
  40432. }
  40433. };
  40434. /* harmony default export */ var http_xdomain_request = (http_xdomain_request_hooks);
  40435. // CONCATENATED MODULE: ./src/core/http/http_request.ts
  40436. var http_request_extends = (undefined && undefined.__extends) || (function () {
  40437. var extendStatics = function (d, b) {
  40438. extendStatics = Object.setPrototypeOf ||
  40439. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  40440. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  40441. return extendStatics(d, b);
  40442. };
  40443. return function (d, b) {
  40444. extendStatics(d, b);
  40445. function __() { this.constructor = d; }
  40446. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  40447. };
  40448. })();
  40449. var MAX_BUFFER_LENGTH = 256 * 1024;
  40450. var http_request_HTTPRequest = (function (_super) {
  40451. http_request_extends(HTTPRequest, _super);
  40452. function HTTPRequest(hooks, method, url) {
  40453. var _this = _super.call(this) || this;
  40454. _this.hooks = hooks;
  40455. _this.method = method;
  40456. _this.url = url;
  40457. return _this;
  40458. }
  40459. HTTPRequest.prototype.start = function (payload) {
  40460. var _this = this;
  40461. this.position = 0;
  40462. this.xhr = this.hooks.getRequest(this);
  40463. this.unloader = function () {
  40464. _this.close();
  40465. };
  40466. runtime.addUnloadListener(this.unloader);
  40467. this.xhr.open(this.method, this.url, true);
  40468. if (this.xhr.setRequestHeader) {
  40469. this.xhr.setRequestHeader("Content-Type", "application/json");
  40470. }
  40471. this.xhr.send(payload);
  40472. };
  40473. HTTPRequest.prototype.close = function () {
  40474. if (this.unloader) {
  40475. runtime.removeUnloadListener(this.unloader);
  40476. this.unloader = null;
  40477. }
  40478. if (this.xhr) {
  40479. this.hooks.abortRequest(this.xhr);
  40480. this.xhr = null;
  40481. }
  40482. };
  40483. HTTPRequest.prototype.onChunk = function (status, data) {
  40484. while (true) {
  40485. var chunk = this.advanceBuffer(data);
  40486. if (chunk) {
  40487. this.emit("chunk", { status: status, data: chunk });
  40488. }
  40489. else {
  40490. break;
  40491. }
  40492. }
  40493. if (this.isBufferTooLong(data)) {
  40494. this.emit("buffer_too_long");
  40495. }
  40496. };
  40497. HTTPRequest.prototype.advanceBuffer = function (buffer) {
  40498. var unreadData = buffer.slice(this.position);
  40499. var endOfLinePosition = unreadData.indexOf("\n");
  40500. if (endOfLinePosition !== -1) {
  40501. this.position += endOfLinePosition + 1;
  40502. return unreadData.slice(0, endOfLinePosition);
  40503. }
  40504. else {
  40505. return null;
  40506. }
  40507. };
  40508. HTTPRequest.prototype.isBufferTooLong = function (buffer) {
  40509. return this.position === buffer.length && buffer.length > MAX_BUFFER_LENGTH;
  40510. };
  40511. return HTTPRequest;
  40512. }(dispatcher));
  40513. /* harmony default export */ var http_request = (http_request_HTTPRequest);
  40514. // CONCATENATED MODULE: ./src/core/http/state.ts
  40515. var State;
  40516. (function (State) {
  40517. State[State["CONNECTING"] = 0] = "CONNECTING";
  40518. State[State["OPEN"] = 1] = "OPEN";
  40519. State[State["CLOSED"] = 3] = "CLOSED";
  40520. })(State || (State = {}));
  40521. /* harmony default export */ var state = (State);
  40522. // CONCATENATED MODULE: ./src/core/http/http_socket.ts
  40523. var autoIncrement = 1;
  40524. var http_socket_HTTPSocket = (function () {
  40525. function HTTPSocket(hooks, url) {
  40526. this.hooks = hooks;
  40527. this.session = randomNumber(1000) + "/" + randomString(8);
  40528. this.location = getLocation(url);
  40529. this.readyState = state.CONNECTING;
  40530. this.openStream();
  40531. }
  40532. HTTPSocket.prototype.send = function (payload) {
  40533. return this.sendRaw(JSON.stringify([payload]));
  40534. };
  40535. HTTPSocket.prototype.ping = function () {
  40536. this.hooks.sendHeartbeat(this);
  40537. };
  40538. HTTPSocket.prototype.close = function (code, reason) {
  40539. this.onClose(code, reason, true);
  40540. };
  40541. HTTPSocket.prototype.sendRaw = function (payload) {
  40542. if (this.readyState === state.OPEN) {
  40543. try {
  40544. runtime.createSocketRequest("POST", getUniqueURL(getSendURL(this.location, this.session))).start(payload);
  40545. return true;
  40546. }
  40547. catch (e) {
  40548. return false;
  40549. }
  40550. }
  40551. else {
  40552. return false;
  40553. }
  40554. };
  40555. HTTPSocket.prototype.reconnect = function () {
  40556. this.closeStream();
  40557. this.openStream();
  40558. };
  40559. ;
  40560. HTTPSocket.prototype.onClose = function (code, reason, wasClean) {
  40561. this.closeStream();
  40562. this.readyState = state.CLOSED;
  40563. if (this.onclose) {
  40564. this.onclose({
  40565. code: code,
  40566. reason: reason,
  40567. wasClean: wasClean
  40568. });
  40569. }
  40570. };
  40571. HTTPSocket.prototype.onChunk = function (chunk) {
  40572. if (chunk.status !== 200) {
  40573. return;
  40574. }
  40575. if (this.readyState === state.OPEN) {
  40576. this.onActivity();
  40577. }
  40578. var payload;
  40579. var type = chunk.data.slice(0, 1);
  40580. switch (type) {
  40581. case 'o':
  40582. payload = JSON.parse(chunk.data.slice(1) || '{}');
  40583. this.onOpen(payload);
  40584. break;
  40585. case 'a':
  40586. payload = JSON.parse(chunk.data.slice(1) || '[]');
  40587. for (var i = 0; i < payload.length; i++) {
  40588. this.onEvent(payload[i]);
  40589. }
  40590. break;
  40591. case 'm':
  40592. payload = JSON.parse(chunk.data.slice(1) || 'null');
  40593. this.onEvent(payload);
  40594. break;
  40595. case 'h':
  40596. this.hooks.onHeartbeat(this);
  40597. break;
  40598. case 'c':
  40599. payload = JSON.parse(chunk.data.slice(1) || '[]');
  40600. this.onClose(payload[0], payload[1], true);
  40601. break;
  40602. }
  40603. };
  40604. HTTPSocket.prototype.onOpen = function (options) {
  40605. if (this.readyState === state.CONNECTING) {
  40606. if (options && options.hostname) {
  40607. this.location.base = replaceHost(this.location.base, options.hostname);
  40608. }
  40609. this.readyState = state.OPEN;
  40610. if (this.onopen) {
  40611. this.onopen();
  40612. }
  40613. }
  40614. else {
  40615. this.onClose(1006, "Server lost session", true);
  40616. }
  40617. };
  40618. HTTPSocket.prototype.onEvent = function (event) {
  40619. if (this.readyState === state.OPEN && this.onmessage) {
  40620. this.onmessage({ data: event });
  40621. }
  40622. };
  40623. HTTPSocket.prototype.onActivity = function () {
  40624. if (this.onactivity) {
  40625. this.onactivity();
  40626. }
  40627. };
  40628. HTTPSocket.prototype.onError = function (error) {
  40629. if (this.onerror) {
  40630. this.onerror(error);
  40631. }
  40632. };
  40633. HTTPSocket.prototype.openStream = function () {
  40634. var _this = this;
  40635. this.stream = runtime.createSocketRequest("POST", getUniqueURL(this.hooks.getReceiveURL(this.location, this.session)));
  40636. this.stream.bind("chunk", function (chunk) {
  40637. _this.onChunk(chunk);
  40638. });
  40639. this.stream.bind("finished", function (status) {
  40640. _this.hooks.onFinished(_this, status);
  40641. });
  40642. this.stream.bind("buffer_too_long", function () {
  40643. _this.reconnect();
  40644. });
  40645. try {
  40646. this.stream.start();
  40647. }
  40648. catch (error) {
  40649. util.defer(function () {
  40650. _this.onError(error);
  40651. _this.onClose(1006, "Could not start streaming", false);
  40652. });
  40653. }
  40654. };
  40655. HTTPSocket.prototype.closeStream = function () {
  40656. if (this.stream) {
  40657. this.stream.unbind_all();
  40658. this.stream.close();
  40659. this.stream = null;
  40660. }
  40661. };
  40662. return HTTPSocket;
  40663. }());
  40664. function getLocation(url) {
  40665. var parts = /([^\?]*)\/*(\??.*)/.exec(url);
  40666. return {
  40667. base: parts[1],
  40668. queryString: parts[2]
  40669. };
  40670. }
  40671. function getSendURL(url, session) {
  40672. return url.base + "/" + session + "/xhr_send";
  40673. }
  40674. function getUniqueURL(url) {
  40675. var separator = (url.indexOf('?') === -1) ? "?" : "&";
  40676. return url + separator + "t=" + (+new Date()) + "&n=" + autoIncrement++;
  40677. }
  40678. function replaceHost(url, hostname) {
  40679. var urlParts = /(https?:\/\/)([^\/:]+)((\/|:)?.*)/.exec(url);
  40680. return urlParts[1] + hostname + urlParts[3];
  40681. }
  40682. function randomNumber(max) {
  40683. return Math.floor(Math.random() * max);
  40684. }
  40685. function randomString(length) {
  40686. var result = [];
  40687. for (var i = 0; i < length; i++) {
  40688. result.push(randomNumber(32).toString(32));
  40689. }
  40690. return result.join('');
  40691. }
  40692. /* harmony default export */ var http_socket = (http_socket_HTTPSocket);
  40693. // CONCATENATED MODULE: ./src/core/http/http_streaming_socket.ts
  40694. var http_streaming_socket_hooks = {
  40695. getReceiveURL: function (url, session) {
  40696. return url.base + "/" + session + "/xhr_streaming" + url.queryString;
  40697. },
  40698. onHeartbeat: function (socket) {
  40699. socket.sendRaw("[]");
  40700. },
  40701. sendHeartbeat: function (socket) {
  40702. socket.sendRaw("[]");
  40703. },
  40704. onFinished: function (socket, status) {
  40705. socket.onClose(1006, "Connection interrupted (" + status + ")", false);
  40706. }
  40707. };
  40708. /* harmony default export */ var http_streaming_socket = (http_streaming_socket_hooks);
  40709. // CONCATENATED MODULE: ./src/core/http/http_polling_socket.ts
  40710. var http_polling_socket_hooks = {
  40711. getReceiveURL: function (url, session) {
  40712. return url.base + "/" + session + "/xhr" + url.queryString;
  40713. },
  40714. onHeartbeat: function () {
  40715. },
  40716. sendHeartbeat: function (socket) {
  40717. socket.sendRaw("[]");
  40718. },
  40719. onFinished: function (socket, status) {
  40720. if (status === 200) {
  40721. socket.reconnect();
  40722. }
  40723. else {
  40724. socket.onClose(1006, "Connection interrupted (" + status + ")", false);
  40725. }
  40726. }
  40727. };
  40728. /* harmony default export */ var http_polling_socket = (http_polling_socket_hooks);
  40729. // CONCATENATED MODULE: ./src/runtimes/isomorphic/http/http_xhr_request.ts
  40730. var http_xhr_request_hooks = {
  40731. getRequest: function (socket) {
  40732. var Constructor = runtime.getXHRAPI();
  40733. var xhr = new Constructor();
  40734. xhr.onreadystatechange = xhr.onprogress = function () {
  40735. switch (xhr.readyState) {
  40736. case 3:
  40737. if (xhr.responseText && xhr.responseText.length > 0) {
  40738. socket.onChunk(xhr.status, xhr.responseText);
  40739. }
  40740. break;
  40741. case 4:
  40742. if (xhr.responseText && xhr.responseText.length > 0) {
  40743. socket.onChunk(xhr.status, xhr.responseText);
  40744. }
  40745. socket.emit("finished", xhr.status);
  40746. socket.close();
  40747. break;
  40748. }
  40749. };
  40750. return xhr;
  40751. },
  40752. abortRequest: function (xhr) {
  40753. xhr.onreadystatechange = null;
  40754. xhr.abort();
  40755. }
  40756. };
  40757. /* harmony default export */ var http_xhr_request = (http_xhr_request_hooks);
  40758. // CONCATENATED MODULE: ./src/runtimes/isomorphic/http/http.ts
  40759. var HTTP = {
  40760. createStreamingSocket: function (url) {
  40761. return this.createSocket(http_streaming_socket, url);
  40762. },
  40763. createPollingSocket: function (url) {
  40764. return this.createSocket(http_polling_socket, url);
  40765. },
  40766. createSocket: function (hooks, url) {
  40767. return new http_socket(hooks, url);
  40768. },
  40769. createXHR: function (method, url) {
  40770. return this.createRequest(http_xhr_request, method, url);
  40771. },
  40772. createRequest: function (hooks, method, url) {
  40773. return new http_request(hooks, method, url);
  40774. }
  40775. };
  40776. /* harmony default export */ var http_http = (HTTP);
  40777. // CONCATENATED MODULE: ./src/runtimes/web/http/http.ts
  40778. http_http.createXDR = function (method, url) {
  40779. return this.createRequest(http_xdomain_request, method, url);
  40780. };
  40781. /* harmony default export */ var web_http_http = (http_http);
  40782. // CONCATENATED MODULE: ./src/runtimes/web/runtime.ts
  40783. var Runtime = {
  40784. nextAuthCallbackID: 1,
  40785. auth_callbacks: {},
  40786. ScriptReceivers: ScriptReceivers,
  40787. DependenciesReceivers: DependenciesReceivers,
  40788. getDefaultStrategy: default_strategy,
  40789. Transports: transports_transports,
  40790. transportConnectionInitializer: transport_connection_initializer,
  40791. HTTPFactory: web_http_http,
  40792. TimelineTransport: jsonp_timeline,
  40793. getXHRAPI: function () {
  40794. return window.XMLHttpRequest;
  40795. },
  40796. getWebSocketAPI: function () {
  40797. return window.WebSocket || window.MozWebSocket;
  40798. },
  40799. setup: function (PusherClass) {
  40800. var _this = this;
  40801. window.Pusher = PusherClass;
  40802. var initializeOnDocumentBody = function () {
  40803. _this.onDocumentBody(PusherClass.ready);
  40804. };
  40805. if (!window.JSON) {
  40806. Dependencies.load("json2", {}, initializeOnDocumentBody);
  40807. }
  40808. else {
  40809. initializeOnDocumentBody();
  40810. }
  40811. },
  40812. getDocument: function () {
  40813. return document;
  40814. },
  40815. getProtocol: function () {
  40816. return this.getDocument().location.protocol;
  40817. },
  40818. getAuthorizers: function () {
  40819. return { ajax: xhr_auth, jsonp: jsonp_auth };
  40820. },
  40821. onDocumentBody: function (callback) {
  40822. var _this = this;
  40823. if (document.body) {
  40824. callback();
  40825. }
  40826. else {
  40827. setTimeout(function () {
  40828. _this.onDocumentBody(callback);
  40829. }, 0);
  40830. }
  40831. },
  40832. createJSONPRequest: function (url, data) {
  40833. return new jsonp_request(url, data);
  40834. },
  40835. createScriptRequest: function (src) {
  40836. return new script_request(src);
  40837. },
  40838. getLocalStorage: function () {
  40839. try {
  40840. return window.localStorage;
  40841. }
  40842. catch (e) {
  40843. return undefined;
  40844. }
  40845. },
  40846. createXHR: function () {
  40847. if (this.getXHRAPI()) {
  40848. return this.createXMLHttpRequest();
  40849. }
  40850. else {
  40851. return this.createMicrosoftXHR();
  40852. }
  40853. },
  40854. createXMLHttpRequest: function () {
  40855. var Constructor = this.getXHRAPI();
  40856. return new Constructor();
  40857. },
  40858. createMicrosoftXHR: function () {
  40859. return new ActiveXObject("Microsoft.XMLHTTP");
  40860. },
  40861. getNetwork: function () {
  40862. return net_info_Network;
  40863. },
  40864. createWebSocket: function (url) {
  40865. var Constructor = this.getWebSocketAPI();
  40866. return new Constructor(url);
  40867. },
  40868. createSocketRequest: function (method, url) {
  40869. if (this.isXHRSupported()) {
  40870. return this.HTTPFactory.createXHR(method, url);
  40871. }
  40872. else if (this.isXDRSupported(url.indexOf("https:") === 0)) {
  40873. return this.HTTPFactory.createXDR(method, url);
  40874. }
  40875. else {
  40876. throw "Cross-origin HTTP requests are not supported";
  40877. }
  40878. },
  40879. isXHRSupported: function () {
  40880. var Constructor = this.getXHRAPI();
  40881. return Boolean(Constructor) && (new Constructor()).withCredentials !== undefined;
  40882. },
  40883. isXDRSupported: function (useTLS) {
  40884. var protocol = useTLS ? "https:" : "http:";
  40885. var documentProtocol = this.getProtocol();
  40886. return Boolean((window['XDomainRequest'])) && documentProtocol === protocol;
  40887. },
  40888. addUnloadListener: function (listener) {
  40889. if (window.addEventListener !== undefined) {
  40890. window.addEventListener("unload", listener, false);
  40891. }
  40892. else if (window.attachEvent !== undefined) {
  40893. window.attachEvent("onunload", listener);
  40894. }
  40895. },
  40896. removeUnloadListener: function (listener) {
  40897. if (window.addEventListener !== undefined) {
  40898. window.removeEventListener("unload", listener, false);
  40899. }
  40900. else if (window.detachEvent !== undefined) {
  40901. window.detachEvent("onunload", listener);
  40902. }
  40903. }
  40904. };
  40905. /* harmony default export */ var runtime = (Runtime);
  40906. // CONCATENATED MODULE: ./src/core/timeline/level.ts
  40907. var TimelineLevel;
  40908. (function (TimelineLevel) {
  40909. TimelineLevel[TimelineLevel["ERROR"] = 3] = "ERROR";
  40910. TimelineLevel[TimelineLevel["INFO"] = 6] = "INFO";
  40911. TimelineLevel[TimelineLevel["DEBUG"] = 7] = "DEBUG";
  40912. })(TimelineLevel || (TimelineLevel = {}));
  40913. /* harmony default export */ var timeline_level = (TimelineLevel);
  40914. // CONCATENATED MODULE: ./src/core/timeline/timeline.ts
  40915. var timeline_Timeline = (function () {
  40916. function Timeline(key, session, options) {
  40917. this.key = key;
  40918. this.session = session;
  40919. this.events = [];
  40920. this.options = options || {};
  40921. this.sent = 0;
  40922. this.uniqueID = 0;
  40923. }
  40924. Timeline.prototype.log = function (level, event) {
  40925. if (level <= this.options.level) {
  40926. this.events.push(extend({}, event, { timestamp: util.now() }));
  40927. if (this.options.limit && this.events.length > this.options.limit) {
  40928. this.events.shift();
  40929. }
  40930. }
  40931. };
  40932. Timeline.prototype.error = function (event) {
  40933. this.log(timeline_level.ERROR, event);
  40934. };
  40935. Timeline.prototype.info = function (event) {
  40936. this.log(timeline_level.INFO, event);
  40937. };
  40938. Timeline.prototype.debug = function (event) {
  40939. this.log(timeline_level.DEBUG, event);
  40940. };
  40941. Timeline.prototype.isEmpty = function () {
  40942. return this.events.length === 0;
  40943. };
  40944. Timeline.prototype.send = function (sendfn, callback) {
  40945. var _this = this;
  40946. var data = extend({
  40947. session: this.session,
  40948. bundle: this.sent + 1,
  40949. key: this.key,
  40950. lib: "js",
  40951. version: this.options.version,
  40952. cluster: this.options.cluster,
  40953. features: this.options.features,
  40954. timeline: this.events
  40955. }, this.options.params);
  40956. this.events = [];
  40957. sendfn(data, function (error, result) {
  40958. if (!error) {
  40959. _this.sent++;
  40960. }
  40961. if (callback) {
  40962. callback(error, result);
  40963. }
  40964. });
  40965. return true;
  40966. };
  40967. Timeline.prototype.generateUniqueID = function () {
  40968. this.uniqueID++;
  40969. return this.uniqueID;
  40970. };
  40971. return Timeline;
  40972. }());
  40973. /* harmony default export */ var timeline_timeline = (timeline_Timeline);
  40974. // CONCATENATED MODULE: ./src/core/strategies/transport_strategy.ts
  40975. var transport_strategy_TransportStrategy = (function () {
  40976. function TransportStrategy(name, priority, transport, options) {
  40977. this.name = name;
  40978. this.priority = priority;
  40979. this.transport = transport;
  40980. this.options = options || {};
  40981. }
  40982. TransportStrategy.prototype.isSupported = function () {
  40983. return this.transport.isSupported({
  40984. useTLS: this.options.useTLS
  40985. });
  40986. };
  40987. TransportStrategy.prototype.connect = function (minPriority, callback) {
  40988. var _this = this;
  40989. if (!this.isSupported()) {
  40990. return failAttempt(new UnsupportedStrategy(), callback);
  40991. }
  40992. else if (this.priority < minPriority) {
  40993. return failAttempt(new TransportPriorityTooLow(), callback);
  40994. }
  40995. var connected = false;
  40996. var transport = this.transport.createConnection(this.name, this.priority, this.options.key, this.options);
  40997. var handshake = null;
  40998. var onInitialized = function () {
  40999. transport.unbind("initialized", onInitialized);
  41000. transport.connect();
  41001. };
  41002. var onOpen = function () {
  41003. handshake = factory.createHandshake(transport, function (result) {
  41004. connected = true;
  41005. unbindListeners();
  41006. callback(null, result);
  41007. });
  41008. };
  41009. var onError = function (error) {
  41010. unbindListeners();
  41011. callback(error);
  41012. };
  41013. var onClosed = function () {
  41014. unbindListeners();
  41015. var serializedTransport;
  41016. serializedTransport = safeJSONStringify(transport);
  41017. callback(new TransportClosed(serializedTransport));
  41018. };
  41019. var unbindListeners = function () {
  41020. transport.unbind("initialized", onInitialized);
  41021. transport.unbind("open", onOpen);
  41022. transport.unbind("error", onError);
  41023. transport.unbind("closed", onClosed);
  41024. };
  41025. transport.bind("initialized", onInitialized);
  41026. transport.bind("open", onOpen);
  41027. transport.bind("error", onError);
  41028. transport.bind("closed", onClosed);
  41029. transport.initialize();
  41030. return {
  41031. abort: function () {
  41032. if (connected) {
  41033. return;
  41034. }
  41035. unbindListeners();
  41036. if (handshake) {
  41037. handshake.close();
  41038. }
  41039. else {
  41040. transport.close();
  41041. }
  41042. },
  41043. forceMinPriority: function (p) {
  41044. if (connected) {
  41045. return;
  41046. }
  41047. if (_this.priority < p) {
  41048. if (handshake) {
  41049. handshake.close();
  41050. }
  41051. else {
  41052. transport.close();
  41053. }
  41054. }
  41055. }
  41056. };
  41057. };
  41058. return TransportStrategy;
  41059. }());
  41060. /* harmony default export */ var transport_strategy = (transport_strategy_TransportStrategy);
  41061. function failAttempt(error, callback) {
  41062. util.defer(function () {
  41063. callback(error);
  41064. });
  41065. return {
  41066. abort: function () { },
  41067. forceMinPriority: function () { }
  41068. };
  41069. }
  41070. // CONCATENATED MODULE: ./src/core/strategies/strategy_builder.ts
  41071. var strategy_builder_Transports = runtime.Transports;
  41072. var strategy_builder_defineTransport = function (config, name, type, priority, options, manager) {
  41073. var transportClass = strategy_builder_Transports[type];
  41074. if (!transportClass) {
  41075. throw new UnsupportedTransport(type);
  41076. }
  41077. var enabled = (!config.enabledTransports ||
  41078. arrayIndexOf(config.enabledTransports, name) !== -1) &&
  41079. (!config.disabledTransports ||
  41080. arrayIndexOf(config.disabledTransports, name) === -1);
  41081. var transport;
  41082. if (enabled) {
  41083. transport = new transport_strategy(name, priority, manager ? manager.getAssistant(transportClass) : transportClass, extend({
  41084. key: config.key,
  41085. useTLS: config.useTLS,
  41086. timeline: config.timeline,
  41087. ignoreNullOrigin: config.ignoreNullOrigin
  41088. }, options));
  41089. }
  41090. else {
  41091. transport = strategy_builder_UnsupportedStrategy;
  41092. }
  41093. return transport;
  41094. };
  41095. var strategy_builder_UnsupportedStrategy = {
  41096. isSupported: function () {
  41097. return false;
  41098. },
  41099. connect: function (_, callback) {
  41100. var deferred = util.defer(function () {
  41101. callback(new UnsupportedStrategy());
  41102. });
  41103. return {
  41104. abort: function () {
  41105. deferred.ensureAborted();
  41106. },
  41107. forceMinPriority: function () { }
  41108. };
  41109. }
  41110. };
  41111. // CONCATENATED MODULE: ./src/core/config.ts
  41112. var getGlobalConfig = function () {
  41113. return {
  41114. wsHost: defaults.host,
  41115. wsPort: defaults.ws_port,
  41116. wssPort: defaults.wss_port,
  41117. wsPath: defaults.ws_path,
  41118. httpHost: defaults.sockjs_host,
  41119. httpPort: defaults.sockjs_http_port,
  41120. httpsPort: defaults.sockjs_https_port,
  41121. httpPath: defaults.sockjs_path,
  41122. statsHost: defaults.stats_host,
  41123. authEndpoint: defaults.channel_auth_endpoint,
  41124. authTransport: defaults.channel_auth_transport,
  41125. activity_timeout: defaults.activity_timeout,
  41126. pong_timeout: defaults.pong_timeout,
  41127. unavailable_timeout: defaults.unavailable_timeout
  41128. };
  41129. };
  41130. var getClusterConfig = function (clusterName) {
  41131. return {
  41132. wsHost: 'ws-' + clusterName + '.pusher.com',
  41133. httpHost: 'sockjs-' + clusterName + '.pusher.com'
  41134. };
  41135. };
  41136. // CONCATENATED MODULE: ./src/core/pusher.ts
  41137. var pusher_Pusher = (function () {
  41138. function Pusher(app_key, options) {
  41139. var _this = this;
  41140. checkAppKey(app_key);
  41141. options = options || {};
  41142. if (!options.cluster && !(options.wsHost || options.httpHost)) {
  41143. var suffix = url_store.buildLogSuffix('javascriptQuickStart');
  41144. logger.warn("You should always specify a cluster when connecting. " + suffix);
  41145. }
  41146. this.key = app_key;
  41147. this.config = extend(getGlobalConfig(), options.cluster ? getClusterConfig(options.cluster) : {}, options);
  41148. this.channels = factory.createChannels();
  41149. this.global_emitter = new dispatcher();
  41150. this.sessionID = Math.floor(Math.random() * 1000000000);
  41151. this.timeline = new timeline_timeline(this.key, this.sessionID, {
  41152. cluster: this.config.cluster,
  41153. features: Pusher.getClientFeatures(),
  41154. params: this.config.timelineParams || {},
  41155. limit: 50,
  41156. level: timeline_level.INFO,
  41157. version: defaults.VERSION
  41158. });
  41159. if (!this.config.disableStats) {
  41160. this.timelineSender = factory.createTimelineSender(this.timeline, {
  41161. host: this.config.statsHost,
  41162. path: '/timeline/v2/' + runtime.TimelineTransport.name
  41163. });
  41164. }
  41165. var getStrategy = function (options) {
  41166. var config = extend({}, _this.config, options);
  41167. return runtime.getDefaultStrategy(config, strategy_builder_defineTransport);
  41168. };
  41169. this.connection = factory.createConnectionManager(this.key, extend({
  41170. getStrategy: getStrategy,
  41171. timeline: this.timeline,
  41172. activityTimeout: this.config.activity_timeout,
  41173. pongTimeout: this.config.pong_timeout,
  41174. unavailableTimeout: this.config.unavailable_timeout
  41175. }, this.config, { useTLS: this.shouldUseTLS() }));
  41176. this.connection.bind('connected', function () {
  41177. _this.subscribeAll();
  41178. if (_this.timelineSender) {
  41179. _this.timelineSender.send(_this.connection.isUsingTLS());
  41180. }
  41181. });
  41182. this.connection.bind('message', function (event) {
  41183. var eventName = event.event;
  41184. var internal = eventName.indexOf('pusher_internal:') === 0;
  41185. if (event.channel) {
  41186. var channel = _this.channel(event.channel);
  41187. if (channel) {
  41188. channel.handleEvent(event);
  41189. }
  41190. }
  41191. if (!internal) {
  41192. _this.global_emitter.emit(event.event, event.data);
  41193. }
  41194. });
  41195. this.connection.bind('connecting', function () {
  41196. _this.channels.disconnect();
  41197. });
  41198. this.connection.bind('disconnected', function () {
  41199. _this.channels.disconnect();
  41200. });
  41201. this.connection.bind('error', function (err) {
  41202. logger.warn(err);
  41203. });
  41204. Pusher.instances.push(this);
  41205. this.timeline.info({ instances: Pusher.instances.length });
  41206. if (Pusher.isReady) {
  41207. this.connect();
  41208. }
  41209. }
  41210. Pusher.ready = function () {
  41211. Pusher.isReady = true;
  41212. for (var i = 0, l = Pusher.instances.length; i < l; i++) {
  41213. Pusher.instances[i].connect();
  41214. }
  41215. };
  41216. Pusher.getClientFeatures = function () {
  41217. return keys(filterObject({ ws: runtime.Transports.ws }, function (t) {
  41218. return t.isSupported({});
  41219. }));
  41220. };
  41221. Pusher.prototype.channel = function (name) {
  41222. return this.channels.find(name);
  41223. };
  41224. Pusher.prototype.allChannels = function () {
  41225. return this.channels.all();
  41226. };
  41227. Pusher.prototype.connect = function () {
  41228. this.connection.connect();
  41229. if (this.timelineSender) {
  41230. if (!this.timelineSenderTimer) {
  41231. var usingTLS = this.connection.isUsingTLS();
  41232. var timelineSender = this.timelineSender;
  41233. this.timelineSenderTimer = new PeriodicTimer(60000, function () {
  41234. timelineSender.send(usingTLS);
  41235. });
  41236. }
  41237. }
  41238. };
  41239. Pusher.prototype.disconnect = function () {
  41240. this.connection.disconnect();
  41241. if (this.timelineSenderTimer) {
  41242. this.timelineSenderTimer.ensureAborted();
  41243. this.timelineSenderTimer = null;
  41244. }
  41245. };
  41246. Pusher.prototype.bind = function (event_name, callback, context) {
  41247. this.global_emitter.bind(event_name, callback, context);
  41248. return this;
  41249. };
  41250. Pusher.prototype.unbind = function (event_name, callback, context) {
  41251. this.global_emitter.unbind(event_name, callback, context);
  41252. return this;
  41253. };
  41254. Pusher.prototype.bind_global = function (callback) {
  41255. this.global_emitter.bind_global(callback);
  41256. return this;
  41257. };
  41258. Pusher.prototype.unbind_global = function (callback) {
  41259. this.global_emitter.unbind_global(callback);
  41260. return this;
  41261. };
  41262. Pusher.prototype.unbind_all = function (callback) {
  41263. this.global_emitter.unbind_all();
  41264. return this;
  41265. };
  41266. Pusher.prototype.subscribeAll = function () {
  41267. var channelName;
  41268. for (channelName in this.channels.channels) {
  41269. if (this.channels.channels.hasOwnProperty(channelName)) {
  41270. this.subscribe(channelName);
  41271. }
  41272. }
  41273. };
  41274. Pusher.prototype.subscribe = function (channel_name) {
  41275. var channel = this.channels.add(channel_name, this);
  41276. if (channel.subscriptionPending && channel.subscriptionCancelled) {
  41277. channel.reinstateSubscription();
  41278. }
  41279. else if (!channel.subscriptionPending &&
  41280. this.connection.state === 'connected') {
  41281. channel.subscribe();
  41282. }
  41283. return channel;
  41284. };
  41285. Pusher.prototype.unsubscribe = function (channel_name) {
  41286. var channel = this.channels.find(channel_name);
  41287. if (channel && channel.subscriptionPending) {
  41288. channel.cancelSubscription();
  41289. }
  41290. else {
  41291. channel = this.channels.remove(channel_name);
  41292. if (channel && this.connection.state === 'connected') {
  41293. channel.unsubscribe();
  41294. }
  41295. }
  41296. };
  41297. Pusher.prototype.send_event = function (event_name, data, channel) {
  41298. return this.connection.send_event(event_name, data, channel);
  41299. };
  41300. Pusher.prototype.shouldUseTLS = function () {
  41301. if (runtime.getProtocol() === 'https:') {
  41302. return true;
  41303. }
  41304. else if (this.config.forceTLS === true) {
  41305. return true;
  41306. }
  41307. else {
  41308. return Boolean(this.config.encrypted);
  41309. }
  41310. };
  41311. Pusher.instances = [];
  41312. Pusher.isReady = false;
  41313. Pusher.logToConsole = false;
  41314. Pusher.Runtime = runtime;
  41315. Pusher.ScriptReceivers = runtime.ScriptReceivers;
  41316. Pusher.DependenciesReceivers = runtime.DependenciesReceivers;
  41317. Pusher.auth_callbacks = runtime.auth_callbacks;
  41318. return Pusher;
  41319. }());
  41320. /* harmony default export */ var core_pusher = __webpack_exports__["default"] = (pusher_Pusher);
  41321. function checkAppKey(key) {
  41322. if (key === null || key === undefined) {
  41323. throw 'You must pass your app key when you instantiate Pusher.';
  41324. }
  41325. }
  41326. runtime.setup(pusher_Pusher);
  41327. /***/ })
  41328. /******/ ]);
  41329. });
  41330. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../../buffer/index.js */ "./node_modules/buffer/index.js").Buffer))
  41331. /***/ }),
  41332. /***/ "./node_modules/setimmediate/setImmediate.js":
  41333. /*!***************************************************!*\
  41334. !*** ./node_modules/setimmediate/setImmediate.js ***!
  41335. \***************************************************/
  41336. /*! no static exports found */
  41337. /***/ (function(module, exports, __webpack_require__) {
  41338. /* WEBPACK VAR INJECTION */(function(global, process) {(function (global, undefined) {
  41339. "use strict";
  41340. if (global.setImmediate) {
  41341. return;
  41342. }
  41343. var nextHandle = 1; // Spec says greater than zero
  41344. var tasksByHandle = {};
  41345. var currentlyRunningATask = false;
  41346. var doc = global.document;
  41347. var registerImmediate;
  41348. function setImmediate(callback) {
  41349. // Callback can either be a function or a string
  41350. if (typeof callback !== "function") {
  41351. callback = new Function("" + callback);
  41352. }
  41353. // Copy function arguments
  41354. var args = new Array(arguments.length - 1);
  41355. for (var i = 0; i < args.length; i++) {
  41356. args[i] = arguments[i + 1];
  41357. }
  41358. // Store and register the task
  41359. var task = { callback: callback, args: args };
  41360. tasksByHandle[nextHandle] = task;
  41361. registerImmediate(nextHandle);
  41362. return nextHandle++;
  41363. }
  41364. function clearImmediate(handle) {
  41365. delete tasksByHandle[handle];
  41366. }
  41367. function run(task) {
  41368. var callback = task.callback;
  41369. var args = task.args;
  41370. switch (args.length) {
  41371. case 0:
  41372. callback();
  41373. break;
  41374. case 1:
  41375. callback(args[0]);
  41376. break;
  41377. case 2:
  41378. callback(args[0], args[1]);
  41379. break;
  41380. case 3:
  41381. callback(args[0], args[1], args[2]);
  41382. break;
  41383. default:
  41384. callback.apply(undefined, args);
  41385. break;
  41386. }
  41387. }
  41388. function runIfPresent(handle) {
  41389. // From the spec: "Wait until any invocations of this algorithm started before this one have completed."
  41390. // So if we're currently running a task, we'll need to delay this invocation.
  41391. if (currentlyRunningATask) {
  41392. // Delay by doing a setTimeout. setImmediate was tried instead, but in Firefox 7 it generated a
  41393. // "too much recursion" error.
  41394. setTimeout(runIfPresent, 0, handle);
  41395. } else {
  41396. var task = tasksByHandle[handle];
  41397. if (task) {
  41398. currentlyRunningATask = true;
  41399. try {
  41400. run(task);
  41401. } finally {
  41402. clearImmediate(handle);
  41403. currentlyRunningATask = false;
  41404. }
  41405. }
  41406. }
  41407. }
  41408. function installNextTickImplementation() {
  41409. registerImmediate = function(handle) {
  41410. process.nextTick(function () { runIfPresent(handle); });
  41411. };
  41412. }
  41413. function canUsePostMessage() {
  41414. // The test against `importScripts` prevents this implementation from being installed inside a web worker,
  41415. // where `global.postMessage` means something completely different and can't be used for this purpose.
  41416. if (global.postMessage && !global.importScripts) {
  41417. var postMessageIsAsynchronous = true;
  41418. var oldOnMessage = global.onmessage;
  41419. global.onmessage = function() {
  41420. postMessageIsAsynchronous = false;
  41421. };
  41422. global.postMessage("", "*");
  41423. global.onmessage = oldOnMessage;
  41424. return postMessageIsAsynchronous;
  41425. }
  41426. }
  41427. function installPostMessageImplementation() {
  41428. // Installs an event handler on `global` for the `message` event: see
  41429. // * https://developer.mozilla.org/en/DOM/window.postMessage
  41430. // * http://www.whatwg.org/specs/web-apps/current-work/multipage/comms.html#crossDocumentMessages
  41431. var messagePrefix = "setImmediate$" + Math.random() + "$";
  41432. var onGlobalMessage = function(event) {
  41433. if (event.source === global &&
  41434. typeof event.data === "string" &&
  41435. event.data.indexOf(messagePrefix) === 0) {
  41436. runIfPresent(+event.data.slice(messagePrefix.length));
  41437. }
  41438. };
  41439. if (global.addEventListener) {
  41440. global.addEventListener("message", onGlobalMessage, false);
  41441. } else {
  41442. global.attachEvent("onmessage", onGlobalMessage);
  41443. }
  41444. registerImmediate = function(handle) {
  41445. global.postMessage(messagePrefix + handle, "*");
  41446. };
  41447. }
  41448. function installMessageChannelImplementation() {
  41449. var channel = new MessageChannel();
  41450. channel.port1.onmessage = function(event) {
  41451. var handle = event.data;
  41452. runIfPresent(handle);
  41453. };
  41454. registerImmediate = function(handle) {
  41455. channel.port2.postMessage(handle);
  41456. };
  41457. }
  41458. function installReadyStateChangeImplementation() {
  41459. var html = doc.documentElement;
  41460. registerImmediate = function(handle) {
  41461. // Create a <script> element; its readystatechange event will be fired asynchronously once it is inserted
  41462. // into the document. Do so, thus queuing up the task. Remember to clean up once it's been called.
  41463. var script = doc.createElement("script");
  41464. script.onreadystatechange = function () {
  41465. runIfPresent(handle);
  41466. script.onreadystatechange = null;
  41467. html.removeChild(script);
  41468. script = null;
  41469. };
  41470. html.appendChild(script);
  41471. };
  41472. }
  41473. function installSetTimeoutImplementation() {
  41474. registerImmediate = function(handle) {
  41475. setTimeout(runIfPresent, 0, handle);
  41476. };
  41477. }
  41478. // If supported, we should attach to the prototype of global, since that is where setTimeout et al. live.
  41479. var attachTo = Object.getPrototypeOf && Object.getPrototypeOf(global);
  41480. attachTo = attachTo && attachTo.setTimeout ? attachTo : global;
  41481. // Don't get fooled by e.g. browserify environments.
  41482. if ({}.toString.call(global.process) === "[object process]") {
  41483. // For Node.js before 0.9
  41484. installNextTickImplementation();
  41485. } else if (canUsePostMessage()) {
  41486. // For non-IE10 modern browsers
  41487. installPostMessageImplementation();
  41488. } else if (global.MessageChannel) {
  41489. // For web workers, where supported
  41490. installMessageChannelImplementation();
  41491. } else if (doc && "onreadystatechange" in doc.createElement("script")) {
  41492. // For IE 6–8
  41493. installReadyStateChangeImplementation();
  41494. } else {
  41495. // For older browsers
  41496. installSetTimeoutImplementation();
  41497. }
  41498. attachTo.setImmediate = setImmediate;
  41499. attachTo.clearImmediate = clearImmediate;
  41500. }(typeof self === "undefined" ? typeof global === "undefined" ? this : global : self));
  41501. /* 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")))
  41502. /***/ }),
  41503. /***/ "./node_modules/timers-browserify/main.js":
  41504. /*!************************************************!*\
  41505. !*** ./node_modules/timers-browserify/main.js ***!
  41506. \************************************************/
  41507. /*! no static exports found */
  41508. /***/ (function(module, exports, __webpack_require__) {
  41509. /* WEBPACK VAR INJECTION */(function(global) {var scope = (typeof global !== "undefined" && global) ||
  41510. (typeof self !== "undefined" && self) ||
  41511. window;
  41512. var apply = Function.prototype.apply;
  41513. // DOM APIs, for completeness
  41514. exports.setTimeout = function() {
  41515. return new Timeout(apply.call(setTimeout, scope, arguments), clearTimeout);
  41516. };
  41517. exports.setInterval = function() {
  41518. return new Timeout(apply.call(setInterval, scope, arguments), clearInterval);
  41519. };
  41520. exports.clearTimeout =
  41521. exports.clearInterval = function(timeout) {
  41522. if (timeout) {
  41523. timeout.close();
  41524. }
  41525. };
  41526. function Timeout(id, clearFn) {
  41527. this._id = id;
  41528. this._clearFn = clearFn;
  41529. }
  41530. Timeout.prototype.unref = Timeout.prototype.ref = function() {};
  41531. Timeout.prototype.close = function() {
  41532. this._clearFn.call(scope, this._id);
  41533. };
  41534. // Does not start the time, just sets up the members needed.
  41535. exports.enroll = function(item, msecs) {
  41536. clearTimeout(item._idleTimeoutId);
  41537. item._idleTimeout = msecs;
  41538. };
  41539. exports.unenroll = function(item) {
  41540. clearTimeout(item._idleTimeoutId);
  41541. item._idleTimeout = -1;
  41542. };
  41543. exports._unrefActive = exports.active = function(item) {
  41544. clearTimeout(item._idleTimeoutId);
  41545. var msecs = item._idleTimeout;
  41546. if (msecs >= 0) {
  41547. item._idleTimeoutId = setTimeout(function onTimeout() {
  41548. if (item._onTimeout)
  41549. item._onTimeout();
  41550. }, msecs);
  41551. }
  41552. };
  41553. // setimmediate attaches itself to the global object
  41554. __webpack_require__(/*! setimmediate */ "./node_modules/setimmediate/setImmediate.js");
  41555. // On some exotic environments, it's not clear which object `setimmediate` was
  41556. // able to install onto. Search each possibility in the same order as the
  41557. // `setimmediate` library.
  41558. exports.setImmediate = (typeof self !== "undefined" && self.setImmediate) ||
  41559. (typeof global !== "undefined" && global.setImmediate) ||
  41560. (this && this.setImmediate);
  41561. exports.clearImmediate = (typeof self !== "undefined" && self.clearImmediate) ||
  41562. (typeof global !== "undefined" && global.clearImmediate) ||
  41563. (this && this.clearImmediate);
  41564. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../webpack/buildin/global.js */ "./node_modules/webpack/buildin/global.js")))
  41565. /***/ }),
  41566. /***/ "./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&":
  41567. /*!*******************************************************************************************************************************************************************************************************************!*\
  41568. !*** ./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& ***!
  41569. \*******************************************************************************************************************************************************************************************************************/
  41570. /*! exports provided: render, staticRenderFns */
  41571. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  41572. "use strict";
  41573. __webpack_require__.r(__webpack_exports__);
  41574. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "render", function() { return render; });
  41575. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "staticRenderFns", function() { return staticRenderFns; });
  41576. var render = function() {
  41577. var _vm = this
  41578. var _h = _vm.$createElement
  41579. var _c = _vm._self._c || _h
  41580. return _vm._m(0)
  41581. }
  41582. var staticRenderFns = [
  41583. function() {
  41584. var _vm = this
  41585. var _h = _vm.$createElement
  41586. var _c = _vm._self._c || _h
  41587. return _c("div", { staticClass: "container" }, [
  41588. _c("div", { staticClass: "row justify-content-center" }, [
  41589. _c("div", { staticClass: "col-md-8" }, [
  41590. _c("div", { staticClass: "card" }, [
  41591. _c("div", { staticClass: "card-header" }, [
  41592. _vm._v("Example Component")
  41593. ]),
  41594. _vm._v(" "),
  41595. _c("div", { staticClass: "card-body" }, [
  41596. _vm._v(
  41597. "\n I'm an example component.\n "
  41598. )
  41599. ])
  41600. ])
  41601. ])
  41602. ])
  41603. ])
  41604. }
  41605. ]
  41606. render._withStripped = true
  41607. /***/ }),
  41608. /***/ "./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&":
  41609. /*!************************************************************************************************************************************************************************************************************!*\
  41610. !*** ./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& ***!
  41611. \************************************************************************************************************************************************************************************************************/
  41612. /*! exports provided: render, staticRenderFns */
  41613. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  41614. "use strict";
  41615. __webpack_require__.r(__webpack_exports__);
  41616. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "render", function() { return render; });
  41617. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "staticRenderFns", function() { return staticRenderFns; });
  41618. var render = function() {
  41619. var _vm = this
  41620. var _h = _vm.$createElement
  41621. var _c = _vm._self._c || _h
  41622. return _c("div", [
  41623. _c("h4", { staticClass: "text-center" }, [
  41624. _vm._v(_vm._s(this.data.pcmanu) + " " + _vm._s(this.data.pcmake) + " - "),
  41625. _c("small", { staticClass: "text-muted" }, [
  41626. _vm._v(_vm._s(this.data.pcnickname))
  41627. ])
  41628. ])
  41629. ])
  41630. }
  41631. var staticRenderFns = []
  41632. render._withStripped = true
  41633. /***/ }),
  41634. /***/ "./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&":
  41635. /*!*********************************************************************************************************************************************************************************************************!*\
  41636. !*** ./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& ***!
  41637. \*********************************************************************************************************************************************************************************************************/
  41638. /*! exports provided: render, staticRenderFns */
  41639. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  41640. "use strict";
  41641. __webpack_require__.r(__webpack_exports__);
  41642. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "render", function() { return render; });
  41643. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "staticRenderFns", function() { return staticRenderFns; });
  41644. var render = function() {
  41645. var _vm = this
  41646. var _h = _vm.$createElement
  41647. var _c = _vm._self._c || _h
  41648. return _c("div", [
  41649. _c("p", [
  41650. _c("i", { staticClass: "fas fa-info-circle" }),
  41651. _vm._v(" "),
  41652. _c("span", { domProps: { textContent: _vm._s(this.data.probdesc) } })
  41653. ]),
  41654. _vm._v(" "),
  41655. _c("p", [
  41656. _c("i", { staticClass: "far fa-lightbulb" }),
  41657. _vm._v(" "),
  41658. _c("span", { domProps: { textContent: _vm._s(this.data.suggested) } })
  41659. ]),
  41660. _vm._v(" "),
  41661. _c("p", [
  41662. _c("i", { staticClass: "fas fa-paste" }),
  41663. _vm._v(" "),
  41664. _c("span", { domProps: { textContent: _vm._s(this.data.woid) } })
  41665. ]),
  41666. _vm._v(" "),
  41667. _c("p", [
  41668. _c("i", { staticClass: "fas fa-building" }),
  41669. _vm._v(" "),
  41670. _c("span", { domProps: { textContent: _vm._s(this.data.storeid) } })
  41671. ]),
  41672. _vm._v(" "),
  41673. _c("p", [
  41674. _c("i", { staticClass: "fas fa-sign-in-alt" }),
  41675. _vm._v(" "),
  41676. _c(
  41677. "span",
  41678. {
  41679. staticClass: "dashed-underline",
  41680. attrs: {
  41681. "data-toggle": "tooltip",
  41682. "data-placement": "bottom",
  41683. title: this.getHRDate(this.data.dropdate)
  41684. }
  41685. },
  41686. [
  41687. _vm._v(
  41688. "\n " +
  41689. _vm._s(Math.floor(this.daysSinceToday(this.data.dropdate))) +
  41690. " days ago\n "
  41691. )
  41692. ]
  41693. )
  41694. ]),
  41695. _vm._v(" "),
  41696. _c("p", [
  41697. _c("i", { staticClass: "fas fa-sign-out-alt" }),
  41698. _vm._v(" "),
  41699. !this.isZero(this.data.pickupdate)
  41700. ? _c(
  41701. "span",
  41702. {
  41703. staticClass: "dashed-underline",
  41704. attrs: {
  41705. "data-toggle": "tooltip",
  41706. "data-placement": "bottom",
  41707. tittle: this.getHRDate(this.data.pickupdate)
  41708. }
  41709. },
  41710. [
  41711. _vm._v(
  41712. "\n " +
  41713. _vm._s(
  41714. Math.floor(this.daysSinceToday(this.data.pickupdate))
  41715. ) +
  41716. " days ago\n "
  41717. )
  41718. ]
  41719. )
  41720. : _vm._e()
  41721. ])
  41722. ])
  41723. }
  41724. var staticRenderFns = []
  41725. render._withStripped = true
  41726. /***/ }),
  41727. /***/ "./node_modules/vue-loader/lib/runtime/componentNormalizer.js":
  41728. /*!********************************************************************!*\
  41729. !*** ./node_modules/vue-loader/lib/runtime/componentNormalizer.js ***!
  41730. \********************************************************************/
  41731. /*! exports provided: default */
  41732. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  41733. "use strict";
  41734. __webpack_require__.r(__webpack_exports__);
  41735. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return normalizeComponent; });
  41736. /* globals __VUE_SSR_CONTEXT__ */
  41737. // IMPORTANT: Do NOT use ES2015 features in this file (except for modules).
  41738. // This module is a runtime utility for cleaner component module output and will
  41739. // be included in the final webpack user bundle.
  41740. function normalizeComponent (
  41741. scriptExports,
  41742. render,
  41743. staticRenderFns,
  41744. functionalTemplate,
  41745. injectStyles,
  41746. scopeId,
  41747. moduleIdentifier, /* server only */
  41748. shadowMode /* vue-cli only */
  41749. ) {
  41750. // Vue.extend constructor export interop
  41751. var options = typeof scriptExports === 'function'
  41752. ? scriptExports.options
  41753. : scriptExports
  41754. // render functions
  41755. if (render) {
  41756. options.render = render
  41757. options.staticRenderFns = staticRenderFns
  41758. options._compiled = true
  41759. }
  41760. // functional template
  41761. if (functionalTemplate) {
  41762. options.functional = true
  41763. }
  41764. // scopedId
  41765. if (scopeId) {
  41766. options._scopeId = 'data-v-' + scopeId
  41767. }
  41768. var hook
  41769. if (moduleIdentifier) { // server build
  41770. hook = function (context) {
  41771. // 2.3 injection
  41772. context =
  41773. context || // cached call
  41774. (this.$vnode && this.$vnode.ssrContext) || // stateful
  41775. (this.parent && this.parent.$vnode && this.parent.$vnode.ssrContext) // functional
  41776. // 2.2 with runInNewContext: true
  41777. if (!context && typeof __VUE_SSR_CONTEXT__ !== 'undefined') {
  41778. context = __VUE_SSR_CONTEXT__
  41779. }
  41780. // inject component styles
  41781. if (injectStyles) {
  41782. injectStyles.call(this, context)
  41783. }
  41784. // register component module identifier for async chunk inferrence
  41785. if (context && context._registeredComponents) {
  41786. context._registeredComponents.add(moduleIdentifier)
  41787. }
  41788. }
  41789. // used by ssr in case component is cached and beforeCreate
  41790. // never gets called
  41791. options._ssrRegister = hook
  41792. } else if (injectStyles) {
  41793. hook = shadowMode
  41794. ? function () { injectStyles.call(this, this.$root.$options.shadowRoot) }
  41795. : injectStyles
  41796. }
  41797. if (hook) {
  41798. if (options.functional) {
  41799. // for template-only hot-reload because in that case the render fn doesn't
  41800. // go through the normalizer
  41801. options._injectStyles = hook
  41802. // register for functioal component in vue file
  41803. var originalRender = options.render
  41804. options.render = function renderWithStyleInjection (h, context) {
  41805. hook.call(context)
  41806. return originalRender(h, context)
  41807. }
  41808. } else {
  41809. // inject component registration as beforeCreate hook
  41810. var existing = options.beforeCreate
  41811. options.beforeCreate = existing
  41812. ? [].concat(existing, hook)
  41813. : [hook]
  41814. }
  41815. }
  41816. return {
  41817. exports: scriptExports,
  41818. options: options
  41819. }
  41820. }
  41821. /***/ }),
  41822. /***/ "./node_modules/vue/dist/vue.common.dev.js":
  41823. /*!*************************************************!*\
  41824. !*** ./node_modules/vue/dist/vue.common.dev.js ***!
  41825. \*************************************************/
  41826. /*! no static exports found */
  41827. /***/ (function(module, exports, __webpack_require__) {
  41828. "use strict";
  41829. /* WEBPACK VAR INJECTION */(function(global, setImmediate) {/*!
  41830. * Vue.js v2.6.11
  41831. * (c) 2014-2019 Evan You
  41832. * Released under the MIT License.
  41833. */
  41834. /* */
  41835. var emptyObject = Object.freeze({});
  41836. // These helpers produce better VM code in JS engines due to their
  41837. // explicitness and function inlining.
  41838. function isUndef (v) {
  41839. return v === undefined || v === null
  41840. }
  41841. function isDef (v) {
  41842. return v !== undefined && v !== null
  41843. }
  41844. function isTrue (v) {
  41845. return v === true
  41846. }
  41847. function isFalse (v) {
  41848. return v === false
  41849. }
  41850. /**
  41851. * Check if value is primitive.
  41852. */
  41853. function isPrimitive (value) {
  41854. return (
  41855. typeof value === 'string' ||
  41856. typeof value === 'number' ||
  41857. // $flow-disable-line
  41858. typeof value === 'symbol' ||
  41859. typeof value === 'boolean'
  41860. )
  41861. }
  41862. /**
  41863. * Quick object check - this is primarily used to tell
  41864. * Objects from primitive values when we know the value
  41865. * is a JSON-compliant type.
  41866. */
  41867. function isObject (obj) {
  41868. return obj !== null && typeof obj === 'object'
  41869. }
  41870. /**
  41871. * Get the raw type string of a value, e.g., [object Object].
  41872. */
  41873. var _toString = Object.prototype.toString;
  41874. function toRawType (value) {
  41875. return _toString.call(value).slice(8, -1)
  41876. }
  41877. /**
  41878. * Strict object type check. Only returns true
  41879. * for plain JavaScript objects.
  41880. */
  41881. function isPlainObject (obj) {
  41882. return _toString.call(obj) === '[object Object]'
  41883. }
  41884. function isRegExp (v) {
  41885. return _toString.call(v) === '[object RegExp]'
  41886. }
  41887. /**
  41888. * Check if val is a valid array index.
  41889. */
  41890. function isValidArrayIndex (val) {
  41891. var n = parseFloat(String(val));
  41892. return n >= 0 && Math.floor(n) === n && isFinite(val)
  41893. }
  41894. function isPromise (val) {
  41895. return (
  41896. isDef(val) &&
  41897. typeof val.then === 'function' &&
  41898. typeof val.catch === 'function'
  41899. )
  41900. }
  41901. /**
  41902. * Convert a value to a string that is actually rendered.
  41903. */
  41904. function toString (val) {
  41905. return val == null
  41906. ? ''
  41907. : Array.isArray(val) || (isPlainObject(val) && val.toString === _toString)
  41908. ? JSON.stringify(val, null, 2)
  41909. : String(val)
  41910. }
  41911. /**
  41912. * Convert an input value to a number for persistence.
  41913. * If the conversion fails, return original string.
  41914. */
  41915. function toNumber (val) {
  41916. var n = parseFloat(val);
  41917. return isNaN(n) ? val : n
  41918. }
  41919. /**
  41920. * Make a map and return a function for checking if a key
  41921. * is in that map.
  41922. */
  41923. function makeMap (
  41924. str,
  41925. expectsLowerCase
  41926. ) {
  41927. var map = Object.create(null);
  41928. var list = str.split(',');
  41929. for (var i = 0; i < list.length; i++) {
  41930. map[list[i]] = true;
  41931. }
  41932. return expectsLowerCase
  41933. ? function (val) { return map[val.toLowerCase()]; }
  41934. : function (val) { return map[val]; }
  41935. }
  41936. /**
  41937. * Check if a tag is a built-in tag.
  41938. */
  41939. var isBuiltInTag = makeMap('slot,component', true);
  41940. /**
  41941. * Check if an attribute is a reserved attribute.
  41942. */
  41943. var isReservedAttribute = makeMap('key,ref,slot,slot-scope,is');
  41944. /**
  41945. * Remove an item from an array.
  41946. */
  41947. function remove (arr, item) {
  41948. if (arr.length) {
  41949. var index = arr.indexOf(item);
  41950. if (index > -1) {
  41951. return arr.splice(index, 1)
  41952. }
  41953. }
  41954. }
  41955. /**
  41956. * Check whether an object has the property.
  41957. */
  41958. var hasOwnProperty = Object.prototype.hasOwnProperty;
  41959. function hasOwn (obj, key) {
  41960. return hasOwnProperty.call(obj, key)
  41961. }
  41962. /**
  41963. * Create a cached version of a pure function.
  41964. */
  41965. function cached (fn) {
  41966. var cache = Object.create(null);
  41967. return (function cachedFn (str) {
  41968. var hit = cache[str];
  41969. return hit || (cache[str] = fn(str))
  41970. })
  41971. }
  41972. /**
  41973. * Camelize a hyphen-delimited string.
  41974. */
  41975. var camelizeRE = /-(\w)/g;
  41976. var camelize = cached(function (str) {
  41977. return str.replace(camelizeRE, function (_, c) { return c ? c.toUpperCase() : ''; })
  41978. });
  41979. /**
  41980. * Capitalize a string.
  41981. */
  41982. var capitalize = cached(function (str) {
  41983. return str.charAt(0).toUpperCase() + str.slice(1)
  41984. });
  41985. /**
  41986. * Hyphenate a camelCase string.
  41987. */
  41988. var hyphenateRE = /\B([A-Z])/g;
  41989. var hyphenate = cached(function (str) {
  41990. return str.replace(hyphenateRE, '-$1').toLowerCase()
  41991. });
  41992. /**
  41993. * Simple bind polyfill for environments that do not support it,
  41994. * e.g., PhantomJS 1.x. Technically, we don't need this anymore
  41995. * since native bind is now performant enough in most browsers.
  41996. * But removing it would mean breaking code that was able to run in
  41997. * PhantomJS 1.x, so this must be kept for backward compatibility.
  41998. */
  41999. /* istanbul ignore next */
  42000. function polyfillBind (fn, ctx) {
  42001. function boundFn (a) {
  42002. var l = arguments.length;
  42003. return l
  42004. ? l > 1
  42005. ? fn.apply(ctx, arguments)
  42006. : fn.call(ctx, a)
  42007. : fn.call(ctx)
  42008. }
  42009. boundFn._length = fn.length;
  42010. return boundFn
  42011. }
  42012. function nativeBind (fn, ctx) {
  42013. return fn.bind(ctx)
  42014. }
  42015. var bind = Function.prototype.bind
  42016. ? nativeBind
  42017. : polyfillBind;
  42018. /**
  42019. * Convert an Array-like object to a real Array.
  42020. */
  42021. function toArray (list, start) {
  42022. start = start || 0;
  42023. var i = list.length - start;
  42024. var ret = new Array(i);
  42025. while (i--) {
  42026. ret[i] = list[i + start];
  42027. }
  42028. return ret
  42029. }
  42030. /**
  42031. * Mix properties into target object.
  42032. */
  42033. function extend (to, _from) {
  42034. for (var key in _from) {
  42035. to[key] = _from[key];
  42036. }
  42037. return to
  42038. }
  42039. /**
  42040. * Merge an Array of Objects into a single Object.
  42041. */
  42042. function toObject (arr) {
  42043. var res = {};
  42044. for (var i = 0; i < arr.length; i++) {
  42045. if (arr[i]) {
  42046. extend(res, arr[i]);
  42047. }
  42048. }
  42049. return res
  42050. }
  42051. /* eslint-disable no-unused-vars */
  42052. /**
  42053. * Perform no operation.
  42054. * Stubbing args to make Flow happy without leaving useless transpiled code
  42055. * with ...rest (https://flow.org/blog/2017/05/07/Strict-Function-Call-Arity/).
  42056. */
  42057. function noop (a, b, c) {}
  42058. /**
  42059. * Always return false.
  42060. */
  42061. var no = function (a, b, c) { return false; };
  42062. /* eslint-enable no-unused-vars */
  42063. /**
  42064. * Return the same value.
  42065. */
  42066. var identity = function (_) { return _; };
  42067. /**
  42068. * Generate a string containing static keys from compiler modules.
  42069. */
  42070. function genStaticKeys (modules) {
  42071. return modules.reduce(function (keys, m) {
  42072. return keys.concat(m.staticKeys || [])
  42073. }, []).join(',')
  42074. }
  42075. /**
  42076. * Check if two values are loosely equal - that is,
  42077. * if they are plain objects, do they have the same shape?
  42078. */
  42079. function looseEqual (a, b) {
  42080. if (a === b) { return true }
  42081. var isObjectA = isObject(a);
  42082. var isObjectB = isObject(b);
  42083. if (isObjectA && isObjectB) {
  42084. try {
  42085. var isArrayA = Array.isArray(a);
  42086. var isArrayB = Array.isArray(b);
  42087. if (isArrayA && isArrayB) {
  42088. return a.length === b.length && a.every(function (e, i) {
  42089. return looseEqual(e, b[i])
  42090. })
  42091. } else if (a instanceof Date && b instanceof Date) {
  42092. return a.getTime() === b.getTime()
  42093. } else if (!isArrayA && !isArrayB) {
  42094. var keysA = Object.keys(a);
  42095. var keysB = Object.keys(b);
  42096. return keysA.length === keysB.length && keysA.every(function (key) {
  42097. return looseEqual(a[key], b[key])
  42098. })
  42099. } else {
  42100. /* istanbul ignore next */
  42101. return false
  42102. }
  42103. } catch (e) {
  42104. /* istanbul ignore next */
  42105. return false
  42106. }
  42107. } else if (!isObjectA && !isObjectB) {
  42108. return String(a) === String(b)
  42109. } else {
  42110. return false
  42111. }
  42112. }
  42113. /**
  42114. * Return the first index at which a loosely equal value can be
  42115. * found in the array (if value is a plain object, the array must
  42116. * contain an object of the same shape), or -1 if it is not present.
  42117. */
  42118. function looseIndexOf (arr, val) {
  42119. for (var i = 0; i < arr.length; i++) {
  42120. if (looseEqual(arr[i], val)) { return i }
  42121. }
  42122. return -1
  42123. }
  42124. /**
  42125. * Ensure a function is called only once.
  42126. */
  42127. function once (fn) {
  42128. var called = false;
  42129. return function () {
  42130. if (!called) {
  42131. called = true;
  42132. fn.apply(this, arguments);
  42133. }
  42134. }
  42135. }
  42136. var SSR_ATTR = 'data-server-rendered';
  42137. var ASSET_TYPES = [
  42138. 'component',
  42139. 'directive',
  42140. 'filter'
  42141. ];
  42142. var LIFECYCLE_HOOKS = [
  42143. 'beforeCreate',
  42144. 'created',
  42145. 'beforeMount',
  42146. 'mounted',
  42147. 'beforeUpdate',
  42148. 'updated',
  42149. 'beforeDestroy',
  42150. 'destroyed',
  42151. 'activated',
  42152. 'deactivated',
  42153. 'errorCaptured',
  42154. 'serverPrefetch'
  42155. ];
  42156. /* */
  42157. var config = ({
  42158. /**
  42159. * Option merge strategies (used in core/util/options)
  42160. */
  42161. // $flow-disable-line
  42162. optionMergeStrategies: Object.create(null),
  42163. /**
  42164. * Whether to suppress warnings.
  42165. */
  42166. silent: false,
  42167. /**
  42168. * Show production mode tip message on boot?
  42169. */
  42170. productionTip: "development" !== 'production',
  42171. /**
  42172. * Whether to enable devtools
  42173. */
  42174. devtools: "development" !== 'production',
  42175. /**
  42176. * Whether to record perf
  42177. */
  42178. performance: false,
  42179. /**
  42180. * Error handler for watcher errors
  42181. */
  42182. errorHandler: null,
  42183. /**
  42184. * Warn handler for watcher warns
  42185. */
  42186. warnHandler: null,
  42187. /**
  42188. * Ignore certain custom elements
  42189. */
  42190. ignoredElements: [],
  42191. /**
  42192. * Custom user key aliases for v-on
  42193. */
  42194. // $flow-disable-line
  42195. keyCodes: Object.create(null),
  42196. /**
  42197. * Check if a tag is reserved so that it cannot be registered as a
  42198. * component. This is platform-dependent and may be overwritten.
  42199. */
  42200. isReservedTag: no,
  42201. /**
  42202. * Check if an attribute is reserved so that it cannot be used as a component
  42203. * prop. This is platform-dependent and may be overwritten.
  42204. */
  42205. isReservedAttr: no,
  42206. /**
  42207. * Check if a tag is an unknown element.
  42208. * Platform-dependent.
  42209. */
  42210. isUnknownElement: no,
  42211. /**
  42212. * Get the namespace of an element
  42213. */
  42214. getTagNamespace: noop,
  42215. /**
  42216. * Parse the real tag name for the specific platform.
  42217. */
  42218. parsePlatformTagName: identity,
  42219. /**
  42220. * Check if an attribute must be bound using property, e.g. value
  42221. * Platform-dependent.
  42222. */
  42223. mustUseProp: no,
  42224. /**
  42225. * Perform updates asynchronously. Intended to be used by Vue Test Utils
  42226. * This will significantly reduce performance if set to false.
  42227. */
  42228. async: true,
  42229. /**
  42230. * Exposed for legacy reasons
  42231. */
  42232. _lifecycleHooks: LIFECYCLE_HOOKS
  42233. });
  42234. /* */
  42235. /**
  42236. * unicode letters used for parsing html tags, component names and property paths.
  42237. * using https://www.w3.org/TR/html53/semantics-scripting.html#potentialcustomelementname
  42238. * skipping \u10000-\uEFFFF due to it freezing up PhantomJS
  42239. */
  42240. 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/;
  42241. /**
  42242. * Check if a string starts with $ or _
  42243. */
  42244. function isReserved (str) {
  42245. var c = (str + '').charCodeAt(0);
  42246. return c === 0x24 || c === 0x5F
  42247. }
  42248. /**
  42249. * Define a property.
  42250. */
  42251. function def (obj, key, val, enumerable) {
  42252. Object.defineProperty(obj, key, {
  42253. value: val,
  42254. enumerable: !!enumerable,
  42255. writable: true,
  42256. configurable: true
  42257. });
  42258. }
  42259. /**
  42260. * Parse simple path.
  42261. */
  42262. var bailRE = new RegExp(("[^" + (unicodeRegExp.source) + ".$_\\d]"));
  42263. function parsePath (path) {
  42264. if (bailRE.test(path)) {
  42265. return
  42266. }
  42267. var segments = path.split('.');
  42268. return function (obj) {
  42269. for (var i = 0; i < segments.length; i++) {
  42270. if (!obj) { return }
  42271. obj = obj[segments[i]];
  42272. }
  42273. return obj
  42274. }
  42275. }
  42276. /* */
  42277. // can we use __proto__?
  42278. var hasProto = '__proto__' in {};
  42279. // Browser environment sniffing
  42280. var inBrowser = typeof window !== 'undefined';
  42281. var inWeex = typeof WXEnvironment !== 'undefined' && !!WXEnvironment.platform;
  42282. var weexPlatform = inWeex && WXEnvironment.platform.toLowerCase();
  42283. var UA = inBrowser && window.navigator.userAgent.toLowerCase();
  42284. var isIE = UA && /msie|trident/.test(UA);
  42285. var isIE9 = UA && UA.indexOf('msie 9.0') > 0;
  42286. var isEdge = UA && UA.indexOf('edge/') > 0;
  42287. var isAndroid = (UA && UA.indexOf('android') > 0) || (weexPlatform === 'android');
  42288. var isIOS = (UA && /iphone|ipad|ipod|ios/.test(UA)) || (weexPlatform === 'ios');
  42289. var isChrome = UA && /chrome\/\d+/.test(UA) && !isEdge;
  42290. var isPhantomJS = UA && /phantomjs/.test(UA);
  42291. var isFF = UA && UA.match(/firefox\/(\d+)/);
  42292. // Firefox has a "watch" function on Object.prototype...
  42293. var nativeWatch = ({}).watch;
  42294. var supportsPassive = false;
  42295. if (inBrowser) {
  42296. try {
  42297. var opts = {};
  42298. Object.defineProperty(opts, 'passive', ({
  42299. get: function get () {
  42300. /* istanbul ignore next */
  42301. supportsPassive = true;
  42302. }
  42303. })); // https://github.com/facebook/flow/issues/285
  42304. window.addEventListener('test-passive', null, opts);
  42305. } catch (e) {}
  42306. }
  42307. // this needs to be lazy-evaled because vue may be required before
  42308. // vue-server-renderer can set VUE_ENV
  42309. var _isServer;
  42310. var isServerRendering = function () {
  42311. if (_isServer === undefined) {
  42312. /* istanbul ignore if */
  42313. if (!inBrowser && !inWeex && typeof global !== 'undefined') {
  42314. // detect presence of vue-server-renderer and avoid
  42315. // Webpack shimming the process
  42316. _isServer = global['process'] && global['process'].env.VUE_ENV === 'server';
  42317. } else {
  42318. _isServer = false;
  42319. }
  42320. }
  42321. return _isServer
  42322. };
  42323. // detect devtools
  42324. var devtools = inBrowser && window.__VUE_DEVTOOLS_GLOBAL_HOOK__;
  42325. /* istanbul ignore next */
  42326. function isNative (Ctor) {
  42327. return typeof Ctor === 'function' && /native code/.test(Ctor.toString())
  42328. }
  42329. var hasSymbol =
  42330. typeof Symbol !== 'undefined' && isNative(Symbol) &&
  42331. typeof Reflect !== 'undefined' && isNative(Reflect.ownKeys);
  42332. var _Set;
  42333. /* istanbul ignore if */ // $flow-disable-line
  42334. if (typeof Set !== 'undefined' && isNative(Set)) {
  42335. // use native Set when available.
  42336. _Set = Set;
  42337. } else {
  42338. // a non-standard Set polyfill that only works with primitive keys.
  42339. _Set = /*@__PURE__*/(function () {
  42340. function Set () {
  42341. this.set = Object.create(null);
  42342. }
  42343. Set.prototype.has = function has (key) {
  42344. return this.set[key] === true
  42345. };
  42346. Set.prototype.add = function add (key) {
  42347. this.set[key] = true;
  42348. };
  42349. Set.prototype.clear = function clear () {
  42350. this.set = Object.create(null);
  42351. };
  42352. return Set;
  42353. }());
  42354. }
  42355. /* */
  42356. var warn = noop;
  42357. var tip = noop;
  42358. var generateComponentTrace = (noop); // work around flow check
  42359. var formatComponentName = (noop);
  42360. {
  42361. var hasConsole = typeof console !== 'undefined';
  42362. var classifyRE = /(?:^|[-_])(\w)/g;
  42363. var classify = function (str) { return str
  42364. .replace(classifyRE, function (c) { return c.toUpperCase(); })
  42365. .replace(/[-_]/g, ''); };
  42366. warn = function (msg, vm) {
  42367. var trace = vm ? generateComponentTrace(vm) : '';
  42368. if (config.warnHandler) {
  42369. config.warnHandler.call(null, msg, vm, trace);
  42370. } else if (hasConsole && (!config.silent)) {
  42371. console.error(("[Vue warn]: " + msg + trace));
  42372. }
  42373. };
  42374. tip = function (msg, vm) {
  42375. if (hasConsole && (!config.silent)) {
  42376. console.warn("[Vue tip]: " + msg + (
  42377. vm ? generateComponentTrace(vm) : ''
  42378. ));
  42379. }
  42380. };
  42381. formatComponentName = function (vm, includeFile) {
  42382. if (vm.$root === vm) {
  42383. return '<Root>'
  42384. }
  42385. var options = typeof vm === 'function' && vm.cid != null
  42386. ? vm.options
  42387. : vm._isVue
  42388. ? vm.$options || vm.constructor.options
  42389. : vm;
  42390. var name = options.name || options._componentTag;
  42391. var file = options.__file;
  42392. if (!name && file) {
  42393. var match = file.match(/([^/\\]+)\.vue$/);
  42394. name = match && match[1];
  42395. }
  42396. return (
  42397. (name ? ("<" + (classify(name)) + ">") : "<Anonymous>") +
  42398. (file && includeFile !== false ? (" at " + file) : '')
  42399. )
  42400. };
  42401. var repeat = function (str, n) {
  42402. var res = '';
  42403. while (n) {
  42404. if (n % 2 === 1) { res += str; }
  42405. if (n > 1) { str += str; }
  42406. n >>= 1;
  42407. }
  42408. return res
  42409. };
  42410. generateComponentTrace = function (vm) {
  42411. if (vm._isVue && vm.$parent) {
  42412. var tree = [];
  42413. var currentRecursiveSequence = 0;
  42414. while (vm) {
  42415. if (tree.length > 0) {
  42416. var last = tree[tree.length - 1];
  42417. if (last.constructor === vm.constructor) {
  42418. currentRecursiveSequence++;
  42419. vm = vm.$parent;
  42420. continue
  42421. } else if (currentRecursiveSequence > 0) {
  42422. tree[tree.length - 1] = [last, currentRecursiveSequence];
  42423. currentRecursiveSequence = 0;
  42424. }
  42425. }
  42426. tree.push(vm);
  42427. vm = vm.$parent;
  42428. }
  42429. return '\n\nfound in\n\n' + tree
  42430. .map(function (vm, i) { return ("" + (i === 0 ? '---> ' : repeat(' ', 5 + i * 2)) + (Array.isArray(vm)
  42431. ? ((formatComponentName(vm[0])) + "... (" + (vm[1]) + " recursive calls)")
  42432. : formatComponentName(vm))); })
  42433. .join('\n')
  42434. } else {
  42435. return ("\n\n(found in " + (formatComponentName(vm)) + ")")
  42436. }
  42437. };
  42438. }
  42439. /* */
  42440. var uid = 0;
  42441. /**
  42442. * A dep is an observable that can have multiple
  42443. * directives subscribing to it.
  42444. */
  42445. var Dep = function Dep () {
  42446. this.id = uid++;
  42447. this.subs = [];
  42448. };
  42449. Dep.prototype.addSub = function addSub (sub) {
  42450. this.subs.push(sub);
  42451. };
  42452. Dep.prototype.removeSub = function removeSub (sub) {
  42453. remove(this.subs, sub);
  42454. };
  42455. Dep.prototype.depend = function depend () {
  42456. if (Dep.target) {
  42457. Dep.target.addDep(this);
  42458. }
  42459. };
  42460. Dep.prototype.notify = function notify () {
  42461. // stabilize the subscriber list first
  42462. var subs = this.subs.slice();
  42463. if (!config.async) {
  42464. // subs aren't sorted in scheduler if not running async
  42465. // we need to sort them now to make sure they fire in correct
  42466. // order
  42467. subs.sort(function (a, b) { return a.id - b.id; });
  42468. }
  42469. for (var i = 0, l = subs.length; i < l; i++) {
  42470. subs[i].update();
  42471. }
  42472. };
  42473. // The current target watcher being evaluated.
  42474. // This is globally unique because only one watcher
  42475. // can be evaluated at a time.
  42476. Dep.target = null;
  42477. var targetStack = [];
  42478. function pushTarget (target) {
  42479. targetStack.push(target);
  42480. Dep.target = target;
  42481. }
  42482. function popTarget () {
  42483. targetStack.pop();
  42484. Dep.target = targetStack[targetStack.length - 1];
  42485. }
  42486. /* */
  42487. var VNode = function VNode (
  42488. tag,
  42489. data,
  42490. children,
  42491. text,
  42492. elm,
  42493. context,
  42494. componentOptions,
  42495. asyncFactory
  42496. ) {
  42497. this.tag = tag;
  42498. this.data = data;
  42499. this.children = children;
  42500. this.text = text;
  42501. this.elm = elm;
  42502. this.ns = undefined;
  42503. this.context = context;
  42504. this.fnContext = undefined;
  42505. this.fnOptions = undefined;
  42506. this.fnScopeId = undefined;
  42507. this.key = data && data.key;
  42508. this.componentOptions = componentOptions;
  42509. this.componentInstance = undefined;
  42510. this.parent = undefined;
  42511. this.raw = false;
  42512. this.isStatic = false;
  42513. this.isRootInsert = true;
  42514. this.isComment = false;
  42515. this.isCloned = false;
  42516. this.isOnce = false;
  42517. this.asyncFactory = asyncFactory;
  42518. this.asyncMeta = undefined;
  42519. this.isAsyncPlaceholder = false;
  42520. };
  42521. var prototypeAccessors = { child: { configurable: true } };
  42522. // DEPRECATED: alias for componentInstance for backwards compat.
  42523. /* istanbul ignore next */
  42524. prototypeAccessors.child.get = function () {
  42525. return this.componentInstance
  42526. };
  42527. Object.defineProperties( VNode.prototype, prototypeAccessors );
  42528. var createEmptyVNode = function (text) {
  42529. if ( text === void 0 ) text = '';
  42530. var node = new VNode();
  42531. node.text = text;
  42532. node.isComment = true;
  42533. return node
  42534. };
  42535. function createTextVNode (val) {
  42536. return new VNode(undefined, undefined, undefined, String(val))
  42537. }
  42538. // optimized shallow clone
  42539. // used for static nodes and slot nodes because they may be reused across
  42540. // multiple renders, cloning them avoids errors when DOM manipulations rely
  42541. // on their elm reference.
  42542. function cloneVNode (vnode) {
  42543. var cloned = new VNode(
  42544. vnode.tag,
  42545. vnode.data,
  42546. // #7975
  42547. // clone children array to avoid mutating original in case of cloning
  42548. // a child.
  42549. vnode.children && vnode.children.slice(),
  42550. vnode.text,
  42551. vnode.elm,
  42552. vnode.context,
  42553. vnode.componentOptions,
  42554. vnode.asyncFactory
  42555. );
  42556. cloned.ns = vnode.ns;
  42557. cloned.isStatic = vnode.isStatic;
  42558. cloned.key = vnode.key;
  42559. cloned.isComment = vnode.isComment;
  42560. cloned.fnContext = vnode.fnContext;
  42561. cloned.fnOptions = vnode.fnOptions;
  42562. cloned.fnScopeId = vnode.fnScopeId;
  42563. cloned.asyncMeta = vnode.asyncMeta;
  42564. cloned.isCloned = true;
  42565. return cloned
  42566. }
  42567. /*
  42568. * not type checking this file because flow doesn't play well with
  42569. * dynamically accessing methods on Array prototype
  42570. */
  42571. var arrayProto = Array.prototype;
  42572. var arrayMethods = Object.create(arrayProto);
  42573. var methodsToPatch = [
  42574. 'push',
  42575. 'pop',
  42576. 'shift',
  42577. 'unshift',
  42578. 'splice',
  42579. 'sort',
  42580. 'reverse'
  42581. ];
  42582. /**
  42583. * Intercept mutating methods and emit events
  42584. */
  42585. methodsToPatch.forEach(function (method) {
  42586. // cache original method
  42587. var original = arrayProto[method];
  42588. def(arrayMethods, method, function mutator () {
  42589. var args = [], len = arguments.length;
  42590. while ( len-- ) args[ len ] = arguments[ len ];
  42591. var result = original.apply(this, args);
  42592. var ob = this.__ob__;
  42593. var inserted;
  42594. switch (method) {
  42595. case 'push':
  42596. case 'unshift':
  42597. inserted = args;
  42598. break
  42599. case 'splice':
  42600. inserted = args.slice(2);
  42601. break
  42602. }
  42603. if (inserted) { ob.observeArray(inserted); }
  42604. // notify change
  42605. ob.dep.notify();
  42606. return result
  42607. });
  42608. });
  42609. /* */
  42610. var arrayKeys = Object.getOwnPropertyNames(arrayMethods);
  42611. /**
  42612. * In some cases we may want to disable observation inside a component's
  42613. * update computation.
  42614. */
  42615. var shouldObserve = true;
  42616. function toggleObserving (value) {
  42617. shouldObserve = value;
  42618. }
  42619. /**
  42620. * Observer class that is attached to each observed
  42621. * object. Once attached, the observer converts the target
  42622. * object's property keys into getter/setters that
  42623. * collect dependencies and dispatch updates.
  42624. */
  42625. var Observer = function Observer (value) {
  42626. this.value = value;
  42627. this.dep = new Dep();
  42628. this.vmCount = 0;
  42629. def(value, '__ob__', this);
  42630. if (Array.isArray(value)) {
  42631. if (hasProto) {
  42632. protoAugment(value, arrayMethods);
  42633. } else {
  42634. copyAugment(value, arrayMethods, arrayKeys);
  42635. }
  42636. this.observeArray(value);
  42637. } else {
  42638. this.walk(value);
  42639. }
  42640. };
  42641. /**
  42642. * Walk through all properties and convert them into
  42643. * getter/setters. This method should only be called when
  42644. * value type is Object.
  42645. */
  42646. Observer.prototype.walk = function walk (obj) {
  42647. var keys = Object.keys(obj);
  42648. for (var i = 0; i < keys.length; i++) {
  42649. defineReactive$$1(obj, keys[i]);
  42650. }
  42651. };
  42652. /**
  42653. * Observe a list of Array items.
  42654. */
  42655. Observer.prototype.observeArray = function observeArray (items) {
  42656. for (var i = 0, l = items.length; i < l; i++) {
  42657. observe(items[i]);
  42658. }
  42659. };
  42660. // helpers
  42661. /**
  42662. * Augment a target Object or Array by intercepting
  42663. * the prototype chain using __proto__
  42664. */
  42665. function protoAugment (target, src) {
  42666. /* eslint-disable no-proto */
  42667. target.__proto__ = src;
  42668. /* eslint-enable no-proto */
  42669. }
  42670. /**
  42671. * Augment a target Object or Array by defining
  42672. * hidden properties.
  42673. */
  42674. /* istanbul ignore next */
  42675. function copyAugment (target, src, keys) {
  42676. for (var i = 0, l = keys.length; i < l; i++) {
  42677. var key = keys[i];
  42678. def(target, key, src[key]);
  42679. }
  42680. }
  42681. /**
  42682. * Attempt to create an observer instance for a value,
  42683. * returns the new observer if successfully observed,
  42684. * or the existing observer if the value already has one.
  42685. */
  42686. function observe (value, asRootData) {
  42687. if (!isObject(value) || value instanceof VNode) {
  42688. return
  42689. }
  42690. var ob;
  42691. if (hasOwn(value, '__ob__') && value.__ob__ instanceof Observer) {
  42692. ob = value.__ob__;
  42693. } else if (
  42694. shouldObserve &&
  42695. !isServerRendering() &&
  42696. (Array.isArray(value) || isPlainObject(value)) &&
  42697. Object.isExtensible(value) &&
  42698. !value._isVue
  42699. ) {
  42700. ob = new Observer(value);
  42701. }
  42702. if (asRootData && ob) {
  42703. ob.vmCount++;
  42704. }
  42705. return ob
  42706. }
  42707. /**
  42708. * Define a reactive property on an Object.
  42709. */
  42710. function defineReactive$$1 (
  42711. obj,
  42712. key,
  42713. val,
  42714. customSetter,
  42715. shallow
  42716. ) {
  42717. var dep = new Dep();
  42718. var property = Object.getOwnPropertyDescriptor(obj, key);
  42719. if (property && property.configurable === false) {
  42720. return
  42721. }
  42722. // cater for pre-defined getter/setters
  42723. var getter = property && property.get;
  42724. var setter = property && property.set;
  42725. if ((!getter || setter) && arguments.length === 2) {
  42726. val = obj[key];
  42727. }
  42728. var childOb = !shallow && observe(val);
  42729. Object.defineProperty(obj, key, {
  42730. enumerable: true,
  42731. configurable: true,
  42732. get: function reactiveGetter () {
  42733. var value = getter ? getter.call(obj) : val;
  42734. if (Dep.target) {
  42735. dep.depend();
  42736. if (childOb) {
  42737. childOb.dep.depend();
  42738. if (Array.isArray(value)) {
  42739. dependArray(value);
  42740. }
  42741. }
  42742. }
  42743. return value
  42744. },
  42745. set: function reactiveSetter (newVal) {
  42746. var value = getter ? getter.call(obj) : val;
  42747. /* eslint-disable no-self-compare */
  42748. if (newVal === value || (newVal !== newVal && value !== value)) {
  42749. return
  42750. }
  42751. /* eslint-enable no-self-compare */
  42752. if (customSetter) {
  42753. customSetter();
  42754. }
  42755. // #7981: for accessor properties without setter
  42756. if (getter && !setter) { return }
  42757. if (setter) {
  42758. setter.call(obj, newVal);
  42759. } else {
  42760. val = newVal;
  42761. }
  42762. childOb = !shallow && observe(newVal);
  42763. dep.notify();
  42764. }
  42765. });
  42766. }
  42767. /**
  42768. * Set a property on an object. Adds the new property and
  42769. * triggers change notification if the property doesn't
  42770. * already exist.
  42771. */
  42772. function set (target, key, val) {
  42773. if (isUndef(target) || isPrimitive(target)
  42774. ) {
  42775. warn(("Cannot set reactive property on undefined, null, or primitive value: " + ((target))));
  42776. }
  42777. if (Array.isArray(target) && isValidArrayIndex(key)) {
  42778. target.length = Math.max(target.length, key);
  42779. target.splice(key, 1, val);
  42780. return val
  42781. }
  42782. if (key in target && !(key in Object.prototype)) {
  42783. target[key] = val;
  42784. return val
  42785. }
  42786. var ob = (target).__ob__;
  42787. if (target._isVue || (ob && ob.vmCount)) {
  42788. warn(
  42789. 'Avoid adding reactive properties to a Vue instance or its root $data ' +
  42790. 'at runtime - declare it upfront in the data option.'
  42791. );
  42792. return val
  42793. }
  42794. if (!ob) {
  42795. target[key] = val;
  42796. return val
  42797. }
  42798. defineReactive$$1(ob.value, key, val);
  42799. ob.dep.notify();
  42800. return val
  42801. }
  42802. /**
  42803. * Delete a property and trigger change if necessary.
  42804. */
  42805. function del (target, key) {
  42806. if (isUndef(target) || isPrimitive(target)
  42807. ) {
  42808. warn(("Cannot delete reactive property on undefined, null, or primitive value: " + ((target))));
  42809. }
  42810. if (Array.isArray(target) && isValidArrayIndex(key)) {
  42811. target.splice(key, 1);
  42812. return
  42813. }
  42814. var ob = (target).__ob__;
  42815. if (target._isVue || (ob && ob.vmCount)) {
  42816. warn(
  42817. 'Avoid deleting properties on a Vue instance or its root $data ' +
  42818. '- just set it to null.'
  42819. );
  42820. return
  42821. }
  42822. if (!hasOwn(target, key)) {
  42823. return
  42824. }
  42825. delete target[key];
  42826. if (!ob) {
  42827. return
  42828. }
  42829. ob.dep.notify();
  42830. }
  42831. /**
  42832. * Collect dependencies on array elements when the array is touched, since
  42833. * we cannot intercept array element access like property getters.
  42834. */
  42835. function dependArray (value) {
  42836. for (var e = (void 0), i = 0, l = value.length; i < l; i++) {
  42837. e = value[i];
  42838. e && e.__ob__ && e.__ob__.dep.depend();
  42839. if (Array.isArray(e)) {
  42840. dependArray(e);
  42841. }
  42842. }
  42843. }
  42844. /* */
  42845. /**
  42846. * Option overwriting strategies are functions that handle
  42847. * how to merge a parent option value and a child option
  42848. * value into the final value.
  42849. */
  42850. var strats = config.optionMergeStrategies;
  42851. /**
  42852. * Options with restrictions
  42853. */
  42854. {
  42855. strats.el = strats.propsData = function (parent, child, vm, key) {
  42856. if (!vm) {
  42857. warn(
  42858. "option \"" + key + "\" can only be used during instance " +
  42859. 'creation with the `new` keyword.'
  42860. );
  42861. }
  42862. return defaultStrat(parent, child)
  42863. };
  42864. }
  42865. /**
  42866. * Helper that recursively merges two data objects together.
  42867. */
  42868. function mergeData (to, from) {
  42869. if (!from) { return to }
  42870. var key, toVal, fromVal;
  42871. var keys = hasSymbol
  42872. ? Reflect.ownKeys(from)
  42873. : Object.keys(from);
  42874. for (var i = 0; i < keys.length; i++) {
  42875. key = keys[i];
  42876. // in case the object is already observed...
  42877. if (key === '__ob__') { continue }
  42878. toVal = to[key];
  42879. fromVal = from[key];
  42880. if (!hasOwn(to, key)) {
  42881. set(to, key, fromVal);
  42882. } else if (
  42883. toVal !== fromVal &&
  42884. isPlainObject(toVal) &&
  42885. isPlainObject(fromVal)
  42886. ) {
  42887. mergeData(toVal, fromVal);
  42888. }
  42889. }
  42890. return to
  42891. }
  42892. /**
  42893. * Data
  42894. */
  42895. function mergeDataOrFn (
  42896. parentVal,
  42897. childVal,
  42898. vm
  42899. ) {
  42900. if (!vm) {
  42901. // in a Vue.extend merge, both should be functions
  42902. if (!childVal) {
  42903. return parentVal
  42904. }
  42905. if (!parentVal) {
  42906. return childVal
  42907. }
  42908. // when parentVal & childVal are both present,
  42909. // we need to return a function that returns the
  42910. // merged result of both functions... no need to
  42911. // check if parentVal is a function here because
  42912. // it has to be a function to pass previous merges.
  42913. return function mergedDataFn () {
  42914. return mergeData(
  42915. typeof childVal === 'function' ? childVal.call(this, this) : childVal,
  42916. typeof parentVal === 'function' ? parentVal.call(this, this) : parentVal
  42917. )
  42918. }
  42919. } else {
  42920. return function mergedInstanceDataFn () {
  42921. // instance merge
  42922. var instanceData = typeof childVal === 'function'
  42923. ? childVal.call(vm, vm)
  42924. : childVal;
  42925. var defaultData = typeof parentVal === 'function'
  42926. ? parentVal.call(vm, vm)
  42927. : parentVal;
  42928. if (instanceData) {
  42929. return mergeData(instanceData, defaultData)
  42930. } else {
  42931. return defaultData
  42932. }
  42933. }
  42934. }
  42935. }
  42936. strats.data = function (
  42937. parentVal,
  42938. childVal,
  42939. vm
  42940. ) {
  42941. if (!vm) {
  42942. if (childVal && typeof childVal !== 'function') {
  42943. warn(
  42944. 'The "data" option should be a function ' +
  42945. 'that returns a per-instance value in component ' +
  42946. 'definitions.',
  42947. vm
  42948. );
  42949. return parentVal
  42950. }
  42951. return mergeDataOrFn(parentVal, childVal)
  42952. }
  42953. return mergeDataOrFn(parentVal, childVal, vm)
  42954. };
  42955. /**
  42956. * Hooks and props are merged as arrays.
  42957. */
  42958. function mergeHook (
  42959. parentVal,
  42960. childVal
  42961. ) {
  42962. var res = childVal
  42963. ? parentVal
  42964. ? parentVal.concat(childVal)
  42965. : Array.isArray(childVal)
  42966. ? childVal
  42967. : [childVal]
  42968. : parentVal;
  42969. return res
  42970. ? dedupeHooks(res)
  42971. : res
  42972. }
  42973. function dedupeHooks (hooks) {
  42974. var res = [];
  42975. for (var i = 0; i < hooks.length; i++) {
  42976. if (res.indexOf(hooks[i]) === -1) {
  42977. res.push(hooks[i]);
  42978. }
  42979. }
  42980. return res
  42981. }
  42982. LIFECYCLE_HOOKS.forEach(function (hook) {
  42983. strats[hook] = mergeHook;
  42984. });
  42985. /**
  42986. * Assets
  42987. *
  42988. * When a vm is present (instance creation), we need to do
  42989. * a three-way merge between constructor options, instance
  42990. * options and parent options.
  42991. */
  42992. function mergeAssets (
  42993. parentVal,
  42994. childVal,
  42995. vm,
  42996. key
  42997. ) {
  42998. var res = Object.create(parentVal || null);
  42999. if (childVal) {
  43000. assertObjectType(key, childVal, vm);
  43001. return extend(res, childVal)
  43002. } else {
  43003. return res
  43004. }
  43005. }
  43006. ASSET_TYPES.forEach(function (type) {
  43007. strats[type + 's'] = mergeAssets;
  43008. });
  43009. /**
  43010. * Watchers.
  43011. *
  43012. * Watchers hashes should not overwrite one
  43013. * another, so we merge them as arrays.
  43014. */
  43015. strats.watch = function (
  43016. parentVal,
  43017. childVal,
  43018. vm,
  43019. key
  43020. ) {
  43021. // work around Firefox's Object.prototype.watch...
  43022. if (parentVal === nativeWatch) { parentVal = undefined; }
  43023. if (childVal === nativeWatch) { childVal = undefined; }
  43024. /* istanbul ignore if */
  43025. if (!childVal) { return Object.create(parentVal || null) }
  43026. {
  43027. assertObjectType(key, childVal, vm);
  43028. }
  43029. if (!parentVal) { return childVal }
  43030. var ret = {};
  43031. extend(ret, parentVal);
  43032. for (var key$1 in childVal) {
  43033. var parent = ret[key$1];
  43034. var child = childVal[key$1];
  43035. if (parent && !Array.isArray(parent)) {
  43036. parent = [parent];
  43037. }
  43038. ret[key$1] = parent
  43039. ? parent.concat(child)
  43040. : Array.isArray(child) ? child : [child];
  43041. }
  43042. return ret
  43043. };
  43044. /**
  43045. * Other object hashes.
  43046. */
  43047. strats.props =
  43048. strats.methods =
  43049. strats.inject =
  43050. strats.computed = function (
  43051. parentVal,
  43052. childVal,
  43053. vm,
  43054. key
  43055. ) {
  43056. if (childVal && "development" !== 'production') {
  43057. assertObjectType(key, childVal, vm);
  43058. }
  43059. if (!parentVal) { return childVal }
  43060. var ret = Object.create(null);
  43061. extend(ret, parentVal);
  43062. if (childVal) { extend(ret, childVal); }
  43063. return ret
  43064. };
  43065. strats.provide = mergeDataOrFn;
  43066. /**
  43067. * Default strategy.
  43068. */
  43069. var defaultStrat = function (parentVal, childVal) {
  43070. return childVal === undefined
  43071. ? parentVal
  43072. : childVal
  43073. };
  43074. /**
  43075. * Validate component names
  43076. */
  43077. function checkComponents (options) {
  43078. for (var key in options.components) {
  43079. validateComponentName(key);
  43080. }
  43081. }
  43082. function validateComponentName (name) {
  43083. if (!new RegExp(("^[a-zA-Z][\\-\\.0-9_" + (unicodeRegExp.source) + "]*$")).test(name)) {
  43084. warn(
  43085. 'Invalid component name: "' + name + '". Component names ' +
  43086. 'should conform to valid custom element name in html5 specification.'
  43087. );
  43088. }
  43089. if (isBuiltInTag(name) || config.isReservedTag(name)) {
  43090. warn(
  43091. 'Do not use built-in or reserved HTML elements as component ' +
  43092. 'id: ' + name
  43093. );
  43094. }
  43095. }
  43096. /**
  43097. * Ensure all props option syntax are normalized into the
  43098. * Object-based format.
  43099. */
  43100. function normalizeProps (options, vm) {
  43101. var props = options.props;
  43102. if (!props) { return }
  43103. var res = {};
  43104. var i, val, name;
  43105. if (Array.isArray(props)) {
  43106. i = props.length;
  43107. while (i--) {
  43108. val = props[i];
  43109. if (typeof val === 'string') {
  43110. name = camelize(val);
  43111. res[name] = { type: null };
  43112. } else {
  43113. warn('props must be strings when using array syntax.');
  43114. }
  43115. }
  43116. } else if (isPlainObject(props)) {
  43117. for (var key in props) {
  43118. val = props[key];
  43119. name = camelize(key);
  43120. res[name] = isPlainObject(val)
  43121. ? val
  43122. : { type: val };
  43123. }
  43124. } else {
  43125. warn(
  43126. "Invalid value for option \"props\": expected an Array or an Object, " +
  43127. "but got " + (toRawType(props)) + ".",
  43128. vm
  43129. );
  43130. }
  43131. options.props = res;
  43132. }
  43133. /**
  43134. * Normalize all injections into Object-based format
  43135. */
  43136. function normalizeInject (options, vm) {
  43137. var inject = options.inject;
  43138. if (!inject) { return }
  43139. var normalized = options.inject = {};
  43140. if (Array.isArray(inject)) {
  43141. for (var i = 0; i < inject.length; i++) {
  43142. normalized[inject[i]] = { from: inject[i] };
  43143. }
  43144. } else if (isPlainObject(inject)) {
  43145. for (var key in inject) {
  43146. var val = inject[key];
  43147. normalized[key] = isPlainObject(val)
  43148. ? extend({ from: key }, val)
  43149. : { from: val };
  43150. }
  43151. } else {
  43152. warn(
  43153. "Invalid value for option \"inject\": expected an Array or an Object, " +
  43154. "but got " + (toRawType(inject)) + ".",
  43155. vm
  43156. );
  43157. }
  43158. }
  43159. /**
  43160. * Normalize raw function directives into object format.
  43161. */
  43162. function normalizeDirectives (options) {
  43163. var dirs = options.directives;
  43164. if (dirs) {
  43165. for (var key in dirs) {
  43166. var def$$1 = dirs[key];
  43167. if (typeof def$$1 === 'function') {
  43168. dirs[key] = { bind: def$$1, update: def$$1 };
  43169. }
  43170. }
  43171. }
  43172. }
  43173. function assertObjectType (name, value, vm) {
  43174. if (!isPlainObject(value)) {
  43175. warn(
  43176. "Invalid value for option \"" + name + "\": expected an Object, " +
  43177. "but got " + (toRawType(value)) + ".",
  43178. vm
  43179. );
  43180. }
  43181. }
  43182. /**
  43183. * Merge two option objects into a new one.
  43184. * Core utility used in both instantiation and inheritance.
  43185. */
  43186. function mergeOptions (
  43187. parent,
  43188. child,
  43189. vm
  43190. ) {
  43191. {
  43192. checkComponents(child);
  43193. }
  43194. if (typeof child === 'function') {
  43195. child = child.options;
  43196. }
  43197. normalizeProps(child, vm);
  43198. normalizeInject(child, vm);
  43199. normalizeDirectives(child);
  43200. // Apply extends and mixins on the child options,
  43201. // but only if it is a raw options object that isn't
  43202. // the result of another mergeOptions call.
  43203. // Only merged options has the _base property.
  43204. if (!child._base) {
  43205. if (child.extends) {
  43206. parent = mergeOptions(parent, child.extends, vm);
  43207. }
  43208. if (child.mixins) {
  43209. for (var i = 0, l = child.mixins.length; i < l; i++) {
  43210. parent = mergeOptions(parent, child.mixins[i], vm);
  43211. }
  43212. }
  43213. }
  43214. var options = {};
  43215. var key;
  43216. for (key in parent) {
  43217. mergeField(key);
  43218. }
  43219. for (key in child) {
  43220. if (!hasOwn(parent, key)) {
  43221. mergeField(key);
  43222. }
  43223. }
  43224. function mergeField (key) {
  43225. var strat = strats[key] || defaultStrat;
  43226. options[key] = strat(parent[key], child[key], vm, key);
  43227. }
  43228. return options
  43229. }
  43230. /**
  43231. * Resolve an asset.
  43232. * This function is used because child instances need access
  43233. * to assets defined in its ancestor chain.
  43234. */
  43235. function resolveAsset (
  43236. options,
  43237. type,
  43238. id,
  43239. warnMissing
  43240. ) {
  43241. /* istanbul ignore if */
  43242. if (typeof id !== 'string') {
  43243. return
  43244. }
  43245. var assets = options[type];
  43246. // check local registration variations first
  43247. if (hasOwn(assets, id)) { return assets[id] }
  43248. var camelizedId = camelize(id);
  43249. if (hasOwn(assets, camelizedId)) { return assets[camelizedId] }
  43250. var PascalCaseId = capitalize(camelizedId);
  43251. if (hasOwn(assets, PascalCaseId)) { return assets[PascalCaseId] }
  43252. // fallback to prototype chain
  43253. var res = assets[id] || assets[camelizedId] || assets[PascalCaseId];
  43254. if (warnMissing && !res) {
  43255. warn(
  43256. 'Failed to resolve ' + type.slice(0, -1) + ': ' + id,
  43257. options
  43258. );
  43259. }
  43260. return res
  43261. }
  43262. /* */
  43263. function validateProp (
  43264. key,
  43265. propOptions,
  43266. propsData,
  43267. vm
  43268. ) {
  43269. var prop = propOptions[key];
  43270. var absent = !hasOwn(propsData, key);
  43271. var value = propsData[key];
  43272. // boolean casting
  43273. var booleanIndex = getTypeIndex(Boolean, prop.type);
  43274. if (booleanIndex > -1) {
  43275. if (absent && !hasOwn(prop, 'default')) {
  43276. value = false;
  43277. } else if (value === '' || value === hyphenate(key)) {
  43278. // only cast empty string / same name to boolean if
  43279. // boolean has higher priority
  43280. var stringIndex = getTypeIndex(String, prop.type);
  43281. if (stringIndex < 0 || booleanIndex < stringIndex) {
  43282. value = true;
  43283. }
  43284. }
  43285. }
  43286. // check default value
  43287. if (value === undefined) {
  43288. value = getPropDefaultValue(vm, prop, key);
  43289. // since the default value is a fresh copy,
  43290. // make sure to observe it.
  43291. var prevShouldObserve = shouldObserve;
  43292. toggleObserving(true);
  43293. observe(value);
  43294. toggleObserving(prevShouldObserve);
  43295. }
  43296. {
  43297. assertProp(prop, key, value, vm, absent);
  43298. }
  43299. return value
  43300. }
  43301. /**
  43302. * Get the default value of a prop.
  43303. */
  43304. function getPropDefaultValue (vm, prop, key) {
  43305. // no default, return undefined
  43306. if (!hasOwn(prop, 'default')) {
  43307. return undefined
  43308. }
  43309. var def = prop.default;
  43310. // warn against non-factory defaults for Object & Array
  43311. if (isObject(def)) {
  43312. warn(
  43313. 'Invalid default value for prop "' + key + '": ' +
  43314. 'Props with type Object/Array must use a factory function ' +
  43315. 'to return the default value.',
  43316. vm
  43317. );
  43318. }
  43319. // the raw prop value was also undefined from previous render,
  43320. // return previous default value to avoid unnecessary watcher trigger
  43321. if (vm && vm.$options.propsData &&
  43322. vm.$options.propsData[key] === undefined &&
  43323. vm._props[key] !== undefined
  43324. ) {
  43325. return vm._props[key]
  43326. }
  43327. // call factory function for non-Function types
  43328. // a value is Function if its prototype is function even across different execution context
  43329. return typeof def === 'function' && getType(prop.type) !== 'Function'
  43330. ? def.call(vm)
  43331. : def
  43332. }
  43333. /**
  43334. * Assert whether a prop is valid.
  43335. */
  43336. function assertProp (
  43337. prop,
  43338. name,
  43339. value,
  43340. vm,
  43341. absent
  43342. ) {
  43343. if (prop.required && absent) {
  43344. warn(
  43345. 'Missing required prop: "' + name + '"',
  43346. vm
  43347. );
  43348. return
  43349. }
  43350. if (value == null && !prop.required) {
  43351. return
  43352. }
  43353. var type = prop.type;
  43354. var valid = !type || type === true;
  43355. var expectedTypes = [];
  43356. if (type) {
  43357. if (!Array.isArray(type)) {
  43358. type = [type];
  43359. }
  43360. for (var i = 0; i < type.length && !valid; i++) {
  43361. var assertedType = assertType(value, type[i]);
  43362. expectedTypes.push(assertedType.expectedType || '');
  43363. valid = assertedType.valid;
  43364. }
  43365. }
  43366. if (!valid) {
  43367. warn(
  43368. getInvalidTypeMessage(name, value, expectedTypes),
  43369. vm
  43370. );
  43371. return
  43372. }
  43373. var validator = prop.validator;
  43374. if (validator) {
  43375. if (!validator(value)) {
  43376. warn(
  43377. 'Invalid prop: custom validator check failed for prop "' + name + '".',
  43378. vm
  43379. );
  43380. }
  43381. }
  43382. }
  43383. var simpleCheckRE = /^(String|Number|Boolean|Function|Symbol)$/;
  43384. function assertType (value, type) {
  43385. var valid;
  43386. var expectedType = getType(type);
  43387. if (simpleCheckRE.test(expectedType)) {
  43388. var t = typeof value;
  43389. valid = t === expectedType.toLowerCase();
  43390. // for primitive wrapper objects
  43391. if (!valid && t === 'object') {
  43392. valid = value instanceof type;
  43393. }
  43394. } else if (expectedType === 'Object') {
  43395. valid = isPlainObject(value);
  43396. } else if (expectedType === 'Array') {
  43397. valid = Array.isArray(value);
  43398. } else {
  43399. valid = value instanceof type;
  43400. }
  43401. return {
  43402. valid: valid,
  43403. expectedType: expectedType
  43404. }
  43405. }
  43406. /**
  43407. * Use function string name to check built-in types,
  43408. * because a simple equality check will fail when running
  43409. * across different vms / iframes.
  43410. */
  43411. function getType (fn) {
  43412. var match = fn && fn.toString().match(/^\s*function (\w+)/);
  43413. return match ? match[1] : ''
  43414. }
  43415. function isSameType (a, b) {
  43416. return getType(a) === getType(b)
  43417. }
  43418. function getTypeIndex (type, expectedTypes) {
  43419. if (!Array.isArray(expectedTypes)) {
  43420. return isSameType(expectedTypes, type) ? 0 : -1
  43421. }
  43422. for (var i = 0, len = expectedTypes.length; i < len; i++) {
  43423. if (isSameType(expectedTypes[i], type)) {
  43424. return i
  43425. }
  43426. }
  43427. return -1
  43428. }
  43429. function getInvalidTypeMessage (name, value, expectedTypes) {
  43430. var message = "Invalid prop: type check failed for prop \"" + name + "\"." +
  43431. " Expected " + (expectedTypes.map(capitalize).join(', '));
  43432. var expectedType = expectedTypes[0];
  43433. var receivedType = toRawType(value);
  43434. var expectedValue = styleValue(value, expectedType);
  43435. var receivedValue = styleValue(value, receivedType);
  43436. // check if we need to specify expected value
  43437. if (expectedTypes.length === 1 &&
  43438. isExplicable(expectedType) &&
  43439. !isBoolean(expectedType, receivedType)) {
  43440. message += " with value " + expectedValue;
  43441. }
  43442. message += ", got " + receivedType + " ";
  43443. // check if we need to specify received value
  43444. if (isExplicable(receivedType)) {
  43445. message += "with value " + receivedValue + ".";
  43446. }
  43447. return message
  43448. }
  43449. function styleValue (value, type) {
  43450. if (type === 'String') {
  43451. return ("\"" + value + "\"")
  43452. } else if (type === 'Number') {
  43453. return ("" + (Number(value)))
  43454. } else {
  43455. return ("" + value)
  43456. }
  43457. }
  43458. function isExplicable (value) {
  43459. var explicitTypes = ['string', 'number', 'boolean'];
  43460. return explicitTypes.some(function (elem) { return value.toLowerCase() === elem; })
  43461. }
  43462. function isBoolean () {
  43463. var args = [], len = arguments.length;
  43464. while ( len-- ) args[ len ] = arguments[ len ];
  43465. return args.some(function (elem) { return elem.toLowerCase() === 'boolean'; })
  43466. }
  43467. /* */
  43468. function handleError (err, vm, info) {
  43469. // Deactivate deps tracking while processing error handler to avoid possible infinite rendering.
  43470. // See: https://github.com/vuejs/vuex/issues/1505
  43471. pushTarget();
  43472. try {
  43473. if (vm) {
  43474. var cur = vm;
  43475. while ((cur = cur.$parent)) {
  43476. var hooks = cur.$options.errorCaptured;
  43477. if (hooks) {
  43478. for (var i = 0; i < hooks.length; i++) {
  43479. try {
  43480. var capture = hooks[i].call(cur, err, vm, info) === false;
  43481. if (capture) { return }
  43482. } catch (e) {
  43483. globalHandleError(e, cur, 'errorCaptured hook');
  43484. }
  43485. }
  43486. }
  43487. }
  43488. }
  43489. globalHandleError(err, vm, info);
  43490. } finally {
  43491. popTarget();
  43492. }
  43493. }
  43494. function invokeWithErrorHandling (
  43495. handler,
  43496. context,
  43497. args,
  43498. vm,
  43499. info
  43500. ) {
  43501. var res;
  43502. try {
  43503. res = args ? handler.apply(context, args) : handler.call(context);
  43504. if (res && !res._isVue && isPromise(res) && !res._handled) {
  43505. res.catch(function (e) { return handleError(e, vm, info + " (Promise/async)"); });
  43506. // issue #9511
  43507. // avoid catch triggering multiple times when nested calls
  43508. res._handled = true;
  43509. }
  43510. } catch (e) {
  43511. handleError(e, vm, info);
  43512. }
  43513. return res
  43514. }
  43515. function globalHandleError (err, vm, info) {
  43516. if (config.errorHandler) {
  43517. try {
  43518. return config.errorHandler.call(null, err, vm, info)
  43519. } catch (e) {
  43520. // if the user intentionally throws the original error in the handler,
  43521. // do not log it twice
  43522. if (e !== err) {
  43523. logError(e, null, 'config.errorHandler');
  43524. }
  43525. }
  43526. }
  43527. logError(err, vm, info);
  43528. }
  43529. function logError (err, vm, info) {
  43530. {
  43531. warn(("Error in " + info + ": \"" + (err.toString()) + "\""), vm);
  43532. }
  43533. /* istanbul ignore else */
  43534. if ((inBrowser || inWeex) && typeof console !== 'undefined') {
  43535. console.error(err);
  43536. } else {
  43537. throw err
  43538. }
  43539. }
  43540. /* */
  43541. var isUsingMicroTask = false;
  43542. var callbacks = [];
  43543. var pending = false;
  43544. function flushCallbacks () {
  43545. pending = false;
  43546. var copies = callbacks.slice(0);
  43547. callbacks.length = 0;
  43548. for (var i = 0; i < copies.length; i++) {
  43549. copies[i]();
  43550. }
  43551. }
  43552. // Here we have async deferring wrappers using microtasks.
  43553. // In 2.5 we used (macro) tasks (in combination with microtasks).
  43554. // However, it has subtle problems when state is changed right before repaint
  43555. // (e.g. #6813, out-in transitions).
  43556. // Also, using (macro) tasks in event handler would cause some weird behaviors
  43557. // that cannot be circumvented (e.g. #7109, #7153, #7546, #7834, #8109).
  43558. // So we now use microtasks everywhere, again.
  43559. // A major drawback of this tradeoff is that there are some scenarios
  43560. // where microtasks have too high a priority and fire in between supposedly
  43561. // sequential events (e.g. #4521, #6690, which have workarounds)
  43562. // or even between bubbling of the same event (#6566).
  43563. var timerFunc;
  43564. // The nextTick behavior leverages the microtask queue, which can be accessed
  43565. // via either native Promise.then or MutationObserver.
  43566. // MutationObserver has wider support, however it is seriously bugged in
  43567. // UIWebView in iOS >= 9.3.3 when triggered in touch event handlers. It
  43568. // completely stops working after triggering a few times... so, if native
  43569. // Promise is available, we will use it:
  43570. /* istanbul ignore next, $flow-disable-line */
  43571. if (typeof Promise !== 'undefined' && isNative(Promise)) {
  43572. var p = Promise.resolve();
  43573. timerFunc = function () {
  43574. p.then(flushCallbacks);
  43575. // In problematic UIWebViews, Promise.then doesn't completely break, but
  43576. // it can get stuck in a weird state where callbacks are pushed into the
  43577. // microtask queue but the queue isn't being flushed, until the browser
  43578. // needs to do some other work, e.g. handle a timer. Therefore we can
  43579. // "force" the microtask queue to be flushed by adding an empty timer.
  43580. if (isIOS) { setTimeout(noop); }
  43581. };
  43582. isUsingMicroTask = true;
  43583. } else if (!isIE && typeof MutationObserver !== 'undefined' && (
  43584. isNative(MutationObserver) ||
  43585. // PhantomJS and iOS 7.x
  43586. MutationObserver.toString() === '[object MutationObserverConstructor]'
  43587. )) {
  43588. // Use MutationObserver where native Promise is not available,
  43589. // e.g. PhantomJS, iOS7, Android 4.4
  43590. // (#6466 MutationObserver is unreliable in IE11)
  43591. var counter = 1;
  43592. var observer = new MutationObserver(flushCallbacks);
  43593. var textNode = document.createTextNode(String(counter));
  43594. observer.observe(textNode, {
  43595. characterData: true
  43596. });
  43597. timerFunc = function () {
  43598. counter = (counter + 1) % 2;
  43599. textNode.data = String(counter);
  43600. };
  43601. isUsingMicroTask = true;
  43602. } else if (typeof setImmediate !== 'undefined' && isNative(setImmediate)) {
  43603. // Fallback to setImmediate.
  43604. // Technically it leverages the (macro) task queue,
  43605. // but it is still a better choice than setTimeout.
  43606. timerFunc = function () {
  43607. setImmediate(flushCallbacks);
  43608. };
  43609. } else {
  43610. // Fallback to setTimeout.
  43611. timerFunc = function () {
  43612. setTimeout(flushCallbacks, 0);
  43613. };
  43614. }
  43615. function nextTick (cb, ctx) {
  43616. var _resolve;
  43617. callbacks.push(function () {
  43618. if (cb) {
  43619. try {
  43620. cb.call(ctx);
  43621. } catch (e) {
  43622. handleError(e, ctx, 'nextTick');
  43623. }
  43624. } else if (_resolve) {
  43625. _resolve(ctx);
  43626. }
  43627. });
  43628. if (!pending) {
  43629. pending = true;
  43630. timerFunc();
  43631. }
  43632. // $flow-disable-line
  43633. if (!cb && typeof Promise !== 'undefined') {
  43634. return new Promise(function (resolve) {
  43635. _resolve = resolve;
  43636. })
  43637. }
  43638. }
  43639. /* */
  43640. var mark;
  43641. var measure;
  43642. {
  43643. var perf = inBrowser && window.performance;
  43644. /* istanbul ignore if */
  43645. if (
  43646. perf &&
  43647. perf.mark &&
  43648. perf.measure &&
  43649. perf.clearMarks &&
  43650. perf.clearMeasures
  43651. ) {
  43652. mark = function (tag) { return perf.mark(tag); };
  43653. measure = function (name, startTag, endTag) {
  43654. perf.measure(name, startTag, endTag);
  43655. perf.clearMarks(startTag);
  43656. perf.clearMarks(endTag);
  43657. // perf.clearMeasures(name)
  43658. };
  43659. }
  43660. }
  43661. /* not type checking this file because flow doesn't play well with Proxy */
  43662. var initProxy;
  43663. {
  43664. var allowedGlobals = makeMap(
  43665. 'Infinity,undefined,NaN,isFinite,isNaN,' +
  43666. 'parseFloat,parseInt,decodeURI,decodeURIComponent,encodeURI,encodeURIComponent,' +
  43667. 'Math,Number,Date,Array,Object,Boolean,String,RegExp,Map,Set,JSON,Intl,' +
  43668. 'require' // for Webpack/Browserify
  43669. );
  43670. var warnNonPresent = function (target, key) {
  43671. warn(
  43672. "Property or method \"" + key + "\" is not defined on the instance but " +
  43673. 'referenced during render. Make sure that this property is reactive, ' +
  43674. 'either in the data option, or for class-based components, by ' +
  43675. 'initializing the property. ' +
  43676. 'See: https://vuejs.org/v2/guide/reactivity.html#Declaring-Reactive-Properties.',
  43677. target
  43678. );
  43679. };
  43680. var warnReservedPrefix = function (target, key) {
  43681. warn(
  43682. "Property \"" + key + "\" must be accessed with \"$data." + key + "\" because " +
  43683. 'properties starting with "$" or "_" are not proxied in the Vue instance to ' +
  43684. 'prevent conflicts with Vue internals. ' +
  43685. 'See: https://vuejs.org/v2/api/#data',
  43686. target
  43687. );
  43688. };
  43689. var hasProxy =
  43690. typeof Proxy !== 'undefined' && isNative(Proxy);
  43691. if (hasProxy) {
  43692. var isBuiltInModifier = makeMap('stop,prevent,self,ctrl,shift,alt,meta,exact');
  43693. config.keyCodes = new Proxy(config.keyCodes, {
  43694. set: function set (target, key, value) {
  43695. if (isBuiltInModifier(key)) {
  43696. warn(("Avoid overwriting built-in modifier in config.keyCodes: ." + key));
  43697. return false
  43698. } else {
  43699. target[key] = value;
  43700. return true
  43701. }
  43702. }
  43703. });
  43704. }
  43705. var hasHandler = {
  43706. has: function has (target, key) {
  43707. var has = key in target;
  43708. var isAllowed = allowedGlobals(key) ||
  43709. (typeof key === 'string' && key.charAt(0) === '_' && !(key in target.$data));
  43710. if (!has && !isAllowed) {
  43711. if (key in target.$data) { warnReservedPrefix(target, key); }
  43712. else { warnNonPresent(target, key); }
  43713. }
  43714. return has || !isAllowed
  43715. }
  43716. };
  43717. var getHandler = {
  43718. get: function get (target, key) {
  43719. if (typeof key === 'string' && !(key in target)) {
  43720. if (key in target.$data) { warnReservedPrefix(target, key); }
  43721. else { warnNonPresent(target, key); }
  43722. }
  43723. return target[key]
  43724. }
  43725. };
  43726. initProxy = function initProxy (vm) {
  43727. if (hasProxy) {
  43728. // determine which proxy handler to use
  43729. var options = vm.$options;
  43730. var handlers = options.render && options.render._withStripped
  43731. ? getHandler
  43732. : hasHandler;
  43733. vm._renderProxy = new Proxy(vm, handlers);
  43734. } else {
  43735. vm._renderProxy = vm;
  43736. }
  43737. };
  43738. }
  43739. /* */
  43740. var seenObjects = new _Set();
  43741. /**
  43742. * Recursively traverse an object to evoke all converted
  43743. * getters, so that every nested property inside the object
  43744. * is collected as a "deep" dependency.
  43745. */
  43746. function traverse (val) {
  43747. _traverse(val, seenObjects);
  43748. seenObjects.clear();
  43749. }
  43750. function _traverse (val, seen) {
  43751. var i, keys;
  43752. var isA = Array.isArray(val);
  43753. if ((!isA && !isObject(val)) || Object.isFrozen(val) || val instanceof VNode) {
  43754. return
  43755. }
  43756. if (val.__ob__) {
  43757. var depId = val.__ob__.dep.id;
  43758. if (seen.has(depId)) {
  43759. return
  43760. }
  43761. seen.add(depId);
  43762. }
  43763. if (isA) {
  43764. i = val.length;
  43765. while (i--) { _traverse(val[i], seen); }
  43766. } else {
  43767. keys = Object.keys(val);
  43768. i = keys.length;
  43769. while (i--) { _traverse(val[keys[i]], seen); }
  43770. }
  43771. }
  43772. /* */
  43773. var normalizeEvent = cached(function (name) {
  43774. var passive = name.charAt(0) === '&';
  43775. name = passive ? name.slice(1) : name;
  43776. var once$$1 = name.charAt(0) === '~'; // Prefixed last, checked first
  43777. name = once$$1 ? name.slice(1) : name;
  43778. var capture = name.charAt(0) === '!';
  43779. name = capture ? name.slice(1) : name;
  43780. return {
  43781. name: name,
  43782. once: once$$1,
  43783. capture: capture,
  43784. passive: passive
  43785. }
  43786. });
  43787. function createFnInvoker (fns, vm) {
  43788. function invoker () {
  43789. var arguments$1 = arguments;
  43790. var fns = invoker.fns;
  43791. if (Array.isArray(fns)) {
  43792. var cloned = fns.slice();
  43793. for (var i = 0; i < cloned.length; i++) {
  43794. invokeWithErrorHandling(cloned[i], null, arguments$1, vm, "v-on handler");
  43795. }
  43796. } else {
  43797. // return handler return value for single handlers
  43798. return invokeWithErrorHandling(fns, null, arguments, vm, "v-on handler")
  43799. }
  43800. }
  43801. invoker.fns = fns;
  43802. return invoker
  43803. }
  43804. function updateListeners (
  43805. on,
  43806. oldOn,
  43807. add,
  43808. remove$$1,
  43809. createOnceHandler,
  43810. vm
  43811. ) {
  43812. var name, def$$1, cur, old, event;
  43813. for (name in on) {
  43814. def$$1 = cur = on[name];
  43815. old = oldOn[name];
  43816. event = normalizeEvent(name);
  43817. if (isUndef(cur)) {
  43818. warn(
  43819. "Invalid handler for event \"" + (event.name) + "\": got " + String(cur),
  43820. vm
  43821. );
  43822. } else if (isUndef(old)) {
  43823. if (isUndef(cur.fns)) {
  43824. cur = on[name] = createFnInvoker(cur, vm);
  43825. }
  43826. if (isTrue(event.once)) {
  43827. cur = on[name] = createOnceHandler(event.name, cur, event.capture);
  43828. }
  43829. add(event.name, cur, event.capture, event.passive, event.params);
  43830. } else if (cur !== old) {
  43831. old.fns = cur;
  43832. on[name] = old;
  43833. }
  43834. }
  43835. for (name in oldOn) {
  43836. if (isUndef(on[name])) {
  43837. event = normalizeEvent(name);
  43838. remove$$1(event.name, oldOn[name], event.capture);
  43839. }
  43840. }
  43841. }
  43842. /* */
  43843. function mergeVNodeHook (def, hookKey, hook) {
  43844. if (def instanceof VNode) {
  43845. def = def.data.hook || (def.data.hook = {});
  43846. }
  43847. var invoker;
  43848. var oldHook = def[hookKey];
  43849. function wrappedHook () {
  43850. hook.apply(this, arguments);
  43851. // important: remove merged hook to ensure it's called only once
  43852. // and prevent memory leak
  43853. remove(invoker.fns, wrappedHook);
  43854. }
  43855. if (isUndef(oldHook)) {
  43856. // no existing hook
  43857. invoker = createFnInvoker([wrappedHook]);
  43858. } else {
  43859. /* istanbul ignore if */
  43860. if (isDef(oldHook.fns) && isTrue(oldHook.merged)) {
  43861. // already a merged invoker
  43862. invoker = oldHook;
  43863. invoker.fns.push(wrappedHook);
  43864. } else {
  43865. // existing plain hook
  43866. invoker = createFnInvoker([oldHook, wrappedHook]);
  43867. }
  43868. }
  43869. invoker.merged = true;
  43870. def[hookKey] = invoker;
  43871. }
  43872. /* */
  43873. function extractPropsFromVNodeData (
  43874. data,
  43875. Ctor,
  43876. tag
  43877. ) {
  43878. // we are only extracting raw values here.
  43879. // validation and default values are handled in the child
  43880. // component itself.
  43881. var propOptions = Ctor.options.props;
  43882. if (isUndef(propOptions)) {
  43883. return
  43884. }
  43885. var res = {};
  43886. var attrs = data.attrs;
  43887. var props = data.props;
  43888. if (isDef(attrs) || isDef(props)) {
  43889. for (var key in propOptions) {
  43890. var altKey = hyphenate(key);
  43891. {
  43892. var keyInLowerCase = key.toLowerCase();
  43893. if (
  43894. key !== keyInLowerCase &&
  43895. attrs && hasOwn(attrs, keyInLowerCase)
  43896. ) {
  43897. tip(
  43898. "Prop \"" + keyInLowerCase + "\" is passed to component " +
  43899. (formatComponentName(tag || Ctor)) + ", but the declared prop name is" +
  43900. " \"" + key + "\". " +
  43901. "Note that HTML attributes are case-insensitive and camelCased " +
  43902. "props need to use their kebab-case equivalents when using in-DOM " +
  43903. "templates. You should probably use \"" + altKey + "\" instead of \"" + key + "\"."
  43904. );
  43905. }
  43906. }
  43907. checkProp(res, props, key, altKey, true) ||
  43908. checkProp(res, attrs, key, altKey, false);
  43909. }
  43910. }
  43911. return res
  43912. }
  43913. function checkProp (
  43914. res,
  43915. hash,
  43916. key,
  43917. altKey,
  43918. preserve
  43919. ) {
  43920. if (isDef(hash)) {
  43921. if (hasOwn(hash, key)) {
  43922. res[key] = hash[key];
  43923. if (!preserve) {
  43924. delete hash[key];
  43925. }
  43926. return true
  43927. } else if (hasOwn(hash, altKey)) {
  43928. res[key] = hash[altKey];
  43929. if (!preserve) {
  43930. delete hash[altKey];
  43931. }
  43932. return true
  43933. }
  43934. }
  43935. return false
  43936. }
  43937. /* */
  43938. // The template compiler attempts to minimize the need for normalization by
  43939. // statically analyzing the template at compile time.
  43940. //
  43941. // For plain HTML markup, normalization can be completely skipped because the
  43942. // generated render function is guaranteed to return Array<VNode>. There are
  43943. // two cases where extra normalization is needed:
  43944. // 1. When the children contains components - because a functional component
  43945. // may return an Array instead of a single root. In this case, just a simple
  43946. // normalization is needed - if any child is an Array, we flatten the whole
  43947. // thing with Array.prototype.concat. It is guaranteed to be only 1-level deep
  43948. // because functional components already normalize their own children.
  43949. function simpleNormalizeChildren (children) {
  43950. for (var i = 0; i < children.length; i++) {
  43951. if (Array.isArray(children[i])) {
  43952. return Array.prototype.concat.apply([], children)
  43953. }
  43954. }
  43955. return children
  43956. }
  43957. // 2. When the children contains constructs that always generated nested Arrays,
  43958. // e.g. <template>, <slot>, v-for, or when the children is provided by user
  43959. // with hand-written render functions / JSX. In such cases a full normalization
  43960. // is needed to cater to all possible types of children values.
  43961. function normalizeChildren (children) {
  43962. return isPrimitive(children)
  43963. ? [createTextVNode(children)]
  43964. : Array.isArray(children)
  43965. ? normalizeArrayChildren(children)
  43966. : undefined
  43967. }
  43968. function isTextNode (node) {
  43969. return isDef(node) && isDef(node.text) && isFalse(node.isComment)
  43970. }
  43971. function normalizeArrayChildren (children, nestedIndex) {
  43972. var res = [];
  43973. var i, c, lastIndex, last;
  43974. for (i = 0; i < children.length; i++) {
  43975. c = children[i];
  43976. if (isUndef(c) || typeof c === 'boolean') { continue }
  43977. lastIndex = res.length - 1;
  43978. last = res[lastIndex];
  43979. // nested
  43980. if (Array.isArray(c)) {
  43981. if (c.length > 0) {
  43982. c = normalizeArrayChildren(c, ((nestedIndex || '') + "_" + i));
  43983. // merge adjacent text nodes
  43984. if (isTextNode(c[0]) && isTextNode(last)) {
  43985. res[lastIndex] = createTextVNode(last.text + (c[0]).text);
  43986. c.shift();
  43987. }
  43988. res.push.apply(res, c);
  43989. }
  43990. } else if (isPrimitive(c)) {
  43991. if (isTextNode(last)) {
  43992. // merge adjacent text nodes
  43993. // this is necessary for SSR hydration because text nodes are
  43994. // essentially merged when rendered to HTML strings
  43995. res[lastIndex] = createTextVNode(last.text + c);
  43996. } else if (c !== '') {
  43997. // convert primitive to vnode
  43998. res.push(createTextVNode(c));
  43999. }
  44000. } else {
  44001. if (isTextNode(c) && isTextNode(last)) {
  44002. // merge adjacent text nodes
  44003. res[lastIndex] = createTextVNode(last.text + c.text);
  44004. } else {
  44005. // default key for nested array children (likely generated by v-for)
  44006. if (isTrue(children._isVList) &&
  44007. isDef(c.tag) &&
  44008. isUndef(c.key) &&
  44009. isDef(nestedIndex)) {
  44010. c.key = "__vlist" + nestedIndex + "_" + i + "__";
  44011. }
  44012. res.push(c);
  44013. }
  44014. }
  44015. }
  44016. return res
  44017. }
  44018. /* */
  44019. function initProvide (vm) {
  44020. var provide = vm.$options.provide;
  44021. if (provide) {
  44022. vm._provided = typeof provide === 'function'
  44023. ? provide.call(vm)
  44024. : provide;
  44025. }
  44026. }
  44027. function initInjections (vm) {
  44028. var result = resolveInject(vm.$options.inject, vm);
  44029. if (result) {
  44030. toggleObserving(false);
  44031. Object.keys(result).forEach(function (key) {
  44032. /* istanbul ignore else */
  44033. {
  44034. defineReactive$$1(vm, key, result[key], function () {
  44035. warn(
  44036. "Avoid mutating an injected value directly since the changes will be " +
  44037. "overwritten whenever the provided component re-renders. " +
  44038. "injection being mutated: \"" + key + "\"",
  44039. vm
  44040. );
  44041. });
  44042. }
  44043. });
  44044. toggleObserving(true);
  44045. }
  44046. }
  44047. function resolveInject (inject, vm) {
  44048. if (inject) {
  44049. // inject is :any because flow is not smart enough to figure out cached
  44050. var result = Object.create(null);
  44051. var keys = hasSymbol
  44052. ? Reflect.ownKeys(inject)
  44053. : Object.keys(inject);
  44054. for (var i = 0; i < keys.length; i++) {
  44055. var key = keys[i];
  44056. // #6574 in case the inject object is observed...
  44057. if (key === '__ob__') { continue }
  44058. var provideKey = inject[key].from;
  44059. var source = vm;
  44060. while (source) {
  44061. if (source._provided && hasOwn(source._provided, provideKey)) {
  44062. result[key] = source._provided[provideKey];
  44063. break
  44064. }
  44065. source = source.$parent;
  44066. }
  44067. if (!source) {
  44068. if ('default' in inject[key]) {
  44069. var provideDefault = inject[key].default;
  44070. result[key] = typeof provideDefault === 'function'
  44071. ? provideDefault.call(vm)
  44072. : provideDefault;
  44073. } else {
  44074. warn(("Injection \"" + key + "\" not found"), vm);
  44075. }
  44076. }
  44077. }
  44078. return result
  44079. }
  44080. }
  44081. /* */
  44082. /**
  44083. * Runtime helper for resolving raw children VNodes into a slot object.
  44084. */
  44085. function resolveSlots (
  44086. children,
  44087. context
  44088. ) {
  44089. if (!children || !children.length) {
  44090. return {}
  44091. }
  44092. var slots = {};
  44093. for (var i = 0, l = children.length; i < l; i++) {
  44094. var child = children[i];
  44095. var data = child.data;
  44096. // remove slot attribute if the node is resolved as a Vue slot node
  44097. if (data && data.attrs && data.attrs.slot) {
  44098. delete data.attrs.slot;
  44099. }
  44100. // named slots should only be respected if the vnode was rendered in the
  44101. // same context.
  44102. if ((child.context === context || child.fnContext === context) &&
  44103. data && data.slot != null
  44104. ) {
  44105. var name = data.slot;
  44106. var slot = (slots[name] || (slots[name] = []));
  44107. if (child.tag === 'template') {
  44108. slot.push.apply(slot, child.children || []);
  44109. } else {
  44110. slot.push(child);
  44111. }
  44112. } else {
  44113. (slots.default || (slots.default = [])).push(child);
  44114. }
  44115. }
  44116. // ignore slots that contains only whitespace
  44117. for (var name$1 in slots) {
  44118. if (slots[name$1].every(isWhitespace)) {
  44119. delete slots[name$1];
  44120. }
  44121. }
  44122. return slots
  44123. }
  44124. function isWhitespace (node) {
  44125. return (node.isComment && !node.asyncFactory) || node.text === ' '
  44126. }
  44127. /* */
  44128. function normalizeScopedSlots (
  44129. slots,
  44130. normalSlots,
  44131. prevSlots
  44132. ) {
  44133. var res;
  44134. var hasNormalSlots = Object.keys(normalSlots).length > 0;
  44135. var isStable = slots ? !!slots.$stable : !hasNormalSlots;
  44136. var key = slots && slots.$key;
  44137. if (!slots) {
  44138. res = {};
  44139. } else if (slots._normalized) {
  44140. // fast path 1: child component re-render only, parent did not change
  44141. return slots._normalized
  44142. } else if (
  44143. isStable &&
  44144. prevSlots &&
  44145. prevSlots !== emptyObject &&
  44146. key === prevSlots.$key &&
  44147. !hasNormalSlots &&
  44148. !prevSlots.$hasNormal
  44149. ) {
  44150. // fast path 2: stable scoped slots w/ no normal slots to proxy,
  44151. // only need to normalize once
  44152. return prevSlots
  44153. } else {
  44154. res = {};
  44155. for (var key$1 in slots) {
  44156. if (slots[key$1] && key$1[0] !== '$') {
  44157. res[key$1] = normalizeScopedSlot(normalSlots, key$1, slots[key$1]);
  44158. }
  44159. }
  44160. }
  44161. // expose normal slots on scopedSlots
  44162. for (var key$2 in normalSlots) {
  44163. if (!(key$2 in res)) {
  44164. res[key$2] = proxyNormalSlot(normalSlots, key$2);
  44165. }
  44166. }
  44167. // avoriaz seems to mock a non-extensible $scopedSlots object
  44168. // and when that is passed down this would cause an error
  44169. if (slots && Object.isExtensible(slots)) {
  44170. (slots)._normalized = res;
  44171. }
  44172. def(res, '$stable', isStable);
  44173. def(res, '$key', key);
  44174. def(res, '$hasNormal', hasNormalSlots);
  44175. return res
  44176. }
  44177. function normalizeScopedSlot(normalSlots, key, fn) {
  44178. var normalized = function () {
  44179. var res = arguments.length ? fn.apply(null, arguments) : fn({});
  44180. res = res && typeof res === 'object' && !Array.isArray(res)
  44181. ? [res] // single vnode
  44182. : normalizeChildren(res);
  44183. return res && (
  44184. res.length === 0 ||
  44185. (res.length === 1 && res[0].isComment) // #9658
  44186. ) ? undefined
  44187. : res
  44188. };
  44189. // this is a slot using the new v-slot syntax without scope. although it is
  44190. // compiled as a scoped slot, render fn users would expect it to be present
  44191. // on this.$slots because the usage is semantically a normal slot.
  44192. if (fn.proxy) {
  44193. Object.defineProperty(normalSlots, key, {
  44194. get: normalized,
  44195. enumerable: true,
  44196. configurable: true
  44197. });
  44198. }
  44199. return normalized
  44200. }
  44201. function proxyNormalSlot(slots, key) {
  44202. return function () { return slots[key]; }
  44203. }
  44204. /* */
  44205. /**
  44206. * Runtime helper for rendering v-for lists.
  44207. */
  44208. function renderList (
  44209. val,
  44210. render
  44211. ) {
  44212. var ret, i, l, keys, key;
  44213. if (Array.isArray(val) || typeof val === 'string') {
  44214. ret = new Array(val.length);
  44215. for (i = 0, l = val.length; i < l; i++) {
  44216. ret[i] = render(val[i], i);
  44217. }
  44218. } else if (typeof val === 'number') {
  44219. ret = new Array(val);
  44220. for (i = 0; i < val; i++) {
  44221. ret[i] = render(i + 1, i);
  44222. }
  44223. } else if (isObject(val)) {
  44224. if (hasSymbol && val[Symbol.iterator]) {
  44225. ret = [];
  44226. var iterator = val[Symbol.iterator]();
  44227. var result = iterator.next();
  44228. while (!result.done) {
  44229. ret.push(render(result.value, ret.length));
  44230. result = iterator.next();
  44231. }
  44232. } else {
  44233. keys = Object.keys(val);
  44234. ret = new Array(keys.length);
  44235. for (i = 0, l = keys.length; i < l; i++) {
  44236. key = keys[i];
  44237. ret[i] = render(val[key], key, i);
  44238. }
  44239. }
  44240. }
  44241. if (!isDef(ret)) {
  44242. ret = [];
  44243. }
  44244. (ret)._isVList = true;
  44245. return ret
  44246. }
  44247. /* */
  44248. /**
  44249. * Runtime helper for rendering <slot>
  44250. */
  44251. function renderSlot (
  44252. name,
  44253. fallback,
  44254. props,
  44255. bindObject
  44256. ) {
  44257. var scopedSlotFn = this.$scopedSlots[name];
  44258. var nodes;
  44259. if (scopedSlotFn) { // scoped slot
  44260. props = props || {};
  44261. if (bindObject) {
  44262. if (!isObject(bindObject)) {
  44263. warn(
  44264. 'slot v-bind without argument expects an Object',
  44265. this
  44266. );
  44267. }
  44268. props = extend(extend({}, bindObject), props);
  44269. }
  44270. nodes = scopedSlotFn(props) || fallback;
  44271. } else {
  44272. nodes = this.$slots[name] || fallback;
  44273. }
  44274. var target = props && props.slot;
  44275. if (target) {
  44276. return this.$createElement('template', { slot: target }, nodes)
  44277. } else {
  44278. return nodes
  44279. }
  44280. }
  44281. /* */
  44282. /**
  44283. * Runtime helper for resolving filters
  44284. */
  44285. function resolveFilter (id) {
  44286. return resolveAsset(this.$options, 'filters', id, true) || identity
  44287. }
  44288. /* */
  44289. function isKeyNotMatch (expect, actual) {
  44290. if (Array.isArray(expect)) {
  44291. return expect.indexOf(actual) === -1
  44292. } else {
  44293. return expect !== actual
  44294. }
  44295. }
  44296. /**
  44297. * Runtime helper for checking keyCodes from config.
  44298. * exposed as Vue.prototype._k
  44299. * passing in eventKeyName as last argument separately for backwards compat
  44300. */
  44301. function checkKeyCodes (
  44302. eventKeyCode,
  44303. key,
  44304. builtInKeyCode,
  44305. eventKeyName,
  44306. builtInKeyName
  44307. ) {
  44308. var mappedKeyCode = config.keyCodes[key] || builtInKeyCode;
  44309. if (builtInKeyName && eventKeyName && !config.keyCodes[key]) {
  44310. return isKeyNotMatch(builtInKeyName, eventKeyName)
  44311. } else if (mappedKeyCode) {
  44312. return isKeyNotMatch(mappedKeyCode, eventKeyCode)
  44313. } else if (eventKeyName) {
  44314. return hyphenate(eventKeyName) !== key
  44315. }
  44316. }
  44317. /* */
  44318. /**
  44319. * Runtime helper for merging v-bind="object" into a VNode's data.
  44320. */
  44321. function bindObjectProps (
  44322. data,
  44323. tag,
  44324. value,
  44325. asProp,
  44326. isSync
  44327. ) {
  44328. if (value) {
  44329. if (!isObject(value)) {
  44330. warn(
  44331. 'v-bind without argument expects an Object or Array value',
  44332. this
  44333. );
  44334. } else {
  44335. if (Array.isArray(value)) {
  44336. value = toObject(value);
  44337. }
  44338. var hash;
  44339. var loop = function ( key ) {
  44340. if (
  44341. key === 'class' ||
  44342. key === 'style' ||
  44343. isReservedAttribute(key)
  44344. ) {
  44345. hash = data;
  44346. } else {
  44347. var type = data.attrs && data.attrs.type;
  44348. hash = asProp || config.mustUseProp(tag, type, key)
  44349. ? data.domProps || (data.domProps = {})
  44350. : data.attrs || (data.attrs = {});
  44351. }
  44352. var camelizedKey = camelize(key);
  44353. var hyphenatedKey = hyphenate(key);
  44354. if (!(camelizedKey in hash) && !(hyphenatedKey in hash)) {
  44355. hash[key] = value[key];
  44356. if (isSync) {
  44357. var on = data.on || (data.on = {});
  44358. on[("update:" + key)] = function ($event) {
  44359. value[key] = $event;
  44360. };
  44361. }
  44362. }
  44363. };
  44364. for (var key in value) loop( key );
  44365. }
  44366. }
  44367. return data
  44368. }
  44369. /* */
  44370. /**
  44371. * Runtime helper for rendering static trees.
  44372. */
  44373. function renderStatic (
  44374. index,
  44375. isInFor
  44376. ) {
  44377. var cached = this._staticTrees || (this._staticTrees = []);
  44378. var tree = cached[index];
  44379. // if has already-rendered static tree and not inside v-for,
  44380. // we can reuse the same tree.
  44381. if (tree && !isInFor) {
  44382. return tree
  44383. }
  44384. // otherwise, render a fresh tree.
  44385. tree = cached[index] = this.$options.staticRenderFns[index].call(
  44386. this._renderProxy,
  44387. null,
  44388. this // for render fns generated for functional component templates
  44389. );
  44390. markStatic(tree, ("__static__" + index), false);
  44391. return tree
  44392. }
  44393. /**
  44394. * Runtime helper for v-once.
  44395. * Effectively it means marking the node as static with a unique key.
  44396. */
  44397. function markOnce (
  44398. tree,
  44399. index,
  44400. key
  44401. ) {
  44402. markStatic(tree, ("__once__" + index + (key ? ("_" + key) : "")), true);
  44403. return tree
  44404. }
  44405. function markStatic (
  44406. tree,
  44407. key,
  44408. isOnce
  44409. ) {
  44410. if (Array.isArray(tree)) {
  44411. for (var i = 0; i < tree.length; i++) {
  44412. if (tree[i] && typeof tree[i] !== 'string') {
  44413. markStaticNode(tree[i], (key + "_" + i), isOnce);
  44414. }
  44415. }
  44416. } else {
  44417. markStaticNode(tree, key, isOnce);
  44418. }
  44419. }
  44420. function markStaticNode (node, key, isOnce) {
  44421. node.isStatic = true;
  44422. node.key = key;
  44423. node.isOnce = isOnce;
  44424. }
  44425. /* */
  44426. function bindObjectListeners (data, value) {
  44427. if (value) {
  44428. if (!isPlainObject(value)) {
  44429. warn(
  44430. 'v-on without argument expects an Object value',
  44431. this
  44432. );
  44433. } else {
  44434. var on = data.on = data.on ? extend({}, data.on) : {};
  44435. for (var key in value) {
  44436. var existing = on[key];
  44437. var ours = value[key];
  44438. on[key] = existing ? [].concat(existing, ours) : ours;
  44439. }
  44440. }
  44441. }
  44442. return data
  44443. }
  44444. /* */
  44445. function resolveScopedSlots (
  44446. fns, // see flow/vnode
  44447. res,
  44448. // the following are added in 2.6
  44449. hasDynamicKeys,
  44450. contentHashKey
  44451. ) {
  44452. res = res || { $stable: !hasDynamicKeys };
  44453. for (var i = 0; i < fns.length; i++) {
  44454. var slot = fns[i];
  44455. if (Array.isArray(slot)) {
  44456. resolveScopedSlots(slot, res, hasDynamicKeys);
  44457. } else if (slot) {
  44458. // marker for reverse proxying v-slot without scope on this.$slots
  44459. if (slot.proxy) {
  44460. slot.fn.proxy = true;
  44461. }
  44462. res[slot.key] = slot.fn;
  44463. }
  44464. }
  44465. if (contentHashKey) {
  44466. (res).$key = contentHashKey;
  44467. }
  44468. return res
  44469. }
  44470. /* */
  44471. function bindDynamicKeys (baseObj, values) {
  44472. for (var i = 0; i < values.length; i += 2) {
  44473. var key = values[i];
  44474. if (typeof key === 'string' && key) {
  44475. baseObj[values[i]] = values[i + 1];
  44476. } else if (key !== '' && key !== null) {
  44477. // null is a special value for explicitly removing a binding
  44478. warn(
  44479. ("Invalid value for dynamic directive argument (expected string or null): " + key),
  44480. this
  44481. );
  44482. }
  44483. }
  44484. return baseObj
  44485. }
  44486. // helper to dynamically append modifier runtime markers to event names.
  44487. // ensure only append when value is already string, otherwise it will be cast
  44488. // to string and cause the type check to miss.
  44489. function prependModifier (value, symbol) {
  44490. return typeof value === 'string' ? symbol + value : value
  44491. }
  44492. /* */
  44493. function installRenderHelpers (target) {
  44494. target._o = markOnce;
  44495. target._n = toNumber;
  44496. target._s = toString;
  44497. target._l = renderList;
  44498. target._t = renderSlot;
  44499. target._q = looseEqual;
  44500. target._i = looseIndexOf;
  44501. target._m = renderStatic;
  44502. target._f = resolveFilter;
  44503. target._k = checkKeyCodes;
  44504. target._b = bindObjectProps;
  44505. target._v = createTextVNode;
  44506. target._e = createEmptyVNode;
  44507. target._u = resolveScopedSlots;
  44508. target._g = bindObjectListeners;
  44509. target._d = bindDynamicKeys;
  44510. target._p = prependModifier;
  44511. }
  44512. /* */
  44513. function FunctionalRenderContext (
  44514. data,
  44515. props,
  44516. children,
  44517. parent,
  44518. Ctor
  44519. ) {
  44520. var this$1 = this;
  44521. var options = Ctor.options;
  44522. // ensure the createElement function in functional components
  44523. // gets a unique context - this is necessary for correct named slot check
  44524. var contextVm;
  44525. if (hasOwn(parent, '_uid')) {
  44526. contextVm = Object.create(parent);
  44527. // $flow-disable-line
  44528. contextVm._original = parent;
  44529. } else {
  44530. // the context vm passed in is a functional context as well.
  44531. // in this case we want to make sure we are able to get a hold to the
  44532. // real context instance.
  44533. contextVm = parent;
  44534. // $flow-disable-line
  44535. parent = parent._original;
  44536. }
  44537. var isCompiled = isTrue(options._compiled);
  44538. var needNormalization = !isCompiled;
  44539. this.data = data;
  44540. this.props = props;
  44541. this.children = children;
  44542. this.parent = parent;
  44543. this.listeners = data.on || emptyObject;
  44544. this.injections = resolveInject(options.inject, parent);
  44545. this.slots = function () {
  44546. if (!this$1.$slots) {
  44547. normalizeScopedSlots(
  44548. data.scopedSlots,
  44549. this$1.$slots = resolveSlots(children, parent)
  44550. );
  44551. }
  44552. return this$1.$slots
  44553. };
  44554. Object.defineProperty(this, 'scopedSlots', ({
  44555. enumerable: true,
  44556. get: function get () {
  44557. return normalizeScopedSlots(data.scopedSlots, this.slots())
  44558. }
  44559. }));
  44560. // support for compiled functional template
  44561. if (isCompiled) {
  44562. // exposing $options for renderStatic()
  44563. this.$options = options;
  44564. // pre-resolve slots for renderSlot()
  44565. this.$slots = this.slots();
  44566. this.$scopedSlots = normalizeScopedSlots(data.scopedSlots, this.$slots);
  44567. }
  44568. if (options._scopeId) {
  44569. this._c = function (a, b, c, d) {
  44570. var vnode = createElement(contextVm, a, b, c, d, needNormalization);
  44571. if (vnode && !Array.isArray(vnode)) {
  44572. vnode.fnScopeId = options._scopeId;
  44573. vnode.fnContext = parent;
  44574. }
  44575. return vnode
  44576. };
  44577. } else {
  44578. this._c = function (a, b, c, d) { return createElement(contextVm, a, b, c, d, needNormalization); };
  44579. }
  44580. }
  44581. installRenderHelpers(FunctionalRenderContext.prototype);
  44582. function createFunctionalComponent (
  44583. Ctor,
  44584. propsData,
  44585. data,
  44586. contextVm,
  44587. children
  44588. ) {
  44589. var options = Ctor.options;
  44590. var props = {};
  44591. var propOptions = options.props;
  44592. if (isDef(propOptions)) {
  44593. for (var key in propOptions) {
  44594. props[key] = validateProp(key, propOptions, propsData || emptyObject);
  44595. }
  44596. } else {
  44597. if (isDef(data.attrs)) { mergeProps(props, data.attrs); }
  44598. if (isDef(data.props)) { mergeProps(props, data.props); }
  44599. }
  44600. var renderContext = new FunctionalRenderContext(
  44601. data,
  44602. props,
  44603. children,
  44604. contextVm,
  44605. Ctor
  44606. );
  44607. var vnode = options.render.call(null, renderContext._c, renderContext);
  44608. if (vnode instanceof VNode) {
  44609. return cloneAndMarkFunctionalResult(vnode, data, renderContext.parent, options, renderContext)
  44610. } else if (Array.isArray(vnode)) {
  44611. var vnodes = normalizeChildren(vnode) || [];
  44612. var res = new Array(vnodes.length);
  44613. for (var i = 0; i < vnodes.length; i++) {
  44614. res[i] = cloneAndMarkFunctionalResult(vnodes[i], data, renderContext.parent, options, renderContext);
  44615. }
  44616. return res
  44617. }
  44618. }
  44619. function cloneAndMarkFunctionalResult (vnode, data, contextVm, options, renderContext) {
  44620. // #7817 clone node before setting fnContext, otherwise if the node is reused
  44621. // (e.g. it was from a cached normal slot) the fnContext causes named slots
  44622. // that should not be matched to match.
  44623. var clone = cloneVNode(vnode);
  44624. clone.fnContext = contextVm;
  44625. clone.fnOptions = options;
  44626. {
  44627. (clone.devtoolsMeta = clone.devtoolsMeta || {}).renderContext = renderContext;
  44628. }
  44629. if (data.slot) {
  44630. (clone.data || (clone.data = {})).slot = data.slot;
  44631. }
  44632. return clone
  44633. }
  44634. function mergeProps (to, from) {
  44635. for (var key in from) {
  44636. to[camelize(key)] = from[key];
  44637. }
  44638. }
  44639. /* */
  44640. /* */
  44641. /* */
  44642. /* */
  44643. // inline hooks to be invoked on component VNodes during patch
  44644. var componentVNodeHooks = {
  44645. init: function init (vnode, hydrating) {
  44646. if (
  44647. vnode.componentInstance &&
  44648. !vnode.componentInstance._isDestroyed &&
  44649. vnode.data.keepAlive
  44650. ) {
  44651. // kept-alive components, treat as a patch
  44652. var mountedNode = vnode; // work around flow
  44653. componentVNodeHooks.prepatch(mountedNode, mountedNode);
  44654. } else {
  44655. var child = vnode.componentInstance = createComponentInstanceForVnode(
  44656. vnode,
  44657. activeInstance
  44658. );
  44659. child.$mount(hydrating ? vnode.elm : undefined, hydrating);
  44660. }
  44661. },
  44662. prepatch: function prepatch (oldVnode, vnode) {
  44663. var options = vnode.componentOptions;
  44664. var child = vnode.componentInstance = oldVnode.componentInstance;
  44665. updateChildComponent(
  44666. child,
  44667. options.propsData, // updated props
  44668. options.listeners, // updated listeners
  44669. vnode, // new parent vnode
  44670. options.children // new children
  44671. );
  44672. },
  44673. insert: function insert (vnode) {
  44674. var context = vnode.context;
  44675. var componentInstance = vnode.componentInstance;
  44676. if (!componentInstance._isMounted) {
  44677. componentInstance._isMounted = true;
  44678. callHook(componentInstance, 'mounted');
  44679. }
  44680. if (vnode.data.keepAlive) {
  44681. if (context._isMounted) {
  44682. // vue-router#1212
  44683. // During updates, a kept-alive component's child components may
  44684. // change, so directly walking the tree here may call activated hooks
  44685. // on incorrect children. Instead we push them into a queue which will
  44686. // be processed after the whole patch process ended.
  44687. queueActivatedComponent(componentInstance);
  44688. } else {
  44689. activateChildComponent(componentInstance, true /* direct */);
  44690. }
  44691. }
  44692. },
  44693. destroy: function destroy (vnode) {
  44694. var componentInstance = vnode.componentInstance;
  44695. if (!componentInstance._isDestroyed) {
  44696. if (!vnode.data.keepAlive) {
  44697. componentInstance.$destroy();
  44698. } else {
  44699. deactivateChildComponent(componentInstance, true /* direct */);
  44700. }
  44701. }
  44702. }
  44703. };
  44704. var hooksToMerge = Object.keys(componentVNodeHooks);
  44705. function createComponent (
  44706. Ctor,
  44707. data,
  44708. context,
  44709. children,
  44710. tag
  44711. ) {
  44712. if (isUndef(Ctor)) {
  44713. return
  44714. }
  44715. var baseCtor = context.$options._base;
  44716. // plain options object: turn it into a constructor
  44717. if (isObject(Ctor)) {
  44718. Ctor = baseCtor.extend(Ctor);
  44719. }
  44720. // if at this stage it's not a constructor or an async component factory,
  44721. // reject.
  44722. if (typeof Ctor !== 'function') {
  44723. {
  44724. warn(("Invalid Component definition: " + (String(Ctor))), context);
  44725. }
  44726. return
  44727. }
  44728. // async component
  44729. var asyncFactory;
  44730. if (isUndef(Ctor.cid)) {
  44731. asyncFactory = Ctor;
  44732. Ctor = resolveAsyncComponent(asyncFactory, baseCtor);
  44733. if (Ctor === undefined) {
  44734. // return a placeholder node for async component, which is rendered
  44735. // as a comment node but preserves all the raw information for the node.
  44736. // the information will be used for async server-rendering and hydration.
  44737. return createAsyncPlaceholder(
  44738. asyncFactory,
  44739. data,
  44740. context,
  44741. children,
  44742. tag
  44743. )
  44744. }
  44745. }
  44746. data = data || {};
  44747. // resolve constructor options in case global mixins are applied after
  44748. // component constructor creation
  44749. resolveConstructorOptions(Ctor);
  44750. // transform component v-model data into props & events
  44751. if (isDef(data.model)) {
  44752. transformModel(Ctor.options, data);
  44753. }
  44754. // extract props
  44755. var propsData = extractPropsFromVNodeData(data, Ctor, tag);
  44756. // functional component
  44757. if (isTrue(Ctor.options.functional)) {
  44758. return createFunctionalComponent(Ctor, propsData, data, context, children)
  44759. }
  44760. // extract listeners, since these needs to be treated as
  44761. // child component listeners instead of DOM listeners
  44762. var listeners = data.on;
  44763. // replace with listeners with .native modifier
  44764. // so it gets processed during parent component patch.
  44765. data.on = data.nativeOn;
  44766. if (isTrue(Ctor.options.abstract)) {
  44767. // abstract components do not keep anything
  44768. // other than props & listeners & slot
  44769. // work around flow
  44770. var slot = data.slot;
  44771. data = {};
  44772. if (slot) {
  44773. data.slot = slot;
  44774. }
  44775. }
  44776. // install component management hooks onto the placeholder node
  44777. installComponentHooks(data);
  44778. // return a placeholder vnode
  44779. var name = Ctor.options.name || tag;
  44780. var vnode = new VNode(
  44781. ("vue-component-" + (Ctor.cid) + (name ? ("-" + name) : '')),
  44782. data, undefined, undefined, undefined, context,
  44783. { Ctor: Ctor, propsData: propsData, listeners: listeners, tag: tag, children: children },
  44784. asyncFactory
  44785. );
  44786. return vnode
  44787. }
  44788. function createComponentInstanceForVnode (
  44789. vnode, // we know it's MountedComponentVNode but flow doesn't
  44790. parent // activeInstance in lifecycle state
  44791. ) {
  44792. var options = {
  44793. _isComponent: true,
  44794. _parentVnode: vnode,
  44795. parent: parent
  44796. };
  44797. // check inline-template render functions
  44798. var inlineTemplate = vnode.data.inlineTemplate;
  44799. if (isDef(inlineTemplate)) {
  44800. options.render = inlineTemplate.render;
  44801. options.staticRenderFns = inlineTemplate.staticRenderFns;
  44802. }
  44803. return new vnode.componentOptions.Ctor(options)
  44804. }
  44805. function installComponentHooks (data) {
  44806. var hooks = data.hook || (data.hook = {});
  44807. for (var i = 0; i < hooksToMerge.length; i++) {
  44808. var key = hooksToMerge[i];
  44809. var existing = hooks[key];
  44810. var toMerge = componentVNodeHooks[key];
  44811. if (existing !== toMerge && !(existing && existing._merged)) {
  44812. hooks[key] = existing ? mergeHook$1(toMerge, existing) : toMerge;
  44813. }
  44814. }
  44815. }
  44816. function mergeHook$1 (f1, f2) {
  44817. var merged = function (a, b) {
  44818. // flow complains about extra args which is why we use any
  44819. f1(a, b);
  44820. f2(a, b);
  44821. };
  44822. merged._merged = true;
  44823. return merged
  44824. }
  44825. // transform component v-model info (value and callback) into
  44826. // prop and event handler respectively.
  44827. function transformModel (options, data) {
  44828. var prop = (options.model && options.model.prop) || 'value';
  44829. var event = (options.model && options.model.event) || 'input'
  44830. ;(data.attrs || (data.attrs = {}))[prop] = data.model.value;
  44831. var on = data.on || (data.on = {});
  44832. var existing = on[event];
  44833. var callback = data.model.callback;
  44834. if (isDef(existing)) {
  44835. if (
  44836. Array.isArray(existing)
  44837. ? existing.indexOf(callback) === -1
  44838. : existing !== callback
  44839. ) {
  44840. on[event] = [callback].concat(existing);
  44841. }
  44842. } else {
  44843. on[event] = callback;
  44844. }
  44845. }
  44846. /* */
  44847. var SIMPLE_NORMALIZE = 1;
  44848. var ALWAYS_NORMALIZE = 2;
  44849. // wrapper function for providing a more flexible interface
  44850. // without getting yelled at by flow
  44851. function createElement (
  44852. context,
  44853. tag,
  44854. data,
  44855. children,
  44856. normalizationType,
  44857. alwaysNormalize
  44858. ) {
  44859. if (Array.isArray(data) || isPrimitive(data)) {
  44860. normalizationType = children;
  44861. children = data;
  44862. data = undefined;
  44863. }
  44864. if (isTrue(alwaysNormalize)) {
  44865. normalizationType = ALWAYS_NORMALIZE;
  44866. }
  44867. return _createElement(context, tag, data, children, normalizationType)
  44868. }
  44869. function _createElement (
  44870. context,
  44871. tag,
  44872. data,
  44873. children,
  44874. normalizationType
  44875. ) {
  44876. if (isDef(data) && isDef((data).__ob__)) {
  44877. warn(
  44878. "Avoid using observed data object as vnode data: " + (JSON.stringify(data)) + "\n" +
  44879. 'Always create fresh vnode data objects in each render!',
  44880. context
  44881. );
  44882. return createEmptyVNode()
  44883. }
  44884. // object syntax in v-bind
  44885. if (isDef(data) && isDef(data.is)) {
  44886. tag = data.is;
  44887. }
  44888. if (!tag) {
  44889. // in case of component :is set to falsy value
  44890. return createEmptyVNode()
  44891. }
  44892. // warn against non-primitive key
  44893. if (isDef(data) && isDef(data.key) && !isPrimitive(data.key)
  44894. ) {
  44895. {
  44896. warn(
  44897. 'Avoid using non-primitive value as key, ' +
  44898. 'use string/number value instead.',
  44899. context
  44900. );
  44901. }
  44902. }
  44903. // support single function children as default scoped slot
  44904. if (Array.isArray(children) &&
  44905. typeof children[0] === 'function'
  44906. ) {
  44907. data = data || {};
  44908. data.scopedSlots = { default: children[0] };
  44909. children.length = 0;
  44910. }
  44911. if (normalizationType === ALWAYS_NORMALIZE) {
  44912. children = normalizeChildren(children);
  44913. } else if (normalizationType === SIMPLE_NORMALIZE) {
  44914. children = simpleNormalizeChildren(children);
  44915. }
  44916. var vnode, ns;
  44917. if (typeof tag === 'string') {
  44918. var Ctor;
  44919. ns = (context.$vnode && context.$vnode.ns) || config.getTagNamespace(tag);
  44920. if (config.isReservedTag(tag)) {
  44921. // platform built-in elements
  44922. if (isDef(data) && isDef(data.nativeOn)) {
  44923. warn(
  44924. ("The .native modifier for v-on is only valid on components but it was used on <" + tag + ">."),
  44925. context
  44926. );
  44927. }
  44928. vnode = new VNode(
  44929. config.parsePlatformTagName(tag), data, children,
  44930. undefined, undefined, context
  44931. );
  44932. } else if ((!data || !data.pre) && isDef(Ctor = resolveAsset(context.$options, 'components', tag))) {
  44933. // component
  44934. vnode = createComponent(Ctor, data, context, children, tag);
  44935. } else {
  44936. // unknown or unlisted namespaced elements
  44937. // check at runtime because it may get assigned a namespace when its
  44938. // parent normalizes children
  44939. vnode = new VNode(
  44940. tag, data, children,
  44941. undefined, undefined, context
  44942. );
  44943. }
  44944. } else {
  44945. // direct component options / constructor
  44946. vnode = createComponent(tag, data, context, children);
  44947. }
  44948. if (Array.isArray(vnode)) {
  44949. return vnode
  44950. } else if (isDef(vnode)) {
  44951. if (isDef(ns)) { applyNS(vnode, ns); }
  44952. if (isDef(data)) { registerDeepBindings(data); }
  44953. return vnode
  44954. } else {
  44955. return createEmptyVNode()
  44956. }
  44957. }
  44958. function applyNS (vnode, ns, force) {
  44959. vnode.ns = ns;
  44960. if (vnode.tag === 'foreignObject') {
  44961. // use default namespace inside foreignObject
  44962. ns = undefined;
  44963. force = true;
  44964. }
  44965. if (isDef(vnode.children)) {
  44966. for (var i = 0, l = vnode.children.length; i < l; i++) {
  44967. var child = vnode.children[i];
  44968. if (isDef(child.tag) && (
  44969. isUndef(child.ns) || (isTrue(force) && child.tag !== 'svg'))) {
  44970. applyNS(child, ns, force);
  44971. }
  44972. }
  44973. }
  44974. }
  44975. // ref #5318
  44976. // necessary to ensure parent re-render when deep bindings like :style and
  44977. // :class are used on slot nodes
  44978. function registerDeepBindings (data) {
  44979. if (isObject(data.style)) {
  44980. traverse(data.style);
  44981. }
  44982. if (isObject(data.class)) {
  44983. traverse(data.class);
  44984. }
  44985. }
  44986. /* */
  44987. function initRender (vm) {
  44988. vm._vnode = null; // the root of the child tree
  44989. vm._staticTrees = null; // v-once cached trees
  44990. var options = vm.$options;
  44991. var parentVnode = vm.$vnode = options._parentVnode; // the placeholder node in parent tree
  44992. var renderContext = parentVnode && parentVnode.context;
  44993. vm.$slots = resolveSlots(options._renderChildren, renderContext);
  44994. vm.$scopedSlots = emptyObject;
  44995. // bind the createElement fn to this instance
  44996. // so that we get proper render context inside it.
  44997. // args order: tag, data, children, normalizationType, alwaysNormalize
  44998. // internal version is used by render functions compiled from templates
  44999. vm._c = function (a, b, c, d) { return createElement(vm, a, b, c, d, false); };
  45000. // normalization is always applied for the public version, used in
  45001. // user-written render functions.
  45002. vm.$createElement = function (a, b, c, d) { return createElement(vm, a, b, c, d, true); };
  45003. // $attrs & $listeners are exposed for easier HOC creation.
  45004. // they need to be reactive so that HOCs using them are always updated
  45005. var parentData = parentVnode && parentVnode.data;
  45006. /* istanbul ignore else */
  45007. {
  45008. defineReactive$$1(vm, '$attrs', parentData && parentData.attrs || emptyObject, function () {
  45009. !isUpdatingChildComponent && warn("$attrs is readonly.", vm);
  45010. }, true);
  45011. defineReactive$$1(vm, '$listeners', options._parentListeners || emptyObject, function () {
  45012. !isUpdatingChildComponent && warn("$listeners is readonly.", vm);
  45013. }, true);
  45014. }
  45015. }
  45016. var currentRenderingInstance = null;
  45017. function renderMixin (Vue) {
  45018. // install runtime convenience helpers
  45019. installRenderHelpers(Vue.prototype);
  45020. Vue.prototype.$nextTick = function (fn) {
  45021. return nextTick(fn, this)
  45022. };
  45023. Vue.prototype._render = function () {
  45024. var vm = this;
  45025. var ref = vm.$options;
  45026. var render = ref.render;
  45027. var _parentVnode = ref._parentVnode;
  45028. if (_parentVnode) {
  45029. vm.$scopedSlots = normalizeScopedSlots(
  45030. _parentVnode.data.scopedSlots,
  45031. vm.$slots,
  45032. vm.$scopedSlots
  45033. );
  45034. }
  45035. // set parent vnode. this allows render functions to have access
  45036. // to the data on the placeholder node.
  45037. vm.$vnode = _parentVnode;
  45038. // render self
  45039. var vnode;
  45040. try {
  45041. // There's no need to maintain a stack because all render fns are called
  45042. // separately from one another. Nested component's render fns are called
  45043. // when parent component is patched.
  45044. currentRenderingInstance = vm;
  45045. vnode = render.call(vm._renderProxy, vm.$createElement);
  45046. } catch (e) {
  45047. handleError(e, vm, "render");
  45048. // return error render result,
  45049. // or previous vnode to prevent render error causing blank component
  45050. /* istanbul ignore else */
  45051. if (vm.$options.renderError) {
  45052. try {
  45053. vnode = vm.$options.renderError.call(vm._renderProxy, vm.$createElement, e);
  45054. } catch (e) {
  45055. handleError(e, vm, "renderError");
  45056. vnode = vm._vnode;
  45057. }
  45058. } else {
  45059. vnode = vm._vnode;
  45060. }
  45061. } finally {
  45062. currentRenderingInstance = null;
  45063. }
  45064. // if the returned array contains only a single node, allow it
  45065. if (Array.isArray(vnode) && vnode.length === 1) {
  45066. vnode = vnode[0];
  45067. }
  45068. // return empty vnode in case the render function errored out
  45069. if (!(vnode instanceof VNode)) {
  45070. if (Array.isArray(vnode)) {
  45071. warn(
  45072. 'Multiple root nodes returned from render function. Render function ' +
  45073. 'should return a single root node.',
  45074. vm
  45075. );
  45076. }
  45077. vnode = createEmptyVNode();
  45078. }
  45079. // set parent
  45080. vnode.parent = _parentVnode;
  45081. return vnode
  45082. };
  45083. }
  45084. /* */
  45085. function ensureCtor (comp, base) {
  45086. if (
  45087. comp.__esModule ||
  45088. (hasSymbol && comp[Symbol.toStringTag] === 'Module')
  45089. ) {
  45090. comp = comp.default;
  45091. }
  45092. return isObject(comp)
  45093. ? base.extend(comp)
  45094. : comp
  45095. }
  45096. function createAsyncPlaceholder (
  45097. factory,
  45098. data,
  45099. context,
  45100. children,
  45101. tag
  45102. ) {
  45103. var node = createEmptyVNode();
  45104. node.asyncFactory = factory;
  45105. node.asyncMeta = { data: data, context: context, children: children, tag: tag };
  45106. return node
  45107. }
  45108. function resolveAsyncComponent (
  45109. factory,
  45110. baseCtor
  45111. ) {
  45112. if (isTrue(factory.error) && isDef(factory.errorComp)) {
  45113. return factory.errorComp
  45114. }
  45115. if (isDef(factory.resolved)) {
  45116. return factory.resolved
  45117. }
  45118. var owner = currentRenderingInstance;
  45119. if (owner && isDef(factory.owners) && factory.owners.indexOf(owner) === -1) {
  45120. // already pending
  45121. factory.owners.push(owner);
  45122. }
  45123. if (isTrue(factory.loading) && isDef(factory.loadingComp)) {
  45124. return factory.loadingComp
  45125. }
  45126. if (owner && !isDef(factory.owners)) {
  45127. var owners = factory.owners = [owner];
  45128. var sync = true;
  45129. var timerLoading = null;
  45130. var timerTimeout = null
  45131. ;(owner).$on('hook:destroyed', function () { return remove(owners, owner); });
  45132. var forceRender = function (renderCompleted) {
  45133. for (var i = 0, l = owners.length; i < l; i++) {
  45134. (owners[i]).$forceUpdate();
  45135. }
  45136. if (renderCompleted) {
  45137. owners.length = 0;
  45138. if (timerLoading !== null) {
  45139. clearTimeout(timerLoading);
  45140. timerLoading = null;
  45141. }
  45142. if (timerTimeout !== null) {
  45143. clearTimeout(timerTimeout);
  45144. timerTimeout = null;
  45145. }
  45146. }
  45147. };
  45148. var resolve = once(function (res) {
  45149. // cache resolved
  45150. factory.resolved = ensureCtor(res, baseCtor);
  45151. // invoke callbacks only if this is not a synchronous resolve
  45152. // (async resolves are shimmed as synchronous during SSR)
  45153. if (!sync) {
  45154. forceRender(true);
  45155. } else {
  45156. owners.length = 0;
  45157. }
  45158. });
  45159. var reject = once(function (reason) {
  45160. warn(
  45161. "Failed to resolve async component: " + (String(factory)) +
  45162. (reason ? ("\nReason: " + reason) : '')
  45163. );
  45164. if (isDef(factory.errorComp)) {
  45165. factory.error = true;
  45166. forceRender(true);
  45167. }
  45168. });
  45169. var res = factory(resolve, reject);
  45170. if (isObject(res)) {
  45171. if (isPromise(res)) {
  45172. // () => Promise
  45173. if (isUndef(factory.resolved)) {
  45174. res.then(resolve, reject);
  45175. }
  45176. } else if (isPromise(res.component)) {
  45177. res.component.then(resolve, reject);
  45178. if (isDef(res.error)) {
  45179. factory.errorComp = ensureCtor(res.error, baseCtor);
  45180. }
  45181. if (isDef(res.loading)) {
  45182. factory.loadingComp = ensureCtor(res.loading, baseCtor);
  45183. if (res.delay === 0) {
  45184. factory.loading = true;
  45185. } else {
  45186. timerLoading = setTimeout(function () {
  45187. timerLoading = null;
  45188. if (isUndef(factory.resolved) && isUndef(factory.error)) {
  45189. factory.loading = true;
  45190. forceRender(false);
  45191. }
  45192. }, res.delay || 200);
  45193. }
  45194. }
  45195. if (isDef(res.timeout)) {
  45196. timerTimeout = setTimeout(function () {
  45197. timerTimeout = null;
  45198. if (isUndef(factory.resolved)) {
  45199. reject(
  45200. "timeout (" + (res.timeout) + "ms)"
  45201. );
  45202. }
  45203. }, res.timeout);
  45204. }
  45205. }
  45206. }
  45207. sync = false;
  45208. // return in case resolved synchronously
  45209. return factory.loading
  45210. ? factory.loadingComp
  45211. : factory.resolved
  45212. }
  45213. }
  45214. /* */
  45215. function isAsyncPlaceholder (node) {
  45216. return node.isComment && node.asyncFactory
  45217. }
  45218. /* */
  45219. function getFirstComponentChild (children) {
  45220. if (Array.isArray(children)) {
  45221. for (var i = 0; i < children.length; i++) {
  45222. var c = children[i];
  45223. if (isDef(c) && (isDef(c.componentOptions) || isAsyncPlaceholder(c))) {
  45224. return c
  45225. }
  45226. }
  45227. }
  45228. }
  45229. /* */
  45230. /* */
  45231. function initEvents (vm) {
  45232. vm._events = Object.create(null);
  45233. vm._hasHookEvent = false;
  45234. // init parent attached events
  45235. var listeners = vm.$options._parentListeners;
  45236. if (listeners) {
  45237. updateComponentListeners(vm, listeners);
  45238. }
  45239. }
  45240. var target;
  45241. function add (event, fn) {
  45242. target.$on(event, fn);
  45243. }
  45244. function remove$1 (event, fn) {
  45245. target.$off(event, fn);
  45246. }
  45247. function createOnceHandler (event, fn) {
  45248. var _target = target;
  45249. return function onceHandler () {
  45250. var res = fn.apply(null, arguments);
  45251. if (res !== null) {
  45252. _target.$off(event, onceHandler);
  45253. }
  45254. }
  45255. }
  45256. function updateComponentListeners (
  45257. vm,
  45258. listeners,
  45259. oldListeners
  45260. ) {
  45261. target = vm;
  45262. updateListeners(listeners, oldListeners || {}, add, remove$1, createOnceHandler, vm);
  45263. target = undefined;
  45264. }
  45265. function eventsMixin (Vue) {
  45266. var hookRE = /^hook:/;
  45267. Vue.prototype.$on = function (event, fn) {
  45268. var vm = this;
  45269. if (Array.isArray(event)) {
  45270. for (var i = 0, l = event.length; i < l; i++) {
  45271. vm.$on(event[i], fn);
  45272. }
  45273. } else {
  45274. (vm._events[event] || (vm._events[event] = [])).push(fn);
  45275. // optimize hook:event cost by using a boolean flag marked at registration
  45276. // instead of a hash lookup
  45277. if (hookRE.test(event)) {
  45278. vm._hasHookEvent = true;
  45279. }
  45280. }
  45281. return vm
  45282. };
  45283. Vue.prototype.$once = function (event, fn) {
  45284. var vm = this;
  45285. function on () {
  45286. vm.$off(event, on);
  45287. fn.apply(vm, arguments);
  45288. }
  45289. on.fn = fn;
  45290. vm.$on(event, on);
  45291. return vm
  45292. };
  45293. Vue.prototype.$off = function (event, fn) {
  45294. var vm = this;
  45295. // all
  45296. if (!arguments.length) {
  45297. vm._events = Object.create(null);
  45298. return vm
  45299. }
  45300. // array of events
  45301. if (Array.isArray(event)) {
  45302. for (var i$1 = 0, l = event.length; i$1 < l; i$1++) {
  45303. vm.$off(event[i$1], fn);
  45304. }
  45305. return vm
  45306. }
  45307. // specific event
  45308. var cbs = vm._events[event];
  45309. if (!cbs) {
  45310. return vm
  45311. }
  45312. if (!fn) {
  45313. vm._events[event] = null;
  45314. return vm
  45315. }
  45316. // specific handler
  45317. var cb;
  45318. var i = cbs.length;
  45319. while (i--) {
  45320. cb = cbs[i];
  45321. if (cb === fn || cb.fn === fn) {
  45322. cbs.splice(i, 1);
  45323. break
  45324. }
  45325. }
  45326. return vm
  45327. };
  45328. Vue.prototype.$emit = function (event) {
  45329. var vm = this;
  45330. {
  45331. var lowerCaseEvent = event.toLowerCase();
  45332. if (lowerCaseEvent !== event && vm._events[lowerCaseEvent]) {
  45333. tip(
  45334. "Event \"" + lowerCaseEvent + "\" is emitted in component " +
  45335. (formatComponentName(vm)) + " but the handler is registered for \"" + event + "\". " +
  45336. "Note that HTML attributes are case-insensitive and you cannot use " +
  45337. "v-on to listen to camelCase events when using in-DOM templates. " +
  45338. "You should probably use \"" + (hyphenate(event)) + "\" instead of \"" + event + "\"."
  45339. );
  45340. }
  45341. }
  45342. var cbs = vm._events[event];
  45343. if (cbs) {
  45344. cbs = cbs.length > 1 ? toArray(cbs) : cbs;
  45345. var args = toArray(arguments, 1);
  45346. var info = "event handler for \"" + event + "\"";
  45347. for (var i = 0, l = cbs.length; i < l; i++) {
  45348. invokeWithErrorHandling(cbs[i], vm, args, vm, info);
  45349. }
  45350. }
  45351. return vm
  45352. };
  45353. }
  45354. /* */
  45355. var activeInstance = null;
  45356. var isUpdatingChildComponent = false;
  45357. function setActiveInstance(vm) {
  45358. var prevActiveInstance = activeInstance;
  45359. activeInstance = vm;
  45360. return function () {
  45361. activeInstance = prevActiveInstance;
  45362. }
  45363. }
  45364. function initLifecycle (vm) {
  45365. var options = vm.$options;
  45366. // locate first non-abstract parent
  45367. var parent = options.parent;
  45368. if (parent && !options.abstract) {
  45369. while (parent.$options.abstract && parent.$parent) {
  45370. parent = parent.$parent;
  45371. }
  45372. parent.$children.push(vm);
  45373. }
  45374. vm.$parent = parent;
  45375. vm.$root = parent ? parent.$root : vm;
  45376. vm.$children = [];
  45377. vm.$refs = {};
  45378. vm._watcher = null;
  45379. vm._inactive = null;
  45380. vm._directInactive = false;
  45381. vm._isMounted = false;
  45382. vm._isDestroyed = false;
  45383. vm._isBeingDestroyed = false;
  45384. }
  45385. function lifecycleMixin (Vue) {
  45386. Vue.prototype._update = function (vnode, hydrating) {
  45387. var vm = this;
  45388. var prevEl = vm.$el;
  45389. var prevVnode = vm._vnode;
  45390. var restoreActiveInstance = setActiveInstance(vm);
  45391. vm._vnode = vnode;
  45392. // Vue.prototype.__patch__ is injected in entry points
  45393. // based on the rendering backend used.
  45394. if (!prevVnode) {
  45395. // initial render
  45396. vm.$el = vm.__patch__(vm.$el, vnode, hydrating, false /* removeOnly */);
  45397. } else {
  45398. // updates
  45399. vm.$el = vm.__patch__(prevVnode, vnode);
  45400. }
  45401. restoreActiveInstance();
  45402. // update __vue__ reference
  45403. if (prevEl) {
  45404. prevEl.__vue__ = null;
  45405. }
  45406. if (vm.$el) {
  45407. vm.$el.__vue__ = vm;
  45408. }
  45409. // if parent is an HOC, update its $el as well
  45410. if (vm.$vnode && vm.$parent && vm.$vnode === vm.$parent._vnode) {
  45411. vm.$parent.$el = vm.$el;
  45412. }
  45413. // updated hook is called by the scheduler to ensure that children are
  45414. // updated in a parent's updated hook.
  45415. };
  45416. Vue.prototype.$forceUpdate = function () {
  45417. var vm = this;
  45418. if (vm._watcher) {
  45419. vm._watcher.update();
  45420. }
  45421. };
  45422. Vue.prototype.$destroy = function () {
  45423. var vm = this;
  45424. if (vm._isBeingDestroyed) {
  45425. return
  45426. }
  45427. callHook(vm, 'beforeDestroy');
  45428. vm._isBeingDestroyed = true;
  45429. // remove self from parent
  45430. var parent = vm.$parent;
  45431. if (parent && !parent._isBeingDestroyed && !vm.$options.abstract) {
  45432. remove(parent.$children, vm);
  45433. }
  45434. // teardown watchers
  45435. if (vm._watcher) {
  45436. vm._watcher.teardown();
  45437. }
  45438. var i = vm._watchers.length;
  45439. while (i--) {
  45440. vm._watchers[i].teardown();
  45441. }
  45442. // remove reference from data ob
  45443. // frozen object may not have observer.
  45444. if (vm._data.__ob__) {
  45445. vm._data.__ob__.vmCount--;
  45446. }
  45447. // call the last hook...
  45448. vm._isDestroyed = true;
  45449. // invoke destroy hooks on current rendered tree
  45450. vm.__patch__(vm._vnode, null);
  45451. // fire destroyed hook
  45452. callHook(vm, 'destroyed');
  45453. // turn off all instance listeners.
  45454. vm.$off();
  45455. // remove __vue__ reference
  45456. if (vm.$el) {
  45457. vm.$el.__vue__ = null;
  45458. }
  45459. // release circular reference (#6759)
  45460. if (vm.$vnode) {
  45461. vm.$vnode.parent = null;
  45462. }
  45463. };
  45464. }
  45465. function mountComponent (
  45466. vm,
  45467. el,
  45468. hydrating
  45469. ) {
  45470. vm.$el = el;
  45471. if (!vm.$options.render) {
  45472. vm.$options.render = createEmptyVNode;
  45473. {
  45474. /* istanbul ignore if */
  45475. if ((vm.$options.template && vm.$options.template.charAt(0) !== '#') ||
  45476. vm.$options.el || el) {
  45477. warn(
  45478. 'You are using the runtime-only build of Vue where the template ' +
  45479. 'compiler is not available. Either pre-compile the templates into ' +
  45480. 'render functions, or use the compiler-included build.',
  45481. vm
  45482. );
  45483. } else {
  45484. warn(
  45485. 'Failed to mount component: template or render function not defined.',
  45486. vm
  45487. );
  45488. }
  45489. }
  45490. }
  45491. callHook(vm, 'beforeMount');
  45492. var updateComponent;
  45493. /* istanbul ignore if */
  45494. if (config.performance && mark) {
  45495. updateComponent = function () {
  45496. var name = vm._name;
  45497. var id = vm._uid;
  45498. var startTag = "vue-perf-start:" + id;
  45499. var endTag = "vue-perf-end:" + id;
  45500. mark(startTag);
  45501. var vnode = vm._render();
  45502. mark(endTag);
  45503. measure(("vue " + name + " render"), startTag, endTag);
  45504. mark(startTag);
  45505. vm._update(vnode, hydrating);
  45506. mark(endTag);
  45507. measure(("vue " + name + " patch"), startTag, endTag);
  45508. };
  45509. } else {
  45510. updateComponent = function () {
  45511. vm._update(vm._render(), hydrating);
  45512. };
  45513. }
  45514. // we set this to vm._watcher inside the watcher's constructor
  45515. // since the watcher's initial patch may call $forceUpdate (e.g. inside child
  45516. // component's mounted hook), which relies on vm._watcher being already defined
  45517. new Watcher(vm, updateComponent, noop, {
  45518. before: function before () {
  45519. if (vm._isMounted && !vm._isDestroyed) {
  45520. callHook(vm, 'beforeUpdate');
  45521. }
  45522. }
  45523. }, true /* isRenderWatcher */);
  45524. hydrating = false;
  45525. // manually mounted instance, call mounted on self
  45526. // mounted is called for render-created child components in its inserted hook
  45527. if (vm.$vnode == null) {
  45528. vm._isMounted = true;
  45529. callHook(vm, 'mounted');
  45530. }
  45531. return vm
  45532. }
  45533. function updateChildComponent (
  45534. vm,
  45535. propsData,
  45536. listeners,
  45537. parentVnode,
  45538. renderChildren
  45539. ) {
  45540. {
  45541. isUpdatingChildComponent = true;
  45542. }
  45543. // determine whether component has slot children
  45544. // we need to do this before overwriting $options._renderChildren.
  45545. // check if there are dynamic scopedSlots (hand-written or compiled but with
  45546. // dynamic slot names). Static scoped slots compiled from template has the
  45547. // "$stable" marker.
  45548. var newScopedSlots = parentVnode.data.scopedSlots;
  45549. var oldScopedSlots = vm.$scopedSlots;
  45550. var hasDynamicScopedSlot = !!(
  45551. (newScopedSlots && !newScopedSlots.$stable) ||
  45552. (oldScopedSlots !== emptyObject && !oldScopedSlots.$stable) ||
  45553. (newScopedSlots && vm.$scopedSlots.$key !== newScopedSlots.$key)
  45554. );
  45555. // Any static slot children from the parent may have changed during parent's
  45556. // update. Dynamic scoped slots may also have changed. In such cases, a forced
  45557. // update is necessary to ensure correctness.
  45558. var needsForceUpdate = !!(
  45559. renderChildren || // has new static slots
  45560. vm.$options._renderChildren || // has old static slots
  45561. hasDynamicScopedSlot
  45562. );
  45563. vm.$options._parentVnode = parentVnode;
  45564. vm.$vnode = parentVnode; // update vm's placeholder node without re-render
  45565. if (vm._vnode) { // update child tree's parent
  45566. vm._vnode.parent = parentVnode;
  45567. }
  45568. vm.$options._renderChildren = renderChildren;
  45569. // update $attrs and $listeners hash
  45570. // these are also reactive so they may trigger child update if the child
  45571. // used them during render
  45572. vm.$attrs = parentVnode.data.attrs || emptyObject;
  45573. vm.$listeners = listeners || emptyObject;
  45574. // update props
  45575. if (propsData && vm.$options.props) {
  45576. toggleObserving(false);
  45577. var props = vm._props;
  45578. var propKeys = vm.$options._propKeys || [];
  45579. for (var i = 0; i < propKeys.length; i++) {
  45580. var key = propKeys[i];
  45581. var propOptions = vm.$options.props; // wtf flow?
  45582. props[key] = validateProp(key, propOptions, propsData, vm);
  45583. }
  45584. toggleObserving(true);
  45585. // keep a copy of raw propsData
  45586. vm.$options.propsData = propsData;
  45587. }
  45588. // update listeners
  45589. listeners = listeners || emptyObject;
  45590. var oldListeners = vm.$options._parentListeners;
  45591. vm.$options._parentListeners = listeners;
  45592. updateComponentListeners(vm, listeners, oldListeners);
  45593. // resolve slots + force update if has children
  45594. if (needsForceUpdate) {
  45595. vm.$slots = resolveSlots(renderChildren, parentVnode.context);
  45596. vm.$forceUpdate();
  45597. }
  45598. {
  45599. isUpdatingChildComponent = false;
  45600. }
  45601. }
  45602. function isInInactiveTree (vm) {
  45603. while (vm && (vm = vm.$parent)) {
  45604. if (vm._inactive) { return true }
  45605. }
  45606. return false
  45607. }
  45608. function activateChildComponent (vm, direct) {
  45609. if (direct) {
  45610. vm._directInactive = false;
  45611. if (isInInactiveTree(vm)) {
  45612. return
  45613. }
  45614. } else if (vm._directInactive) {
  45615. return
  45616. }
  45617. if (vm._inactive || vm._inactive === null) {
  45618. vm._inactive = false;
  45619. for (var i = 0; i < vm.$children.length; i++) {
  45620. activateChildComponent(vm.$children[i]);
  45621. }
  45622. callHook(vm, 'activated');
  45623. }
  45624. }
  45625. function deactivateChildComponent (vm, direct) {
  45626. if (direct) {
  45627. vm._directInactive = true;
  45628. if (isInInactiveTree(vm)) {
  45629. return
  45630. }
  45631. }
  45632. if (!vm._inactive) {
  45633. vm._inactive = true;
  45634. for (var i = 0; i < vm.$children.length; i++) {
  45635. deactivateChildComponent(vm.$children[i]);
  45636. }
  45637. callHook(vm, 'deactivated');
  45638. }
  45639. }
  45640. function callHook (vm, hook) {
  45641. // #7573 disable dep collection when invoking lifecycle hooks
  45642. pushTarget();
  45643. var handlers = vm.$options[hook];
  45644. var info = hook + " hook";
  45645. if (handlers) {
  45646. for (var i = 0, j = handlers.length; i < j; i++) {
  45647. invokeWithErrorHandling(handlers[i], vm, null, vm, info);
  45648. }
  45649. }
  45650. if (vm._hasHookEvent) {
  45651. vm.$emit('hook:' + hook);
  45652. }
  45653. popTarget();
  45654. }
  45655. /* */
  45656. var MAX_UPDATE_COUNT = 100;
  45657. var queue = [];
  45658. var activatedChildren = [];
  45659. var has = {};
  45660. var circular = {};
  45661. var waiting = false;
  45662. var flushing = false;
  45663. var index = 0;
  45664. /**
  45665. * Reset the scheduler's state.
  45666. */
  45667. function resetSchedulerState () {
  45668. index = queue.length = activatedChildren.length = 0;
  45669. has = {};
  45670. {
  45671. circular = {};
  45672. }
  45673. waiting = flushing = false;
  45674. }
  45675. // Async edge case #6566 requires saving the timestamp when event listeners are
  45676. // attached. However, calling performance.now() has a perf overhead especially
  45677. // if the page has thousands of event listeners. Instead, we take a timestamp
  45678. // every time the scheduler flushes and use that for all event listeners
  45679. // attached during that flush.
  45680. var currentFlushTimestamp = 0;
  45681. // Async edge case fix requires storing an event listener's attach timestamp.
  45682. var getNow = Date.now;
  45683. // Determine what event timestamp the browser is using. Annoyingly, the
  45684. // timestamp can either be hi-res (relative to page load) or low-res
  45685. // (relative to UNIX epoch), so in order to compare time we have to use the
  45686. // same timestamp type when saving the flush timestamp.
  45687. // All IE versions use low-res event timestamps, and have problematic clock
  45688. // implementations (#9632)
  45689. if (inBrowser && !isIE) {
  45690. var performance = window.performance;
  45691. if (
  45692. performance &&
  45693. typeof performance.now === 'function' &&
  45694. getNow() > document.createEvent('Event').timeStamp
  45695. ) {
  45696. // if the event timestamp, although evaluated AFTER the Date.now(), is
  45697. // smaller than it, it means the event is using a hi-res timestamp,
  45698. // and we need to use the hi-res version for event listener timestamps as
  45699. // well.
  45700. getNow = function () { return performance.now(); };
  45701. }
  45702. }
  45703. /**
  45704. * Flush both queues and run the watchers.
  45705. */
  45706. function flushSchedulerQueue () {
  45707. currentFlushTimestamp = getNow();
  45708. flushing = true;
  45709. var watcher, id;
  45710. // Sort queue before flush.
  45711. // This ensures that:
  45712. // 1. Components are updated from parent to child. (because parent is always
  45713. // created before the child)
  45714. // 2. A component's user watchers are run before its render watcher (because
  45715. // user watchers are created before the render watcher)
  45716. // 3. If a component is destroyed during a parent component's watcher run,
  45717. // its watchers can be skipped.
  45718. queue.sort(function (a, b) { return a.id - b.id; });
  45719. // do not cache length because more watchers might be pushed
  45720. // as we run existing watchers
  45721. for (index = 0; index < queue.length; index++) {
  45722. watcher = queue[index];
  45723. if (watcher.before) {
  45724. watcher.before();
  45725. }
  45726. id = watcher.id;
  45727. has[id] = null;
  45728. watcher.run();
  45729. // in dev build, check and stop circular updates.
  45730. if (has[id] != null) {
  45731. circular[id] = (circular[id] || 0) + 1;
  45732. if (circular[id] > MAX_UPDATE_COUNT) {
  45733. warn(
  45734. 'You may have an infinite update loop ' + (
  45735. watcher.user
  45736. ? ("in watcher with expression \"" + (watcher.expression) + "\"")
  45737. : "in a component render function."
  45738. ),
  45739. watcher.vm
  45740. );
  45741. break
  45742. }
  45743. }
  45744. }
  45745. // keep copies of post queues before resetting state
  45746. var activatedQueue = activatedChildren.slice();
  45747. var updatedQueue = queue.slice();
  45748. resetSchedulerState();
  45749. // call component updated and activated hooks
  45750. callActivatedHooks(activatedQueue);
  45751. callUpdatedHooks(updatedQueue);
  45752. // devtool hook
  45753. /* istanbul ignore if */
  45754. if (devtools && config.devtools) {
  45755. devtools.emit('flush');
  45756. }
  45757. }
  45758. function callUpdatedHooks (queue) {
  45759. var i = queue.length;
  45760. while (i--) {
  45761. var watcher = queue[i];
  45762. var vm = watcher.vm;
  45763. if (vm._watcher === watcher && vm._isMounted && !vm._isDestroyed) {
  45764. callHook(vm, 'updated');
  45765. }
  45766. }
  45767. }
  45768. /**
  45769. * Queue a kept-alive component that was activated during patch.
  45770. * The queue will be processed after the entire tree has been patched.
  45771. */
  45772. function queueActivatedComponent (vm) {
  45773. // setting _inactive to false here so that a render function can
  45774. // rely on checking whether it's in an inactive tree (e.g. router-view)
  45775. vm._inactive = false;
  45776. activatedChildren.push(vm);
  45777. }
  45778. function callActivatedHooks (queue) {
  45779. for (var i = 0; i < queue.length; i++) {
  45780. queue[i]._inactive = true;
  45781. activateChildComponent(queue[i], true /* true */);
  45782. }
  45783. }
  45784. /**
  45785. * Push a watcher into the watcher queue.
  45786. * Jobs with duplicate IDs will be skipped unless it's
  45787. * pushed when the queue is being flushed.
  45788. */
  45789. function queueWatcher (watcher) {
  45790. var id = watcher.id;
  45791. if (has[id] == null) {
  45792. has[id] = true;
  45793. if (!flushing) {
  45794. queue.push(watcher);
  45795. } else {
  45796. // if already flushing, splice the watcher based on its id
  45797. // if already past its id, it will be run next immediately.
  45798. var i = queue.length - 1;
  45799. while (i > index && queue[i].id > watcher.id) {
  45800. i--;
  45801. }
  45802. queue.splice(i + 1, 0, watcher);
  45803. }
  45804. // queue the flush
  45805. if (!waiting) {
  45806. waiting = true;
  45807. if (!config.async) {
  45808. flushSchedulerQueue();
  45809. return
  45810. }
  45811. nextTick(flushSchedulerQueue);
  45812. }
  45813. }
  45814. }
  45815. /* */
  45816. var uid$2 = 0;
  45817. /**
  45818. * A watcher parses an expression, collects dependencies,
  45819. * and fires callback when the expression value changes.
  45820. * This is used for both the $watch() api and directives.
  45821. */
  45822. var Watcher = function Watcher (
  45823. vm,
  45824. expOrFn,
  45825. cb,
  45826. options,
  45827. isRenderWatcher
  45828. ) {
  45829. this.vm = vm;
  45830. if (isRenderWatcher) {
  45831. vm._watcher = this;
  45832. }
  45833. vm._watchers.push(this);
  45834. // options
  45835. if (options) {
  45836. this.deep = !!options.deep;
  45837. this.user = !!options.user;
  45838. this.lazy = !!options.lazy;
  45839. this.sync = !!options.sync;
  45840. this.before = options.before;
  45841. } else {
  45842. this.deep = this.user = this.lazy = this.sync = false;
  45843. }
  45844. this.cb = cb;
  45845. this.id = ++uid$2; // uid for batching
  45846. this.active = true;
  45847. this.dirty = this.lazy; // for lazy watchers
  45848. this.deps = [];
  45849. this.newDeps = [];
  45850. this.depIds = new _Set();
  45851. this.newDepIds = new _Set();
  45852. this.expression = expOrFn.toString();
  45853. // parse expression for getter
  45854. if (typeof expOrFn === 'function') {
  45855. this.getter = expOrFn;
  45856. } else {
  45857. this.getter = parsePath(expOrFn);
  45858. if (!this.getter) {
  45859. this.getter = noop;
  45860. warn(
  45861. "Failed watching path: \"" + expOrFn + "\" " +
  45862. 'Watcher only accepts simple dot-delimited paths. ' +
  45863. 'For full control, use a function instead.',
  45864. vm
  45865. );
  45866. }
  45867. }
  45868. this.value = this.lazy
  45869. ? undefined
  45870. : this.get();
  45871. };
  45872. /**
  45873. * Evaluate the getter, and re-collect dependencies.
  45874. */
  45875. Watcher.prototype.get = function get () {
  45876. pushTarget(this);
  45877. var value;
  45878. var vm = this.vm;
  45879. try {
  45880. value = this.getter.call(vm, vm);
  45881. } catch (e) {
  45882. if (this.user) {
  45883. handleError(e, vm, ("getter for watcher \"" + (this.expression) + "\""));
  45884. } else {
  45885. throw e
  45886. }
  45887. } finally {
  45888. // "touch" every property so they are all tracked as
  45889. // dependencies for deep watching
  45890. if (this.deep) {
  45891. traverse(value);
  45892. }
  45893. popTarget();
  45894. this.cleanupDeps();
  45895. }
  45896. return value
  45897. };
  45898. /**
  45899. * Add a dependency to this directive.
  45900. */
  45901. Watcher.prototype.addDep = function addDep (dep) {
  45902. var id = dep.id;
  45903. if (!this.newDepIds.has(id)) {
  45904. this.newDepIds.add(id);
  45905. this.newDeps.push(dep);
  45906. if (!this.depIds.has(id)) {
  45907. dep.addSub(this);
  45908. }
  45909. }
  45910. };
  45911. /**
  45912. * Clean up for dependency collection.
  45913. */
  45914. Watcher.prototype.cleanupDeps = function cleanupDeps () {
  45915. var i = this.deps.length;
  45916. while (i--) {
  45917. var dep = this.deps[i];
  45918. if (!this.newDepIds.has(dep.id)) {
  45919. dep.removeSub(this);
  45920. }
  45921. }
  45922. var tmp = this.depIds;
  45923. this.depIds = this.newDepIds;
  45924. this.newDepIds = tmp;
  45925. this.newDepIds.clear();
  45926. tmp = this.deps;
  45927. this.deps = this.newDeps;
  45928. this.newDeps = tmp;
  45929. this.newDeps.length = 0;
  45930. };
  45931. /**
  45932. * Subscriber interface.
  45933. * Will be called when a dependency changes.
  45934. */
  45935. Watcher.prototype.update = function update () {
  45936. /* istanbul ignore else */
  45937. if (this.lazy) {
  45938. this.dirty = true;
  45939. } else if (this.sync) {
  45940. this.run();
  45941. } else {
  45942. queueWatcher(this);
  45943. }
  45944. };
  45945. /**
  45946. * Scheduler job interface.
  45947. * Will be called by the scheduler.
  45948. */
  45949. Watcher.prototype.run = function run () {
  45950. if (this.active) {
  45951. var value = this.get();
  45952. if (
  45953. value !== this.value ||
  45954. // Deep watchers and watchers on Object/Arrays should fire even
  45955. // when the value is the same, because the value may
  45956. // have mutated.
  45957. isObject(value) ||
  45958. this.deep
  45959. ) {
  45960. // set new value
  45961. var oldValue = this.value;
  45962. this.value = value;
  45963. if (this.user) {
  45964. try {
  45965. this.cb.call(this.vm, value, oldValue);
  45966. } catch (e) {
  45967. handleError(e, this.vm, ("callback for watcher \"" + (this.expression) + "\""));
  45968. }
  45969. } else {
  45970. this.cb.call(this.vm, value, oldValue);
  45971. }
  45972. }
  45973. }
  45974. };
  45975. /**
  45976. * Evaluate the value of the watcher.
  45977. * This only gets called for lazy watchers.
  45978. */
  45979. Watcher.prototype.evaluate = function evaluate () {
  45980. this.value = this.get();
  45981. this.dirty = false;
  45982. };
  45983. /**
  45984. * Depend on all deps collected by this watcher.
  45985. */
  45986. Watcher.prototype.depend = function depend () {
  45987. var i = this.deps.length;
  45988. while (i--) {
  45989. this.deps[i].depend();
  45990. }
  45991. };
  45992. /**
  45993. * Remove self from all dependencies' subscriber list.
  45994. */
  45995. Watcher.prototype.teardown = function teardown () {
  45996. if (this.active) {
  45997. // remove self from vm's watcher list
  45998. // this is a somewhat expensive operation so we skip it
  45999. // if the vm is being destroyed.
  46000. if (!this.vm._isBeingDestroyed) {
  46001. remove(this.vm._watchers, this);
  46002. }
  46003. var i = this.deps.length;
  46004. while (i--) {
  46005. this.deps[i].removeSub(this);
  46006. }
  46007. this.active = false;
  46008. }
  46009. };
  46010. /* */
  46011. var sharedPropertyDefinition = {
  46012. enumerable: true,
  46013. configurable: true,
  46014. get: noop,
  46015. set: noop
  46016. };
  46017. function proxy (target, sourceKey, key) {
  46018. sharedPropertyDefinition.get = function proxyGetter () {
  46019. return this[sourceKey][key]
  46020. };
  46021. sharedPropertyDefinition.set = function proxySetter (val) {
  46022. this[sourceKey][key] = val;
  46023. };
  46024. Object.defineProperty(target, key, sharedPropertyDefinition);
  46025. }
  46026. function initState (vm) {
  46027. vm._watchers = [];
  46028. var opts = vm.$options;
  46029. if (opts.props) { initProps(vm, opts.props); }
  46030. if (opts.methods) { initMethods(vm, opts.methods); }
  46031. if (opts.data) {
  46032. initData(vm);
  46033. } else {
  46034. observe(vm._data = {}, true /* asRootData */);
  46035. }
  46036. if (opts.computed) { initComputed(vm, opts.computed); }
  46037. if (opts.watch && opts.watch !== nativeWatch) {
  46038. initWatch(vm, opts.watch);
  46039. }
  46040. }
  46041. function initProps (vm, propsOptions) {
  46042. var propsData = vm.$options.propsData || {};
  46043. var props = vm._props = {};
  46044. // cache prop keys so that future props updates can iterate using Array
  46045. // instead of dynamic object key enumeration.
  46046. var keys = vm.$options._propKeys = [];
  46047. var isRoot = !vm.$parent;
  46048. // root instance props should be converted
  46049. if (!isRoot) {
  46050. toggleObserving(false);
  46051. }
  46052. var loop = function ( key ) {
  46053. keys.push(key);
  46054. var value = validateProp(key, propsOptions, propsData, vm);
  46055. /* istanbul ignore else */
  46056. {
  46057. var hyphenatedKey = hyphenate(key);
  46058. if (isReservedAttribute(hyphenatedKey) ||
  46059. config.isReservedAttr(hyphenatedKey)) {
  46060. warn(
  46061. ("\"" + hyphenatedKey + "\" is a reserved attribute and cannot be used as component prop."),
  46062. vm
  46063. );
  46064. }
  46065. defineReactive$$1(props, key, value, function () {
  46066. if (!isRoot && !isUpdatingChildComponent) {
  46067. warn(
  46068. "Avoid mutating a prop directly since the value will be " +
  46069. "overwritten whenever the parent component re-renders. " +
  46070. "Instead, use a data or computed property based on the prop's " +
  46071. "value. Prop being mutated: \"" + key + "\"",
  46072. vm
  46073. );
  46074. }
  46075. });
  46076. }
  46077. // static props are already proxied on the component's prototype
  46078. // during Vue.extend(). We only need to proxy props defined at
  46079. // instantiation here.
  46080. if (!(key in vm)) {
  46081. proxy(vm, "_props", key);
  46082. }
  46083. };
  46084. for (var key in propsOptions) loop( key );
  46085. toggleObserving(true);
  46086. }
  46087. function initData (vm) {
  46088. var data = vm.$options.data;
  46089. data = vm._data = typeof data === 'function'
  46090. ? getData(data, vm)
  46091. : data || {};
  46092. if (!isPlainObject(data)) {
  46093. data = {};
  46094. warn(
  46095. 'data functions should return an object:\n' +
  46096. 'https://vuejs.org/v2/guide/components.html#data-Must-Be-a-Function',
  46097. vm
  46098. );
  46099. }
  46100. // proxy data on instance
  46101. var keys = Object.keys(data);
  46102. var props = vm.$options.props;
  46103. var methods = vm.$options.methods;
  46104. var i = keys.length;
  46105. while (i--) {
  46106. var key = keys[i];
  46107. {
  46108. if (methods && hasOwn(methods, key)) {
  46109. warn(
  46110. ("Method \"" + key + "\" has already been defined as a data property."),
  46111. vm
  46112. );
  46113. }
  46114. }
  46115. if (props && hasOwn(props, key)) {
  46116. warn(
  46117. "The data property \"" + key + "\" is already declared as a prop. " +
  46118. "Use prop default value instead.",
  46119. vm
  46120. );
  46121. } else if (!isReserved(key)) {
  46122. proxy(vm, "_data", key);
  46123. }
  46124. }
  46125. // observe data
  46126. observe(data, true /* asRootData */);
  46127. }
  46128. function getData (data, vm) {
  46129. // #7573 disable dep collection when invoking data getters
  46130. pushTarget();
  46131. try {
  46132. return data.call(vm, vm)
  46133. } catch (e) {
  46134. handleError(e, vm, "data()");
  46135. return {}
  46136. } finally {
  46137. popTarget();
  46138. }
  46139. }
  46140. var computedWatcherOptions = { lazy: true };
  46141. function initComputed (vm, computed) {
  46142. // $flow-disable-line
  46143. var watchers = vm._computedWatchers = Object.create(null);
  46144. // computed properties are just getters during SSR
  46145. var isSSR = isServerRendering();
  46146. for (var key in computed) {
  46147. var userDef = computed[key];
  46148. var getter = typeof userDef === 'function' ? userDef : userDef.get;
  46149. if (getter == null) {
  46150. warn(
  46151. ("Getter is missing for computed property \"" + key + "\"."),
  46152. vm
  46153. );
  46154. }
  46155. if (!isSSR) {
  46156. // create internal watcher for the computed property.
  46157. watchers[key] = new Watcher(
  46158. vm,
  46159. getter || noop,
  46160. noop,
  46161. computedWatcherOptions
  46162. );
  46163. }
  46164. // component-defined computed properties are already defined on the
  46165. // component prototype. We only need to define computed properties defined
  46166. // at instantiation here.
  46167. if (!(key in vm)) {
  46168. defineComputed(vm, key, userDef);
  46169. } else {
  46170. if (key in vm.$data) {
  46171. warn(("The computed property \"" + key + "\" is already defined in data."), vm);
  46172. } else if (vm.$options.props && key in vm.$options.props) {
  46173. warn(("The computed property \"" + key + "\" is already defined as a prop."), vm);
  46174. }
  46175. }
  46176. }
  46177. }
  46178. function defineComputed (
  46179. target,
  46180. key,
  46181. userDef
  46182. ) {
  46183. var shouldCache = !isServerRendering();
  46184. if (typeof userDef === 'function') {
  46185. sharedPropertyDefinition.get = shouldCache
  46186. ? createComputedGetter(key)
  46187. : createGetterInvoker(userDef);
  46188. sharedPropertyDefinition.set = noop;
  46189. } else {
  46190. sharedPropertyDefinition.get = userDef.get
  46191. ? shouldCache && userDef.cache !== false
  46192. ? createComputedGetter(key)
  46193. : createGetterInvoker(userDef.get)
  46194. : noop;
  46195. sharedPropertyDefinition.set = userDef.set || noop;
  46196. }
  46197. if (sharedPropertyDefinition.set === noop) {
  46198. sharedPropertyDefinition.set = function () {
  46199. warn(
  46200. ("Computed property \"" + key + "\" was assigned to but it has no setter."),
  46201. this
  46202. );
  46203. };
  46204. }
  46205. Object.defineProperty(target, key, sharedPropertyDefinition);
  46206. }
  46207. function createComputedGetter (key) {
  46208. return function computedGetter () {
  46209. var watcher = this._computedWatchers && this._computedWatchers[key];
  46210. if (watcher) {
  46211. if (watcher.dirty) {
  46212. watcher.evaluate();
  46213. }
  46214. if (Dep.target) {
  46215. watcher.depend();
  46216. }
  46217. return watcher.value
  46218. }
  46219. }
  46220. }
  46221. function createGetterInvoker(fn) {
  46222. return function computedGetter () {
  46223. return fn.call(this, this)
  46224. }
  46225. }
  46226. function initMethods (vm, methods) {
  46227. var props = vm.$options.props;
  46228. for (var key in methods) {
  46229. {
  46230. if (typeof methods[key] !== 'function') {
  46231. warn(
  46232. "Method \"" + key + "\" has type \"" + (typeof methods[key]) + "\" in the component definition. " +
  46233. "Did you reference the function correctly?",
  46234. vm
  46235. );
  46236. }
  46237. if (props && hasOwn(props, key)) {
  46238. warn(
  46239. ("Method \"" + key + "\" has already been defined as a prop."),
  46240. vm
  46241. );
  46242. }
  46243. if ((key in vm) && isReserved(key)) {
  46244. warn(
  46245. "Method \"" + key + "\" conflicts with an existing Vue instance method. " +
  46246. "Avoid defining component methods that start with _ or $."
  46247. );
  46248. }
  46249. }
  46250. vm[key] = typeof methods[key] !== 'function' ? noop : bind(methods[key], vm);
  46251. }
  46252. }
  46253. function initWatch (vm, watch) {
  46254. for (var key in watch) {
  46255. var handler = watch[key];
  46256. if (Array.isArray(handler)) {
  46257. for (var i = 0; i < handler.length; i++) {
  46258. createWatcher(vm, key, handler[i]);
  46259. }
  46260. } else {
  46261. createWatcher(vm, key, handler);
  46262. }
  46263. }
  46264. }
  46265. function createWatcher (
  46266. vm,
  46267. expOrFn,
  46268. handler,
  46269. options
  46270. ) {
  46271. if (isPlainObject(handler)) {
  46272. options = handler;
  46273. handler = handler.handler;
  46274. }
  46275. if (typeof handler === 'string') {
  46276. handler = vm[handler];
  46277. }
  46278. return vm.$watch(expOrFn, handler, options)
  46279. }
  46280. function stateMixin (Vue) {
  46281. // flow somehow has problems with directly declared definition object
  46282. // when using Object.defineProperty, so we have to procedurally build up
  46283. // the object here.
  46284. var dataDef = {};
  46285. dataDef.get = function () { return this._data };
  46286. var propsDef = {};
  46287. propsDef.get = function () { return this._props };
  46288. {
  46289. dataDef.set = function () {
  46290. warn(
  46291. 'Avoid replacing instance root $data. ' +
  46292. 'Use nested data properties instead.',
  46293. this
  46294. );
  46295. };
  46296. propsDef.set = function () {
  46297. warn("$props is readonly.", this);
  46298. };
  46299. }
  46300. Object.defineProperty(Vue.prototype, '$data', dataDef);
  46301. Object.defineProperty(Vue.prototype, '$props', propsDef);
  46302. Vue.prototype.$set = set;
  46303. Vue.prototype.$delete = del;
  46304. Vue.prototype.$watch = function (
  46305. expOrFn,
  46306. cb,
  46307. options
  46308. ) {
  46309. var vm = this;
  46310. if (isPlainObject(cb)) {
  46311. return createWatcher(vm, expOrFn, cb, options)
  46312. }
  46313. options = options || {};
  46314. options.user = true;
  46315. var watcher = new Watcher(vm, expOrFn, cb, options);
  46316. if (options.immediate) {
  46317. try {
  46318. cb.call(vm, watcher.value);
  46319. } catch (error) {
  46320. handleError(error, vm, ("callback for immediate watcher \"" + (watcher.expression) + "\""));
  46321. }
  46322. }
  46323. return function unwatchFn () {
  46324. watcher.teardown();
  46325. }
  46326. };
  46327. }
  46328. /* */
  46329. var uid$3 = 0;
  46330. function initMixin (Vue) {
  46331. Vue.prototype._init = function (options) {
  46332. var vm = this;
  46333. // a uid
  46334. vm._uid = uid$3++;
  46335. var startTag, endTag;
  46336. /* istanbul ignore if */
  46337. if (config.performance && mark) {
  46338. startTag = "vue-perf-start:" + (vm._uid);
  46339. endTag = "vue-perf-end:" + (vm._uid);
  46340. mark(startTag);
  46341. }
  46342. // a flag to avoid this being observed
  46343. vm._isVue = true;
  46344. // merge options
  46345. if (options && options._isComponent) {
  46346. // optimize internal component instantiation
  46347. // since dynamic options merging is pretty slow, and none of the
  46348. // internal component options needs special treatment.
  46349. initInternalComponent(vm, options);
  46350. } else {
  46351. vm.$options = mergeOptions(
  46352. resolveConstructorOptions(vm.constructor),
  46353. options || {},
  46354. vm
  46355. );
  46356. }
  46357. /* istanbul ignore else */
  46358. {
  46359. initProxy(vm);
  46360. }
  46361. // expose real self
  46362. vm._self = vm;
  46363. initLifecycle(vm);
  46364. initEvents(vm);
  46365. initRender(vm);
  46366. callHook(vm, 'beforeCreate');
  46367. initInjections(vm); // resolve injections before data/props
  46368. initState(vm);
  46369. initProvide(vm); // resolve provide after data/props
  46370. callHook(vm, 'created');
  46371. /* istanbul ignore if */
  46372. if (config.performance && mark) {
  46373. vm._name = formatComponentName(vm, false);
  46374. mark(endTag);
  46375. measure(("vue " + (vm._name) + " init"), startTag, endTag);
  46376. }
  46377. if (vm.$options.el) {
  46378. vm.$mount(vm.$options.el);
  46379. }
  46380. };
  46381. }
  46382. function initInternalComponent (vm, options) {
  46383. var opts = vm.$options = Object.create(vm.constructor.options);
  46384. // doing this because it's faster than dynamic enumeration.
  46385. var parentVnode = options._parentVnode;
  46386. opts.parent = options.parent;
  46387. opts._parentVnode = parentVnode;
  46388. var vnodeComponentOptions = parentVnode.componentOptions;
  46389. opts.propsData = vnodeComponentOptions.propsData;
  46390. opts._parentListeners = vnodeComponentOptions.listeners;
  46391. opts._renderChildren = vnodeComponentOptions.children;
  46392. opts._componentTag = vnodeComponentOptions.tag;
  46393. if (options.render) {
  46394. opts.render = options.render;
  46395. opts.staticRenderFns = options.staticRenderFns;
  46396. }
  46397. }
  46398. function resolveConstructorOptions (Ctor) {
  46399. var options = Ctor.options;
  46400. if (Ctor.super) {
  46401. var superOptions = resolveConstructorOptions(Ctor.super);
  46402. var cachedSuperOptions = Ctor.superOptions;
  46403. if (superOptions !== cachedSuperOptions) {
  46404. // super option changed,
  46405. // need to resolve new options.
  46406. Ctor.superOptions = superOptions;
  46407. // check if there are any late-modified/attached options (#4976)
  46408. var modifiedOptions = resolveModifiedOptions(Ctor);
  46409. // update base extend options
  46410. if (modifiedOptions) {
  46411. extend(Ctor.extendOptions, modifiedOptions);
  46412. }
  46413. options = Ctor.options = mergeOptions(superOptions, Ctor.extendOptions);
  46414. if (options.name) {
  46415. options.components[options.name] = Ctor;
  46416. }
  46417. }
  46418. }
  46419. return options
  46420. }
  46421. function resolveModifiedOptions (Ctor) {
  46422. var modified;
  46423. var latest = Ctor.options;
  46424. var sealed = Ctor.sealedOptions;
  46425. for (var key in latest) {
  46426. if (latest[key] !== sealed[key]) {
  46427. if (!modified) { modified = {}; }
  46428. modified[key] = latest[key];
  46429. }
  46430. }
  46431. return modified
  46432. }
  46433. function Vue (options) {
  46434. if (!(this instanceof Vue)
  46435. ) {
  46436. warn('Vue is a constructor and should be called with the `new` keyword');
  46437. }
  46438. this._init(options);
  46439. }
  46440. initMixin(Vue);
  46441. stateMixin(Vue);
  46442. eventsMixin(Vue);
  46443. lifecycleMixin(Vue);
  46444. renderMixin(Vue);
  46445. /* */
  46446. function initUse (Vue) {
  46447. Vue.use = function (plugin) {
  46448. var installedPlugins = (this._installedPlugins || (this._installedPlugins = []));
  46449. if (installedPlugins.indexOf(plugin) > -1) {
  46450. return this
  46451. }
  46452. // additional parameters
  46453. var args = toArray(arguments, 1);
  46454. args.unshift(this);
  46455. if (typeof plugin.install === 'function') {
  46456. plugin.install.apply(plugin, args);
  46457. } else if (typeof plugin === 'function') {
  46458. plugin.apply(null, args);
  46459. }
  46460. installedPlugins.push(plugin);
  46461. return this
  46462. };
  46463. }
  46464. /* */
  46465. function initMixin$1 (Vue) {
  46466. Vue.mixin = function (mixin) {
  46467. this.options = mergeOptions(this.options, mixin);
  46468. return this
  46469. };
  46470. }
  46471. /* */
  46472. function initExtend (Vue) {
  46473. /**
  46474. * Each instance constructor, including Vue, has a unique
  46475. * cid. This enables us to create wrapped "child
  46476. * constructors" for prototypal inheritance and cache them.
  46477. */
  46478. Vue.cid = 0;
  46479. var cid = 1;
  46480. /**
  46481. * Class inheritance
  46482. */
  46483. Vue.extend = function (extendOptions) {
  46484. extendOptions = extendOptions || {};
  46485. var Super = this;
  46486. var SuperId = Super.cid;
  46487. var cachedCtors = extendOptions._Ctor || (extendOptions._Ctor = {});
  46488. if (cachedCtors[SuperId]) {
  46489. return cachedCtors[SuperId]
  46490. }
  46491. var name = extendOptions.name || Super.options.name;
  46492. if (name) {
  46493. validateComponentName(name);
  46494. }
  46495. var Sub = function VueComponent (options) {
  46496. this._init(options);
  46497. };
  46498. Sub.prototype = Object.create(Super.prototype);
  46499. Sub.prototype.constructor = Sub;
  46500. Sub.cid = cid++;
  46501. Sub.options = mergeOptions(
  46502. Super.options,
  46503. extendOptions
  46504. );
  46505. Sub['super'] = Super;
  46506. // For props and computed properties, we define the proxy getters on
  46507. // the Vue instances at extension time, on the extended prototype. This
  46508. // avoids Object.defineProperty calls for each instance created.
  46509. if (Sub.options.props) {
  46510. initProps$1(Sub);
  46511. }
  46512. if (Sub.options.computed) {
  46513. initComputed$1(Sub);
  46514. }
  46515. // allow further extension/mixin/plugin usage
  46516. Sub.extend = Super.extend;
  46517. Sub.mixin = Super.mixin;
  46518. Sub.use = Super.use;
  46519. // create asset registers, so extended classes
  46520. // can have their private assets too.
  46521. ASSET_TYPES.forEach(function (type) {
  46522. Sub[type] = Super[type];
  46523. });
  46524. // enable recursive self-lookup
  46525. if (name) {
  46526. Sub.options.components[name] = Sub;
  46527. }
  46528. // keep a reference to the super options at extension time.
  46529. // later at instantiation we can check if Super's options have
  46530. // been updated.
  46531. Sub.superOptions = Super.options;
  46532. Sub.extendOptions = extendOptions;
  46533. Sub.sealedOptions = extend({}, Sub.options);
  46534. // cache constructor
  46535. cachedCtors[SuperId] = Sub;
  46536. return Sub
  46537. };
  46538. }
  46539. function initProps$1 (Comp) {
  46540. var props = Comp.options.props;
  46541. for (var key in props) {
  46542. proxy(Comp.prototype, "_props", key);
  46543. }
  46544. }
  46545. function initComputed$1 (Comp) {
  46546. var computed = Comp.options.computed;
  46547. for (var key in computed) {
  46548. defineComputed(Comp.prototype, key, computed[key]);
  46549. }
  46550. }
  46551. /* */
  46552. function initAssetRegisters (Vue) {
  46553. /**
  46554. * Create asset registration methods.
  46555. */
  46556. ASSET_TYPES.forEach(function (type) {
  46557. Vue[type] = function (
  46558. id,
  46559. definition
  46560. ) {
  46561. if (!definition) {
  46562. return this.options[type + 's'][id]
  46563. } else {
  46564. /* istanbul ignore if */
  46565. if (type === 'component') {
  46566. validateComponentName(id);
  46567. }
  46568. if (type === 'component' && isPlainObject(definition)) {
  46569. definition.name = definition.name || id;
  46570. definition = this.options._base.extend(definition);
  46571. }
  46572. if (type === 'directive' && typeof definition === 'function') {
  46573. definition = { bind: definition, update: definition };
  46574. }
  46575. this.options[type + 's'][id] = definition;
  46576. return definition
  46577. }
  46578. };
  46579. });
  46580. }
  46581. /* */
  46582. function getComponentName (opts) {
  46583. return opts && (opts.Ctor.options.name || opts.tag)
  46584. }
  46585. function matches (pattern, name) {
  46586. if (Array.isArray(pattern)) {
  46587. return pattern.indexOf(name) > -1
  46588. } else if (typeof pattern === 'string') {
  46589. return pattern.split(',').indexOf(name) > -1
  46590. } else if (isRegExp(pattern)) {
  46591. return pattern.test(name)
  46592. }
  46593. /* istanbul ignore next */
  46594. return false
  46595. }
  46596. function pruneCache (keepAliveInstance, filter) {
  46597. var cache = keepAliveInstance.cache;
  46598. var keys = keepAliveInstance.keys;
  46599. var _vnode = keepAliveInstance._vnode;
  46600. for (var key in cache) {
  46601. var cachedNode = cache[key];
  46602. if (cachedNode) {
  46603. var name = getComponentName(cachedNode.componentOptions);
  46604. if (name && !filter(name)) {
  46605. pruneCacheEntry(cache, key, keys, _vnode);
  46606. }
  46607. }
  46608. }
  46609. }
  46610. function pruneCacheEntry (
  46611. cache,
  46612. key,
  46613. keys,
  46614. current
  46615. ) {
  46616. var cached$$1 = cache[key];
  46617. if (cached$$1 && (!current || cached$$1.tag !== current.tag)) {
  46618. cached$$1.componentInstance.$destroy();
  46619. }
  46620. cache[key] = null;
  46621. remove(keys, key);
  46622. }
  46623. var patternTypes = [String, RegExp, Array];
  46624. var KeepAlive = {
  46625. name: 'keep-alive',
  46626. abstract: true,
  46627. props: {
  46628. include: patternTypes,
  46629. exclude: patternTypes,
  46630. max: [String, Number]
  46631. },
  46632. created: function created () {
  46633. this.cache = Object.create(null);
  46634. this.keys = [];
  46635. },
  46636. destroyed: function destroyed () {
  46637. for (var key in this.cache) {
  46638. pruneCacheEntry(this.cache, key, this.keys);
  46639. }
  46640. },
  46641. mounted: function mounted () {
  46642. var this$1 = this;
  46643. this.$watch('include', function (val) {
  46644. pruneCache(this$1, function (name) { return matches(val, name); });
  46645. });
  46646. this.$watch('exclude', function (val) {
  46647. pruneCache(this$1, function (name) { return !matches(val, name); });
  46648. });
  46649. },
  46650. render: function render () {
  46651. var slot = this.$slots.default;
  46652. var vnode = getFirstComponentChild(slot);
  46653. var componentOptions = vnode && vnode.componentOptions;
  46654. if (componentOptions) {
  46655. // check pattern
  46656. var name = getComponentName(componentOptions);
  46657. var ref = this;
  46658. var include = ref.include;
  46659. var exclude = ref.exclude;
  46660. if (
  46661. // not included
  46662. (include && (!name || !matches(include, name))) ||
  46663. // excluded
  46664. (exclude && name && matches(exclude, name))
  46665. ) {
  46666. return vnode
  46667. }
  46668. var ref$1 = this;
  46669. var cache = ref$1.cache;
  46670. var keys = ref$1.keys;
  46671. var key = vnode.key == null
  46672. // same constructor may get registered as different local components
  46673. // so cid alone is not enough (#3269)
  46674. ? componentOptions.Ctor.cid + (componentOptions.tag ? ("::" + (componentOptions.tag)) : '')
  46675. : vnode.key;
  46676. if (cache[key]) {
  46677. vnode.componentInstance = cache[key].componentInstance;
  46678. // make current key freshest
  46679. remove(keys, key);
  46680. keys.push(key);
  46681. } else {
  46682. cache[key] = vnode;
  46683. keys.push(key);
  46684. // prune oldest entry
  46685. if (this.max && keys.length > parseInt(this.max)) {
  46686. pruneCacheEntry(cache, keys[0], keys, this._vnode);
  46687. }
  46688. }
  46689. vnode.data.keepAlive = true;
  46690. }
  46691. return vnode || (slot && slot[0])
  46692. }
  46693. };
  46694. var builtInComponents = {
  46695. KeepAlive: KeepAlive
  46696. };
  46697. /* */
  46698. function initGlobalAPI (Vue) {
  46699. // config
  46700. var configDef = {};
  46701. configDef.get = function () { return config; };
  46702. {
  46703. configDef.set = function () {
  46704. warn(
  46705. 'Do not replace the Vue.config object, set individual fields instead.'
  46706. );
  46707. };
  46708. }
  46709. Object.defineProperty(Vue, 'config', configDef);
  46710. // exposed util methods.
  46711. // NOTE: these are not considered part of the public API - avoid relying on
  46712. // them unless you are aware of the risk.
  46713. Vue.util = {
  46714. warn: warn,
  46715. extend: extend,
  46716. mergeOptions: mergeOptions,
  46717. defineReactive: defineReactive$$1
  46718. };
  46719. Vue.set = set;
  46720. Vue.delete = del;
  46721. Vue.nextTick = nextTick;
  46722. // 2.6 explicit observable API
  46723. Vue.observable = function (obj) {
  46724. observe(obj);
  46725. return obj
  46726. };
  46727. Vue.options = Object.create(null);
  46728. ASSET_TYPES.forEach(function (type) {
  46729. Vue.options[type + 's'] = Object.create(null);
  46730. });
  46731. // this is used to identify the "base" constructor to extend all plain-object
  46732. // components with in Weex's multi-instance scenarios.
  46733. Vue.options._base = Vue;
  46734. extend(Vue.options.components, builtInComponents);
  46735. initUse(Vue);
  46736. initMixin$1(Vue);
  46737. initExtend(Vue);
  46738. initAssetRegisters(Vue);
  46739. }
  46740. initGlobalAPI(Vue);
  46741. Object.defineProperty(Vue.prototype, '$isServer', {
  46742. get: isServerRendering
  46743. });
  46744. Object.defineProperty(Vue.prototype, '$ssrContext', {
  46745. get: function get () {
  46746. /* istanbul ignore next */
  46747. return this.$vnode && this.$vnode.ssrContext
  46748. }
  46749. });
  46750. // expose FunctionalRenderContext for ssr runtime helper installation
  46751. Object.defineProperty(Vue, 'FunctionalRenderContext', {
  46752. value: FunctionalRenderContext
  46753. });
  46754. Vue.version = '2.6.11';
  46755. /* */
  46756. // these are reserved for web because they are directly compiled away
  46757. // during template compilation
  46758. var isReservedAttr = makeMap('style,class');
  46759. // attributes that should be using props for binding
  46760. var acceptValue = makeMap('input,textarea,option,select,progress');
  46761. var mustUseProp = function (tag, type, attr) {
  46762. return (
  46763. (attr === 'value' && acceptValue(tag)) && type !== 'button' ||
  46764. (attr === 'selected' && tag === 'option') ||
  46765. (attr === 'checked' && tag === 'input') ||
  46766. (attr === 'muted' && tag === 'video')
  46767. )
  46768. };
  46769. var isEnumeratedAttr = makeMap('contenteditable,draggable,spellcheck');
  46770. var isValidContentEditableValue = makeMap('events,caret,typing,plaintext-only');
  46771. var convertEnumeratedValue = function (key, value) {
  46772. return isFalsyAttrValue(value) || value === 'false'
  46773. ? 'false'
  46774. // allow arbitrary string value for contenteditable
  46775. : key === 'contenteditable' && isValidContentEditableValue(value)
  46776. ? value
  46777. : 'true'
  46778. };
  46779. var isBooleanAttr = makeMap(
  46780. 'allowfullscreen,async,autofocus,autoplay,checked,compact,controls,declare,' +
  46781. 'default,defaultchecked,defaultmuted,defaultselected,defer,disabled,' +
  46782. 'enabled,formnovalidate,hidden,indeterminate,inert,ismap,itemscope,loop,multiple,' +
  46783. 'muted,nohref,noresize,noshade,novalidate,nowrap,open,pauseonexit,readonly,' +
  46784. 'required,reversed,scoped,seamless,selected,sortable,translate,' +
  46785. 'truespeed,typemustmatch,visible'
  46786. );
  46787. var xlinkNS = 'http://www.w3.org/1999/xlink';
  46788. var isXlink = function (name) {
  46789. return name.charAt(5) === ':' && name.slice(0, 5) === 'xlink'
  46790. };
  46791. var getXlinkProp = function (name) {
  46792. return isXlink(name) ? name.slice(6, name.length) : ''
  46793. };
  46794. var isFalsyAttrValue = function (val) {
  46795. return val == null || val === false
  46796. };
  46797. /* */
  46798. function genClassForVnode (vnode) {
  46799. var data = vnode.data;
  46800. var parentNode = vnode;
  46801. var childNode = vnode;
  46802. while (isDef(childNode.componentInstance)) {
  46803. childNode = childNode.componentInstance._vnode;
  46804. if (childNode && childNode.data) {
  46805. data = mergeClassData(childNode.data, data);
  46806. }
  46807. }
  46808. while (isDef(parentNode = parentNode.parent)) {
  46809. if (parentNode && parentNode.data) {
  46810. data = mergeClassData(data, parentNode.data);
  46811. }
  46812. }
  46813. return renderClass(data.staticClass, data.class)
  46814. }
  46815. function mergeClassData (child, parent) {
  46816. return {
  46817. staticClass: concat(child.staticClass, parent.staticClass),
  46818. class: isDef(child.class)
  46819. ? [child.class, parent.class]
  46820. : parent.class
  46821. }
  46822. }
  46823. function renderClass (
  46824. staticClass,
  46825. dynamicClass
  46826. ) {
  46827. if (isDef(staticClass) || isDef(dynamicClass)) {
  46828. return concat(staticClass, stringifyClass(dynamicClass))
  46829. }
  46830. /* istanbul ignore next */
  46831. return ''
  46832. }
  46833. function concat (a, b) {
  46834. return a ? b ? (a + ' ' + b) : a : (b || '')
  46835. }
  46836. function stringifyClass (value) {
  46837. if (Array.isArray(value)) {
  46838. return stringifyArray(value)
  46839. }
  46840. if (isObject(value)) {
  46841. return stringifyObject(value)
  46842. }
  46843. if (typeof value === 'string') {
  46844. return value
  46845. }
  46846. /* istanbul ignore next */
  46847. return ''
  46848. }
  46849. function stringifyArray (value) {
  46850. var res = '';
  46851. var stringified;
  46852. for (var i = 0, l = value.length; i < l; i++) {
  46853. if (isDef(stringified = stringifyClass(value[i])) && stringified !== '') {
  46854. if (res) { res += ' '; }
  46855. res += stringified;
  46856. }
  46857. }
  46858. return res
  46859. }
  46860. function stringifyObject (value) {
  46861. var res = '';
  46862. for (var key in value) {
  46863. if (value[key]) {
  46864. if (res) { res += ' '; }
  46865. res += key;
  46866. }
  46867. }
  46868. return res
  46869. }
  46870. /* */
  46871. var namespaceMap = {
  46872. svg: 'http://www.w3.org/2000/svg',
  46873. math: 'http://www.w3.org/1998/Math/MathML'
  46874. };
  46875. var isHTMLTag = makeMap(
  46876. 'html,body,base,head,link,meta,style,title,' +
  46877. 'address,article,aside,footer,header,h1,h2,h3,h4,h5,h6,hgroup,nav,section,' +
  46878. 'div,dd,dl,dt,figcaption,figure,picture,hr,img,li,main,ol,p,pre,ul,' +
  46879. 'a,b,abbr,bdi,bdo,br,cite,code,data,dfn,em,i,kbd,mark,q,rp,rt,rtc,ruby,' +
  46880. 's,samp,small,span,strong,sub,sup,time,u,var,wbr,area,audio,map,track,video,' +
  46881. 'embed,object,param,source,canvas,script,noscript,del,ins,' +
  46882. 'caption,col,colgroup,table,thead,tbody,td,th,tr,' +
  46883. 'button,datalist,fieldset,form,input,label,legend,meter,optgroup,option,' +
  46884. 'output,progress,select,textarea,' +
  46885. 'details,dialog,menu,menuitem,summary,' +
  46886. 'content,element,shadow,template,blockquote,iframe,tfoot'
  46887. );
  46888. // this map is intentionally selective, only covering SVG elements that may
  46889. // contain child elements.
  46890. var isSVG = makeMap(
  46891. 'svg,animate,circle,clippath,cursor,defs,desc,ellipse,filter,font-face,' +
  46892. 'foreignObject,g,glyph,image,line,marker,mask,missing-glyph,path,pattern,' +
  46893. 'polygon,polyline,rect,switch,symbol,text,textpath,tspan,use,view',
  46894. true
  46895. );
  46896. var isPreTag = function (tag) { return tag === 'pre'; };
  46897. var isReservedTag = function (tag) {
  46898. return isHTMLTag(tag) || isSVG(tag)
  46899. };
  46900. function getTagNamespace (tag) {
  46901. if (isSVG(tag)) {
  46902. return 'svg'
  46903. }
  46904. // basic support for MathML
  46905. // note it doesn't support other MathML elements being component roots
  46906. if (tag === 'math') {
  46907. return 'math'
  46908. }
  46909. }
  46910. var unknownElementCache = Object.create(null);
  46911. function isUnknownElement (tag) {
  46912. /* istanbul ignore if */
  46913. if (!inBrowser) {
  46914. return true
  46915. }
  46916. if (isReservedTag(tag)) {
  46917. return false
  46918. }
  46919. tag = tag.toLowerCase();
  46920. /* istanbul ignore if */
  46921. if (unknownElementCache[tag] != null) {
  46922. return unknownElementCache[tag]
  46923. }
  46924. var el = document.createElement(tag);
  46925. if (tag.indexOf('-') > -1) {
  46926. // http://stackoverflow.com/a/28210364/1070244
  46927. return (unknownElementCache[tag] = (
  46928. el.constructor === window.HTMLUnknownElement ||
  46929. el.constructor === window.HTMLElement
  46930. ))
  46931. } else {
  46932. return (unknownElementCache[tag] = /HTMLUnknownElement/.test(el.toString()))
  46933. }
  46934. }
  46935. var isTextInputType = makeMap('text,number,password,search,email,tel,url');
  46936. /* */
  46937. /**
  46938. * Query an element selector if it's not an element already.
  46939. */
  46940. function query (el) {
  46941. if (typeof el === 'string') {
  46942. var selected = document.querySelector(el);
  46943. if (!selected) {
  46944. warn(
  46945. 'Cannot find element: ' + el
  46946. );
  46947. return document.createElement('div')
  46948. }
  46949. return selected
  46950. } else {
  46951. return el
  46952. }
  46953. }
  46954. /* */
  46955. function createElement$1 (tagName, vnode) {
  46956. var elm = document.createElement(tagName);
  46957. if (tagName !== 'select') {
  46958. return elm
  46959. }
  46960. // false or null will remove the attribute but undefined will not
  46961. if (vnode.data && vnode.data.attrs && vnode.data.attrs.multiple !== undefined) {
  46962. elm.setAttribute('multiple', 'multiple');
  46963. }
  46964. return elm
  46965. }
  46966. function createElementNS (namespace, tagName) {
  46967. return document.createElementNS(namespaceMap[namespace], tagName)
  46968. }
  46969. function createTextNode (text) {
  46970. return document.createTextNode(text)
  46971. }
  46972. function createComment (text) {
  46973. return document.createComment(text)
  46974. }
  46975. function insertBefore (parentNode, newNode, referenceNode) {
  46976. parentNode.insertBefore(newNode, referenceNode);
  46977. }
  46978. function removeChild (node, child) {
  46979. node.removeChild(child);
  46980. }
  46981. function appendChild (node, child) {
  46982. node.appendChild(child);
  46983. }
  46984. function parentNode (node) {
  46985. return node.parentNode
  46986. }
  46987. function nextSibling (node) {
  46988. return node.nextSibling
  46989. }
  46990. function tagName (node) {
  46991. return node.tagName
  46992. }
  46993. function setTextContent (node, text) {
  46994. node.textContent = text;
  46995. }
  46996. function setStyleScope (node, scopeId) {
  46997. node.setAttribute(scopeId, '');
  46998. }
  46999. var nodeOps = /*#__PURE__*/Object.freeze({
  47000. createElement: createElement$1,
  47001. createElementNS: createElementNS,
  47002. createTextNode: createTextNode,
  47003. createComment: createComment,
  47004. insertBefore: insertBefore,
  47005. removeChild: removeChild,
  47006. appendChild: appendChild,
  47007. parentNode: parentNode,
  47008. nextSibling: nextSibling,
  47009. tagName: tagName,
  47010. setTextContent: setTextContent,
  47011. setStyleScope: setStyleScope
  47012. });
  47013. /* */
  47014. var ref = {
  47015. create: function create (_, vnode) {
  47016. registerRef(vnode);
  47017. },
  47018. update: function update (oldVnode, vnode) {
  47019. if (oldVnode.data.ref !== vnode.data.ref) {
  47020. registerRef(oldVnode, true);
  47021. registerRef(vnode);
  47022. }
  47023. },
  47024. destroy: function destroy (vnode) {
  47025. registerRef(vnode, true);
  47026. }
  47027. };
  47028. function registerRef (vnode, isRemoval) {
  47029. var key = vnode.data.ref;
  47030. if (!isDef(key)) { return }
  47031. var vm = vnode.context;
  47032. var ref = vnode.componentInstance || vnode.elm;
  47033. var refs = vm.$refs;
  47034. if (isRemoval) {
  47035. if (Array.isArray(refs[key])) {
  47036. remove(refs[key], ref);
  47037. } else if (refs[key] === ref) {
  47038. refs[key] = undefined;
  47039. }
  47040. } else {
  47041. if (vnode.data.refInFor) {
  47042. if (!Array.isArray(refs[key])) {
  47043. refs[key] = [ref];
  47044. } else if (refs[key].indexOf(ref) < 0) {
  47045. // $flow-disable-line
  47046. refs[key].push(ref);
  47047. }
  47048. } else {
  47049. refs[key] = ref;
  47050. }
  47051. }
  47052. }
  47053. /**
  47054. * Virtual DOM patching algorithm based on Snabbdom by
  47055. * Simon Friis Vindum (@paldepind)
  47056. * Licensed under the MIT License
  47057. * https://github.com/paldepind/snabbdom/blob/master/LICENSE
  47058. *
  47059. * modified by Evan You (@yyx990803)
  47060. *
  47061. * Not type-checking this because this file is perf-critical and the cost
  47062. * of making flow understand it is not worth it.
  47063. */
  47064. var emptyNode = new VNode('', {}, []);
  47065. var hooks = ['create', 'activate', 'update', 'remove', 'destroy'];
  47066. function sameVnode (a, b) {
  47067. return (
  47068. a.key === b.key && (
  47069. (
  47070. a.tag === b.tag &&
  47071. a.isComment === b.isComment &&
  47072. isDef(a.data) === isDef(b.data) &&
  47073. sameInputType(a, b)
  47074. ) || (
  47075. isTrue(a.isAsyncPlaceholder) &&
  47076. a.asyncFactory === b.asyncFactory &&
  47077. isUndef(b.asyncFactory.error)
  47078. )
  47079. )
  47080. )
  47081. }
  47082. function sameInputType (a, b) {
  47083. if (a.tag !== 'input') { return true }
  47084. var i;
  47085. var typeA = isDef(i = a.data) && isDef(i = i.attrs) && i.type;
  47086. var typeB = isDef(i = b.data) && isDef(i = i.attrs) && i.type;
  47087. return typeA === typeB || isTextInputType(typeA) && isTextInputType(typeB)
  47088. }
  47089. function createKeyToOldIdx (children, beginIdx, endIdx) {
  47090. var i, key;
  47091. var map = {};
  47092. for (i = beginIdx; i <= endIdx; ++i) {
  47093. key = children[i].key;
  47094. if (isDef(key)) { map[key] = i; }
  47095. }
  47096. return map
  47097. }
  47098. function createPatchFunction (backend) {
  47099. var i, j;
  47100. var cbs = {};
  47101. var modules = backend.modules;
  47102. var nodeOps = backend.nodeOps;
  47103. for (i = 0; i < hooks.length; ++i) {
  47104. cbs[hooks[i]] = [];
  47105. for (j = 0; j < modules.length; ++j) {
  47106. if (isDef(modules[j][hooks[i]])) {
  47107. cbs[hooks[i]].push(modules[j][hooks[i]]);
  47108. }
  47109. }
  47110. }
  47111. function emptyNodeAt (elm) {
  47112. return new VNode(nodeOps.tagName(elm).toLowerCase(), {}, [], undefined, elm)
  47113. }
  47114. function createRmCb (childElm, listeners) {
  47115. function remove$$1 () {
  47116. if (--remove$$1.listeners === 0) {
  47117. removeNode(childElm);
  47118. }
  47119. }
  47120. remove$$1.listeners = listeners;
  47121. return remove$$1
  47122. }
  47123. function removeNode (el) {
  47124. var parent = nodeOps.parentNode(el);
  47125. // element may have already been removed due to v-html / v-text
  47126. if (isDef(parent)) {
  47127. nodeOps.removeChild(parent, el);
  47128. }
  47129. }
  47130. function isUnknownElement$$1 (vnode, inVPre) {
  47131. return (
  47132. !inVPre &&
  47133. !vnode.ns &&
  47134. !(
  47135. config.ignoredElements.length &&
  47136. config.ignoredElements.some(function (ignore) {
  47137. return isRegExp(ignore)
  47138. ? ignore.test(vnode.tag)
  47139. : ignore === vnode.tag
  47140. })
  47141. ) &&
  47142. config.isUnknownElement(vnode.tag)
  47143. )
  47144. }
  47145. var creatingElmInVPre = 0;
  47146. function createElm (
  47147. vnode,
  47148. insertedVnodeQueue,
  47149. parentElm,
  47150. refElm,
  47151. nested,
  47152. ownerArray,
  47153. index
  47154. ) {
  47155. if (isDef(vnode.elm) && isDef(ownerArray)) {
  47156. // This vnode was used in a previous render!
  47157. // now it's used as a new node, overwriting its elm would cause
  47158. // potential patch errors down the road when it's used as an insertion
  47159. // reference node. Instead, we clone the node on-demand before creating
  47160. // associated DOM element for it.
  47161. vnode = ownerArray[index] = cloneVNode(vnode);
  47162. }
  47163. vnode.isRootInsert = !nested; // for transition enter check
  47164. if (createComponent(vnode, insertedVnodeQueue, parentElm, refElm)) {
  47165. return
  47166. }
  47167. var data = vnode.data;
  47168. var children = vnode.children;
  47169. var tag = vnode.tag;
  47170. if (isDef(tag)) {
  47171. {
  47172. if (data && data.pre) {
  47173. creatingElmInVPre++;
  47174. }
  47175. if (isUnknownElement$$1(vnode, creatingElmInVPre)) {
  47176. warn(
  47177. 'Unknown custom element: <' + tag + '> - did you ' +
  47178. 'register the component correctly? For recursive components, ' +
  47179. 'make sure to provide the "name" option.',
  47180. vnode.context
  47181. );
  47182. }
  47183. }
  47184. vnode.elm = vnode.ns
  47185. ? nodeOps.createElementNS(vnode.ns, tag)
  47186. : nodeOps.createElement(tag, vnode);
  47187. setScope(vnode);
  47188. /* istanbul ignore if */
  47189. {
  47190. createChildren(vnode, children, insertedVnodeQueue);
  47191. if (isDef(data)) {
  47192. invokeCreateHooks(vnode, insertedVnodeQueue);
  47193. }
  47194. insert(parentElm, vnode.elm, refElm);
  47195. }
  47196. if (data && data.pre) {
  47197. creatingElmInVPre--;
  47198. }
  47199. } else if (isTrue(vnode.isComment)) {
  47200. vnode.elm = nodeOps.createComment(vnode.text);
  47201. insert(parentElm, vnode.elm, refElm);
  47202. } else {
  47203. vnode.elm = nodeOps.createTextNode(vnode.text);
  47204. insert(parentElm, vnode.elm, refElm);
  47205. }
  47206. }
  47207. function createComponent (vnode, insertedVnodeQueue, parentElm, refElm) {
  47208. var i = vnode.data;
  47209. if (isDef(i)) {
  47210. var isReactivated = isDef(vnode.componentInstance) && i.keepAlive;
  47211. if (isDef(i = i.hook) && isDef(i = i.init)) {
  47212. i(vnode, false /* hydrating */);
  47213. }
  47214. // after calling the init hook, if the vnode is a child component
  47215. // it should've created a child instance and mounted it. the child
  47216. // component also has set the placeholder vnode's elm.
  47217. // in that case we can just return the element and be done.
  47218. if (isDef(vnode.componentInstance)) {
  47219. initComponent(vnode, insertedVnodeQueue);
  47220. insert(parentElm, vnode.elm, refElm);
  47221. if (isTrue(isReactivated)) {
  47222. reactivateComponent(vnode, insertedVnodeQueue, parentElm, refElm);
  47223. }
  47224. return true
  47225. }
  47226. }
  47227. }
  47228. function initComponent (vnode, insertedVnodeQueue) {
  47229. if (isDef(vnode.data.pendingInsert)) {
  47230. insertedVnodeQueue.push.apply(insertedVnodeQueue, vnode.data.pendingInsert);
  47231. vnode.data.pendingInsert = null;
  47232. }
  47233. vnode.elm = vnode.componentInstance.$el;
  47234. if (isPatchable(vnode)) {
  47235. invokeCreateHooks(vnode, insertedVnodeQueue);
  47236. setScope(vnode);
  47237. } else {
  47238. // empty component root.
  47239. // skip all element-related modules except for ref (#3455)
  47240. registerRef(vnode);
  47241. // make sure to invoke the insert hook
  47242. insertedVnodeQueue.push(vnode);
  47243. }
  47244. }
  47245. function reactivateComponent (vnode, insertedVnodeQueue, parentElm, refElm) {
  47246. var i;
  47247. // hack for #4339: a reactivated component with inner transition
  47248. // does not trigger because the inner node's created hooks are not called
  47249. // again. It's not ideal to involve module-specific logic in here but
  47250. // there doesn't seem to be a better way to do it.
  47251. var innerNode = vnode;
  47252. while (innerNode.componentInstance) {
  47253. innerNode = innerNode.componentInstance._vnode;
  47254. if (isDef(i = innerNode.data) && isDef(i = i.transition)) {
  47255. for (i = 0; i < cbs.activate.length; ++i) {
  47256. cbs.activate[i](emptyNode, innerNode);
  47257. }
  47258. insertedVnodeQueue.push(innerNode);
  47259. break
  47260. }
  47261. }
  47262. // unlike a newly created component,
  47263. // a reactivated keep-alive component doesn't insert itself
  47264. insert(parentElm, vnode.elm, refElm);
  47265. }
  47266. function insert (parent, elm, ref$$1) {
  47267. if (isDef(parent)) {
  47268. if (isDef(ref$$1)) {
  47269. if (nodeOps.parentNode(ref$$1) === parent) {
  47270. nodeOps.insertBefore(parent, elm, ref$$1);
  47271. }
  47272. } else {
  47273. nodeOps.appendChild(parent, elm);
  47274. }
  47275. }
  47276. }
  47277. function createChildren (vnode, children, insertedVnodeQueue) {
  47278. if (Array.isArray(children)) {
  47279. {
  47280. checkDuplicateKeys(children);
  47281. }
  47282. for (var i = 0; i < children.length; ++i) {
  47283. createElm(children[i], insertedVnodeQueue, vnode.elm, null, true, children, i);
  47284. }
  47285. } else if (isPrimitive(vnode.text)) {
  47286. nodeOps.appendChild(vnode.elm, nodeOps.createTextNode(String(vnode.text)));
  47287. }
  47288. }
  47289. function isPatchable (vnode) {
  47290. while (vnode.componentInstance) {
  47291. vnode = vnode.componentInstance._vnode;
  47292. }
  47293. return isDef(vnode.tag)
  47294. }
  47295. function invokeCreateHooks (vnode, insertedVnodeQueue) {
  47296. for (var i$1 = 0; i$1 < cbs.create.length; ++i$1) {
  47297. cbs.create[i$1](emptyNode, vnode);
  47298. }
  47299. i = vnode.data.hook; // Reuse variable
  47300. if (isDef(i)) {
  47301. if (isDef(i.create)) { i.create(emptyNode, vnode); }
  47302. if (isDef(i.insert)) { insertedVnodeQueue.push(vnode); }
  47303. }
  47304. }
  47305. // set scope id attribute for scoped CSS.
  47306. // this is implemented as a special case to avoid the overhead
  47307. // of going through the normal attribute patching process.
  47308. function setScope (vnode) {
  47309. var i;
  47310. if (isDef(i = vnode.fnScopeId)) {
  47311. nodeOps.setStyleScope(vnode.elm, i);
  47312. } else {
  47313. var ancestor = vnode;
  47314. while (ancestor) {
  47315. if (isDef(i = ancestor.context) && isDef(i = i.$options._scopeId)) {
  47316. nodeOps.setStyleScope(vnode.elm, i);
  47317. }
  47318. ancestor = ancestor.parent;
  47319. }
  47320. }
  47321. // for slot content they should also get the scopeId from the host instance.
  47322. if (isDef(i = activeInstance) &&
  47323. i !== vnode.context &&
  47324. i !== vnode.fnContext &&
  47325. isDef(i = i.$options._scopeId)
  47326. ) {
  47327. nodeOps.setStyleScope(vnode.elm, i);
  47328. }
  47329. }
  47330. function addVnodes (parentElm, refElm, vnodes, startIdx, endIdx, insertedVnodeQueue) {
  47331. for (; startIdx <= endIdx; ++startIdx) {
  47332. createElm(vnodes[startIdx], insertedVnodeQueue, parentElm, refElm, false, vnodes, startIdx);
  47333. }
  47334. }
  47335. function invokeDestroyHook (vnode) {
  47336. var i, j;
  47337. var data = vnode.data;
  47338. if (isDef(data)) {
  47339. if (isDef(i = data.hook) && isDef(i = i.destroy)) { i(vnode); }
  47340. for (i = 0; i < cbs.destroy.length; ++i) { cbs.destroy[i](vnode); }
  47341. }
  47342. if (isDef(i = vnode.children)) {
  47343. for (j = 0; j < vnode.children.length; ++j) {
  47344. invokeDestroyHook(vnode.children[j]);
  47345. }
  47346. }
  47347. }
  47348. function removeVnodes (vnodes, startIdx, endIdx) {
  47349. for (; startIdx <= endIdx; ++startIdx) {
  47350. var ch = vnodes[startIdx];
  47351. if (isDef(ch)) {
  47352. if (isDef(ch.tag)) {
  47353. removeAndInvokeRemoveHook(ch);
  47354. invokeDestroyHook(ch);
  47355. } else { // Text node
  47356. removeNode(ch.elm);
  47357. }
  47358. }
  47359. }
  47360. }
  47361. function removeAndInvokeRemoveHook (vnode, rm) {
  47362. if (isDef(rm) || isDef(vnode.data)) {
  47363. var i;
  47364. var listeners = cbs.remove.length + 1;
  47365. if (isDef(rm)) {
  47366. // we have a recursively passed down rm callback
  47367. // increase the listeners count
  47368. rm.listeners += listeners;
  47369. } else {
  47370. // directly removing
  47371. rm = createRmCb(vnode.elm, listeners);
  47372. }
  47373. // recursively invoke hooks on child component root node
  47374. if (isDef(i = vnode.componentInstance) && isDef(i = i._vnode) && isDef(i.data)) {
  47375. removeAndInvokeRemoveHook(i, rm);
  47376. }
  47377. for (i = 0; i < cbs.remove.length; ++i) {
  47378. cbs.remove[i](vnode, rm);
  47379. }
  47380. if (isDef(i = vnode.data.hook) && isDef(i = i.remove)) {
  47381. i(vnode, rm);
  47382. } else {
  47383. rm();
  47384. }
  47385. } else {
  47386. removeNode(vnode.elm);
  47387. }
  47388. }
  47389. function updateChildren (parentElm, oldCh, newCh, insertedVnodeQueue, removeOnly) {
  47390. var oldStartIdx = 0;
  47391. var newStartIdx = 0;
  47392. var oldEndIdx = oldCh.length - 1;
  47393. var oldStartVnode = oldCh[0];
  47394. var oldEndVnode = oldCh[oldEndIdx];
  47395. var newEndIdx = newCh.length - 1;
  47396. var newStartVnode = newCh[0];
  47397. var newEndVnode = newCh[newEndIdx];
  47398. var oldKeyToIdx, idxInOld, vnodeToMove, refElm;
  47399. // removeOnly is a special flag used only by <transition-group>
  47400. // to ensure removed elements stay in correct relative positions
  47401. // during leaving transitions
  47402. var canMove = !removeOnly;
  47403. {
  47404. checkDuplicateKeys(newCh);
  47405. }
  47406. while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
  47407. if (isUndef(oldStartVnode)) {
  47408. oldStartVnode = oldCh[++oldStartIdx]; // Vnode has been moved left
  47409. } else if (isUndef(oldEndVnode)) {
  47410. oldEndVnode = oldCh[--oldEndIdx];
  47411. } else if (sameVnode(oldStartVnode, newStartVnode)) {
  47412. patchVnode(oldStartVnode, newStartVnode, insertedVnodeQueue, newCh, newStartIdx);
  47413. oldStartVnode = oldCh[++oldStartIdx];
  47414. newStartVnode = newCh[++newStartIdx];
  47415. } else if (sameVnode(oldEndVnode, newEndVnode)) {
  47416. patchVnode(oldEndVnode, newEndVnode, insertedVnodeQueue, newCh, newEndIdx);
  47417. oldEndVnode = oldCh[--oldEndIdx];
  47418. newEndVnode = newCh[--newEndIdx];
  47419. } else if (sameVnode(oldStartVnode, newEndVnode)) { // Vnode moved right
  47420. patchVnode(oldStartVnode, newEndVnode, insertedVnodeQueue, newCh, newEndIdx);
  47421. canMove && nodeOps.insertBefore(parentElm, oldStartVnode.elm, nodeOps.nextSibling(oldEndVnode.elm));
  47422. oldStartVnode = oldCh[++oldStartIdx];
  47423. newEndVnode = newCh[--newEndIdx];
  47424. } else if (sameVnode(oldEndVnode, newStartVnode)) { // Vnode moved left
  47425. patchVnode(oldEndVnode, newStartVnode, insertedVnodeQueue, newCh, newStartIdx);
  47426. canMove && nodeOps.insertBefore(parentElm, oldEndVnode.elm, oldStartVnode.elm);
  47427. oldEndVnode = oldCh[--oldEndIdx];
  47428. newStartVnode = newCh[++newStartIdx];
  47429. } else {
  47430. if (isUndef(oldKeyToIdx)) { oldKeyToIdx = createKeyToOldIdx(oldCh, oldStartIdx, oldEndIdx); }
  47431. idxInOld = isDef(newStartVnode.key)
  47432. ? oldKeyToIdx[newStartVnode.key]
  47433. : findIdxInOld(newStartVnode, oldCh, oldStartIdx, oldEndIdx);
  47434. if (isUndef(idxInOld)) { // New element
  47435. createElm(newStartVnode, insertedVnodeQueue, parentElm, oldStartVnode.elm, false, newCh, newStartIdx);
  47436. } else {
  47437. vnodeToMove = oldCh[idxInOld];
  47438. if (sameVnode(vnodeToMove, newStartVnode)) {
  47439. patchVnode(vnodeToMove, newStartVnode, insertedVnodeQueue, newCh, newStartIdx);
  47440. oldCh[idxInOld] = undefined;
  47441. canMove && nodeOps.insertBefore(parentElm, vnodeToMove.elm, oldStartVnode.elm);
  47442. } else {
  47443. // same key but different element. treat as new element
  47444. createElm(newStartVnode, insertedVnodeQueue, parentElm, oldStartVnode.elm, false, newCh, newStartIdx);
  47445. }
  47446. }
  47447. newStartVnode = newCh[++newStartIdx];
  47448. }
  47449. }
  47450. if (oldStartIdx > oldEndIdx) {
  47451. refElm = isUndef(newCh[newEndIdx + 1]) ? null : newCh[newEndIdx + 1].elm;
  47452. addVnodes(parentElm, refElm, newCh, newStartIdx, newEndIdx, insertedVnodeQueue);
  47453. } else if (newStartIdx > newEndIdx) {
  47454. removeVnodes(oldCh, oldStartIdx, oldEndIdx);
  47455. }
  47456. }
  47457. function checkDuplicateKeys (children) {
  47458. var seenKeys = {};
  47459. for (var i = 0; i < children.length; i++) {
  47460. var vnode = children[i];
  47461. var key = vnode.key;
  47462. if (isDef(key)) {
  47463. if (seenKeys[key]) {
  47464. warn(
  47465. ("Duplicate keys detected: '" + key + "'. This may cause an update error."),
  47466. vnode.context
  47467. );
  47468. } else {
  47469. seenKeys[key] = true;
  47470. }
  47471. }
  47472. }
  47473. }
  47474. function findIdxInOld (node, oldCh, start, end) {
  47475. for (var i = start; i < end; i++) {
  47476. var c = oldCh[i];
  47477. if (isDef(c) && sameVnode(node, c)) { return i }
  47478. }
  47479. }
  47480. function patchVnode (
  47481. oldVnode,
  47482. vnode,
  47483. insertedVnodeQueue,
  47484. ownerArray,
  47485. index,
  47486. removeOnly
  47487. ) {
  47488. if (oldVnode === vnode) {
  47489. return
  47490. }
  47491. if (isDef(vnode.elm) && isDef(ownerArray)) {
  47492. // clone reused vnode
  47493. vnode = ownerArray[index] = cloneVNode(vnode);
  47494. }
  47495. var elm = vnode.elm = oldVnode.elm;
  47496. if (isTrue(oldVnode.isAsyncPlaceholder)) {
  47497. if (isDef(vnode.asyncFactory.resolved)) {
  47498. hydrate(oldVnode.elm, vnode, insertedVnodeQueue);
  47499. } else {
  47500. vnode.isAsyncPlaceholder = true;
  47501. }
  47502. return
  47503. }
  47504. // reuse element for static trees.
  47505. // note we only do this if the vnode is cloned -
  47506. // if the new node is not cloned it means the render functions have been
  47507. // reset by the hot-reload-api and we need to do a proper re-render.
  47508. if (isTrue(vnode.isStatic) &&
  47509. isTrue(oldVnode.isStatic) &&
  47510. vnode.key === oldVnode.key &&
  47511. (isTrue(vnode.isCloned) || isTrue(vnode.isOnce))
  47512. ) {
  47513. vnode.componentInstance = oldVnode.componentInstance;
  47514. return
  47515. }
  47516. var i;
  47517. var data = vnode.data;
  47518. if (isDef(data) && isDef(i = data.hook) && isDef(i = i.prepatch)) {
  47519. i(oldVnode, vnode);
  47520. }
  47521. var oldCh = oldVnode.children;
  47522. var ch = vnode.children;
  47523. if (isDef(data) && isPatchable(vnode)) {
  47524. for (i = 0; i < cbs.update.length; ++i) { cbs.update[i](oldVnode, vnode); }
  47525. if (isDef(i = data.hook) && isDef(i = i.update)) { i(oldVnode, vnode); }
  47526. }
  47527. if (isUndef(vnode.text)) {
  47528. if (isDef(oldCh) && isDef(ch)) {
  47529. if (oldCh !== ch) { updateChildren(elm, oldCh, ch, insertedVnodeQueue, removeOnly); }
  47530. } else if (isDef(ch)) {
  47531. {
  47532. checkDuplicateKeys(ch);
  47533. }
  47534. if (isDef(oldVnode.text)) { nodeOps.setTextContent(elm, ''); }
  47535. addVnodes(elm, null, ch, 0, ch.length - 1, insertedVnodeQueue);
  47536. } else if (isDef(oldCh)) {
  47537. removeVnodes(oldCh, 0, oldCh.length - 1);
  47538. } else if (isDef(oldVnode.text)) {
  47539. nodeOps.setTextContent(elm, '');
  47540. }
  47541. } else if (oldVnode.text !== vnode.text) {
  47542. nodeOps.setTextContent(elm, vnode.text);
  47543. }
  47544. if (isDef(data)) {
  47545. if (isDef(i = data.hook) && isDef(i = i.postpatch)) { i(oldVnode, vnode); }
  47546. }
  47547. }
  47548. function invokeInsertHook (vnode, queue, initial) {
  47549. // delay insert hooks for component root nodes, invoke them after the
  47550. // element is really inserted
  47551. if (isTrue(initial) && isDef(vnode.parent)) {
  47552. vnode.parent.data.pendingInsert = queue;
  47553. } else {
  47554. for (var i = 0; i < queue.length; ++i) {
  47555. queue[i].data.hook.insert(queue[i]);
  47556. }
  47557. }
  47558. }
  47559. var hydrationBailed = false;
  47560. // list of modules that can skip create hook during hydration because they
  47561. // are already rendered on the client or has no need for initialization
  47562. // Note: style is excluded because it relies on initial clone for future
  47563. // deep updates (#7063).
  47564. var isRenderedModule = makeMap('attrs,class,staticClass,staticStyle,key');
  47565. // Note: this is a browser-only function so we can assume elms are DOM nodes.
  47566. function hydrate (elm, vnode, insertedVnodeQueue, inVPre) {
  47567. var i;
  47568. var tag = vnode.tag;
  47569. var data = vnode.data;
  47570. var children = vnode.children;
  47571. inVPre = inVPre || (data && data.pre);
  47572. vnode.elm = elm;
  47573. if (isTrue(vnode.isComment) && isDef(vnode.asyncFactory)) {
  47574. vnode.isAsyncPlaceholder = true;
  47575. return true
  47576. }
  47577. // assert node match
  47578. {
  47579. if (!assertNodeMatch(elm, vnode, inVPre)) {
  47580. return false
  47581. }
  47582. }
  47583. if (isDef(data)) {
  47584. if (isDef(i = data.hook) && isDef(i = i.init)) { i(vnode, true /* hydrating */); }
  47585. if (isDef(i = vnode.componentInstance)) {
  47586. // child component. it should have hydrated its own tree.
  47587. initComponent(vnode, insertedVnodeQueue);
  47588. return true
  47589. }
  47590. }
  47591. if (isDef(tag)) {
  47592. if (isDef(children)) {
  47593. // empty element, allow client to pick up and populate children
  47594. if (!elm.hasChildNodes()) {
  47595. createChildren(vnode, children, insertedVnodeQueue);
  47596. } else {
  47597. // v-html and domProps: innerHTML
  47598. if (isDef(i = data) && isDef(i = i.domProps) && isDef(i = i.innerHTML)) {
  47599. if (i !== elm.innerHTML) {
  47600. /* istanbul ignore if */
  47601. if (typeof console !== 'undefined' &&
  47602. !hydrationBailed
  47603. ) {
  47604. hydrationBailed = true;
  47605. console.warn('Parent: ', elm);
  47606. console.warn('server innerHTML: ', i);
  47607. console.warn('client innerHTML: ', elm.innerHTML);
  47608. }
  47609. return false
  47610. }
  47611. } else {
  47612. // iterate and compare children lists
  47613. var childrenMatch = true;
  47614. var childNode = elm.firstChild;
  47615. for (var i$1 = 0; i$1 < children.length; i$1++) {
  47616. if (!childNode || !hydrate(childNode, children[i$1], insertedVnodeQueue, inVPre)) {
  47617. childrenMatch = false;
  47618. break
  47619. }
  47620. childNode = childNode.nextSibling;
  47621. }
  47622. // if childNode is not null, it means the actual childNodes list is
  47623. // longer than the virtual children list.
  47624. if (!childrenMatch || childNode) {
  47625. /* istanbul ignore if */
  47626. if (typeof console !== 'undefined' &&
  47627. !hydrationBailed
  47628. ) {
  47629. hydrationBailed = true;
  47630. console.warn('Parent: ', elm);
  47631. console.warn('Mismatching childNodes vs. VNodes: ', elm.childNodes, children);
  47632. }
  47633. return false
  47634. }
  47635. }
  47636. }
  47637. }
  47638. if (isDef(data)) {
  47639. var fullInvoke = false;
  47640. for (var key in data) {
  47641. if (!isRenderedModule(key)) {
  47642. fullInvoke = true;
  47643. invokeCreateHooks(vnode, insertedVnodeQueue);
  47644. break
  47645. }
  47646. }
  47647. if (!fullInvoke && data['class']) {
  47648. // ensure collecting deps for deep class bindings for future updates
  47649. traverse(data['class']);
  47650. }
  47651. }
  47652. } else if (elm.data !== vnode.text) {
  47653. elm.data = vnode.text;
  47654. }
  47655. return true
  47656. }
  47657. function assertNodeMatch (node, vnode, inVPre) {
  47658. if (isDef(vnode.tag)) {
  47659. return vnode.tag.indexOf('vue-component') === 0 || (
  47660. !isUnknownElement$$1(vnode, inVPre) &&
  47661. vnode.tag.toLowerCase() === (node.tagName && node.tagName.toLowerCase())
  47662. )
  47663. } else {
  47664. return node.nodeType === (vnode.isComment ? 8 : 3)
  47665. }
  47666. }
  47667. return function patch (oldVnode, vnode, hydrating, removeOnly) {
  47668. if (isUndef(vnode)) {
  47669. if (isDef(oldVnode)) { invokeDestroyHook(oldVnode); }
  47670. return
  47671. }
  47672. var isInitialPatch = false;
  47673. var insertedVnodeQueue = [];
  47674. if (isUndef(oldVnode)) {
  47675. // empty mount (likely as component), create new root element
  47676. isInitialPatch = true;
  47677. createElm(vnode, insertedVnodeQueue);
  47678. } else {
  47679. var isRealElement = isDef(oldVnode.nodeType);
  47680. if (!isRealElement && sameVnode(oldVnode, vnode)) {
  47681. // patch existing root node
  47682. patchVnode(oldVnode, vnode, insertedVnodeQueue, null, null, removeOnly);
  47683. } else {
  47684. if (isRealElement) {
  47685. // mounting to a real element
  47686. // check if this is server-rendered content and if we can perform
  47687. // a successful hydration.
  47688. if (oldVnode.nodeType === 1 && oldVnode.hasAttribute(SSR_ATTR)) {
  47689. oldVnode.removeAttribute(SSR_ATTR);
  47690. hydrating = true;
  47691. }
  47692. if (isTrue(hydrating)) {
  47693. if (hydrate(oldVnode, vnode, insertedVnodeQueue)) {
  47694. invokeInsertHook(vnode, insertedVnodeQueue, true);
  47695. return oldVnode
  47696. } else {
  47697. warn(
  47698. 'The client-side rendered virtual DOM tree is not matching ' +
  47699. 'server-rendered content. This is likely caused by incorrect ' +
  47700. 'HTML markup, for example nesting block-level elements inside ' +
  47701. '<p>, or missing <tbody>. Bailing hydration and performing ' +
  47702. 'full client-side render.'
  47703. );
  47704. }
  47705. }
  47706. // either not server-rendered, or hydration failed.
  47707. // create an empty node and replace it
  47708. oldVnode = emptyNodeAt(oldVnode);
  47709. }
  47710. // replacing existing element
  47711. var oldElm = oldVnode.elm;
  47712. var parentElm = nodeOps.parentNode(oldElm);
  47713. // create new node
  47714. createElm(
  47715. vnode,
  47716. insertedVnodeQueue,
  47717. // extremely rare edge case: do not insert if old element is in a
  47718. // leaving transition. Only happens when combining transition +
  47719. // keep-alive + HOCs. (#4590)
  47720. oldElm._leaveCb ? null : parentElm,
  47721. nodeOps.nextSibling(oldElm)
  47722. );
  47723. // update parent placeholder node element, recursively
  47724. if (isDef(vnode.parent)) {
  47725. var ancestor = vnode.parent;
  47726. var patchable = isPatchable(vnode);
  47727. while (ancestor) {
  47728. for (var i = 0; i < cbs.destroy.length; ++i) {
  47729. cbs.destroy[i](ancestor);
  47730. }
  47731. ancestor.elm = vnode.elm;
  47732. if (patchable) {
  47733. for (var i$1 = 0; i$1 < cbs.create.length; ++i$1) {
  47734. cbs.create[i$1](emptyNode, ancestor);
  47735. }
  47736. // #6513
  47737. // invoke insert hooks that may have been merged by create hooks.
  47738. // e.g. for directives that uses the "inserted" hook.
  47739. var insert = ancestor.data.hook.insert;
  47740. if (insert.merged) {
  47741. // start at index 1 to avoid re-invoking component mounted hook
  47742. for (var i$2 = 1; i$2 < insert.fns.length; i$2++) {
  47743. insert.fns[i$2]();
  47744. }
  47745. }
  47746. } else {
  47747. registerRef(ancestor);
  47748. }
  47749. ancestor = ancestor.parent;
  47750. }
  47751. }
  47752. // destroy old node
  47753. if (isDef(parentElm)) {
  47754. removeVnodes([oldVnode], 0, 0);
  47755. } else if (isDef(oldVnode.tag)) {
  47756. invokeDestroyHook(oldVnode);
  47757. }
  47758. }
  47759. }
  47760. invokeInsertHook(vnode, insertedVnodeQueue, isInitialPatch);
  47761. return vnode.elm
  47762. }
  47763. }
  47764. /* */
  47765. var directives = {
  47766. create: updateDirectives,
  47767. update: updateDirectives,
  47768. destroy: function unbindDirectives (vnode) {
  47769. updateDirectives(vnode, emptyNode);
  47770. }
  47771. };
  47772. function updateDirectives (oldVnode, vnode) {
  47773. if (oldVnode.data.directives || vnode.data.directives) {
  47774. _update(oldVnode, vnode);
  47775. }
  47776. }
  47777. function _update (oldVnode, vnode) {
  47778. var isCreate = oldVnode === emptyNode;
  47779. var isDestroy = vnode === emptyNode;
  47780. var oldDirs = normalizeDirectives$1(oldVnode.data.directives, oldVnode.context);
  47781. var newDirs = normalizeDirectives$1(vnode.data.directives, vnode.context);
  47782. var dirsWithInsert = [];
  47783. var dirsWithPostpatch = [];
  47784. var key, oldDir, dir;
  47785. for (key in newDirs) {
  47786. oldDir = oldDirs[key];
  47787. dir = newDirs[key];
  47788. if (!oldDir) {
  47789. // new directive, bind
  47790. callHook$1(dir, 'bind', vnode, oldVnode);
  47791. if (dir.def && dir.def.inserted) {
  47792. dirsWithInsert.push(dir);
  47793. }
  47794. } else {
  47795. // existing directive, update
  47796. dir.oldValue = oldDir.value;
  47797. dir.oldArg = oldDir.arg;
  47798. callHook$1(dir, 'update', vnode, oldVnode);
  47799. if (dir.def && dir.def.componentUpdated) {
  47800. dirsWithPostpatch.push(dir);
  47801. }
  47802. }
  47803. }
  47804. if (dirsWithInsert.length) {
  47805. var callInsert = function () {
  47806. for (var i = 0; i < dirsWithInsert.length; i++) {
  47807. callHook$1(dirsWithInsert[i], 'inserted', vnode, oldVnode);
  47808. }
  47809. };
  47810. if (isCreate) {
  47811. mergeVNodeHook(vnode, 'insert', callInsert);
  47812. } else {
  47813. callInsert();
  47814. }
  47815. }
  47816. if (dirsWithPostpatch.length) {
  47817. mergeVNodeHook(vnode, 'postpatch', function () {
  47818. for (var i = 0; i < dirsWithPostpatch.length; i++) {
  47819. callHook$1(dirsWithPostpatch[i], 'componentUpdated', vnode, oldVnode);
  47820. }
  47821. });
  47822. }
  47823. if (!isCreate) {
  47824. for (key in oldDirs) {
  47825. if (!newDirs[key]) {
  47826. // no longer present, unbind
  47827. callHook$1(oldDirs[key], 'unbind', oldVnode, oldVnode, isDestroy);
  47828. }
  47829. }
  47830. }
  47831. }
  47832. var emptyModifiers = Object.create(null);
  47833. function normalizeDirectives$1 (
  47834. dirs,
  47835. vm
  47836. ) {
  47837. var res = Object.create(null);
  47838. if (!dirs) {
  47839. // $flow-disable-line
  47840. return res
  47841. }
  47842. var i, dir;
  47843. for (i = 0; i < dirs.length; i++) {
  47844. dir = dirs[i];
  47845. if (!dir.modifiers) {
  47846. // $flow-disable-line
  47847. dir.modifiers = emptyModifiers;
  47848. }
  47849. res[getRawDirName(dir)] = dir;
  47850. dir.def = resolveAsset(vm.$options, 'directives', dir.name, true);
  47851. }
  47852. // $flow-disable-line
  47853. return res
  47854. }
  47855. function getRawDirName (dir) {
  47856. return dir.rawName || ((dir.name) + "." + (Object.keys(dir.modifiers || {}).join('.')))
  47857. }
  47858. function callHook$1 (dir, hook, vnode, oldVnode, isDestroy) {
  47859. var fn = dir.def && dir.def[hook];
  47860. if (fn) {
  47861. try {
  47862. fn(vnode.elm, dir, vnode, oldVnode, isDestroy);
  47863. } catch (e) {
  47864. handleError(e, vnode.context, ("directive " + (dir.name) + " " + hook + " hook"));
  47865. }
  47866. }
  47867. }
  47868. var baseModules = [
  47869. ref,
  47870. directives
  47871. ];
  47872. /* */
  47873. function updateAttrs (oldVnode, vnode) {
  47874. var opts = vnode.componentOptions;
  47875. if (isDef(opts) && opts.Ctor.options.inheritAttrs === false) {
  47876. return
  47877. }
  47878. if (isUndef(oldVnode.data.attrs) && isUndef(vnode.data.attrs)) {
  47879. return
  47880. }
  47881. var key, cur, old;
  47882. var elm = vnode.elm;
  47883. var oldAttrs = oldVnode.data.attrs || {};
  47884. var attrs = vnode.data.attrs || {};
  47885. // clone observed objects, as the user probably wants to mutate it
  47886. if (isDef(attrs.__ob__)) {
  47887. attrs = vnode.data.attrs = extend({}, attrs);
  47888. }
  47889. for (key in attrs) {
  47890. cur = attrs[key];
  47891. old = oldAttrs[key];
  47892. if (old !== cur) {
  47893. setAttr(elm, key, cur);
  47894. }
  47895. }
  47896. // #4391: in IE9, setting type can reset value for input[type=radio]
  47897. // #6666: IE/Edge forces progress value down to 1 before setting a max
  47898. /* istanbul ignore if */
  47899. if ((isIE || isEdge) && attrs.value !== oldAttrs.value) {
  47900. setAttr(elm, 'value', attrs.value);
  47901. }
  47902. for (key in oldAttrs) {
  47903. if (isUndef(attrs[key])) {
  47904. if (isXlink(key)) {
  47905. elm.removeAttributeNS(xlinkNS, getXlinkProp(key));
  47906. } else if (!isEnumeratedAttr(key)) {
  47907. elm.removeAttribute(key);
  47908. }
  47909. }
  47910. }
  47911. }
  47912. function setAttr (el, key, value) {
  47913. if (el.tagName.indexOf('-') > -1) {
  47914. baseSetAttr(el, key, value);
  47915. } else if (isBooleanAttr(key)) {
  47916. // set attribute for blank value
  47917. // e.g. <option disabled>Select one</option>
  47918. if (isFalsyAttrValue(value)) {
  47919. el.removeAttribute(key);
  47920. } else {
  47921. // technically allowfullscreen is a boolean attribute for <iframe>,
  47922. // but Flash expects a value of "true" when used on <embed> tag
  47923. value = key === 'allowfullscreen' && el.tagName === 'EMBED'
  47924. ? 'true'
  47925. : key;
  47926. el.setAttribute(key, value);
  47927. }
  47928. } else if (isEnumeratedAttr(key)) {
  47929. el.setAttribute(key, convertEnumeratedValue(key, value));
  47930. } else if (isXlink(key)) {
  47931. if (isFalsyAttrValue(value)) {
  47932. el.removeAttributeNS(xlinkNS, getXlinkProp(key));
  47933. } else {
  47934. el.setAttributeNS(xlinkNS, key, value);
  47935. }
  47936. } else {
  47937. baseSetAttr(el, key, value);
  47938. }
  47939. }
  47940. function baseSetAttr (el, key, value) {
  47941. if (isFalsyAttrValue(value)) {
  47942. el.removeAttribute(key);
  47943. } else {
  47944. // #7138: IE10 & 11 fires input event when setting placeholder on
  47945. // <textarea>... block the first input event and remove the blocker
  47946. // immediately.
  47947. /* istanbul ignore if */
  47948. if (
  47949. isIE && !isIE9 &&
  47950. el.tagName === 'TEXTAREA' &&
  47951. key === 'placeholder' && value !== '' && !el.__ieph
  47952. ) {
  47953. var blocker = function (e) {
  47954. e.stopImmediatePropagation();
  47955. el.removeEventListener('input', blocker);
  47956. };
  47957. el.addEventListener('input', blocker);
  47958. // $flow-disable-line
  47959. el.__ieph = true; /* IE placeholder patched */
  47960. }
  47961. el.setAttribute(key, value);
  47962. }
  47963. }
  47964. var attrs = {
  47965. create: updateAttrs,
  47966. update: updateAttrs
  47967. };
  47968. /* */
  47969. function updateClass (oldVnode, vnode) {
  47970. var el = vnode.elm;
  47971. var data = vnode.data;
  47972. var oldData = oldVnode.data;
  47973. if (
  47974. isUndef(data.staticClass) &&
  47975. isUndef(data.class) && (
  47976. isUndef(oldData) || (
  47977. isUndef(oldData.staticClass) &&
  47978. isUndef(oldData.class)
  47979. )
  47980. )
  47981. ) {
  47982. return
  47983. }
  47984. var cls = genClassForVnode(vnode);
  47985. // handle transition classes
  47986. var transitionClass = el._transitionClasses;
  47987. if (isDef(transitionClass)) {
  47988. cls = concat(cls, stringifyClass(transitionClass));
  47989. }
  47990. // set the class
  47991. if (cls !== el._prevClass) {
  47992. el.setAttribute('class', cls);
  47993. el._prevClass = cls;
  47994. }
  47995. }
  47996. var klass = {
  47997. create: updateClass,
  47998. update: updateClass
  47999. };
  48000. /* */
  48001. var validDivisionCharRE = /[\w).+\-_$\]]/;
  48002. function parseFilters (exp) {
  48003. var inSingle = false;
  48004. var inDouble = false;
  48005. var inTemplateString = false;
  48006. var inRegex = false;
  48007. var curly = 0;
  48008. var square = 0;
  48009. var paren = 0;
  48010. var lastFilterIndex = 0;
  48011. var c, prev, i, expression, filters;
  48012. for (i = 0; i < exp.length; i++) {
  48013. prev = c;
  48014. c = exp.charCodeAt(i);
  48015. if (inSingle) {
  48016. if (c === 0x27 && prev !== 0x5C) { inSingle = false; }
  48017. } else if (inDouble) {
  48018. if (c === 0x22 && prev !== 0x5C) { inDouble = false; }
  48019. } else if (inTemplateString) {
  48020. if (c === 0x60 && prev !== 0x5C) { inTemplateString = false; }
  48021. } else if (inRegex) {
  48022. if (c === 0x2f && prev !== 0x5C) { inRegex = false; }
  48023. } else if (
  48024. c === 0x7C && // pipe
  48025. exp.charCodeAt(i + 1) !== 0x7C &&
  48026. exp.charCodeAt(i - 1) !== 0x7C &&
  48027. !curly && !square && !paren
  48028. ) {
  48029. if (expression === undefined) {
  48030. // first filter, end of expression
  48031. lastFilterIndex = i + 1;
  48032. expression = exp.slice(0, i).trim();
  48033. } else {
  48034. pushFilter();
  48035. }
  48036. } else {
  48037. switch (c) {
  48038. case 0x22: inDouble = true; break // "
  48039. case 0x27: inSingle = true; break // '
  48040. case 0x60: inTemplateString = true; break // `
  48041. case 0x28: paren++; break // (
  48042. case 0x29: paren--; break // )
  48043. case 0x5B: square++; break // [
  48044. case 0x5D: square--; break // ]
  48045. case 0x7B: curly++; break // {
  48046. case 0x7D: curly--; break // }
  48047. }
  48048. if (c === 0x2f) { // /
  48049. var j = i - 1;
  48050. var p = (void 0);
  48051. // find first non-whitespace prev char
  48052. for (; j >= 0; j--) {
  48053. p = exp.charAt(j);
  48054. if (p !== ' ') { break }
  48055. }
  48056. if (!p || !validDivisionCharRE.test(p)) {
  48057. inRegex = true;
  48058. }
  48059. }
  48060. }
  48061. }
  48062. if (expression === undefined) {
  48063. expression = exp.slice(0, i).trim();
  48064. } else if (lastFilterIndex !== 0) {
  48065. pushFilter();
  48066. }
  48067. function pushFilter () {
  48068. (filters || (filters = [])).push(exp.slice(lastFilterIndex, i).trim());
  48069. lastFilterIndex = i + 1;
  48070. }
  48071. if (filters) {
  48072. for (i = 0; i < filters.length; i++) {
  48073. expression = wrapFilter(expression, filters[i]);
  48074. }
  48075. }
  48076. return expression
  48077. }
  48078. function wrapFilter (exp, filter) {
  48079. var i = filter.indexOf('(');
  48080. if (i < 0) {
  48081. // _f: resolveFilter
  48082. return ("_f(\"" + filter + "\")(" + exp + ")")
  48083. } else {
  48084. var name = filter.slice(0, i);
  48085. var args = filter.slice(i + 1);
  48086. return ("_f(\"" + name + "\")(" + exp + (args !== ')' ? ',' + args : args))
  48087. }
  48088. }
  48089. /* */
  48090. /* eslint-disable no-unused-vars */
  48091. function baseWarn (msg, range) {
  48092. console.error(("[Vue compiler]: " + msg));
  48093. }
  48094. /* eslint-enable no-unused-vars */
  48095. function pluckModuleFunction (
  48096. modules,
  48097. key
  48098. ) {
  48099. return modules
  48100. ? modules.map(function (m) { return m[key]; }).filter(function (_) { return _; })
  48101. : []
  48102. }
  48103. function addProp (el, name, value, range, dynamic) {
  48104. (el.props || (el.props = [])).push(rangeSetItem({ name: name, value: value, dynamic: dynamic }, range));
  48105. el.plain = false;
  48106. }
  48107. function addAttr (el, name, value, range, dynamic) {
  48108. var attrs = dynamic
  48109. ? (el.dynamicAttrs || (el.dynamicAttrs = []))
  48110. : (el.attrs || (el.attrs = []));
  48111. attrs.push(rangeSetItem({ name: name, value: value, dynamic: dynamic }, range));
  48112. el.plain = false;
  48113. }
  48114. // add a raw attr (use this in preTransforms)
  48115. function addRawAttr (el, name, value, range) {
  48116. el.attrsMap[name] = value;
  48117. el.attrsList.push(rangeSetItem({ name: name, value: value }, range));
  48118. }
  48119. function addDirective (
  48120. el,
  48121. name,
  48122. rawName,
  48123. value,
  48124. arg,
  48125. isDynamicArg,
  48126. modifiers,
  48127. range
  48128. ) {
  48129. (el.directives || (el.directives = [])).push(rangeSetItem({
  48130. name: name,
  48131. rawName: rawName,
  48132. value: value,
  48133. arg: arg,
  48134. isDynamicArg: isDynamicArg,
  48135. modifiers: modifiers
  48136. }, range));
  48137. el.plain = false;
  48138. }
  48139. function prependModifierMarker (symbol, name, dynamic) {
  48140. return dynamic
  48141. ? ("_p(" + name + ",\"" + symbol + "\")")
  48142. : symbol + name // mark the event as captured
  48143. }
  48144. function addHandler (
  48145. el,
  48146. name,
  48147. value,
  48148. modifiers,
  48149. important,
  48150. warn,
  48151. range,
  48152. dynamic
  48153. ) {
  48154. modifiers = modifiers || emptyObject;
  48155. // warn prevent and passive modifier
  48156. /* istanbul ignore if */
  48157. if (
  48158. warn &&
  48159. modifiers.prevent && modifiers.passive
  48160. ) {
  48161. warn(
  48162. 'passive and prevent can\'t be used together. ' +
  48163. 'Passive handler can\'t prevent default event.',
  48164. range
  48165. );
  48166. }
  48167. // normalize click.right and click.middle since they don't actually fire
  48168. // this is technically browser-specific, but at least for now browsers are
  48169. // the only target envs that have right/middle clicks.
  48170. if (modifiers.right) {
  48171. if (dynamic) {
  48172. name = "(" + name + ")==='click'?'contextmenu':(" + name + ")";
  48173. } else if (name === 'click') {
  48174. name = 'contextmenu';
  48175. delete modifiers.right;
  48176. }
  48177. } else if (modifiers.middle) {
  48178. if (dynamic) {
  48179. name = "(" + name + ")==='click'?'mouseup':(" + name + ")";
  48180. } else if (name === 'click') {
  48181. name = 'mouseup';
  48182. }
  48183. }
  48184. // check capture modifier
  48185. if (modifiers.capture) {
  48186. delete modifiers.capture;
  48187. name = prependModifierMarker('!', name, dynamic);
  48188. }
  48189. if (modifiers.once) {
  48190. delete modifiers.once;
  48191. name = prependModifierMarker('~', name, dynamic);
  48192. }
  48193. /* istanbul ignore if */
  48194. if (modifiers.passive) {
  48195. delete modifiers.passive;
  48196. name = prependModifierMarker('&', name, dynamic);
  48197. }
  48198. var events;
  48199. if (modifiers.native) {
  48200. delete modifiers.native;
  48201. events = el.nativeEvents || (el.nativeEvents = {});
  48202. } else {
  48203. events = el.events || (el.events = {});
  48204. }
  48205. var newHandler = rangeSetItem({ value: value.trim(), dynamic: dynamic }, range);
  48206. if (modifiers !== emptyObject) {
  48207. newHandler.modifiers = modifiers;
  48208. }
  48209. var handlers = events[name];
  48210. /* istanbul ignore if */
  48211. if (Array.isArray(handlers)) {
  48212. important ? handlers.unshift(newHandler) : handlers.push(newHandler);
  48213. } else if (handlers) {
  48214. events[name] = important ? [newHandler, handlers] : [handlers, newHandler];
  48215. } else {
  48216. events[name] = newHandler;
  48217. }
  48218. el.plain = false;
  48219. }
  48220. function getRawBindingAttr (
  48221. el,
  48222. name
  48223. ) {
  48224. return el.rawAttrsMap[':' + name] ||
  48225. el.rawAttrsMap['v-bind:' + name] ||
  48226. el.rawAttrsMap[name]
  48227. }
  48228. function getBindingAttr (
  48229. el,
  48230. name,
  48231. getStatic
  48232. ) {
  48233. var dynamicValue =
  48234. getAndRemoveAttr(el, ':' + name) ||
  48235. getAndRemoveAttr(el, 'v-bind:' + name);
  48236. if (dynamicValue != null) {
  48237. return parseFilters(dynamicValue)
  48238. } else if (getStatic !== false) {
  48239. var staticValue = getAndRemoveAttr(el, name);
  48240. if (staticValue != null) {
  48241. return JSON.stringify(staticValue)
  48242. }
  48243. }
  48244. }
  48245. // note: this only removes the attr from the Array (attrsList) so that it
  48246. // doesn't get processed by processAttrs.
  48247. // By default it does NOT remove it from the map (attrsMap) because the map is
  48248. // needed during codegen.
  48249. function getAndRemoveAttr (
  48250. el,
  48251. name,
  48252. removeFromMap
  48253. ) {
  48254. var val;
  48255. if ((val = el.attrsMap[name]) != null) {
  48256. var list = el.attrsList;
  48257. for (var i = 0, l = list.length; i < l; i++) {
  48258. if (list[i].name === name) {
  48259. list.splice(i, 1);
  48260. break
  48261. }
  48262. }
  48263. }
  48264. if (removeFromMap) {
  48265. delete el.attrsMap[name];
  48266. }
  48267. return val
  48268. }
  48269. function getAndRemoveAttrByRegex (
  48270. el,
  48271. name
  48272. ) {
  48273. var list = el.attrsList;
  48274. for (var i = 0, l = list.length; i < l; i++) {
  48275. var attr = list[i];
  48276. if (name.test(attr.name)) {
  48277. list.splice(i, 1);
  48278. return attr
  48279. }
  48280. }
  48281. }
  48282. function rangeSetItem (
  48283. item,
  48284. range
  48285. ) {
  48286. if (range) {
  48287. if (range.start != null) {
  48288. item.start = range.start;
  48289. }
  48290. if (range.end != null) {
  48291. item.end = range.end;
  48292. }
  48293. }
  48294. return item
  48295. }
  48296. /* */
  48297. /**
  48298. * Cross-platform code generation for component v-model
  48299. */
  48300. function genComponentModel (
  48301. el,
  48302. value,
  48303. modifiers
  48304. ) {
  48305. var ref = modifiers || {};
  48306. var number = ref.number;
  48307. var trim = ref.trim;
  48308. var baseValueExpression = '$$v';
  48309. var valueExpression = baseValueExpression;
  48310. if (trim) {
  48311. valueExpression =
  48312. "(typeof " + baseValueExpression + " === 'string'" +
  48313. "? " + baseValueExpression + ".trim()" +
  48314. ": " + baseValueExpression + ")";
  48315. }
  48316. if (number) {
  48317. valueExpression = "_n(" + valueExpression + ")";
  48318. }
  48319. var assignment = genAssignmentCode(value, valueExpression);
  48320. el.model = {
  48321. value: ("(" + value + ")"),
  48322. expression: JSON.stringify(value),
  48323. callback: ("function (" + baseValueExpression + ") {" + assignment + "}")
  48324. };
  48325. }
  48326. /**
  48327. * Cross-platform codegen helper for generating v-model value assignment code.
  48328. */
  48329. function genAssignmentCode (
  48330. value,
  48331. assignment
  48332. ) {
  48333. var res = parseModel(value);
  48334. if (res.key === null) {
  48335. return (value + "=" + assignment)
  48336. } else {
  48337. return ("$set(" + (res.exp) + ", " + (res.key) + ", " + assignment + ")")
  48338. }
  48339. }
  48340. /**
  48341. * Parse a v-model expression into a base path and a final key segment.
  48342. * Handles both dot-path and possible square brackets.
  48343. *
  48344. * Possible cases:
  48345. *
  48346. * - test
  48347. * - test[key]
  48348. * - test[test1[key]]
  48349. * - test["a"][key]
  48350. * - xxx.test[a[a].test1[key]]
  48351. * - test.xxx.a["asa"][test1[key]]
  48352. *
  48353. */
  48354. var len, str, chr, index$1, expressionPos, expressionEndPos;
  48355. function parseModel (val) {
  48356. // Fix https://github.com/vuejs/vue/pull/7730
  48357. // allow v-model="obj.val " (trailing whitespace)
  48358. val = val.trim();
  48359. len = val.length;
  48360. if (val.indexOf('[') < 0 || val.lastIndexOf(']') < len - 1) {
  48361. index$1 = val.lastIndexOf('.');
  48362. if (index$1 > -1) {
  48363. return {
  48364. exp: val.slice(0, index$1),
  48365. key: '"' + val.slice(index$1 + 1) + '"'
  48366. }
  48367. } else {
  48368. return {
  48369. exp: val,
  48370. key: null
  48371. }
  48372. }
  48373. }
  48374. str = val;
  48375. index$1 = expressionPos = expressionEndPos = 0;
  48376. while (!eof()) {
  48377. chr = next();
  48378. /* istanbul ignore if */
  48379. if (isStringStart(chr)) {
  48380. parseString(chr);
  48381. } else if (chr === 0x5B) {
  48382. parseBracket(chr);
  48383. }
  48384. }
  48385. return {
  48386. exp: val.slice(0, expressionPos),
  48387. key: val.slice(expressionPos + 1, expressionEndPos)
  48388. }
  48389. }
  48390. function next () {
  48391. return str.charCodeAt(++index$1)
  48392. }
  48393. function eof () {
  48394. return index$1 >= len
  48395. }
  48396. function isStringStart (chr) {
  48397. return chr === 0x22 || chr === 0x27
  48398. }
  48399. function parseBracket (chr) {
  48400. var inBracket = 1;
  48401. expressionPos = index$1;
  48402. while (!eof()) {
  48403. chr = next();
  48404. if (isStringStart(chr)) {
  48405. parseString(chr);
  48406. continue
  48407. }
  48408. if (chr === 0x5B) { inBracket++; }
  48409. if (chr === 0x5D) { inBracket--; }
  48410. if (inBracket === 0) {
  48411. expressionEndPos = index$1;
  48412. break
  48413. }
  48414. }
  48415. }
  48416. function parseString (chr) {
  48417. var stringQuote = chr;
  48418. while (!eof()) {
  48419. chr = next();
  48420. if (chr === stringQuote) {
  48421. break
  48422. }
  48423. }
  48424. }
  48425. /* */
  48426. var warn$1;
  48427. // in some cases, the event used has to be determined at runtime
  48428. // so we used some reserved tokens during compile.
  48429. var RANGE_TOKEN = '__r';
  48430. var CHECKBOX_RADIO_TOKEN = '__c';
  48431. function model (
  48432. el,
  48433. dir,
  48434. _warn
  48435. ) {
  48436. warn$1 = _warn;
  48437. var value = dir.value;
  48438. var modifiers = dir.modifiers;
  48439. var tag = el.tag;
  48440. var type = el.attrsMap.type;
  48441. {
  48442. // inputs with type="file" are read only and setting the input's
  48443. // value will throw an error.
  48444. if (tag === 'input' && type === 'file') {
  48445. warn$1(
  48446. "<" + (el.tag) + " v-model=\"" + value + "\" type=\"file\">:\n" +
  48447. "File inputs are read only. Use a v-on:change listener instead.",
  48448. el.rawAttrsMap['v-model']
  48449. );
  48450. }
  48451. }
  48452. if (el.component) {
  48453. genComponentModel(el, value, modifiers);
  48454. // component v-model doesn't need extra runtime
  48455. return false
  48456. } else if (tag === 'select') {
  48457. genSelect(el, value, modifiers);
  48458. } else if (tag === 'input' && type === 'checkbox') {
  48459. genCheckboxModel(el, value, modifiers);
  48460. } else if (tag === 'input' && type === 'radio') {
  48461. genRadioModel(el, value, modifiers);
  48462. } else if (tag === 'input' || tag === 'textarea') {
  48463. genDefaultModel(el, value, modifiers);
  48464. } else if (!config.isReservedTag(tag)) {
  48465. genComponentModel(el, value, modifiers);
  48466. // component v-model doesn't need extra runtime
  48467. return false
  48468. } else {
  48469. warn$1(
  48470. "<" + (el.tag) + " v-model=\"" + value + "\">: " +
  48471. "v-model is not supported on this element type. " +
  48472. 'If you are working with contenteditable, it\'s recommended to ' +
  48473. 'wrap a library dedicated for that purpose inside a custom component.',
  48474. el.rawAttrsMap['v-model']
  48475. );
  48476. }
  48477. // ensure runtime directive metadata
  48478. return true
  48479. }
  48480. function genCheckboxModel (
  48481. el,
  48482. value,
  48483. modifiers
  48484. ) {
  48485. var number = modifiers && modifiers.number;
  48486. var valueBinding = getBindingAttr(el, 'value') || 'null';
  48487. var trueValueBinding = getBindingAttr(el, 'true-value') || 'true';
  48488. var falseValueBinding = getBindingAttr(el, 'false-value') || 'false';
  48489. addProp(el, 'checked',
  48490. "Array.isArray(" + value + ")" +
  48491. "?_i(" + value + "," + valueBinding + ")>-1" + (
  48492. trueValueBinding === 'true'
  48493. ? (":(" + value + ")")
  48494. : (":_q(" + value + "," + trueValueBinding + ")")
  48495. )
  48496. );
  48497. addHandler(el, 'change',
  48498. "var $$a=" + value + "," +
  48499. '$$el=$event.target,' +
  48500. "$$c=$$el.checked?(" + trueValueBinding + "):(" + falseValueBinding + ");" +
  48501. 'if(Array.isArray($$a)){' +
  48502. "var $$v=" + (number ? '_n(' + valueBinding + ')' : valueBinding) + "," +
  48503. '$$i=_i($$a,$$v);' +
  48504. "if($$el.checked){$$i<0&&(" + (genAssignmentCode(value, '$$a.concat([$$v])')) + ")}" +
  48505. "else{$$i>-1&&(" + (genAssignmentCode(value, '$$a.slice(0,$$i).concat($$a.slice($$i+1))')) + ")}" +
  48506. "}else{" + (genAssignmentCode(value, '$$c')) + "}",
  48507. null, true
  48508. );
  48509. }
  48510. function genRadioModel (
  48511. el,
  48512. value,
  48513. modifiers
  48514. ) {
  48515. var number = modifiers && modifiers.number;
  48516. var valueBinding = getBindingAttr(el, 'value') || 'null';
  48517. valueBinding = number ? ("_n(" + valueBinding + ")") : valueBinding;
  48518. addProp(el, 'checked', ("_q(" + value + "," + valueBinding + ")"));
  48519. addHandler(el, 'change', genAssignmentCode(value, valueBinding), null, true);
  48520. }
  48521. function genSelect (
  48522. el,
  48523. value,
  48524. modifiers
  48525. ) {
  48526. var number = modifiers && modifiers.number;
  48527. var selectedVal = "Array.prototype.filter" +
  48528. ".call($event.target.options,function(o){return o.selected})" +
  48529. ".map(function(o){var val = \"_value\" in o ? o._value : o.value;" +
  48530. "return " + (number ? '_n(val)' : 'val') + "})";
  48531. var assignment = '$event.target.multiple ? $$selectedVal : $$selectedVal[0]';
  48532. var code = "var $$selectedVal = " + selectedVal + ";";
  48533. code = code + " " + (genAssignmentCode(value, assignment));
  48534. addHandler(el, 'change', code, null, true);
  48535. }
  48536. function genDefaultModel (
  48537. el,
  48538. value,
  48539. modifiers
  48540. ) {
  48541. var type = el.attrsMap.type;
  48542. // warn if v-bind:value conflicts with v-model
  48543. // except for inputs with v-bind:type
  48544. {
  48545. var value$1 = el.attrsMap['v-bind:value'] || el.attrsMap[':value'];
  48546. var typeBinding = el.attrsMap['v-bind:type'] || el.attrsMap[':type'];
  48547. if (value$1 && !typeBinding) {
  48548. var binding = el.attrsMap['v-bind:value'] ? 'v-bind:value' : ':value';
  48549. warn$1(
  48550. binding + "=\"" + value$1 + "\" conflicts with v-model on the same element " +
  48551. 'because the latter already expands to a value binding internally',
  48552. el.rawAttrsMap[binding]
  48553. );
  48554. }
  48555. }
  48556. var ref = modifiers || {};
  48557. var lazy = ref.lazy;
  48558. var number = ref.number;
  48559. var trim = ref.trim;
  48560. var needCompositionGuard = !lazy && type !== 'range';
  48561. var event = lazy
  48562. ? 'change'
  48563. : type === 'range'
  48564. ? RANGE_TOKEN
  48565. : 'input';
  48566. var valueExpression = '$event.target.value';
  48567. if (trim) {
  48568. valueExpression = "$event.target.value.trim()";
  48569. }
  48570. if (number) {
  48571. valueExpression = "_n(" + valueExpression + ")";
  48572. }
  48573. var code = genAssignmentCode(value, valueExpression);
  48574. if (needCompositionGuard) {
  48575. code = "if($event.target.composing)return;" + code;
  48576. }
  48577. addProp(el, 'value', ("(" + value + ")"));
  48578. addHandler(el, event, code, null, true);
  48579. if (trim || number) {
  48580. addHandler(el, 'blur', '$forceUpdate()');
  48581. }
  48582. }
  48583. /* */
  48584. // normalize v-model event tokens that can only be determined at runtime.
  48585. // it's important to place the event as the first in the array because
  48586. // the whole point is ensuring the v-model callback gets called before
  48587. // user-attached handlers.
  48588. function normalizeEvents (on) {
  48589. /* istanbul ignore if */
  48590. if (isDef(on[RANGE_TOKEN])) {
  48591. // IE input[type=range] only supports `change` event
  48592. var event = isIE ? 'change' : 'input';
  48593. on[event] = [].concat(on[RANGE_TOKEN], on[event] || []);
  48594. delete on[RANGE_TOKEN];
  48595. }
  48596. // This was originally intended to fix #4521 but no longer necessary
  48597. // after 2.5. Keeping it for backwards compat with generated code from < 2.4
  48598. /* istanbul ignore if */
  48599. if (isDef(on[CHECKBOX_RADIO_TOKEN])) {
  48600. on.change = [].concat(on[CHECKBOX_RADIO_TOKEN], on.change || []);
  48601. delete on[CHECKBOX_RADIO_TOKEN];
  48602. }
  48603. }
  48604. var target$1;
  48605. function createOnceHandler$1 (event, handler, capture) {
  48606. var _target = target$1; // save current target element in closure
  48607. return function onceHandler () {
  48608. var res = handler.apply(null, arguments);
  48609. if (res !== null) {
  48610. remove$2(event, onceHandler, capture, _target);
  48611. }
  48612. }
  48613. }
  48614. // #9446: Firefox <= 53 (in particular, ESR 52) has incorrect Event.timeStamp
  48615. // implementation and does not fire microtasks in between event propagation, so
  48616. // safe to exclude.
  48617. var useMicrotaskFix = isUsingMicroTask && !(isFF && Number(isFF[1]) <= 53);
  48618. function add$1 (
  48619. name,
  48620. handler,
  48621. capture,
  48622. passive
  48623. ) {
  48624. // async edge case #6566: inner click event triggers patch, event handler
  48625. // attached to outer element during patch, and triggered again. This
  48626. // happens because browsers fire microtask ticks between event propagation.
  48627. // the solution is simple: we save the timestamp when a handler is attached,
  48628. // and the handler would only fire if the event passed to it was fired
  48629. // AFTER it was attached.
  48630. if (useMicrotaskFix) {
  48631. var attachedTimestamp = currentFlushTimestamp;
  48632. var original = handler;
  48633. handler = original._wrapper = function (e) {
  48634. if (
  48635. // no bubbling, should always fire.
  48636. // this is just a safety net in case event.timeStamp is unreliable in
  48637. // certain weird environments...
  48638. e.target === e.currentTarget ||
  48639. // event is fired after handler attachment
  48640. e.timeStamp >= attachedTimestamp ||
  48641. // bail for environments that have buggy event.timeStamp implementations
  48642. // #9462 iOS 9 bug: event.timeStamp is 0 after history.pushState
  48643. // #9681 QtWebEngine event.timeStamp is negative value
  48644. e.timeStamp <= 0 ||
  48645. // #9448 bail if event is fired in another document in a multi-page
  48646. // electron/nw.js app, since event.timeStamp will be using a different
  48647. // starting reference
  48648. e.target.ownerDocument !== document
  48649. ) {
  48650. return original.apply(this, arguments)
  48651. }
  48652. };
  48653. }
  48654. target$1.addEventListener(
  48655. name,
  48656. handler,
  48657. supportsPassive
  48658. ? { capture: capture, passive: passive }
  48659. : capture
  48660. );
  48661. }
  48662. function remove$2 (
  48663. name,
  48664. handler,
  48665. capture,
  48666. _target
  48667. ) {
  48668. (_target || target$1).removeEventListener(
  48669. name,
  48670. handler._wrapper || handler,
  48671. capture
  48672. );
  48673. }
  48674. function updateDOMListeners (oldVnode, vnode) {
  48675. if (isUndef(oldVnode.data.on) && isUndef(vnode.data.on)) {
  48676. return
  48677. }
  48678. var on = vnode.data.on || {};
  48679. var oldOn = oldVnode.data.on || {};
  48680. target$1 = vnode.elm;
  48681. normalizeEvents(on);
  48682. updateListeners(on, oldOn, add$1, remove$2, createOnceHandler$1, vnode.context);
  48683. target$1 = undefined;
  48684. }
  48685. var events = {
  48686. create: updateDOMListeners,
  48687. update: updateDOMListeners
  48688. };
  48689. /* */
  48690. var svgContainer;
  48691. function updateDOMProps (oldVnode, vnode) {
  48692. if (isUndef(oldVnode.data.domProps) && isUndef(vnode.data.domProps)) {
  48693. return
  48694. }
  48695. var key, cur;
  48696. var elm = vnode.elm;
  48697. var oldProps = oldVnode.data.domProps || {};
  48698. var props = vnode.data.domProps || {};
  48699. // clone observed objects, as the user probably wants to mutate it
  48700. if (isDef(props.__ob__)) {
  48701. props = vnode.data.domProps = extend({}, props);
  48702. }
  48703. for (key in oldProps) {
  48704. if (!(key in props)) {
  48705. elm[key] = '';
  48706. }
  48707. }
  48708. for (key in props) {
  48709. cur = props[key];
  48710. // ignore children if the node has textContent or innerHTML,
  48711. // as these will throw away existing DOM nodes and cause removal errors
  48712. // on subsequent patches (#3360)
  48713. if (key === 'textContent' || key === 'innerHTML') {
  48714. if (vnode.children) { vnode.children.length = 0; }
  48715. if (cur === oldProps[key]) { continue }
  48716. // #6601 work around Chrome version <= 55 bug where single textNode
  48717. // replaced by innerHTML/textContent retains its parentNode property
  48718. if (elm.childNodes.length === 1) {
  48719. elm.removeChild(elm.childNodes[0]);
  48720. }
  48721. }
  48722. if (key === 'value' && elm.tagName !== 'PROGRESS') {
  48723. // store value as _value as well since
  48724. // non-string values will be stringified
  48725. elm._value = cur;
  48726. // avoid resetting cursor position when value is the same
  48727. var strCur = isUndef(cur) ? '' : String(cur);
  48728. if (shouldUpdateValue(elm, strCur)) {
  48729. elm.value = strCur;
  48730. }
  48731. } else if (key === 'innerHTML' && isSVG(elm.tagName) && isUndef(elm.innerHTML)) {
  48732. // IE doesn't support innerHTML for SVG elements
  48733. svgContainer = svgContainer || document.createElement('div');
  48734. svgContainer.innerHTML = "<svg>" + cur + "</svg>";
  48735. var svg = svgContainer.firstChild;
  48736. while (elm.firstChild) {
  48737. elm.removeChild(elm.firstChild);
  48738. }
  48739. while (svg.firstChild) {
  48740. elm.appendChild(svg.firstChild);
  48741. }
  48742. } else if (
  48743. // skip the update if old and new VDOM state is the same.
  48744. // `value` is handled separately because the DOM value may be temporarily
  48745. // out of sync with VDOM state due to focus, composition and modifiers.
  48746. // This #4521 by skipping the unnecesarry `checked` update.
  48747. cur !== oldProps[key]
  48748. ) {
  48749. // some property updates can throw
  48750. // e.g. `value` on <progress> w/ non-finite value
  48751. try {
  48752. elm[key] = cur;
  48753. } catch (e) {}
  48754. }
  48755. }
  48756. }
  48757. // check platforms/web/util/attrs.js acceptValue
  48758. function shouldUpdateValue (elm, checkVal) {
  48759. return (!elm.composing && (
  48760. elm.tagName === 'OPTION' ||
  48761. isNotInFocusAndDirty(elm, checkVal) ||
  48762. isDirtyWithModifiers(elm, checkVal)
  48763. ))
  48764. }
  48765. function isNotInFocusAndDirty (elm, checkVal) {
  48766. // return true when textbox (.number and .trim) loses focus and its value is
  48767. // not equal to the updated value
  48768. var notInFocus = true;
  48769. // #6157
  48770. // work around IE bug when accessing document.activeElement in an iframe
  48771. try { notInFocus = document.activeElement !== elm; } catch (e) {}
  48772. return notInFocus && elm.value !== checkVal
  48773. }
  48774. function isDirtyWithModifiers (elm, newVal) {
  48775. var value = elm.value;
  48776. var modifiers = elm._vModifiers; // injected by v-model runtime
  48777. if (isDef(modifiers)) {
  48778. if (modifiers.number) {
  48779. return toNumber(value) !== toNumber(newVal)
  48780. }
  48781. if (modifiers.trim) {
  48782. return value.trim() !== newVal.trim()
  48783. }
  48784. }
  48785. return value !== newVal
  48786. }
  48787. var domProps = {
  48788. create: updateDOMProps,
  48789. update: updateDOMProps
  48790. };
  48791. /* */
  48792. var parseStyleText = cached(function (cssText) {
  48793. var res = {};
  48794. var listDelimiter = /;(?![^(]*\))/g;
  48795. var propertyDelimiter = /:(.+)/;
  48796. cssText.split(listDelimiter).forEach(function (item) {
  48797. if (item) {
  48798. var tmp = item.split(propertyDelimiter);
  48799. tmp.length > 1 && (res[tmp[0].trim()] = tmp[1].trim());
  48800. }
  48801. });
  48802. return res
  48803. });
  48804. // merge static and dynamic style data on the same vnode
  48805. function normalizeStyleData (data) {
  48806. var style = normalizeStyleBinding(data.style);
  48807. // static style is pre-processed into an object during compilation
  48808. // and is always a fresh object, so it's safe to merge into it
  48809. return data.staticStyle
  48810. ? extend(data.staticStyle, style)
  48811. : style
  48812. }
  48813. // normalize possible array / string values into Object
  48814. function normalizeStyleBinding (bindingStyle) {
  48815. if (Array.isArray(bindingStyle)) {
  48816. return toObject(bindingStyle)
  48817. }
  48818. if (typeof bindingStyle === 'string') {
  48819. return parseStyleText(bindingStyle)
  48820. }
  48821. return bindingStyle
  48822. }
  48823. /**
  48824. * parent component style should be after child's
  48825. * so that parent component's style could override it
  48826. */
  48827. function getStyle (vnode, checkChild) {
  48828. var res = {};
  48829. var styleData;
  48830. if (checkChild) {
  48831. var childNode = vnode;
  48832. while (childNode.componentInstance) {
  48833. childNode = childNode.componentInstance._vnode;
  48834. if (
  48835. childNode && childNode.data &&
  48836. (styleData = normalizeStyleData(childNode.data))
  48837. ) {
  48838. extend(res, styleData);
  48839. }
  48840. }
  48841. }
  48842. if ((styleData = normalizeStyleData(vnode.data))) {
  48843. extend(res, styleData);
  48844. }
  48845. var parentNode = vnode;
  48846. while ((parentNode = parentNode.parent)) {
  48847. if (parentNode.data && (styleData = normalizeStyleData(parentNode.data))) {
  48848. extend(res, styleData);
  48849. }
  48850. }
  48851. return res
  48852. }
  48853. /* */
  48854. var cssVarRE = /^--/;
  48855. var importantRE = /\s*!important$/;
  48856. var setProp = function (el, name, val) {
  48857. /* istanbul ignore if */
  48858. if (cssVarRE.test(name)) {
  48859. el.style.setProperty(name, val);
  48860. } else if (importantRE.test(val)) {
  48861. el.style.setProperty(hyphenate(name), val.replace(importantRE, ''), 'important');
  48862. } else {
  48863. var normalizedName = normalize(name);
  48864. if (Array.isArray(val)) {
  48865. // Support values array created by autoprefixer, e.g.
  48866. // {display: ["-webkit-box", "-ms-flexbox", "flex"]}
  48867. // Set them one by one, and the browser will only set those it can recognize
  48868. for (var i = 0, len = val.length; i < len; i++) {
  48869. el.style[normalizedName] = val[i];
  48870. }
  48871. } else {
  48872. el.style[normalizedName] = val;
  48873. }
  48874. }
  48875. };
  48876. var vendorNames = ['Webkit', 'Moz', 'ms'];
  48877. var emptyStyle;
  48878. var normalize = cached(function (prop) {
  48879. emptyStyle = emptyStyle || document.createElement('div').style;
  48880. prop = camelize(prop);
  48881. if (prop !== 'filter' && (prop in emptyStyle)) {
  48882. return prop
  48883. }
  48884. var capName = prop.charAt(0).toUpperCase() + prop.slice(1);
  48885. for (var i = 0; i < vendorNames.length; i++) {
  48886. var name = vendorNames[i] + capName;
  48887. if (name in emptyStyle) {
  48888. return name
  48889. }
  48890. }
  48891. });
  48892. function updateStyle (oldVnode, vnode) {
  48893. var data = vnode.data;
  48894. var oldData = oldVnode.data;
  48895. if (isUndef(data.staticStyle) && isUndef(data.style) &&
  48896. isUndef(oldData.staticStyle) && isUndef(oldData.style)
  48897. ) {
  48898. return
  48899. }
  48900. var cur, name;
  48901. var el = vnode.elm;
  48902. var oldStaticStyle = oldData.staticStyle;
  48903. var oldStyleBinding = oldData.normalizedStyle || oldData.style || {};
  48904. // if static style exists, stylebinding already merged into it when doing normalizeStyleData
  48905. var oldStyle = oldStaticStyle || oldStyleBinding;
  48906. var style = normalizeStyleBinding(vnode.data.style) || {};
  48907. // store normalized style under a different key for next diff
  48908. // make sure to clone it if it's reactive, since the user likely wants
  48909. // to mutate it.
  48910. vnode.data.normalizedStyle = isDef(style.__ob__)
  48911. ? extend({}, style)
  48912. : style;
  48913. var newStyle = getStyle(vnode, true);
  48914. for (name in oldStyle) {
  48915. if (isUndef(newStyle[name])) {
  48916. setProp(el, name, '');
  48917. }
  48918. }
  48919. for (name in newStyle) {
  48920. cur = newStyle[name];
  48921. if (cur !== oldStyle[name]) {
  48922. // ie9 setting to null has no effect, must use empty string
  48923. setProp(el, name, cur == null ? '' : cur);
  48924. }
  48925. }
  48926. }
  48927. var style = {
  48928. create: updateStyle,
  48929. update: updateStyle
  48930. };
  48931. /* */
  48932. var whitespaceRE = /\s+/;
  48933. /**
  48934. * Add class with compatibility for SVG since classList is not supported on
  48935. * SVG elements in IE
  48936. */
  48937. function addClass (el, cls) {
  48938. /* istanbul ignore if */
  48939. if (!cls || !(cls = cls.trim())) {
  48940. return
  48941. }
  48942. /* istanbul ignore else */
  48943. if (el.classList) {
  48944. if (cls.indexOf(' ') > -1) {
  48945. cls.split(whitespaceRE).forEach(function (c) { return el.classList.add(c); });
  48946. } else {
  48947. el.classList.add(cls);
  48948. }
  48949. } else {
  48950. var cur = " " + (el.getAttribute('class') || '') + " ";
  48951. if (cur.indexOf(' ' + cls + ' ') < 0) {
  48952. el.setAttribute('class', (cur + cls).trim());
  48953. }
  48954. }
  48955. }
  48956. /**
  48957. * Remove class with compatibility for SVG since classList is not supported on
  48958. * SVG elements in IE
  48959. */
  48960. function removeClass (el, cls) {
  48961. /* istanbul ignore if */
  48962. if (!cls || !(cls = cls.trim())) {
  48963. return
  48964. }
  48965. /* istanbul ignore else */
  48966. if (el.classList) {
  48967. if (cls.indexOf(' ') > -1) {
  48968. cls.split(whitespaceRE).forEach(function (c) { return el.classList.remove(c); });
  48969. } else {
  48970. el.classList.remove(cls);
  48971. }
  48972. if (!el.classList.length) {
  48973. el.removeAttribute('class');
  48974. }
  48975. } else {
  48976. var cur = " " + (el.getAttribute('class') || '') + " ";
  48977. var tar = ' ' + cls + ' ';
  48978. while (cur.indexOf(tar) >= 0) {
  48979. cur = cur.replace(tar, ' ');
  48980. }
  48981. cur = cur.trim();
  48982. if (cur) {
  48983. el.setAttribute('class', cur);
  48984. } else {
  48985. el.removeAttribute('class');
  48986. }
  48987. }
  48988. }
  48989. /* */
  48990. function resolveTransition (def$$1) {
  48991. if (!def$$1) {
  48992. return
  48993. }
  48994. /* istanbul ignore else */
  48995. if (typeof def$$1 === 'object') {
  48996. var res = {};
  48997. if (def$$1.css !== false) {
  48998. extend(res, autoCssTransition(def$$1.name || 'v'));
  48999. }
  49000. extend(res, def$$1);
  49001. return res
  49002. } else if (typeof def$$1 === 'string') {
  49003. return autoCssTransition(def$$1)
  49004. }
  49005. }
  49006. var autoCssTransition = cached(function (name) {
  49007. return {
  49008. enterClass: (name + "-enter"),
  49009. enterToClass: (name + "-enter-to"),
  49010. enterActiveClass: (name + "-enter-active"),
  49011. leaveClass: (name + "-leave"),
  49012. leaveToClass: (name + "-leave-to"),
  49013. leaveActiveClass: (name + "-leave-active")
  49014. }
  49015. });
  49016. var hasTransition = inBrowser && !isIE9;
  49017. var TRANSITION = 'transition';
  49018. var ANIMATION = 'animation';
  49019. // Transition property/event sniffing
  49020. var transitionProp = 'transition';
  49021. var transitionEndEvent = 'transitionend';
  49022. var animationProp = 'animation';
  49023. var animationEndEvent = 'animationend';
  49024. if (hasTransition) {
  49025. /* istanbul ignore if */
  49026. if (window.ontransitionend === undefined &&
  49027. window.onwebkittransitionend !== undefined
  49028. ) {
  49029. transitionProp = 'WebkitTransition';
  49030. transitionEndEvent = 'webkitTransitionEnd';
  49031. }
  49032. if (window.onanimationend === undefined &&
  49033. window.onwebkitanimationend !== undefined
  49034. ) {
  49035. animationProp = 'WebkitAnimation';
  49036. animationEndEvent = 'webkitAnimationEnd';
  49037. }
  49038. }
  49039. // binding to window is necessary to make hot reload work in IE in strict mode
  49040. var raf = inBrowser
  49041. ? window.requestAnimationFrame
  49042. ? window.requestAnimationFrame.bind(window)
  49043. : setTimeout
  49044. : /* istanbul ignore next */ function (fn) { return fn(); };
  49045. function nextFrame (fn) {
  49046. raf(function () {
  49047. raf(fn);
  49048. });
  49049. }
  49050. function addTransitionClass (el, cls) {
  49051. var transitionClasses = el._transitionClasses || (el._transitionClasses = []);
  49052. if (transitionClasses.indexOf(cls) < 0) {
  49053. transitionClasses.push(cls);
  49054. addClass(el, cls);
  49055. }
  49056. }
  49057. function removeTransitionClass (el, cls) {
  49058. if (el._transitionClasses) {
  49059. remove(el._transitionClasses, cls);
  49060. }
  49061. removeClass(el, cls);
  49062. }
  49063. function whenTransitionEnds (
  49064. el,
  49065. expectedType,
  49066. cb
  49067. ) {
  49068. var ref = getTransitionInfo(el, expectedType);
  49069. var type = ref.type;
  49070. var timeout = ref.timeout;
  49071. var propCount = ref.propCount;
  49072. if (!type) { return cb() }
  49073. var event = type === TRANSITION ? transitionEndEvent : animationEndEvent;
  49074. var ended = 0;
  49075. var end = function () {
  49076. el.removeEventListener(event, onEnd);
  49077. cb();
  49078. };
  49079. var onEnd = function (e) {
  49080. if (e.target === el) {
  49081. if (++ended >= propCount) {
  49082. end();
  49083. }
  49084. }
  49085. };
  49086. setTimeout(function () {
  49087. if (ended < propCount) {
  49088. end();
  49089. }
  49090. }, timeout + 1);
  49091. el.addEventListener(event, onEnd);
  49092. }
  49093. var transformRE = /\b(transform|all)(,|$)/;
  49094. function getTransitionInfo (el, expectedType) {
  49095. var styles = window.getComputedStyle(el);
  49096. // JSDOM may return undefined for transition properties
  49097. var transitionDelays = (styles[transitionProp + 'Delay'] || '').split(', ');
  49098. var transitionDurations = (styles[transitionProp + 'Duration'] || '').split(', ');
  49099. var transitionTimeout = getTimeout(transitionDelays, transitionDurations);
  49100. var animationDelays = (styles[animationProp + 'Delay'] || '').split(', ');
  49101. var animationDurations = (styles[animationProp + 'Duration'] || '').split(', ');
  49102. var animationTimeout = getTimeout(animationDelays, animationDurations);
  49103. var type;
  49104. var timeout = 0;
  49105. var propCount = 0;
  49106. /* istanbul ignore if */
  49107. if (expectedType === TRANSITION) {
  49108. if (transitionTimeout > 0) {
  49109. type = TRANSITION;
  49110. timeout = transitionTimeout;
  49111. propCount = transitionDurations.length;
  49112. }
  49113. } else if (expectedType === ANIMATION) {
  49114. if (animationTimeout > 0) {
  49115. type = ANIMATION;
  49116. timeout = animationTimeout;
  49117. propCount = animationDurations.length;
  49118. }
  49119. } else {
  49120. timeout = Math.max(transitionTimeout, animationTimeout);
  49121. type = timeout > 0
  49122. ? transitionTimeout > animationTimeout
  49123. ? TRANSITION
  49124. : ANIMATION
  49125. : null;
  49126. propCount = type
  49127. ? type === TRANSITION
  49128. ? transitionDurations.length
  49129. : animationDurations.length
  49130. : 0;
  49131. }
  49132. var hasTransform =
  49133. type === TRANSITION &&
  49134. transformRE.test(styles[transitionProp + 'Property']);
  49135. return {
  49136. type: type,
  49137. timeout: timeout,
  49138. propCount: propCount,
  49139. hasTransform: hasTransform
  49140. }
  49141. }
  49142. function getTimeout (delays, durations) {
  49143. /* istanbul ignore next */
  49144. while (delays.length < durations.length) {
  49145. delays = delays.concat(delays);
  49146. }
  49147. return Math.max.apply(null, durations.map(function (d, i) {
  49148. return toMs(d) + toMs(delays[i])
  49149. }))
  49150. }
  49151. // Old versions of Chromium (below 61.0.3163.100) formats floating pointer numbers
  49152. // in a locale-dependent way, using a comma instead of a dot.
  49153. // If comma is not replaced with a dot, the input will be rounded down (i.e. acting
  49154. // as a floor function) causing unexpected behaviors
  49155. function toMs (s) {
  49156. return Number(s.slice(0, -1).replace(',', '.')) * 1000
  49157. }
  49158. /* */
  49159. function enter (vnode, toggleDisplay) {
  49160. var el = vnode.elm;
  49161. // call leave callback now
  49162. if (isDef(el._leaveCb)) {
  49163. el._leaveCb.cancelled = true;
  49164. el._leaveCb();
  49165. }
  49166. var data = resolveTransition(vnode.data.transition);
  49167. if (isUndef(data)) {
  49168. return
  49169. }
  49170. /* istanbul ignore if */
  49171. if (isDef(el._enterCb) || el.nodeType !== 1) {
  49172. return
  49173. }
  49174. var css = data.css;
  49175. var type = data.type;
  49176. var enterClass = data.enterClass;
  49177. var enterToClass = data.enterToClass;
  49178. var enterActiveClass = data.enterActiveClass;
  49179. var appearClass = data.appearClass;
  49180. var appearToClass = data.appearToClass;
  49181. var appearActiveClass = data.appearActiveClass;
  49182. var beforeEnter = data.beforeEnter;
  49183. var enter = data.enter;
  49184. var afterEnter = data.afterEnter;
  49185. var enterCancelled = data.enterCancelled;
  49186. var beforeAppear = data.beforeAppear;
  49187. var appear = data.appear;
  49188. var afterAppear = data.afterAppear;
  49189. var appearCancelled = data.appearCancelled;
  49190. var duration = data.duration;
  49191. // activeInstance will always be the <transition> component managing this
  49192. // transition. One edge case to check is when the <transition> is placed
  49193. // as the root node of a child component. In that case we need to check
  49194. // <transition>'s parent for appear check.
  49195. var context = activeInstance;
  49196. var transitionNode = activeInstance.$vnode;
  49197. while (transitionNode && transitionNode.parent) {
  49198. context = transitionNode.context;
  49199. transitionNode = transitionNode.parent;
  49200. }
  49201. var isAppear = !context._isMounted || !vnode.isRootInsert;
  49202. if (isAppear && !appear && appear !== '') {
  49203. return
  49204. }
  49205. var startClass = isAppear && appearClass
  49206. ? appearClass
  49207. : enterClass;
  49208. var activeClass = isAppear && appearActiveClass
  49209. ? appearActiveClass
  49210. : enterActiveClass;
  49211. var toClass = isAppear && appearToClass
  49212. ? appearToClass
  49213. : enterToClass;
  49214. var beforeEnterHook = isAppear
  49215. ? (beforeAppear || beforeEnter)
  49216. : beforeEnter;
  49217. var enterHook = isAppear
  49218. ? (typeof appear === 'function' ? appear : enter)
  49219. : enter;
  49220. var afterEnterHook = isAppear
  49221. ? (afterAppear || afterEnter)
  49222. : afterEnter;
  49223. var enterCancelledHook = isAppear
  49224. ? (appearCancelled || enterCancelled)
  49225. : enterCancelled;
  49226. var explicitEnterDuration = toNumber(
  49227. isObject(duration)
  49228. ? duration.enter
  49229. : duration
  49230. );
  49231. if (explicitEnterDuration != null) {
  49232. checkDuration(explicitEnterDuration, 'enter', vnode);
  49233. }
  49234. var expectsCSS = css !== false && !isIE9;
  49235. var userWantsControl = getHookArgumentsLength(enterHook);
  49236. var cb = el._enterCb = once(function () {
  49237. if (expectsCSS) {
  49238. removeTransitionClass(el, toClass);
  49239. removeTransitionClass(el, activeClass);
  49240. }
  49241. if (cb.cancelled) {
  49242. if (expectsCSS) {
  49243. removeTransitionClass(el, startClass);
  49244. }
  49245. enterCancelledHook && enterCancelledHook(el);
  49246. } else {
  49247. afterEnterHook && afterEnterHook(el);
  49248. }
  49249. el._enterCb = null;
  49250. });
  49251. if (!vnode.data.show) {
  49252. // remove pending leave element on enter by injecting an insert hook
  49253. mergeVNodeHook(vnode, 'insert', function () {
  49254. var parent = el.parentNode;
  49255. var pendingNode = parent && parent._pending && parent._pending[vnode.key];
  49256. if (pendingNode &&
  49257. pendingNode.tag === vnode.tag &&
  49258. pendingNode.elm._leaveCb
  49259. ) {
  49260. pendingNode.elm._leaveCb();
  49261. }
  49262. enterHook && enterHook(el, cb);
  49263. });
  49264. }
  49265. // start enter transition
  49266. beforeEnterHook && beforeEnterHook(el);
  49267. if (expectsCSS) {
  49268. addTransitionClass(el, startClass);
  49269. addTransitionClass(el, activeClass);
  49270. nextFrame(function () {
  49271. removeTransitionClass(el, startClass);
  49272. if (!cb.cancelled) {
  49273. addTransitionClass(el, toClass);
  49274. if (!userWantsControl) {
  49275. if (isValidDuration(explicitEnterDuration)) {
  49276. setTimeout(cb, explicitEnterDuration);
  49277. } else {
  49278. whenTransitionEnds(el, type, cb);
  49279. }
  49280. }
  49281. }
  49282. });
  49283. }
  49284. if (vnode.data.show) {
  49285. toggleDisplay && toggleDisplay();
  49286. enterHook && enterHook(el, cb);
  49287. }
  49288. if (!expectsCSS && !userWantsControl) {
  49289. cb();
  49290. }
  49291. }
  49292. function leave (vnode, rm) {
  49293. var el = vnode.elm;
  49294. // call enter callback now
  49295. if (isDef(el._enterCb)) {
  49296. el._enterCb.cancelled = true;
  49297. el._enterCb();
  49298. }
  49299. var data = resolveTransition(vnode.data.transition);
  49300. if (isUndef(data) || el.nodeType !== 1) {
  49301. return rm()
  49302. }
  49303. /* istanbul ignore if */
  49304. if (isDef(el._leaveCb)) {
  49305. return
  49306. }
  49307. var css = data.css;
  49308. var type = data.type;
  49309. var leaveClass = data.leaveClass;
  49310. var leaveToClass = data.leaveToClass;
  49311. var leaveActiveClass = data.leaveActiveClass;
  49312. var beforeLeave = data.beforeLeave;
  49313. var leave = data.leave;
  49314. var afterLeave = data.afterLeave;
  49315. var leaveCancelled = data.leaveCancelled;
  49316. var delayLeave = data.delayLeave;
  49317. var duration = data.duration;
  49318. var expectsCSS = css !== false && !isIE9;
  49319. var userWantsControl = getHookArgumentsLength(leave);
  49320. var explicitLeaveDuration = toNumber(
  49321. isObject(duration)
  49322. ? duration.leave
  49323. : duration
  49324. );
  49325. if (isDef(explicitLeaveDuration)) {
  49326. checkDuration(explicitLeaveDuration, 'leave', vnode);
  49327. }
  49328. var cb = el._leaveCb = once(function () {
  49329. if (el.parentNode && el.parentNode._pending) {
  49330. el.parentNode._pending[vnode.key] = null;
  49331. }
  49332. if (expectsCSS) {
  49333. removeTransitionClass(el, leaveToClass);
  49334. removeTransitionClass(el, leaveActiveClass);
  49335. }
  49336. if (cb.cancelled) {
  49337. if (expectsCSS) {
  49338. removeTransitionClass(el, leaveClass);
  49339. }
  49340. leaveCancelled && leaveCancelled(el);
  49341. } else {
  49342. rm();
  49343. afterLeave && afterLeave(el);
  49344. }
  49345. el._leaveCb = null;
  49346. });
  49347. if (delayLeave) {
  49348. delayLeave(performLeave);
  49349. } else {
  49350. performLeave();
  49351. }
  49352. function performLeave () {
  49353. // the delayed leave may have already been cancelled
  49354. if (cb.cancelled) {
  49355. return
  49356. }
  49357. // record leaving element
  49358. if (!vnode.data.show && el.parentNode) {
  49359. (el.parentNode._pending || (el.parentNode._pending = {}))[(vnode.key)] = vnode;
  49360. }
  49361. beforeLeave && beforeLeave(el);
  49362. if (expectsCSS) {
  49363. addTransitionClass(el, leaveClass);
  49364. addTransitionClass(el, leaveActiveClass);
  49365. nextFrame(function () {
  49366. removeTransitionClass(el, leaveClass);
  49367. if (!cb.cancelled) {
  49368. addTransitionClass(el, leaveToClass);
  49369. if (!userWantsControl) {
  49370. if (isValidDuration(explicitLeaveDuration)) {
  49371. setTimeout(cb, explicitLeaveDuration);
  49372. } else {
  49373. whenTransitionEnds(el, type, cb);
  49374. }
  49375. }
  49376. }
  49377. });
  49378. }
  49379. leave && leave(el, cb);
  49380. if (!expectsCSS && !userWantsControl) {
  49381. cb();
  49382. }
  49383. }
  49384. }
  49385. // only used in dev mode
  49386. function checkDuration (val, name, vnode) {
  49387. if (typeof val !== 'number') {
  49388. warn(
  49389. "<transition> explicit " + name + " duration is not a valid number - " +
  49390. "got " + (JSON.stringify(val)) + ".",
  49391. vnode.context
  49392. );
  49393. } else if (isNaN(val)) {
  49394. warn(
  49395. "<transition> explicit " + name + " duration is NaN - " +
  49396. 'the duration expression might be incorrect.',
  49397. vnode.context
  49398. );
  49399. }
  49400. }
  49401. function isValidDuration (val) {
  49402. return typeof val === 'number' && !isNaN(val)
  49403. }
  49404. /**
  49405. * Normalize a transition hook's argument length. The hook may be:
  49406. * - a merged hook (invoker) with the original in .fns
  49407. * - a wrapped component method (check ._length)
  49408. * - a plain function (.length)
  49409. */
  49410. function getHookArgumentsLength (fn) {
  49411. if (isUndef(fn)) {
  49412. return false
  49413. }
  49414. var invokerFns = fn.fns;
  49415. if (isDef(invokerFns)) {
  49416. // invoker
  49417. return getHookArgumentsLength(
  49418. Array.isArray(invokerFns)
  49419. ? invokerFns[0]
  49420. : invokerFns
  49421. )
  49422. } else {
  49423. return (fn._length || fn.length) > 1
  49424. }
  49425. }
  49426. function _enter (_, vnode) {
  49427. if (vnode.data.show !== true) {
  49428. enter(vnode);
  49429. }
  49430. }
  49431. var transition = inBrowser ? {
  49432. create: _enter,
  49433. activate: _enter,
  49434. remove: function remove$$1 (vnode, rm) {
  49435. /* istanbul ignore else */
  49436. if (vnode.data.show !== true) {
  49437. leave(vnode, rm);
  49438. } else {
  49439. rm();
  49440. }
  49441. }
  49442. } : {};
  49443. var platformModules = [
  49444. attrs,
  49445. klass,
  49446. events,
  49447. domProps,
  49448. style,
  49449. transition
  49450. ];
  49451. /* */
  49452. // the directive module should be applied last, after all
  49453. // built-in modules have been applied.
  49454. var modules = platformModules.concat(baseModules);
  49455. var patch = createPatchFunction({ nodeOps: nodeOps, modules: modules });
  49456. /**
  49457. * Not type checking this file because flow doesn't like attaching
  49458. * properties to Elements.
  49459. */
  49460. /* istanbul ignore if */
  49461. if (isIE9) {
  49462. // http://www.matts411.com/post/internet-explorer-9-oninput/
  49463. document.addEventListener('selectionchange', function () {
  49464. var el = document.activeElement;
  49465. if (el && el.vmodel) {
  49466. trigger(el, 'input');
  49467. }
  49468. });
  49469. }
  49470. var directive = {
  49471. inserted: function inserted (el, binding, vnode, oldVnode) {
  49472. if (vnode.tag === 'select') {
  49473. // #6903
  49474. if (oldVnode.elm && !oldVnode.elm._vOptions) {
  49475. mergeVNodeHook(vnode, 'postpatch', function () {
  49476. directive.componentUpdated(el, binding, vnode);
  49477. });
  49478. } else {
  49479. setSelected(el, binding, vnode.context);
  49480. }
  49481. el._vOptions = [].map.call(el.options, getValue);
  49482. } else if (vnode.tag === 'textarea' || isTextInputType(el.type)) {
  49483. el._vModifiers = binding.modifiers;
  49484. if (!binding.modifiers.lazy) {
  49485. el.addEventListener('compositionstart', onCompositionStart);
  49486. el.addEventListener('compositionend', onCompositionEnd);
  49487. // Safari < 10.2 & UIWebView doesn't fire compositionend when
  49488. // switching focus before confirming composition choice
  49489. // this also fixes the issue where some browsers e.g. iOS Chrome
  49490. // fires "change" instead of "input" on autocomplete.
  49491. el.addEventListener('change', onCompositionEnd);
  49492. /* istanbul ignore if */
  49493. if (isIE9) {
  49494. el.vmodel = true;
  49495. }
  49496. }
  49497. }
  49498. },
  49499. componentUpdated: function componentUpdated (el, binding, vnode) {
  49500. if (vnode.tag === 'select') {
  49501. setSelected(el, binding, vnode.context);
  49502. // in case the options rendered by v-for have changed,
  49503. // it's possible that the value is out-of-sync with the rendered options.
  49504. // detect such cases and filter out values that no longer has a matching
  49505. // option in the DOM.
  49506. var prevOptions = el._vOptions;
  49507. var curOptions = el._vOptions = [].map.call(el.options, getValue);
  49508. if (curOptions.some(function (o, i) { return !looseEqual(o, prevOptions[i]); })) {
  49509. // trigger change event if
  49510. // no matching option found for at least one value
  49511. var needReset = el.multiple
  49512. ? binding.value.some(function (v) { return hasNoMatchingOption(v, curOptions); })
  49513. : binding.value !== binding.oldValue && hasNoMatchingOption(binding.value, curOptions);
  49514. if (needReset) {
  49515. trigger(el, 'change');
  49516. }
  49517. }
  49518. }
  49519. }
  49520. };
  49521. function setSelected (el, binding, vm) {
  49522. actuallySetSelected(el, binding, vm);
  49523. /* istanbul ignore if */
  49524. if (isIE || isEdge) {
  49525. setTimeout(function () {
  49526. actuallySetSelected(el, binding, vm);
  49527. }, 0);
  49528. }
  49529. }
  49530. function actuallySetSelected (el, binding, vm) {
  49531. var value = binding.value;
  49532. var isMultiple = el.multiple;
  49533. if (isMultiple && !Array.isArray(value)) {
  49534. warn(
  49535. "<select multiple v-model=\"" + (binding.expression) + "\"> " +
  49536. "expects an Array value for its binding, but got " + (Object.prototype.toString.call(value).slice(8, -1)),
  49537. vm
  49538. );
  49539. return
  49540. }
  49541. var selected, option;
  49542. for (var i = 0, l = el.options.length; i < l; i++) {
  49543. option = el.options[i];
  49544. if (isMultiple) {
  49545. selected = looseIndexOf(value, getValue(option)) > -1;
  49546. if (option.selected !== selected) {
  49547. option.selected = selected;
  49548. }
  49549. } else {
  49550. if (looseEqual(getValue(option), value)) {
  49551. if (el.selectedIndex !== i) {
  49552. el.selectedIndex = i;
  49553. }
  49554. return
  49555. }
  49556. }
  49557. }
  49558. if (!isMultiple) {
  49559. el.selectedIndex = -1;
  49560. }
  49561. }
  49562. function hasNoMatchingOption (value, options) {
  49563. return options.every(function (o) { return !looseEqual(o, value); })
  49564. }
  49565. function getValue (option) {
  49566. return '_value' in option
  49567. ? option._value
  49568. : option.value
  49569. }
  49570. function onCompositionStart (e) {
  49571. e.target.composing = true;
  49572. }
  49573. function onCompositionEnd (e) {
  49574. // prevent triggering an input event for no reason
  49575. if (!e.target.composing) { return }
  49576. e.target.composing = false;
  49577. trigger(e.target, 'input');
  49578. }
  49579. function trigger (el, type) {
  49580. var e = document.createEvent('HTMLEvents');
  49581. e.initEvent(type, true, true);
  49582. el.dispatchEvent(e);
  49583. }
  49584. /* */
  49585. // recursively search for possible transition defined inside the component root
  49586. function locateNode (vnode) {
  49587. return vnode.componentInstance && (!vnode.data || !vnode.data.transition)
  49588. ? locateNode(vnode.componentInstance._vnode)
  49589. : vnode
  49590. }
  49591. var show = {
  49592. bind: function bind (el, ref, vnode) {
  49593. var value = ref.value;
  49594. vnode = locateNode(vnode);
  49595. var transition$$1 = vnode.data && vnode.data.transition;
  49596. var originalDisplay = el.__vOriginalDisplay =
  49597. el.style.display === 'none' ? '' : el.style.display;
  49598. if (value && transition$$1) {
  49599. vnode.data.show = true;
  49600. enter(vnode, function () {
  49601. el.style.display = originalDisplay;
  49602. });
  49603. } else {
  49604. el.style.display = value ? originalDisplay : 'none';
  49605. }
  49606. },
  49607. update: function update (el, ref, vnode) {
  49608. var value = ref.value;
  49609. var oldValue = ref.oldValue;
  49610. /* istanbul ignore if */
  49611. if (!value === !oldValue) { return }
  49612. vnode = locateNode(vnode);
  49613. var transition$$1 = vnode.data && vnode.data.transition;
  49614. if (transition$$1) {
  49615. vnode.data.show = true;
  49616. if (value) {
  49617. enter(vnode, function () {
  49618. el.style.display = el.__vOriginalDisplay;
  49619. });
  49620. } else {
  49621. leave(vnode, function () {
  49622. el.style.display = 'none';
  49623. });
  49624. }
  49625. } else {
  49626. el.style.display = value ? el.__vOriginalDisplay : 'none';
  49627. }
  49628. },
  49629. unbind: function unbind (
  49630. el,
  49631. binding,
  49632. vnode,
  49633. oldVnode,
  49634. isDestroy
  49635. ) {
  49636. if (!isDestroy) {
  49637. el.style.display = el.__vOriginalDisplay;
  49638. }
  49639. }
  49640. };
  49641. var platformDirectives = {
  49642. model: directive,
  49643. show: show
  49644. };
  49645. /* */
  49646. var transitionProps = {
  49647. name: String,
  49648. appear: Boolean,
  49649. css: Boolean,
  49650. mode: String,
  49651. type: String,
  49652. enterClass: String,
  49653. leaveClass: String,
  49654. enterToClass: String,
  49655. leaveToClass: String,
  49656. enterActiveClass: String,
  49657. leaveActiveClass: String,
  49658. appearClass: String,
  49659. appearActiveClass: String,
  49660. appearToClass: String,
  49661. duration: [Number, String, Object]
  49662. };
  49663. // in case the child is also an abstract component, e.g. <keep-alive>
  49664. // we want to recursively retrieve the real component to be rendered
  49665. function getRealChild (vnode) {
  49666. var compOptions = vnode && vnode.componentOptions;
  49667. if (compOptions && compOptions.Ctor.options.abstract) {
  49668. return getRealChild(getFirstComponentChild(compOptions.children))
  49669. } else {
  49670. return vnode
  49671. }
  49672. }
  49673. function extractTransitionData (comp) {
  49674. var data = {};
  49675. var options = comp.$options;
  49676. // props
  49677. for (var key in options.propsData) {
  49678. data[key] = comp[key];
  49679. }
  49680. // events.
  49681. // extract listeners and pass them directly to the transition methods
  49682. var listeners = options._parentListeners;
  49683. for (var key$1 in listeners) {
  49684. data[camelize(key$1)] = listeners[key$1];
  49685. }
  49686. return data
  49687. }
  49688. function placeholder (h, rawChild) {
  49689. if (/\d-keep-alive$/.test(rawChild.tag)) {
  49690. return h('keep-alive', {
  49691. props: rawChild.componentOptions.propsData
  49692. })
  49693. }
  49694. }
  49695. function hasParentTransition (vnode) {
  49696. while ((vnode = vnode.parent)) {
  49697. if (vnode.data.transition) {
  49698. return true
  49699. }
  49700. }
  49701. }
  49702. function isSameChild (child, oldChild) {
  49703. return oldChild.key === child.key && oldChild.tag === child.tag
  49704. }
  49705. var isNotTextNode = function (c) { return c.tag || isAsyncPlaceholder(c); };
  49706. var isVShowDirective = function (d) { return d.name === 'show'; };
  49707. var Transition = {
  49708. name: 'transition',
  49709. props: transitionProps,
  49710. abstract: true,
  49711. render: function render (h) {
  49712. var this$1 = this;
  49713. var children = this.$slots.default;
  49714. if (!children) {
  49715. return
  49716. }
  49717. // filter out text nodes (possible whitespaces)
  49718. children = children.filter(isNotTextNode);
  49719. /* istanbul ignore if */
  49720. if (!children.length) {
  49721. return
  49722. }
  49723. // warn multiple elements
  49724. if (children.length > 1) {
  49725. warn(
  49726. '<transition> can only be used on a single element. Use ' +
  49727. '<transition-group> for lists.',
  49728. this.$parent
  49729. );
  49730. }
  49731. var mode = this.mode;
  49732. // warn invalid mode
  49733. if (mode && mode !== 'in-out' && mode !== 'out-in'
  49734. ) {
  49735. warn(
  49736. 'invalid <transition> mode: ' + mode,
  49737. this.$parent
  49738. );
  49739. }
  49740. var rawChild = children[0];
  49741. // if this is a component root node and the component's
  49742. // parent container node also has transition, skip.
  49743. if (hasParentTransition(this.$vnode)) {
  49744. return rawChild
  49745. }
  49746. // apply transition data to child
  49747. // use getRealChild() to ignore abstract components e.g. keep-alive
  49748. var child = getRealChild(rawChild);
  49749. /* istanbul ignore if */
  49750. if (!child) {
  49751. return rawChild
  49752. }
  49753. if (this._leaving) {
  49754. return placeholder(h, rawChild)
  49755. }
  49756. // ensure a key that is unique to the vnode type and to this transition
  49757. // component instance. This key will be used to remove pending leaving nodes
  49758. // during entering.
  49759. var id = "__transition-" + (this._uid) + "-";
  49760. child.key = child.key == null
  49761. ? child.isComment
  49762. ? id + 'comment'
  49763. : id + child.tag
  49764. : isPrimitive(child.key)
  49765. ? (String(child.key).indexOf(id) === 0 ? child.key : id + child.key)
  49766. : child.key;
  49767. var data = (child.data || (child.data = {})).transition = extractTransitionData(this);
  49768. var oldRawChild = this._vnode;
  49769. var oldChild = getRealChild(oldRawChild);
  49770. // mark v-show
  49771. // so that the transition module can hand over the control to the directive
  49772. if (child.data.directives && child.data.directives.some(isVShowDirective)) {
  49773. child.data.show = true;
  49774. }
  49775. if (
  49776. oldChild &&
  49777. oldChild.data &&
  49778. !isSameChild(child, oldChild) &&
  49779. !isAsyncPlaceholder(oldChild) &&
  49780. // #6687 component root is a comment node
  49781. !(oldChild.componentInstance && oldChild.componentInstance._vnode.isComment)
  49782. ) {
  49783. // replace old child transition data with fresh one
  49784. // important for dynamic transitions!
  49785. var oldData = oldChild.data.transition = extend({}, data);
  49786. // handle transition mode
  49787. if (mode === 'out-in') {
  49788. // return placeholder node and queue update when leave finishes
  49789. this._leaving = true;
  49790. mergeVNodeHook(oldData, 'afterLeave', function () {
  49791. this$1._leaving = false;
  49792. this$1.$forceUpdate();
  49793. });
  49794. return placeholder(h, rawChild)
  49795. } else if (mode === 'in-out') {
  49796. if (isAsyncPlaceholder(child)) {
  49797. return oldRawChild
  49798. }
  49799. var delayedLeave;
  49800. var performLeave = function () { delayedLeave(); };
  49801. mergeVNodeHook(data, 'afterEnter', performLeave);
  49802. mergeVNodeHook(data, 'enterCancelled', performLeave);
  49803. mergeVNodeHook(oldData, 'delayLeave', function (leave) { delayedLeave = leave; });
  49804. }
  49805. }
  49806. return rawChild
  49807. }
  49808. };
  49809. /* */
  49810. var props = extend({
  49811. tag: String,
  49812. moveClass: String
  49813. }, transitionProps);
  49814. delete props.mode;
  49815. var TransitionGroup = {
  49816. props: props,
  49817. beforeMount: function beforeMount () {
  49818. var this$1 = this;
  49819. var update = this._update;
  49820. this._update = function (vnode, hydrating) {
  49821. var restoreActiveInstance = setActiveInstance(this$1);
  49822. // force removing pass
  49823. this$1.__patch__(
  49824. this$1._vnode,
  49825. this$1.kept,
  49826. false, // hydrating
  49827. true // removeOnly (!important, avoids unnecessary moves)
  49828. );
  49829. this$1._vnode = this$1.kept;
  49830. restoreActiveInstance();
  49831. update.call(this$1, vnode, hydrating);
  49832. };
  49833. },
  49834. render: function render (h) {
  49835. var tag = this.tag || this.$vnode.data.tag || 'span';
  49836. var map = Object.create(null);
  49837. var prevChildren = this.prevChildren = this.children;
  49838. var rawChildren = this.$slots.default || [];
  49839. var children = this.children = [];
  49840. var transitionData = extractTransitionData(this);
  49841. for (var i = 0; i < rawChildren.length; i++) {
  49842. var c = rawChildren[i];
  49843. if (c.tag) {
  49844. if (c.key != null && String(c.key).indexOf('__vlist') !== 0) {
  49845. children.push(c);
  49846. map[c.key] = c
  49847. ;(c.data || (c.data = {})).transition = transitionData;
  49848. } else {
  49849. var opts = c.componentOptions;
  49850. var name = opts ? (opts.Ctor.options.name || opts.tag || '') : c.tag;
  49851. warn(("<transition-group> children must be keyed: <" + name + ">"));
  49852. }
  49853. }
  49854. }
  49855. if (prevChildren) {
  49856. var kept = [];
  49857. var removed = [];
  49858. for (var i$1 = 0; i$1 < prevChildren.length; i$1++) {
  49859. var c$1 = prevChildren[i$1];
  49860. c$1.data.transition = transitionData;
  49861. c$1.data.pos = c$1.elm.getBoundingClientRect();
  49862. if (map[c$1.key]) {
  49863. kept.push(c$1);
  49864. } else {
  49865. removed.push(c$1);
  49866. }
  49867. }
  49868. this.kept = h(tag, null, kept);
  49869. this.removed = removed;
  49870. }
  49871. return h(tag, null, children)
  49872. },
  49873. updated: function updated () {
  49874. var children = this.prevChildren;
  49875. var moveClass = this.moveClass || ((this.name || 'v') + '-move');
  49876. if (!children.length || !this.hasMove(children[0].elm, moveClass)) {
  49877. return
  49878. }
  49879. // we divide the work into three loops to avoid mixing DOM reads and writes
  49880. // in each iteration - which helps prevent layout thrashing.
  49881. children.forEach(callPendingCbs);
  49882. children.forEach(recordPosition);
  49883. children.forEach(applyTranslation);
  49884. // force reflow to put everything in position
  49885. // assign to this to avoid being removed in tree-shaking
  49886. // $flow-disable-line
  49887. this._reflow = document.body.offsetHeight;
  49888. children.forEach(function (c) {
  49889. if (c.data.moved) {
  49890. var el = c.elm;
  49891. var s = el.style;
  49892. addTransitionClass(el, moveClass);
  49893. s.transform = s.WebkitTransform = s.transitionDuration = '';
  49894. el.addEventListener(transitionEndEvent, el._moveCb = function cb (e) {
  49895. if (e && e.target !== el) {
  49896. return
  49897. }
  49898. if (!e || /transform$/.test(e.propertyName)) {
  49899. el.removeEventListener(transitionEndEvent, cb);
  49900. el._moveCb = null;
  49901. removeTransitionClass(el, moveClass);
  49902. }
  49903. });
  49904. }
  49905. });
  49906. },
  49907. methods: {
  49908. hasMove: function hasMove (el, moveClass) {
  49909. /* istanbul ignore if */
  49910. if (!hasTransition) {
  49911. return false
  49912. }
  49913. /* istanbul ignore if */
  49914. if (this._hasMove) {
  49915. return this._hasMove
  49916. }
  49917. // Detect whether an element with the move class applied has
  49918. // CSS transitions. Since the element may be inside an entering
  49919. // transition at this very moment, we make a clone of it and remove
  49920. // all other transition classes applied to ensure only the move class
  49921. // is applied.
  49922. var clone = el.cloneNode();
  49923. if (el._transitionClasses) {
  49924. el._transitionClasses.forEach(function (cls) { removeClass(clone, cls); });
  49925. }
  49926. addClass(clone, moveClass);
  49927. clone.style.display = 'none';
  49928. this.$el.appendChild(clone);
  49929. var info = getTransitionInfo(clone);
  49930. this.$el.removeChild(clone);
  49931. return (this._hasMove = info.hasTransform)
  49932. }
  49933. }
  49934. };
  49935. function callPendingCbs (c) {
  49936. /* istanbul ignore if */
  49937. if (c.elm._moveCb) {
  49938. c.elm._moveCb();
  49939. }
  49940. /* istanbul ignore if */
  49941. if (c.elm._enterCb) {
  49942. c.elm._enterCb();
  49943. }
  49944. }
  49945. function recordPosition (c) {
  49946. c.data.newPos = c.elm.getBoundingClientRect();
  49947. }
  49948. function applyTranslation (c) {
  49949. var oldPos = c.data.pos;
  49950. var newPos = c.data.newPos;
  49951. var dx = oldPos.left - newPos.left;
  49952. var dy = oldPos.top - newPos.top;
  49953. if (dx || dy) {
  49954. c.data.moved = true;
  49955. var s = c.elm.style;
  49956. s.transform = s.WebkitTransform = "translate(" + dx + "px," + dy + "px)";
  49957. s.transitionDuration = '0s';
  49958. }
  49959. }
  49960. var platformComponents = {
  49961. Transition: Transition,
  49962. TransitionGroup: TransitionGroup
  49963. };
  49964. /* */
  49965. // install platform specific utils
  49966. Vue.config.mustUseProp = mustUseProp;
  49967. Vue.config.isReservedTag = isReservedTag;
  49968. Vue.config.isReservedAttr = isReservedAttr;
  49969. Vue.config.getTagNamespace = getTagNamespace;
  49970. Vue.config.isUnknownElement = isUnknownElement;
  49971. // install platform runtime directives & components
  49972. extend(Vue.options.directives, platformDirectives);
  49973. extend(Vue.options.components, platformComponents);
  49974. // install platform patch function
  49975. Vue.prototype.__patch__ = inBrowser ? patch : noop;
  49976. // public mount method
  49977. Vue.prototype.$mount = function (
  49978. el,
  49979. hydrating
  49980. ) {
  49981. el = el && inBrowser ? query(el) : undefined;
  49982. return mountComponent(this, el, hydrating)
  49983. };
  49984. // devtools global hook
  49985. /* istanbul ignore next */
  49986. if (inBrowser) {
  49987. setTimeout(function () {
  49988. if (config.devtools) {
  49989. if (devtools) {
  49990. devtools.emit('init', Vue);
  49991. } else {
  49992. console[console.info ? 'info' : 'log'](
  49993. 'Download the Vue Devtools extension for a better development experience:\n' +
  49994. 'https://github.com/vuejs/vue-devtools'
  49995. );
  49996. }
  49997. }
  49998. if (config.productionTip !== false &&
  49999. typeof console !== 'undefined'
  50000. ) {
  50001. console[console.info ? 'info' : 'log'](
  50002. "You are running Vue in development mode.\n" +
  50003. "Make sure to turn on production mode when deploying for production.\n" +
  50004. "See more tips at https://vuejs.org/guide/deployment.html"
  50005. );
  50006. }
  50007. }, 0);
  50008. }
  50009. /* */
  50010. var defaultTagRE = /\{\{((?:.|\r?\n)+?)\}\}/g;
  50011. var regexEscapeRE = /[-.*+?^${}()|[\]\/\\]/g;
  50012. var buildRegex = cached(function (delimiters) {
  50013. var open = delimiters[0].replace(regexEscapeRE, '\\$&');
  50014. var close = delimiters[1].replace(regexEscapeRE, '\\$&');
  50015. return new RegExp(open + '((?:.|\\n)+?)' + close, 'g')
  50016. });
  50017. function parseText (
  50018. text,
  50019. delimiters
  50020. ) {
  50021. var tagRE = delimiters ? buildRegex(delimiters) : defaultTagRE;
  50022. if (!tagRE.test(text)) {
  50023. return
  50024. }
  50025. var tokens = [];
  50026. var rawTokens = [];
  50027. var lastIndex = tagRE.lastIndex = 0;
  50028. var match, index, tokenValue;
  50029. while ((match = tagRE.exec(text))) {
  50030. index = match.index;
  50031. // push text token
  50032. if (index > lastIndex) {
  50033. rawTokens.push(tokenValue = text.slice(lastIndex, index));
  50034. tokens.push(JSON.stringify(tokenValue));
  50035. }
  50036. // tag token
  50037. var exp = parseFilters(match[1].trim());
  50038. tokens.push(("_s(" + exp + ")"));
  50039. rawTokens.push({ '@binding': exp });
  50040. lastIndex = index + match[0].length;
  50041. }
  50042. if (lastIndex < text.length) {
  50043. rawTokens.push(tokenValue = text.slice(lastIndex));
  50044. tokens.push(JSON.stringify(tokenValue));
  50045. }
  50046. return {
  50047. expression: tokens.join('+'),
  50048. tokens: rawTokens
  50049. }
  50050. }
  50051. /* */
  50052. function transformNode (el, options) {
  50053. var warn = options.warn || baseWarn;
  50054. var staticClass = getAndRemoveAttr(el, 'class');
  50055. if (staticClass) {
  50056. var res = parseText(staticClass, options.delimiters);
  50057. if (res) {
  50058. warn(
  50059. "class=\"" + staticClass + "\": " +
  50060. 'Interpolation inside attributes has been removed. ' +
  50061. 'Use v-bind or the colon shorthand instead. For example, ' +
  50062. 'instead of <div class="{{ val }}">, use <div :class="val">.',
  50063. el.rawAttrsMap['class']
  50064. );
  50065. }
  50066. }
  50067. if (staticClass) {
  50068. el.staticClass = JSON.stringify(staticClass);
  50069. }
  50070. var classBinding = getBindingAttr(el, 'class', false /* getStatic */);
  50071. if (classBinding) {
  50072. el.classBinding = classBinding;
  50073. }
  50074. }
  50075. function genData (el) {
  50076. var data = '';
  50077. if (el.staticClass) {
  50078. data += "staticClass:" + (el.staticClass) + ",";
  50079. }
  50080. if (el.classBinding) {
  50081. data += "class:" + (el.classBinding) + ",";
  50082. }
  50083. return data
  50084. }
  50085. var klass$1 = {
  50086. staticKeys: ['staticClass'],
  50087. transformNode: transformNode,
  50088. genData: genData
  50089. };
  50090. /* */
  50091. function transformNode$1 (el, options) {
  50092. var warn = options.warn || baseWarn;
  50093. var staticStyle = getAndRemoveAttr(el, 'style');
  50094. if (staticStyle) {
  50095. /* istanbul ignore if */
  50096. {
  50097. var res = parseText(staticStyle, options.delimiters);
  50098. if (res) {
  50099. warn(
  50100. "style=\"" + staticStyle + "\": " +
  50101. 'Interpolation inside attributes has been removed. ' +
  50102. 'Use v-bind or the colon shorthand instead. For example, ' +
  50103. 'instead of <div style="{{ val }}">, use <div :style="val">.',
  50104. el.rawAttrsMap['style']
  50105. );
  50106. }
  50107. }
  50108. el.staticStyle = JSON.stringify(parseStyleText(staticStyle));
  50109. }
  50110. var styleBinding = getBindingAttr(el, 'style', false /* getStatic */);
  50111. if (styleBinding) {
  50112. el.styleBinding = styleBinding;
  50113. }
  50114. }
  50115. function genData$1 (el) {
  50116. var data = '';
  50117. if (el.staticStyle) {
  50118. data += "staticStyle:" + (el.staticStyle) + ",";
  50119. }
  50120. if (el.styleBinding) {
  50121. data += "style:(" + (el.styleBinding) + "),";
  50122. }
  50123. return data
  50124. }
  50125. var style$1 = {
  50126. staticKeys: ['staticStyle'],
  50127. transformNode: transformNode$1,
  50128. genData: genData$1
  50129. };
  50130. /* */
  50131. var decoder;
  50132. var he = {
  50133. decode: function decode (html) {
  50134. decoder = decoder || document.createElement('div');
  50135. decoder.innerHTML = html;
  50136. return decoder.textContent
  50137. }
  50138. };
  50139. /* */
  50140. var isUnaryTag = makeMap(
  50141. 'area,base,br,col,embed,frame,hr,img,input,isindex,keygen,' +
  50142. 'link,meta,param,source,track,wbr'
  50143. );
  50144. // Elements that you can, intentionally, leave open
  50145. // (and which close themselves)
  50146. var canBeLeftOpenTag = makeMap(
  50147. 'colgroup,dd,dt,li,options,p,td,tfoot,th,thead,tr,source'
  50148. );
  50149. // HTML5 tags https://html.spec.whatwg.org/multipage/indices.html#elements-3
  50150. // Phrasing Content https://html.spec.whatwg.org/multipage/dom.html#phrasing-content
  50151. var isNonPhrasingTag = makeMap(
  50152. 'address,article,aside,base,blockquote,body,caption,col,colgroup,dd,' +
  50153. 'details,dialog,div,dl,dt,fieldset,figcaption,figure,footer,form,' +
  50154. 'h1,h2,h3,h4,h5,h6,head,header,hgroup,hr,html,legend,li,menuitem,meta,' +
  50155. 'optgroup,option,param,rp,rt,source,style,summary,tbody,td,tfoot,th,thead,' +
  50156. 'title,tr,track'
  50157. );
  50158. /**
  50159. * Not type-checking this file because it's mostly vendor code.
  50160. */
  50161. // Regular Expressions for parsing tags and attributes
  50162. var attribute = /^\s*([^\s"'<>\/=]+)(?:\s*(=)\s*(?:"([^"]*)"+|'([^']*)'+|([^\s"'=<>`]+)))?/;
  50163. var dynamicArgAttribute = /^\s*((?:v-[\w-]+:|@|:|#)\[[^=]+\][^\s"'<>\/=]*)(?:\s*(=)\s*(?:"([^"]*)"+|'([^']*)'+|([^\s"'=<>`]+)))?/;
  50164. var ncname = "[a-zA-Z_][\\-\\.0-9_a-zA-Z" + (unicodeRegExp.source) + "]*";
  50165. var qnameCapture = "((?:" + ncname + "\\:)?" + ncname + ")";
  50166. var startTagOpen = new RegExp(("^<" + qnameCapture));
  50167. var startTagClose = /^\s*(\/?)>/;
  50168. var endTag = new RegExp(("^<\\/" + qnameCapture + "[^>]*>"));
  50169. var doctype = /^<!DOCTYPE [^>]+>/i;
  50170. // #7298: escape - to avoid being passed as HTML comment when inlined in page
  50171. var comment = /^<!\--/;
  50172. var conditionalComment = /^<!\[/;
  50173. // Special Elements (can contain anything)
  50174. var isPlainTextElement = makeMap('script,style,textarea', true);
  50175. var reCache = {};
  50176. var decodingMap = {
  50177. '&lt;': '<',
  50178. '&gt;': '>',
  50179. '&quot;': '"',
  50180. '&amp;': '&',
  50181. '&#10;': '\n',
  50182. '&#9;': '\t',
  50183. '&#39;': "'"
  50184. };
  50185. var encodedAttr = /&(?:lt|gt|quot|amp|#39);/g;
  50186. var encodedAttrWithNewLines = /&(?:lt|gt|quot|amp|#39|#10|#9);/g;
  50187. // #5992
  50188. var isIgnoreNewlineTag = makeMap('pre,textarea', true);
  50189. var shouldIgnoreFirstNewline = function (tag, html) { return tag && isIgnoreNewlineTag(tag) && html[0] === '\n'; };
  50190. function decodeAttr (value, shouldDecodeNewlines) {
  50191. var re = shouldDecodeNewlines ? encodedAttrWithNewLines : encodedAttr;
  50192. return value.replace(re, function (match) { return decodingMap[match]; })
  50193. }
  50194. function parseHTML (html, options) {
  50195. var stack = [];
  50196. var expectHTML = options.expectHTML;
  50197. var isUnaryTag$$1 = options.isUnaryTag || no;
  50198. var canBeLeftOpenTag$$1 = options.canBeLeftOpenTag || no;
  50199. var index = 0;
  50200. var last, lastTag;
  50201. while (html) {
  50202. last = html;
  50203. // Make sure we're not in a plaintext content element like script/style
  50204. if (!lastTag || !isPlainTextElement(lastTag)) {
  50205. var textEnd = html.indexOf('<');
  50206. if (textEnd === 0) {
  50207. // Comment:
  50208. if (comment.test(html)) {
  50209. var commentEnd = html.indexOf('-->');
  50210. if (commentEnd >= 0) {
  50211. if (options.shouldKeepComment) {
  50212. options.comment(html.substring(4, commentEnd), index, index + commentEnd + 3);
  50213. }
  50214. advance(commentEnd + 3);
  50215. continue
  50216. }
  50217. }
  50218. // http://en.wikipedia.org/wiki/Conditional_comment#Downlevel-revealed_conditional_comment
  50219. if (conditionalComment.test(html)) {
  50220. var conditionalEnd = html.indexOf(']>');
  50221. if (conditionalEnd >= 0) {
  50222. advance(conditionalEnd + 2);
  50223. continue
  50224. }
  50225. }
  50226. // Doctype:
  50227. var doctypeMatch = html.match(doctype);
  50228. if (doctypeMatch) {
  50229. advance(doctypeMatch[0].length);
  50230. continue
  50231. }
  50232. // End tag:
  50233. var endTagMatch = html.match(endTag);
  50234. if (endTagMatch) {
  50235. var curIndex = index;
  50236. advance(endTagMatch[0].length);
  50237. parseEndTag(endTagMatch[1], curIndex, index);
  50238. continue
  50239. }
  50240. // Start tag:
  50241. var startTagMatch = parseStartTag();
  50242. if (startTagMatch) {
  50243. handleStartTag(startTagMatch);
  50244. if (shouldIgnoreFirstNewline(startTagMatch.tagName, html)) {
  50245. advance(1);
  50246. }
  50247. continue
  50248. }
  50249. }
  50250. var text = (void 0), rest = (void 0), next = (void 0);
  50251. if (textEnd >= 0) {
  50252. rest = html.slice(textEnd);
  50253. while (
  50254. !endTag.test(rest) &&
  50255. !startTagOpen.test(rest) &&
  50256. !comment.test(rest) &&
  50257. !conditionalComment.test(rest)
  50258. ) {
  50259. // < in plain text, be forgiving and treat it as text
  50260. next = rest.indexOf('<', 1);
  50261. if (next < 0) { break }
  50262. textEnd += next;
  50263. rest = html.slice(textEnd);
  50264. }
  50265. text = html.substring(0, textEnd);
  50266. }
  50267. if (textEnd < 0) {
  50268. text = html;
  50269. }
  50270. if (text) {
  50271. advance(text.length);
  50272. }
  50273. if (options.chars && text) {
  50274. options.chars(text, index - text.length, index);
  50275. }
  50276. } else {
  50277. var endTagLength = 0;
  50278. var stackedTag = lastTag.toLowerCase();
  50279. var reStackedTag = reCache[stackedTag] || (reCache[stackedTag] = new RegExp('([\\s\\S]*?)(</' + stackedTag + '[^>]*>)', 'i'));
  50280. var rest$1 = html.replace(reStackedTag, function (all, text, endTag) {
  50281. endTagLength = endTag.length;
  50282. if (!isPlainTextElement(stackedTag) && stackedTag !== 'noscript') {
  50283. text = text
  50284. .replace(/<!\--([\s\S]*?)-->/g, '$1') // #7298
  50285. .replace(/<!\[CDATA\[([\s\S]*?)]]>/g, '$1');
  50286. }
  50287. if (shouldIgnoreFirstNewline(stackedTag, text)) {
  50288. text = text.slice(1);
  50289. }
  50290. if (options.chars) {
  50291. options.chars(text);
  50292. }
  50293. return ''
  50294. });
  50295. index += html.length - rest$1.length;
  50296. html = rest$1;
  50297. parseEndTag(stackedTag, index - endTagLength, index);
  50298. }
  50299. if (html === last) {
  50300. options.chars && options.chars(html);
  50301. if (!stack.length && options.warn) {
  50302. options.warn(("Mal-formatted tag at end of template: \"" + html + "\""), { start: index + html.length });
  50303. }
  50304. break
  50305. }
  50306. }
  50307. // Clean up any remaining tags
  50308. parseEndTag();
  50309. function advance (n) {
  50310. index += n;
  50311. html = html.substring(n);
  50312. }
  50313. function parseStartTag () {
  50314. var start = html.match(startTagOpen);
  50315. if (start) {
  50316. var match = {
  50317. tagName: start[1],
  50318. attrs: [],
  50319. start: index
  50320. };
  50321. advance(start[0].length);
  50322. var end, attr;
  50323. while (!(end = html.match(startTagClose)) && (attr = html.match(dynamicArgAttribute) || html.match(attribute))) {
  50324. attr.start = index;
  50325. advance(attr[0].length);
  50326. attr.end = index;
  50327. match.attrs.push(attr);
  50328. }
  50329. if (end) {
  50330. match.unarySlash = end[1];
  50331. advance(end[0].length);
  50332. match.end = index;
  50333. return match
  50334. }
  50335. }
  50336. }
  50337. function handleStartTag (match) {
  50338. var tagName = match.tagName;
  50339. var unarySlash = match.unarySlash;
  50340. if (expectHTML) {
  50341. if (lastTag === 'p' && isNonPhrasingTag(tagName)) {
  50342. parseEndTag(lastTag);
  50343. }
  50344. if (canBeLeftOpenTag$$1(tagName) && lastTag === tagName) {
  50345. parseEndTag(tagName);
  50346. }
  50347. }
  50348. var unary = isUnaryTag$$1(tagName) || !!unarySlash;
  50349. var l = match.attrs.length;
  50350. var attrs = new Array(l);
  50351. for (var i = 0; i < l; i++) {
  50352. var args = match.attrs[i];
  50353. var value = args[3] || args[4] || args[5] || '';
  50354. var shouldDecodeNewlines = tagName === 'a' && args[1] === 'href'
  50355. ? options.shouldDecodeNewlinesForHref
  50356. : options.shouldDecodeNewlines;
  50357. attrs[i] = {
  50358. name: args[1],
  50359. value: decodeAttr(value, shouldDecodeNewlines)
  50360. };
  50361. if (options.outputSourceRange) {
  50362. attrs[i].start = args.start + args[0].match(/^\s*/).length;
  50363. attrs[i].end = args.end;
  50364. }
  50365. }
  50366. if (!unary) {
  50367. stack.push({ tag: tagName, lowerCasedTag: tagName.toLowerCase(), attrs: attrs, start: match.start, end: match.end });
  50368. lastTag = tagName;
  50369. }
  50370. if (options.start) {
  50371. options.start(tagName, attrs, unary, match.start, match.end);
  50372. }
  50373. }
  50374. function parseEndTag (tagName, start, end) {
  50375. var pos, lowerCasedTagName;
  50376. if (start == null) { start = index; }
  50377. if (end == null) { end = index; }
  50378. // Find the closest opened tag of the same type
  50379. if (tagName) {
  50380. lowerCasedTagName = tagName.toLowerCase();
  50381. for (pos = stack.length - 1; pos >= 0; pos--) {
  50382. if (stack[pos].lowerCasedTag === lowerCasedTagName) {
  50383. break
  50384. }
  50385. }
  50386. } else {
  50387. // If no tag name is provided, clean shop
  50388. pos = 0;
  50389. }
  50390. if (pos >= 0) {
  50391. // Close all the open elements, up the stack
  50392. for (var i = stack.length - 1; i >= pos; i--) {
  50393. if (i > pos || !tagName &&
  50394. options.warn
  50395. ) {
  50396. options.warn(
  50397. ("tag <" + (stack[i].tag) + "> has no matching end tag."),
  50398. { start: stack[i].start, end: stack[i].end }
  50399. );
  50400. }
  50401. if (options.end) {
  50402. options.end(stack[i].tag, start, end);
  50403. }
  50404. }
  50405. // Remove the open elements from the stack
  50406. stack.length = pos;
  50407. lastTag = pos && stack[pos - 1].tag;
  50408. } else if (lowerCasedTagName === 'br') {
  50409. if (options.start) {
  50410. options.start(tagName, [], true, start, end);
  50411. }
  50412. } else if (lowerCasedTagName === 'p') {
  50413. if (options.start) {
  50414. options.start(tagName, [], false, start, end);
  50415. }
  50416. if (options.end) {
  50417. options.end(tagName, start, end);
  50418. }
  50419. }
  50420. }
  50421. }
  50422. /* */
  50423. var onRE = /^@|^v-on:/;
  50424. var dirRE = /^v-|^@|^:|^#/;
  50425. var forAliasRE = /([\s\S]*?)\s+(?:in|of)\s+([\s\S]*)/;
  50426. var forIteratorRE = /,([^,\}\]]*)(?:,([^,\}\]]*))?$/;
  50427. var stripParensRE = /^\(|\)$/g;
  50428. var dynamicArgRE = /^\[.*\]$/;
  50429. var argRE = /:(.*)$/;
  50430. var bindRE = /^:|^\.|^v-bind:/;
  50431. var modifierRE = /\.[^.\]]+(?=[^\]]*$)/g;
  50432. var slotRE = /^v-slot(:|$)|^#/;
  50433. var lineBreakRE = /[\r\n]/;
  50434. var whitespaceRE$1 = /\s+/g;
  50435. var invalidAttributeRE = /[\s"'<>\/=]/;
  50436. var decodeHTMLCached = cached(he.decode);
  50437. var emptySlotScopeToken = "_empty_";
  50438. // configurable state
  50439. var warn$2;
  50440. var delimiters;
  50441. var transforms;
  50442. var preTransforms;
  50443. var postTransforms;
  50444. var platformIsPreTag;
  50445. var platformMustUseProp;
  50446. var platformGetTagNamespace;
  50447. var maybeComponent;
  50448. function createASTElement (
  50449. tag,
  50450. attrs,
  50451. parent
  50452. ) {
  50453. return {
  50454. type: 1,
  50455. tag: tag,
  50456. attrsList: attrs,
  50457. attrsMap: makeAttrsMap(attrs),
  50458. rawAttrsMap: {},
  50459. parent: parent,
  50460. children: []
  50461. }
  50462. }
  50463. /**
  50464. * Convert HTML string to AST.
  50465. */
  50466. function parse (
  50467. template,
  50468. options
  50469. ) {
  50470. warn$2 = options.warn || baseWarn;
  50471. platformIsPreTag = options.isPreTag || no;
  50472. platformMustUseProp = options.mustUseProp || no;
  50473. platformGetTagNamespace = options.getTagNamespace || no;
  50474. var isReservedTag = options.isReservedTag || no;
  50475. maybeComponent = function (el) { return !!el.component || !isReservedTag(el.tag); };
  50476. transforms = pluckModuleFunction(options.modules, 'transformNode');
  50477. preTransforms = pluckModuleFunction(options.modules, 'preTransformNode');
  50478. postTransforms = pluckModuleFunction(options.modules, 'postTransformNode');
  50479. delimiters = options.delimiters;
  50480. var stack = [];
  50481. var preserveWhitespace = options.preserveWhitespace !== false;
  50482. var whitespaceOption = options.whitespace;
  50483. var root;
  50484. var currentParent;
  50485. var inVPre = false;
  50486. var inPre = false;
  50487. var warned = false;
  50488. function warnOnce (msg, range) {
  50489. if (!warned) {
  50490. warned = true;
  50491. warn$2(msg, range);
  50492. }
  50493. }
  50494. function closeElement (element) {
  50495. trimEndingWhitespace(element);
  50496. if (!inVPre && !element.processed) {
  50497. element = processElement(element, options);
  50498. }
  50499. // tree management
  50500. if (!stack.length && element !== root) {
  50501. // allow root elements with v-if, v-else-if and v-else
  50502. if (root.if && (element.elseif || element.else)) {
  50503. {
  50504. checkRootConstraints(element);
  50505. }
  50506. addIfCondition(root, {
  50507. exp: element.elseif,
  50508. block: element
  50509. });
  50510. } else {
  50511. warnOnce(
  50512. "Component template should contain exactly one root element. " +
  50513. "If you are using v-if on multiple elements, " +
  50514. "use v-else-if to chain them instead.",
  50515. { start: element.start }
  50516. );
  50517. }
  50518. }
  50519. if (currentParent && !element.forbidden) {
  50520. if (element.elseif || element.else) {
  50521. processIfConditions(element, currentParent);
  50522. } else {
  50523. if (element.slotScope) {
  50524. // scoped slot
  50525. // keep it in the children list so that v-else(-if) conditions can
  50526. // find it as the prev node.
  50527. var name = element.slotTarget || '"default"'
  50528. ;(currentParent.scopedSlots || (currentParent.scopedSlots = {}))[name] = element;
  50529. }
  50530. currentParent.children.push(element);
  50531. element.parent = currentParent;
  50532. }
  50533. }
  50534. // final children cleanup
  50535. // filter out scoped slots
  50536. element.children = element.children.filter(function (c) { return !(c).slotScope; });
  50537. // remove trailing whitespace node again
  50538. trimEndingWhitespace(element);
  50539. // check pre state
  50540. if (element.pre) {
  50541. inVPre = false;
  50542. }
  50543. if (platformIsPreTag(element.tag)) {
  50544. inPre = false;
  50545. }
  50546. // apply post-transforms
  50547. for (var i = 0; i < postTransforms.length; i++) {
  50548. postTransforms[i](element, options);
  50549. }
  50550. }
  50551. function trimEndingWhitespace (el) {
  50552. // remove trailing whitespace node
  50553. if (!inPre) {
  50554. var lastNode;
  50555. while (
  50556. (lastNode = el.children[el.children.length - 1]) &&
  50557. lastNode.type === 3 &&
  50558. lastNode.text === ' '
  50559. ) {
  50560. el.children.pop();
  50561. }
  50562. }
  50563. }
  50564. function checkRootConstraints (el) {
  50565. if (el.tag === 'slot' || el.tag === 'template') {
  50566. warnOnce(
  50567. "Cannot use <" + (el.tag) + "> as component root element because it may " +
  50568. 'contain multiple nodes.',
  50569. { start: el.start }
  50570. );
  50571. }
  50572. if (el.attrsMap.hasOwnProperty('v-for')) {
  50573. warnOnce(
  50574. 'Cannot use v-for on stateful component root element because ' +
  50575. 'it renders multiple elements.',
  50576. el.rawAttrsMap['v-for']
  50577. );
  50578. }
  50579. }
  50580. parseHTML(template, {
  50581. warn: warn$2,
  50582. expectHTML: options.expectHTML,
  50583. isUnaryTag: options.isUnaryTag,
  50584. canBeLeftOpenTag: options.canBeLeftOpenTag,
  50585. shouldDecodeNewlines: options.shouldDecodeNewlines,
  50586. shouldDecodeNewlinesForHref: options.shouldDecodeNewlinesForHref,
  50587. shouldKeepComment: options.comments,
  50588. outputSourceRange: options.outputSourceRange,
  50589. start: function start (tag, attrs, unary, start$1, end) {
  50590. // check namespace.
  50591. // inherit parent ns if there is one
  50592. var ns = (currentParent && currentParent.ns) || platformGetTagNamespace(tag);
  50593. // handle IE svg bug
  50594. /* istanbul ignore if */
  50595. if (isIE && ns === 'svg') {
  50596. attrs = guardIESVGBug(attrs);
  50597. }
  50598. var element = createASTElement(tag, attrs, currentParent);
  50599. if (ns) {
  50600. element.ns = ns;
  50601. }
  50602. {
  50603. if (options.outputSourceRange) {
  50604. element.start = start$1;
  50605. element.end = end;
  50606. element.rawAttrsMap = element.attrsList.reduce(function (cumulated, attr) {
  50607. cumulated[attr.name] = attr;
  50608. return cumulated
  50609. }, {});
  50610. }
  50611. attrs.forEach(function (attr) {
  50612. if (invalidAttributeRE.test(attr.name)) {
  50613. warn$2(
  50614. "Invalid dynamic argument expression: attribute names cannot contain " +
  50615. "spaces, quotes, <, >, / or =.",
  50616. {
  50617. start: attr.start + attr.name.indexOf("["),
  50618. end: attr.start + attr.name.length
  50619. }
  50620. );
  50621. }
  50622. });
  50623. }
  50624. if (isForbiddenTag(element) && !isServerRendering()) {
  50625. element.forbidden = true;
  50626. warn$2(
  50627. 'Templates should only be responsible for mapping the state to the ' +
  50628. 'UI. Avoid placing tags with side-effects in your templates, such as ' +
  50629. "<" + tag + ">" + ', as they will not be parsed.',
  50630. { start: element.start }
  50631. );
  50632. }
  50633. // apply pre-transforms
  50634. for (var i = 0; i < preTransforms.length; i++) {
  50635. element = preTransforms[i](element, options) || element;
  50636. }
  50637. if (!inVPre) {
  50638. processPre(element);
  50639. if (element.pre) {
  50640. inVPre = true;
  50641. }
  50642. }
  50643. if (platformIsPreTag(element.tag)) {
  50644. inPre = true;
  50645. }
  50646. if (inVPre) {
  50647. processRawAttrs(element);
  50648. } else if (!element.processed) {
  50649. // structural directives
  50650. processFor(element);
  50651. processIf(element);
  50652. processOnce(element);
  50653. }
  50654. if (!root) {
  50655. root = element;
  50656. {
  50657. checkRootConstraints(root);
  50658. }
  50659. }
  50660. if (!unary) {
  50661. currentParent = element;
  50662. stack.push(element);
  50663. } else {
  50664. closeElement(element);
  50665. }
  50666. },
  50667. end: function end (tag, start, end$1) {
  50668. var element = stack[stack.length - 1];
  50669. // pop stack
  50670. stack.length -= 1;
  50671. currentParent = stack[stack.length - 1];
  50672. if (options.outputSourceRange) {
  50673. element.end = end$1;
  50674. }
  50675. closeElement(element);
  50676. },
  50677. chars: function chars (text, start, end) {
  50678. if (!currentParent) {
  50679. {
  50680. if (text === template) {
  50681. warnOnce(
  50682. 'Component template requires a root element, rather than just text.',
  50683. { start: start }
  50684. );
  50685. } else if ((text = text.trim())) {
  50686. warnOnce(
  50687. ("text \"" + text + "\" outside root element will be ignored."),
  50688. { start: start }
  50689. );
  50690. }
  50691. }
  50692. return
  50693. }
  50694. // IE textarea placeholder bug
  50695. /* istanbul ignore if */
  50696. if (isIE &&
  50697. currentParent.tag === 'textarea' &&
  50698. currentParent.attrsMap.placeholder === text
  50699. ) {
  50700. return
  50701. }
  50702. var children = currentParent.children;
  50703. if (inPre || text.trim()) {
  50704. text = isTextTag(currentParent) ? text : decodeHTMLCached(text);
  50705. } else if (!children.length) {
  50706. // remove the whitespace-only node right after an opening tag
  50707. text = '';
  50708. } else if (whitespaceOption) {
  50709. if (whitespaceOption === 'condense') {
  50710. // in condense mode, remove the whitespace node if it contains
  50711. // line break, otherwise condense to a single space
  50712. text = lineBreakRE.test(text) ? '' : ' ';
  50713. } else {
  50714. text = ' ';
  50715. }
  50716. } else {
  50717. text = preserveWhitespace ? ' ' : '';
  50718. }
  50719. if (text) {
  50720. if (!inPre && whitespaceOption === 'condense') {
  50721. // condense consecutive whitespaces into single space
  50722. text = text.replace(whitespaceRE$1, ' ');
  50723. }
  50724. var res;
  50725. var child;
  50726. if (!inVPre && text !== ' ' && (res = parseText(text, delimiters))) {
  50727. child = {
  50728. type: 2,
  50729. expression: res.expression,
  50730. tokens: res.tokens,
  50731. text: text
  50732. };
  50733. } else if (text !== ' ' || !children.length || children[children.length - 1].text !== ' ') {
  50734. child = {
  50735. type: 3,
  50736. text: text
  50737. };
  50738. }
  50739. if (child) {
  50740. if (options.outputSourceRange) {
  50741. child.start = start;
  50742. child.end = end;
  50743. }
  50744. children.push(child);
  50745. }
  50746. }
  50747. },
  50748. comment: function comment (text, start, end) {
  50749. // adding anyting as a sibling to the root node is forbidden
  50750. // comments should still be allowed, but ignored
  50751. if (currentParent) {
  50752. var child = {
  50753. type: 3,
  50754. text: text,
  50755. isComment: true
  50756. };
  50757. if (options.outputSourceRange) {
  50758. child.start = start;
  50759. child.end = end;
  50760. }
  50761. currentParent.children.push(child);
  50762. }
  50763. }
  50764. });
  50765. return root
  50766. }
  50767. function processPre (el) {
  50768. if (getAndRemoveAttr(el, 'v-pre') != null) {
  50769. el.pre = true;
  50770. }
  50771. }
  50772. function processRawAttrs (el) {
  50773. var list = el.attrsList;
  50774. var len = list.length;
  50775. if (len) {
  50776. var attrs = el.attrs = new Array(len);
  50777. for (var i = 0; i < len; i++) {
  50778. attrs[i] = {
  50779. name: list[i].name,
  50780. value: JSON.stringify(list[i].value)
  50781. };
  50782. if (list[i].start != null) {
  50783. attrs[i].start = list[i].start;
  50784. attrs[i].end = list[i].end;
  50785. }
  50786. }
  50787. } else if (!el.pre) {
  50788. // non root node in pre blocks with no attributes
  50789. el.plain = true;
  50790. }
  50791. }
  50792. function processElement (
  50793. element,
  50794. options
  50795. ) {
  50796. processKey(element);
  50797. // determine whether this is a plain element after
  50798. // removing structural attributes
  50799. element.plain = (
  50800. !element.key &&
  50801. !element.scopedSlots &&
  50802. !element.attrsList.length
  50803. );
  50804. processRef(element);
  50805. processSlotContent(element);
  50806. processSlotOutlet(element);
  50807. processComponent(element);
  50808. for (var i = 0; i < transforms.length; i++) {
  50809. element = transforms[i](element, options) || element;
  50810. }
  50811. processAttrs(element);
  50812. return element
  50813. }
  50814. function processKey (el) {
  50815. var exp = getBindingAttr(el, 'key');
  50816. if (exp) {
  50817. {
  50818. if (el.tag === 'template') {
  50819. warn$2(
  50820. "<template> cannot be keyed. Place the key on real elements instead.",
  50821. getRawBindingAttr(el, 'key')
  50822. );
  50823. }
  50824. if (el.for) {
  50825. var iterator = el.iterator2 || el.iterator1;
  50826. var parent = el.parent;
  50827. if (iterator && iterator === exp && parent && parent.tag === 'transition-group') {
  50828. warn$2(
  50829. "Do not use v-for index as key on <transition-group> children, " +
  50830. "this is the same as not using keys.",
  50831. getRawBindingAttr(el, 'key'),
  50832. true /* tip */
  50833. );
  50834. }
  50835. }
  50836. }
  50837. el.key = exp;
  50838. }
  50839. }
  50840. function processRef (el) {
  50841. var ref = getBindingAttr(el, 'ref');
  50842. if (ref) {
  50843. el.ref = ref;
  50844. el.refInFor = checkInFor(el);
  50845. }
  50846. }
  50847. function processFor (el) {
  50848. var exp;
  50849. if ((exp = getAndRemoveAttr(el, 'v-for'))) {
  50850. var res = parseFor(exp);
  50851. if (res) {
  50852. extend(el, res);
  50853. } else {
  50854. warn$2(
  50855. ("Invalid v-for expression: " + exp),
  50856. el.rawAttrsMap['v-for']
  50857. );
  50858. }
  50859. }
  50860. }
  50861. function parseFor (exp) {
  50862. var inMatch = exp.match(forAliasRE);
  50863. if (!inMatch) { return }
  50864. var res = {};
  50865. res.for = inMatch[2].trim();
  50866. var alias = inMatch[1].trim().replace(stripParensRE, '');
  50867. var iteratorMatch = alias.match(forIteratorRE);
  50868. if (iteratorMatch) {
  50869. res.alias = alias.replace(forIteratorRE, '').trim();
  50870. res.iterator1 = iteratorMatch[1].trim();
  50871. if (iteratorMatch[2]) {
  50872. res.iterator2 = iteratorMatch[2].trim();
  50873. }
  50874. } else {
  50875. res.alias = alias;
  50876. }
  50877. return res
  50878. }
  50879. function processIf (el) {
  50880. var exp = getAndRemoveAttr(el, 'v-if');
  50881. if (exp) {
  50882. el.if = exp;
  50883. addIfCondition(el, {
  50884. exp: exp,
  50885. block: el
  50886. });
  50887. } else {
  50888. if (getAndRemoveAttr(el, 'v-else') != null) {
  50889. el.else = true;
  50890. }
  50891. var elseif = getAndRemoveAttr(el, 'v-else-if');
  50892. if (elseif) {
  50893. el.elseif = elseif;
  50894. }
  50895. }
  50896. }
  50897. function processIfConditions (el, parent) {
  50898. var prev = findPrevElement(parent.children);
  50899. if (prev && prev.if) {
  50900. addIfCondition(prev, {
  50901. exp: el.elseif,
  50902. block: el
  50903. });
  50904. } else {
  50905. warn$2(
  50906. "v-" + (el.elseif ? ('else-if="' + el.elseif + '"') : 'else') + " " +
  50907. "used on element <" + (el.tag) + "> without corresponding v-if.",
  50908. el.rawAttrsMap[el.elseif ? 'v-else-if' : 'v-else']
  50909. );
  50910. }
  50911. }
  50912. function findPrevElement (children) {
  50913. var i = children.length;
  50914. while (i--) {
  50915. if (children[i].type === 1) {
  50916. return children[i]
  50917. } else {
  50918. if (children[i].text !== ' ') {
  50919. warn$2(
  50920. "text \"" + (children[i].text.trim()) + "\" between v-if and v-else(-if) " +
  50921. "will be ignored.",
  50922. children[i]
  50923. );
  50924. }
  50925. children.pop();
  50926. }
  50927. }
  50928. }
  50929. function addIfCondition (el, condition) {
  50930. if (!el.ifConditions) {
  50931. el.ifConditions = [];
  50932. }
  50933. el.ifConditions.push(condition);
  50934. }
  50935. function processOnce (el) {
  50936. var once$$1 = getAndRemoveAttr(el, 'v-once');
  50937. if (once$$1 != null) {
  50938. el.once = true;
  50939. }
  50940. }
  50941. // handle content being passed to a component as slot,
  50942. // e.g. <template slot="xxx">, <div slot-scope="xxx">
  50943. function processSlotContent (el) {
  50944. var slotScope;
  50945. if (el.tag === 'template') {
  50946. slotScope = getAndRemoveAttr(el, 'scope');
  50947. /* istanbul ignore if */
  50948. if (slotScope) {
  50949. warn$2(
  50950. "the \"scope\" attribute for scoped slots have been deprecated and " +
  50951. "replaced by \"slot-scope\" since 2.5. The new \"slot-scope\" attribute " +
  50952. "can also be used on plain elements in addition to <template> to " +
  50953. "denote scoped slots.",
  50954. el.rawAttrsMap['scope'],
  50955. true
  50956. );
  50957. }
  50958. el.slotScope = slotScope || getAndRemoveAttr(el, 'slot-scope');
  50959. } else if ((slotScope = getAndRemoveAttr(el, 'slot-scope'))) {
  50960. /* istanbul ignore if */
  50961. if (el.attrsMap['v-for']) {
  50962. warn$2(
  50963. "Ambiguous combined usage of slot-scope and v-for on <" + (el.tag) + "> " +
  50964. "(v-for takes higher priority). Use a wrapper <template> for the " +
  50965. "scoped slot to make it clearer.",
  50966. el.rawAttrsMap['slot-scope'],
  50967. true
  50968. );
  50969. }
  50970. el.slotScope = slotScope;
  50971. }
  50972. // slot="xxx"
  50973. var slotTarget = getBindingAttr(el, 'slot');
  50974. if (slotTarget) {
  50975. el.slotTarget = slotTarget === '""' ? '"default"' : slotTarget;
  50976. el.slotTargetDynamic = !!(el.attrsMap[':slot'] || el.attrsMap['v-bind:slot']);
  50977. // preserve slot as an attribute for native shadow DOM compat
  50978. // only for non-scoped slots.
  50979. if (el.tag !== 'template' && !el.slotScope) {
  50980. addAttr(el, 'slot', slotTarget, getRawBindingAttr(el, 'slot'));
  50981. }
  50982. }
  50983. // 2.6 v-slot syntax
  50984. {
  50985. if (el.tag === 'template') {
  50986. // v-slot on <template>
  50987. var slotBinding = getAndRemoveAttrByRegex(el, slotRE);
  50988. if (slotBinding) {
  50989. {
  50990. if (el.slotTarget || el.slotScope) {
  50991. warn$2(
  50992. "Unexpected mixed usage of different slot syntaxes.",
  50993. el
  50994. );
  50995. }
  50996. if (el.parent && !maybeComponent(el.parent)) {
  50997. warn$2(
  50998. "<template v-slot> can only appear at the root level inside " +
  50999. "the receiving component",
  51000. el
  51001. );
  51002. }
  51003. }
  51004. var ref = getSlotName(slotBinding);
  51005. var name = ref.name;
  51006. var dynamic = ref.dynamic;
  51007. el.slotTarget = name;
  51008. el.slotTargetDynamic = dynamic;
  51009. el.slotScope = slotBinding.value || emptySlotScopeToken; // force it into a scoped slot for perf
  51010. }
  51011. } else {
  51012. // v-slot on component, denotes default slot
  51013. var slotBinding$1 = getAndRemoveAttrByRegex(el, slotRE);
  51014. if (slotBinding$1) {
  51015. {
  51016. if (!maybeComponent(el)) {
  51017. warn$2(
  51018. "v-slot can only be used on components or <template>.",
  51019. slotBinding$1
  51020. );
  51021. }
  51022. if (el.slotScope || el.slotTarget) {
  51023. warn$2(
  51024. "Unexpected mixed usage of different slot syntaxes.",
  51025. el
  51026. );
  51027. }
  51028. if (el.scopedSlots) {
  51029. warn$2(
  51030. "To avoid scope ambiguity, the default slot should also use " +
  51031. "<template> syntax when there are other named slots.",
  51032. slotBinding$1
  51033. );
  51034. }
  51035. }
  51036. // add the component's children to its default slot
  51037. var slots = el.scopedSlots || (el.scopedSlots = {});
  51038. var ref$1 = getSlotName(slotBinding$1);
  51039. var name$1 = ref$1.name;
  51040. var dynamic$1 = ref$1.dynamic;
  51041. var slotContainer = slots[name$1] = createASTElement('template', [], el);
  51042. slotContainer.slotTarget = name$1;
  51043. slotContainer.slotTargetDynamic = dynamic$1;
  51044. slotContainer.children = el.children.filter(function (c) {
  51045. if (!c.slotScope) {
  51046. c.parent = slotContainer;
  51047. return true
  51048. }
  51049. });
  51050. slotContainer.slotScope = slotBinding$1.value || emptySlotScopeToken;
  51051. // remove children as they are returned from scopedSlots now
  51052. el.children = [];
  51053. // mark el non-plain so data gets generated
  51054. el.plain = false;
  51055. }
  51056. }
  51057. }
  51058. }
  51059. function getSlotName (binding) {
  51060. var name = binding.name.replace(slotRE, '');
  51061. if (!name) {
  51062. if (binding.name[0] !== '#') {
  51063. name = 'default';
  51064. } else {
  51065. warn$2(
  51066. "v-slot shorthand syntax requires a slot name.",
  51067. binding
  51068. );
  51069. }
  51070. }
  51071. return dynamicArgRE.test(name)
  51072. // dynamic [name]
  51073. ? { name: name.slice(1, -1), dynamic: true }
  51074. // static name
  51075. : { name: ("\"" + name + "\""), dynamic: false }
  51076. }
  51077. // handle <slot/> outlets
  51078. function processSlotOutlet (el) {
  51079. if (el.tag === 'slot') {
  51080. el.slotName = getBindingAttr(el, 'name');
  51081. if (el.key) {
  51082. warn$2(
  51083. "`key` does not work on <slot> because slots are abstract outlets " +
  51084. "and can possibly expand into multiple elements. " +
  51085. "Use the key on a wrapping element instead.",
  51086. getRawBindingAttr(el, 'key')
  51087. );
  51088. }
  51089. }
  51090. }
  51091. function processComponent (el) {
  51092. var binding;
  51093. if ((binding = getBindingAttr(el, 'is'))) {
  51094. el.component = binding;
  51095. }
  51096. if (getAndRemoveAttr(el, 'inline-template') != null) {
  51097. el.inlineTemplate = true;
  51098. }
  51099. }
  51100. function processAttrs (el) {
  51101. var list = el.attrsList;
  51102. var i, l, name, rawName, value, modifiers, syncGen, isDynamic;
  51103. for (i = 0, l = list.length; i < l; i++) {
  51104. name = rawName = list[i].name;
  51105. value = list[i].value;
  51106. if (dirRE.test(name)) {
  51107. // mark element as dynamic
  51108. el.hasBindings = true;
  51109. // modifiers
  51110. modifiers = parseModifiers(name.replace(dirRE, ''));
  51111. // support .foo shorthand syntax for the .prop modifier
  51112. if (modifiers) {
  51113. name = name.replace(modifierRE, '');
  51114. }
  51115. if (bindRE.test(name)) { // v-bind
  51116. name = name.replace(bindRE, '');
  51117. value = parseFilters(value);
  51118. isDynamic = dynamicArgRE.test(name);
  51119. if (isDynamic) {
  51120. name = name.slice(1, -1);
  51121. }
  51122. if (
  51123. value.trim().length === 0
  51124. ) {
  51125. warn$2(
  51126. ("The value for a v-bind expression cannot be empty. Found in \"v-bind:" + name + "\"")
  51127. );
  51128. }
  51129. if (modifiers) {
  51130. if (modifiers.prop && !isDynamic) {
  51131. name = camelize(name);
  51132. if (name === 'innerHtml') { name = 'innerHTML'; }
  51133. }
  51134. if (modifiers.camel && !isDynamic) {
  51135. name = camelize(name);
  51136. }
  51137. if (modifiers.sync) {
  51138. syncGen = genAssignmentCode(value, "$event");
  51139. if (!isDynamic) {
  51140. addHandler(
  51141. el,
  51142. ("update:" + (camelize(name))),
  51143. syncGen,
  51144. null,
  51145. false,
  51146. warn$2,
  51147. list[i]
  51148. );
  51149. if (hyphenate(name) !== camelize(name)) {
  51150. addHandler(
  51151. el,
  51152. ("update:" + (hyphenate(name))),
  51153. syncGen,
  51154. null,
  51155. false,
  51156. warn$2,
  51157. list[i]
  51158. );
  51159. }
  51160. } else {
  51161. // handler w/ dynamic event name
  51162. addHandler(
  51163. el,
  51164. ("\"update:\"+(" + name + ")"),
  51165. syncGen,
  51166. null,
  51167. false,
  51168. warn$2,
  51169. list[i],
  51170. true // dynamic
  51171. );
  51172. }
  51173. }
  51174. }
  51175. if ((modifiers && modifiers.prop) || (
  51176. !el.component && platformMustUseProp(el.tag, el.attrsMap.type, name)
  51177. )) {
  51178. addProp(el, name, value, list[i], isDynamic);
  51179. } else {
  51180. addAttr(el, name, value, list[i], isDynamic);
  51181. }
  51182. } else if (onRE.test(name)) { // v-on
  51183. name = name.replace(onRE, '');
  51184. isDynamic = dynamicArgRE.test(name);
  51185. if (isDynamic) {
  51186. name = name.slice(1, -1);
  51187. }
  51188. addHandler(el, name, value, modifiers, false, warn$2, list[i], isDynamic);
  51189. } else { // normal directives
  51190. name = name.replace(dirRE, '');
  51191. // parse arg
  51192. var argMatch = name.match(argRE);
  51193. var arg = argMatch && argMatch[1];
  51194. isDynamic = false;
  51195. if (arg) {
  51196. name = name.slice(0, -(arg.length + 1));
  51197. if (dynamicArgRE.test(arg)) {
  51198. arg = arg.slice(1, -1);
  51199. isDynamic = true;
  51200. }
  51201. }
  51202. addDirective(el, name, rawName, value, arg, isDynamic, modifiers, list[i]);
  51203. if (name === 'model') {
  51204. checkForAliasModel(el, value);
  51205. }
  51206. }
  51207. } else {
  51208. // literal attribute
  51209. {
  51210. var res = parseText(value, delimiters);
  51211. if (res) {
  51212. warn$2(
  51213. name + "=\"" + value + "\": " +
  51214. 'Interpolation inside attributes has been removed. ' +
  51215. 'Use v-bind or the colon shorthand instead. For example, ' +
  51216. 'instead of <div id="{{ val }}">, use <div :id="val">.',
  51217. list[i]
  51218. );
  51219. }
  51220. }
  51221. addAttr(el, name, JSON.stringify(value), list[i]);
  51222. // #6887 firefox doesn't update muted state if set via attribute
  51223. // even immediately after element creation
  51224. if (!el.component &&
  51225. name === 'muted' &&
  51226. platformMustUseProp(el.tag, el.attrsMap.type, name)) {
  51227. addProp(el, name, 'true', list[i]);
  51228. }
  51229. }
  51230. }
  51231. }
  51232. function checkInFor (el) {
  51233. var parent = el;
  51234. while (parent) {
  51235. if (parent.for !== undefined) {
  51236. return true
  51237. }
  51238. parent = parent.parent;
  51239. }
  51240. return false
  51241. }
  51242. function parseModifiers (name) {
  51243. var match = name.match(modifierRE);
  51244. if (match) {
  51245. var ret = {};
  51246. match.forEach(function (m) { ret[m.slice(1)] = true; });
  51247. return ret
  51248. }
  51249. }
  51250. function makeAttrsMap (attrs) {
  51251. var map = {};
  51252. for (var i = 0, l = attrs.length; i < l; i++) {
  51253. if (
  51254. map[attrs[i].name] && !isIE && !isEdge
  51255. ) {
  51256. warn$2('duplicate attribute: ' + attrs[i].name, attrs[i]);
  51257. }
  51258. map[attrs[i].name] = attrs[i].value;
  51259. }
  51260. return map
  51261. }
  51262. // for script (e.g. type="x/template") or style, do not decode content
  51263. function isTextTag (el) {
  51264. return el.tag === 'script' || el.tag === 'style'
  51265. }
  51266. function isForbiddenTag (el) {
  51267. return (
  51268. el.tag === 'style' ||
  51269. (el.tag === 'script' && (
  51270. !el.attrsMap.type ||
  51271. el.attrsMap.type === 'text/javascript'
  51272. ))
  51273. )
  51274. }
  51275. var ieNSBug = /^xmlns:NS\d+/;
  51276. var ieNSPrefix = /^NS\d+:/;
  51277. /* istanbul ignore next */
  51278. function guardIESVGBug (attrs) {
  51279. var res = [];
  51280. for (var i = 0; i < attrs.length; i++) {
  51281. var attr = attrs[i];
  51282. if (!ieNSBug.test(attr.name)) {
  51283. attr.name = attr.name.replace(ieNSPrefix, '');
  51284. res.push(attr);
  51285. }
  51286. }
  51287. return res
  51288. }
  51289. function checkForAliasModel (el, value) {
  51290. var _el = el;
  51291. while (_el) {
  51292. if (_el.for && _el.alias === value) {
  51293. warn$2(
  51294. "<" + (el.tag) + " v-model=\"" + value + "\">: " +
  51295. "You are binding v-model directly to a v-for iteration alias. " +
  51296. "This will not be able to modify the v-for source array because " +
  51297. "writing to the alias is like modifying a function local variable. " +
  51298. "Consider using an array of objects and use v-model on an object property instead.",
  51299. el.rawAttrsMap['v-model']
  51300. );
  51301. }
  51302. _el = _el.parent;
  51303. }
  51304. }
  51305. /* */
  51306. function preTransformNode (el, options) {
  51307. if (el.tag === 'input') {
  51308. var map = el.attrsMap;
  51309. if (!map['v-model']) {
  51310. return
  51311. }
  51312. var typeBinding;
  51313. if (map[':type'] || map['v-bind:type']) {
  51314. typeBinding = getBindingAttr(el, 'type');
  51315. }
  51316. if (!map.type && !typeBinding && map['v-bind']) {
  51317. typeBinding = "(" + (map['v-bind']) + ").type";
  51318. }
  51319. if (typeBinding) {
  51320. var ifCondition = getAndRemoveAttr(el, 'v-if', true);
  51321. var ifConditionExtra = ifCondition ? ("&&(" + ifCondition + ")") : "";
  51322. var hasElse = getAndRemoveAttr(el, 'v-else', true) != null;
  51323. var elseIfCondition = getAndRemoveAttr(el, 'v-else-if', true);
  51324. // 1. checkbox
  51325. var branch0 = cloneASTElement(el);
  51326. // process for on the main node
  51327. processFor(branch0);
  51328. addRawAttr(branch0, 'type', 'checkbox');
  51329. processElement(branch0, options);
  51330. branch0.processed = true; // prevent it from double-processed
  51331. branch0.if = "(" + typeBinding + ")==='checkbox'" + ifConditionExtra;
  51332. addIfCondition(branch0, {
  51333. exp: branch0.if,
  51334. block: branch0
  51335. });
  51336. // 2. add radio else-if condition
  51337. var branch1 = cloneASTElement(el);
  51338. getAndRemoveAttr(branch1, 'v-for', true);
  51339. addRawAttr(branch1, 'type', 'radio');
  51340. processElement(branch1, options);
  51341. addIfCondition(branch0, {
  51342. exp: "(" + typeBinding + ")==='radio'" + ifConditionExtra,
  51343. block: branch1
  51344. });
  51345. // 3. other
  51346. var branch2 = cloneASTElement(el);
  51347. getAndRemoveAttr(branch2, 'v-for', true);
  51348. addRawAttr(branch2, ':type', typeBinding);
  51349. processElement(branch2, options);
  51350. addIfCondition(branch0, {
  51351. exp: ifCondition,
  51352. block: branch2
  51353. });
  51354. if (hasElse) {
  51355. branch0.else = true;
  51356. } else if (elseIfCondition) {
  51357. branch0.elseif = elseIfCondition;
  51358. }
  51359. return branch0
  51360. }
  51361. }
  51362. }
  51363. function cloneASTElement (el) {
  51364. return createASTElement(el.tag, el.attrsList.slice(), el.parent)
  51365. }
  51366. var model$1 = {
  51367. preTransformNode: preTransformNode
  51368. };
  51369. var modules$1 = [
  51370. klass$1,
  51371. style$1,
  51372. model$1
  51373. ];
  51374. /* */
  51375. function text (el, dir) {
  51376. if (dir.value) {
  51377. addProp(el, 'textContent', ("_s(" + (dir.value) + ")"), dir);
  51378. }
  51379. }
  51380. /* */
  51381. function html (el, dir) {
  51382. if (dir.value) {
  51383. addProp(el, 'innerHTML', ("_s(" + (dir.value) + ")"), dir);
  51384. }
  51385. }
  51386. var directives$1 = {
  51387. model: model,
  51388. text: text,
  51389. html: html
  51390. };
  51391. /* */
  51392. var baseOptions = {
  51393. expectHTML: true,
  51394. modules: modules$1,
  51395. directives: directives$1,
  51396. isPreTag: isPreTag,
  51397. isUnaryTag: isUnaryTag,
  51398. mustUseProp: mustUseProp,
  51399. canBeLeftOpenTag: canBeLeftOpenTag,
  51400. isReservedTag: isReservedTag,
  51401. getTagNamespace: getTagNamespace,
  51402. staticKeys: genStaticKeys(modules$1)
  51403. };
  51404. /* */
  51405. var isStaticKey;
  51406. var isPlatformReservedTag;
  51407. var genStaticKeysCached = cached(genStaticKeys$1);
  51408. /**
  51409. * Goal of the optimizer: walk the generated template AST tree
  51410. * and detect sub-trees that are purely static, i.e. parts of
  51411. * the DOM that never needs to change.
  51412. *
  51413. * Once we detect these sub-trees, we can:
  51414. *
  51415. * 1. Hoist them into constants, so that we no longer need to
  51416. * create fresh nodes for them on each re-render;
  51417. * 2. Completely skip them in the patching process.
  51418. */
  51419. function optimize (root, options) {
  51420. if (!root) { return }
  51421. isStaticKey = genStaticKeysCached(options.staticKeys || '');
  51422. isPlatformReservedTag = options.isReservedTag || no;
  51423. // first pass: mark all non-static nodes.
  51424. markStatic$1(root);
  51425. // second pass: mark static roots.
  51426. markStaticRoots(root, false);
  51427. }
  51428. function genStaticKeys$1 (keys) {
  51429. return makeMap(
  51430. 'type,tag,attrsList,attrsMap,plain,parent,children,attrs,start,end,rawAttrsMap' +
  51431. (keys ? ',' + keys : '')
  51432. )
  51433. }
  51434. function markStatic$1 (node) {
  51435. node.static = isStatic(node);
  51436. if (node.type === 1) {
  51437. // do not make component slot content static. this avoids
  51438. // 1. components not able to mutate slot nodes
  51439. // 2. static slot content fails for hot-reloading
  51440. if (
  51441. !isPlatformReservedTag(node.tag) &&
  51442. node.tag !== 'slot' &&
  51443. node.attrsMap['inline-template'] == null
  51444. ) {
  51445. return
  51446. }
  51447. for (var i = 0, l = node.children.length; i < l; i++) {
  51448. var child = node.children[i];
  51449. markStatic$1(child);
  51450. if (!child.static) {
  51451. node.static = false;
  51452. }
  51453. }
  51454. if (node.ifConditions) {
  51455. for (var i$1 = 1, l$1 = node.ifConditions.length; i$1 < l$1; i$1++) {
  51456. var block = node.ifConditions[i$1].block;
  51457. markStatic$1(block);
  51458. if (!block.static) {
  51459. node.static = false;
  51460. }
  51461. }
  51462. }
  51463. }
  51464. }
  51465. function markStaticRoots (node, isInFor) {
  51466. if (node.type === 1) {
  51467. if (node.static || node.once) {
  51468. node.staticInFor = isInFor;
  51469. }
  51470. // For a node to qualify as a static root, it should have children that
  51471. // are not just static text. Otherwise the cost of hoisting out will
  51472. // outweigh the benefits and it's better off to just always render it fresh.
  51473. if (node.static && node.children.length && !(
  51474. node.children.length === 1 &&
  51475. node.children[0].type === 3
  51476. )) {
  51477. node.staticRoot = true;
  51478. return
  51479. } else {
  51480. node.staticRoot = false;
  51481. }
  51482. if (node.children) {
  51483. for (var i = 0, l = node.children.length; i < l; i++) {
  51484. markStaticRoots(node.children[i], isInFor || !!node.for);
  51485. }
  51486. }
  51487. if (node.ifConditions) {
  51488. for (var i$1 = 1, l$1 = node.ifConditions.length; i$1 < l$1; i$1++) {
  51489. markStaticRoots(node.ifConditions[i$1].block, isInFor);
  51490. }
  51491. }
  51492. }
  51493. }
  51494. function isStatic (node) {
  51495. if (node.type === 2) { // expression
  51496. return false
  51497. }
  51498. if (node.type === 3) { // text
  51499. return true
  51500. }
  51501. return !!(node.pre || (
  51502. !node.hasBindings && // no dynamic bindings
  51503. !node.if && !node.for && // not v-if or v-for or v-else
  51504. !isBuiltInTag(node.tag) && // not a built-in
  51505. isPlatformReservedTag(node.tag) && // not a component
  51506. !isDirectChildOfTemplateFor(node) &&
  51507. Object.keys(node).every(isStaticKey)
  51508. ))
  51509. }
  51510. function isDirectChildOfTemplateFor (node) {
  51511. while (node.parent) {
  51512. node = node.parent;
  51513. if (node.tag !== 'template') {
  51514. return false
  51515. }
  51516. if (node.for) {
  51517. return true
  51518. }
  51519. }
  51520. return false
  51521. }
  51522. /* */
  51523. var fnExpRE = /^([\w$_]+|\([^)]*?\))\s*=>|^function(?:\s+[\w$]+)?\s*\(/;
  51524. var fnInvokeRE = /\([^)]*?\);*$/;
  51525. var simplePathRE = /^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*|\['[^']*?']|\["[^"]*?"]|\[\d+]|\[[A-Za-z_$][\w$]*])*$/;
  51526. // KeyboardEvent.keyCode aliases
  51527. var keyCodes = {
  51528. esc: 27,
  51529. tab: 9,
  51530. enter: 13,
  51531. space: 32,
  51532. up: 38,
  51533. left: 37,
  51534. right: 39,
  51535. down: 40,
  51536. 'delete': [8, 46]
  51537. };
  51538. // KeyboardEvent.key aliases
  51539. var keyNames = {
  51540. // #7880: IE11 and Edge use `Esc` for Escape key name.
  51541. esc: ['Esc', 'Escape'],
  51542. tab: 'Tab',
  51543. enter: 'Enter',
  51544. // #9112: IE11 uses `Spacebar` for Space key name.
  51545. space: [' ', 'Spacebar'],
  51546. // #7806: IE11 uses key names without `Arrow` prefix for arrow keys.
  51547. up: ['Up', 'ArrowUp'],
  51548. left: ['Left', 'ArrowLeft'],
  51549. right: ['Right', 'ArrowRight'],
  51550. down: ['Down', 'ArrowDown'],
  51551. // #9112: IE11 uses `Del` for Delete key name.
  51552. 'delete': ['Backspace', 'Delete', 'Del']
  51553. };
  51554. // #4868: modifiers that prevent the execution of the listener
  51555. // need to explicitly return null so that we can determine whether to remove
  51556. // the listener for .once
  51557. var genGuard = function (condition) { return ("if(" + condition + ")return null;"); };
  51558. var modifierCode = {
  51559. stop: '$event.stopPropagation();',
  51560. prevent: '$event.preventDefault();',
  51561. self: genGuard("$event.target !== $event.currentTarget"),
  51562. ctrl: genGuard("!$event.ctrlKey"),
  51563. shift: genGuard("!$event.shiftKey"),
  51564. alt: genGuard("!$event.altKey"),
  51565. meta: genGuard("!$event.metaKey"),
  51566. left: genGuard("'button' in $event && $event.button !== 0"),
  51567. middle: genGuard("'button' in $event && $event.button !== 1"),
  51568. right: genGuard("'button' in $event && $event.button !== 2")
  51569. };
  51570. function genHandlers (
  51571. events,
  51572. isNative
  51573. ) {
  51574. var prefix = isNative ? 'nativeOn:' : 'on:';
  51575. var staticHandlers = "";
  51576. var dynamicHandlers = "";
  51577. for (var name in events) {
  51578. var handlerCode = genHandler(events[name]);
  51579. if (events[name] && events[name].dynamic) {
  51580. dynamicHandlers += name + "," + handlerCode + ",";
  51581. } else {
  51582. staticHandlers += "\"" + name + "\":" + handlerCode + ",";
  51583. }
  51584. }
  51585. staticHandlers = "{" + (staticHandlers.slice(0, -1)) + "}";
  51586. if (dynamicHandlers) {
  51587. return prefix + "_d(" + staticHandlers + ",[" + (dynamicHandlers.slice(0, -1)) + "])"
  51588. } else {
  51589. return prefix + staticHandlers
  51590. }
  51591. }
  51592. function genHandler (handler) {
  51593. if (!handler) {
  51594. return 'function(){}'
  51595. }
  51596. if (Array.isArray(handler)) {
  51597. return ("[" + (handler.map(function (handler) { return genHandler(handler); }).join(',')) + "]")
  51598. }
  51599. var isMethodPath = simplePathRE.test(handler.value);
  51600. var isFunctionExpression = fnExpRE.test(handler.value);
  51601. var isFunctionInvocation = simplePathRE.test(handler.value.replace(fnInvokeRE, ''));
  51602. if (!handler.modifiers) {
  51603. if (isMethodPath || isFunctionExpression) {
  51604. return handler.value
  51605. }
  51606. return ("function($event){" + (isFunctionInvocation ? ("return " + (handler.value)) : handler.value) + "}") // inline statement
  51607. } else {
  51608. var code = '';
  51609. var genModifierCode = '';
  51610. var keys = [];
  51611. for (var key in handler.modifiers) {
  51612. if (modifierCode[key]) {
  51613. genModifierCode += modifierCode[key];
  51614. // left/right
  51615. if (keyCodes[key]) {
  51616. keys.push(key);
  51617. }
  51618. } else if (key === 'exact') {
  51619. var modifiers = (handler.modifiers);
  51620. genModifierCode += genGuard(
  51621. ['ctrl', 'shift', 'alt', 'meta']
  51622. .filter(function (keyModifier) { return !modifiers[keyModifier]; })
  51623. .map(function (keyModifier) { return ("$event." + keyModifier + "Key"); })
  51624. .join('||')
  51625. );
  51626. } else {
  51627. keys.push(key);
  51628. }
  51629. }
  51630. if (keys.length) {
  51631. code += genKeyFilter(keys);
  51632. }
  51633. // Make sure modifiers like prevent and stop get executed after key filtering
  51634. if (genModifierCode) {
  51635. code += genModifierCode;
  51636. }
  51637. var handlerCode = isMethodPath
  51638. ? ("return " + (handler.value) + "($event)")
  51639. : isFunctionExpression
  51640. ? ("return (" + (handler.value) + ")($event)")
  51641. : isFunctionInvocation
  51642. ? ("return " + (handler.value))
  51643. : handler.value;
  51644. return ("function($event){" + code + handlerCode + "}")
  51645. }
  51646. }
  51647. function genKeyFilter (keys) {
  51648. return (
  51649. // make sure the key filters only apply to KeyboardEvents
  51650. // #9441: can't use 'keyCode' in $event because Chrome autofill fires fake
  51651. // key events that do not have keyCode property...
  51652. "if(!$event.type.indexOf('key')&&" +
  51653. (keys.map(genFilterCode).join('&&')) + ")return null;"
  51654. )
  51655. }
  51656. function genFilterCode (key) {
  51657. var keyVal = parseInt(key, 10);
  51658. if (keyVal) {
  51659. return ("$event.keyCode!==" + keyVal)
  51660. }
  51661. var keyCode = keyCodes[key];
  51662. var keyName = keyNames[key];
  51663. return (
  51664. "_k($event.keyCode," +
  51665. (JSON.stringify(key)) + "," +
  51666. (JSON.stringify(keyCode)) + "," +
  51667. "$event.key," +
  51668. "" + (JSON.stringify(keyName)) +
  51669. ")"
  51670. )
  51671. }
  51672. /* */
  51673. function on (el, dir) {
  51674. if (dir.modifiers) {
  51675. warn("v-on without argument does not support modifiers.");
  51676. }
  51677. el.wrapListeners = function (code) { return ("_g(" + code + "," + (dir.value) + ")"); };
  51678. }
  51679. /* */
  51680. function bind$1 (el, dir) {
  51681. el.wrapData = function (code) {
  51682. return ("_b(" + code + ",'" + (el.tag) + "'," + (dir.value) + "," + (dir.modifiers && dir.modifiers.prop ? 'true' : 'false') + (dir.modifiers && dir.modifiers.sync ? ',true' : '') + ")")
  51683. };
  51684. }
  51685. /* */
  51686. var baseDirectives = {
  51687. on: on,
  51688. bind: bind$1,
  51689. cloak: noop
  51690. };
  51691. /* */
  51692. var CodegenState = function CodegenState (options) {
  51693. this.options = options;
  51694. this.warn = options.warn || baseWarn;
  51695. this.transforms = pluckModuleFunction(options.modules, 'transformCode');
  51696. this.dataGenFns = pluckModuleFunction(options.modules, 'genData');
  51697. this.directives = extend(extend({}, baseDirectives), options.directives);
  51698. var isReservedTag = options.isReservedTag || no;
  51699. this.maybeComponent = function (el) { return !!el.component || !isReservedTag(el.tag); };
  51700. this.onceId = 0;
  51701. this.staticRenderFns = [];
  51702. this.pre = false;
  51703. };
  51704. function generate (
  51705. ast,
  51706. options
  51707. ) {
  51708. var state = new CodegenState(options);
  51709. var code = ast ? genElement(ast, state) : '_c("div")';
  51710. return {
  51711. render: ("with(this){return " + code + "}"),
  51712. staticRenderFns: state.staticRenderFns
  51713. }
  51714. }
  51715. function genElement (el, state) {
  51716. if (el.parent) {
  51717. el.pre = el.pre || el.parent.pre;
  51718. }
  51719. if (el.staticRoot && !el.staticProcessed) {
  51720. return genStatic(el, state)
  51721. } else if (el.once && !el.onceProcessed) {
  51722. return genOnce(el, state)
  51723. } else if (el.for && !el.forProcessed) {
  51724. return genFor(el, state)
  51725. } else if (el.if && !el.ifProcessed) {
  51726. return genIf(el, state)
  51727. } else if (el.tag === 'template' && !el.slotTarget && !state.pre) {
  51728. return genChildren(el, state) || 'void 0'
  51729. } else if (el.tag === 'slot') {
  51730. return genSlot(el, state)
  51731. } else {
  51732. // component or element
  51733. var code;
  51734. if (el.component) {
  51735. code = genComponent(el.component, el, state);
  51736. } else {
  51737. var data;
  51738. if (!el.plain || (el.pre && state.maybeComponent(el))) {
  51739. data = genData$2(el, state);
  51740. }
  51741. var children = el.inlineTemplate ? null : genChildren(el, state, true);
  51742. code = "_c('" + (el.tag) + "'" + (data ? ("," + data) : '') + (children ? ("," + children) : '') + ")";
  51743. }
  51744. // module transforms
  51745. for (var i = 0; i < state.transforms.length; i++) {
  51746. code = state.transforms[i](el, code);
  51747. }
  51748. return code
  51749. }
  51750. }
  51751. // hoist static sub-trees out
  51752. function genStatic (el, state) {
  51753. el.staticProcessed = true;
  51754. // Some elements (templates) need to behave differently inside of a v-pre
  51755. // node. All pre nodes are static roots, so we can use this as a location to
  51756. // wrap a state change and reset it upon exiting the pre node.
  51757. var originalPreState = state.pre;
  51758. if (el.pre) {
  51759. state.pre = el.pre;
  51760. }
  51761. state.staticRenderFns.push(("with(this){return " + (genElement(el, state)) + "}"));
  51762. state.pre = originalPreState;
  51763. return ("_m(" + (state.staticRenderFns.length - 1) + (el.staticInFor ? ',true' : '') + ")")
  51764. }
  51765. // v-once
  51766. function genOnce (el, state) {
  51767. el.onceProcessed = true;
  51768. if (el.if && !el.ifProcessed) {
  51769. return genIf(el, state)
  51770. } else if (el.staticInFor) {
  51771. var key = '';
  51772. var parent = el.parent;
  51773. while (parent) {
  51774. if (parent.for) {
  51775. key = parent.key;
  51776. break
  51777. }
  51778. parent = parent.parent;
  51779. }
  51780. if (!key) {
  51781. state.warn(
  51782. "v-once can only be used inside v-for that is keyed. ",
  51783. el.rawAttrsMap['v-once']
  51784. );
  51785. return genElement(el, state)
  51786. }
  51787. return ("_o(" + (genElement(el, state)) + "," + (state.onceId++) + "," + key + ")")
  51788. } else {
  51789. return genStatic(el, state)
  51790. }
  51791. }
  51792. function genIf (
  51793. el,
  51794. state,
  51795. altGen,
  51796. altEmpty
  51797. ) {
  51798. el.ifProcessed = true; // avoid recursion
  51799. return genIfConditions(el.ifConditions.slice(), state, altGen, altEmpty)
  51800. }
  51801. function genIfConditions (
  51802. conditions,
  51803. state,
  51804. altGen,
  51805. altEmpty
  51806. ) {
  51807. if (!conditions.length) {
  51808. return altEmpty || '_e()'
  51809. }
  51810. var condition = conditions.shift();
  51811. if (condition.exp) {
  51812. return ("(" + (condition.exp) + ")?" + (genTernaryExp(condition.block)) + ":" + (genIfConditions(conditions, state, altGen, altEmpty)))
  51813. } else {
  51814. return ("" + (genTernaryExp(condition.block)))
  51815. }
  51816. // v-if with v-once should generate code like (a)?_m(0):_m(1)
  51817. function genTernaryExp (el) {
  51818. return altGen
  51819. ? altGen(el, state)
  51820. : el.once
  51821. ? genOnce(el, state)
  51822. : genElement(el, state)
  51823. }
  51824. }
  51825. function genFor (
  51826. el,
  51827. state,
  51828. altGen,
  51829. altHelper
  51830. ) {
  51831. var exp = el.for;
  51832. var alias = el.alias;
  51833. var iterator1 = el.iterator1 ? ("," + (el.iterator1)) : '';
  51834. var iterator2 = el.iterator2 ? ("," + (el.iterator2)) : '';
  51835. if (state.maybeComponent(el) &&
  51836. el.tag !== 'slot' &&
  51837. el.tag !== 'template' &&
  51838. !el.key
  51839. ) {
  51840. state.warn(
  51841. "<" + (el.tag) + " v-for=\"" + alias + " in " + exp + "\">: component lists rendered with " +
  51842. "v-for should have explicit keys. " +
  51843. "See https://vuejs.org/guide/list.html#key for more info.",
  51844. el.rawAttrsMap['v-for'],
  51845. true /* tip */
  51846. );
  51847. }
  51848. el.forProcessed = true; // avoid recursion
  51849. return (altHelper || '_l') + "((" + exp + ")," +
  51850. "function(" + alias + iterator1 + iterator2 + "){" +
  51851. "return " + ((altGen || genElement)(el, state)) +
  51852. '})'
  51853. }
  51854. function genData$2 (el, state) {
  51855. var data = '{';
  51856. // directives first.
  51857. // directives may mutate the el's other properties before they are generated.
  51858. var dirs = genDirectives(el, state);
  51859. if (dirs) { data += dirs + ','; }
  51860. // key
  51861. if (el.key) {
  51862. data += "key:" + (el.key) + ",";
  51863. }
  51864. // ref
  51865. if (el.ref) {
  51866. data += "ref:" + (el.ref) + ",";
  51867. }
  51868. if (el.refInFor) {
  51869. data += "refInFor:true,";
  51870. }
  51871. // pre
  51872. if (el.pre) {
  51873. data += "pre:true,";
  51874. }
  51875. // record original tag name for components using "is" attribute
  51876. if (el.component) {
  51877. data += "tag:\"" + (el.tag) + "\",";
  51878. }
  51879. // module data generation functions
  51880. for (var i = 0; i < state.dataGenFns.length; i++) {
  51881. data += state.dataGenFns[i](el);
  51882. }
  51883. // attributes
  51884. if (el.attrs) {
  51885. data += "attrs:" + (genProps(el.attrs)) + ",";
  51886. }
  51887. // DOM props
  51888. if (el.props) {
  51889. data += "domProps:" + (genProps(el.props)) + ",";
  51890. }
  51891. // event handlers
  51892. if (el.events) {
  51893. data += (genHandlers(el.events, false)) + ",";
  51894. }
  51895. if (el.nativeEvents) {
  51896. data += (genHandlers(el.nativeEvents, true)) + ",";
  51897. }
  51898. // slot target
  51899. // only for non-scoped slots
  51900. if (el.slotTarget && !el.slotScope) {
  51901. data += "slot:" + (el.slotTarget) + ",";
  51902. }
  51903. // scoped slots
  51904. if (el.scopedSlots) {
  51905. data += (genScopedSlots(el, el.scopedSlots, state)) + ",";
  51906. }
  51907. // component v-model
  51908. if (el.model) {
  51909. data += "model:{value:" + (el.model.value) + ",callback:" + (el.model.callback) + ",expression:" + (el.model.expression) + "},";
  51910. }
  51911. // inline-template
  51912. if (el.inlineTemplate) {
  51913. var inlineTemplate = genInlineTemplate(el, state);
  51914. if (inlineTemplate) {
  51915. data += inlineTemplate + ",";
  51916. }
  51917. }
  51918. data = data.replace(/,$/, '') + '}';
  51919. // v-bind dynamic argument wrap
  51920. // v-bind with dynamic arguments must be applied using the same v-bind object
  51921. // merge helper so that class/style/mustUseProp attrs are handled correctly.
  51922. if (el.dynamicAttrs) {
  51923. data = "_b(" + data + ",\"" + (el.tag) + "\"," + (genProps(el.dynamicAttrs)) + ")";
  51924. }
  51925. // v-bind data wrap
  51926. if (el.wrapData) {
  51927. data = el.wrapData(data);
  51928. }
  51929. // v-on data wrap
  51930. if (el.wrapListeners) {
  51931. data = el.wrapListeners(data);
  51932. }
  51933. return data
  51934. }
  51935. function genDirectives (el, state) {
  51936. var dirs = el.directives;
  51937. if (!dirs) { return }
  51938. var res = 'directives:[';
  51939. var hasRuntime = false;
  51940. var i, l, dir, needRuntime;
  51941. for (i = 0, l = dirs.length; i < l; i++) {
  51942. dir = dirs[i];
  51943. needRuntime = true;
  51944. var gen = state.directives[dir.name];
  51945. if (gen) {
  51946. // compile-time directive that manipulates AST.
  51947. // returns true if it also needs a runtime counterpart.
  51948. needRuntime = !!gen(el, dir, state.warn);
  51949. }
  51950. if (needRuntime) {
  51951. hasRuntime = true;
  51952. 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))) : '') + "},";
  51953. }
  51954. }
  51955. if (hasRuntime) {
  51956. return res.slice(0, -1) + ']'
  51957. }
  51958. }
  51959. function genInlineTemplate (el, state) {
  51960. var ast = el.children[0];
  51961. if (el.children.length !== 1 || ast.type !== 1) {
  51962. state.warn(
  51963. 'Inline-template components must have exactly one child element.',
  51964. { start: el.start }
  51965. );
  51966. }
  51967. if (ast && ast.type === 1) {
  51968. var inlineRenderFns = generate(ast, state.options);
  51969. return ("inlineTemplate:{render:function(){" + (inlineRenderFns.render) + "},staticRenderFns:[" + (inlineRenderFns.staticRenderFns.map(function (code) { return ("function(){" + code + "}"); }).join(',')) + "]}")
  51970. }
  51971. }
  51972. function genScopedSlots (
  51973. el,
  51974. slots,
  51975. state
  51976. ) {
  51977. // by default scoped slots are considered "stable", this allows child
  51978. // components with only scoped slots to skip forced updates from parent.
  51979. // but in some cases we have to bail-out of this optimization
  51980. // for example if the slot contains dynamic names, has v-if or v-for on them...
  51981. var needsForceUpdate = el.for || Object.keys(slots).some(function (key) {
  51982. var slot = slots[key];
  51983. return (
  51984. slot.slotTargetDynamic ||
  51985. slot.if ||
  51986. slot.for ||
  51987. containsSlotChild(slot) // is passing down slot from parent which may be dynamic
  51988. )
  51989. });
  51990. // #9534: if a component with scoped slots is inside a conditional branch,
  51991. // it's possible for the same component to be reused but with different
  51992. // compiled slot content. To avoid that, we generate a unique key based on
  51993. // the generated code of all the slot contents.
  51994. var needsKey = !!el.if;
  51995. // OR when it is inside another scoped slot or v-for (the reactivity may be
  51996. // disconnected due to the intermediate scope variable)
  51997. // #9438, #9506
  51998. // TODO: this can be further optimized by properly analyzing in-scope bindings
  51999. // and skip force updating ones that do not actually use scope variables.
  52000. if (!needsForceUpdate) {
  52001. var parent = el.parent;
  52002. while (parent) {
  52003. if (
  52004. (parent.slotScope && parent.slotScope !== emptySlotScopeToken) ||
  52005. parent.for
  52006. ) {
  52007. needsForceUpdate = true;
  52008. break
  52009. }
  52010. if (parent.if) {
  52011. needsKey = true;
  52012. }
  52013. parent = parent.parent;
  52014. }
  52015. }
  52016. var generatedSlots = Object.keys(slots)
  52017. .map(function (key) { return genScopedSlot(slots[key], state); })
  52018. .join(',');
  52019. return ("scopedSlots:_u([" + generatedSlots + "]" + (needsForceUpdate ? ",null,true" : "") + (!needsForceUpdate && needsKey ? (",null,false," + (hash(generatedSlots))) : "") + ")")
  52020. }
  52021. function hash(str) {
  52022. var hash = 5381;
  52023. var i = str.length;
  52024. while(i) {
  52025. hash = (hash * 33) ^ str.charCodeAt(--i);
  52026. }
  52027. return hash >>> 0
  52028. }
  52029. function containsSlotChild (el) {
  52030. if (el.type === 1) {
  52031. if (el.tag === 'slot') {
  52032. return true
  52033. }
  52034. return el.children.some(containsSlotChild)
  52035. }
  52036. return false
  52037. }
  52038. function genScopedSlot (
  52039. el,
  52040. state
  52041. ) {
  52042. var isLegacySyntax = el.attrsMap['slot-scope'];
  52043. if (el.if && !el.ifProcessed && !isLegacySyntax) {
  52044. return genIf(el, state, genScopedSlot, "null")
  52045. }
  52046. if (el.for && !el.forProcessed) {
  52047. return genFor(el, state, genScopedSlot)
  52048. }
  52049. var slotScope = el.slotScope === emptySlotScopeToken
  52050. ? ""
  52051. : String(el.slotScope);
  52052. var fn = "function(" + slotScope + "){" +
  52053. "return " + (el.tag === 'template'
  52054. ? el.if && isLegacySyntax
  52055. ? ("(" + (el.if) + ")?" + (genChildren(el, state) || 'undefined') + ":undefined")
  52056. : genChildren(el, state) || 'undefined'
  52057. : genElement(el, state)) + "}";
  52058. // reverse proxy v-slot without scope on this.$slots
  52059. var reverseProxy = slotScope ? "" : ",proxy:true";
  52060. return ("{key:" + (el.slotTarget || "\"default\"") + ",fn:" + fn + reverseProxy + "}")
  52061. }
  52062. function genChildren (
  52063. el,
  52064. state,
  52065. checkSkip,
  52066. altGenElement,
  52067. altGenNode
  52068. ) {
  52069. var children = el.children;
  52070. if (children.length) {
  52071. var el$1 = children[0];
  52072. // optimize single v-for
  52073. if (children.length === 1 &&
  52074. el$1.for &&
  52075. el$1.tag !== 'template' &&
  52076. el$1.tag !== 'slot'
  52077. ) {
  52078. var normalizationType = checkSkip
  52079. ? state.maybeComponent(el$1) ? ",1" : ",0"
  52080. : "";
  52081. return ("" + ((altGenElement || genElement)(el$1, state)) + normalizationType)
  52082. }
  52083. var normalizationType$1 = checkSkip
  52084. ? getNormalizationType(children, state.maybeComponent)
  52085. : 0;
  52086. var gen = altGenNode || genNode;
  52087. return ("[" + (children.map(function (c) { return gen(c, state); }).join(',')) + "]" + (normalizationType$1 ? ("," + normalizationType$1) : ''))
  52088. }
  52089. }
  52090. // determine the normalization needed for the children array.
  52091. // 0: no normalization needed
  52092. // 1: simple normalization needed (possible 1-level deep nested array)
  52093. // 2: full normalization needed
  52094. function getNormalizationType (
  52095. children,
  52096. maybeComponent
  52097. ) {
  52098. var res = 0;
  52099. for (var i = 0; i < children.length; i++) {
  52100. var el = children[i];
  52101. if (el.type !== 1) {
  52102. continue
  52103. }
  52104. if (needsNormalization(el) ||
  52105. (el.ifConditions && el.ifConditions.some(function (c) { return needsNormalization(c.block); }))) {
  52106. res = 2;
  52107. break
  52108. }
  52109. if (maybeComponent(el) ||
  52110. (el.ifConditions && el.ifConditions.some(function (c) { return maybeComponent(c.block); }))) {
  52111. res = 1;
  52112. }
  52113. }
  52114. return res
  52115. }
  52116. function needsNormalization (el) {
  52117. return el.for !== undefined || el.tag === 'template' || el.tag === 'slot'
  52118. }
  52119. function genNode (node, state) {
  52120. if (node.type === 1) {
  52121. return genElement(node, state)
  52122. } else if (node.type === 3 && node.isComment) {
  52123. return genComment(node)
  52124. } else {
  52125. return genText(node)
  52126. }
  52127. }
  52128. function genText (text) {
  52129. return ("_v(" + (text.type === 2
  52130. ? text.expression // no need for () because already wrapped in _s()
  52131. : transformSpecialNewlines(JSON.stringify(text.text))) + ")")
  52132. }
  52133. function genComment (comment) {
  52134. return ("_e(" + (JSON.stringify(comment.text)) + ")")
  52135. }
  52136. function genSlot (el, state) {
  52137. var slotName = el.slotName || '"default"';
  52138. var children = genChildren(el, state);
  52139. var res = "_t(" + slotName + (children ? ("," + children) : '');
  52140. var attrs = el.attrs || el.dynamicAttrs
  52141. ? genProps((el.attrs || []).concat(el.dynamicAttrs || []).map(function (attr) { return ({
  52142. // slot props are camelized
  52143. name: camelize(attr.name),
  52144. value: attr.value,
  52145. dynamic: attr.dynamic
  52146. }); }))
  52147. : null;
  52148. var bind$$1 = el.attrsMap['v-bind'];
  52149. if ((attrs || bind$$1) && !children) {
  52150. res += ",null";
  52151. }
  52152. if (attrs) {
  52153. res += "," + attrs;
  52154. }
  52155. if (bind$$1) {
  52156. res += (attrs ? '' : ',null') + "," + bind$$1;
  52157. }
  52158. return res + ')'
  52159. }
  52160. // componentName is el.component, take it as argument to shun flow's pessimistic refinement
  52161. function genComponent (
  52162. componentName,
  52163. el,
  52164. state
  52165. ) {
  52166. var children = el.inlineTemplate ? null : genChildren(el, state, true);
  52167. return ("_c(" + componentName + "," + (genData$2(el, state)) + (children ? ("," + children) : '') + ")")
  52168. }
  52169. function genProps (props) {
  52170. var staticProps = "";
  52171. var dynamicProps = "";
  52172. for (var i = 0; i < props.length; i++) {
  52173. var prop = props[i];
  52174. var value = transformSpecialNewlines(prop.value);
  52175. if (prop.dynamic) {
  52176. dynamicProps += (prop.name) + "," + value + ",";
  52177. } else {
  52178. staticProps += "\"" + (prop.name) + "\":" + value + ",";
  52179. }
  52180. }
  52181. staticProps = "{" + (staticProps.slice(0, -1)) + "}";
  52182. if (dynamicProps) {
  52183. return ("_d(" + staticProps + ",[" + (dynamicProps.slice(0, -1)) + "])")
  52184. } else {
  52185. return staticProps
  52186. }
  52187. }
  52188. // #3895, #4268
  52189. function transformSpecialNewlines (text) {
  52190. return text
  52191. .replace(/\u2028/g, '\\u2028')
  52192. .replace(/\u2029/g, '\\u2029')
  52193. }
  52194. /* */
  52195. // these keywords should not appear inside expressions, but operators like
  52196. // typeof, instanceof and in are allowed
  52197. var prohibitedKeywordRE = new RegExp('\\b' + (
  52198. 'do,if,for,let,new,try,var,case,else,with,await,break,catch,class,const,' +
  52199. 'super,throw,while,yield,delete,export,import,return,switch,default,' +
  52200. 'extends,finally,continue,debugger,function,arguments'
  52201. ).split(',').join('\\b|\\b') + '\\b');
  52202. // these unary operators should not be used as property/method names
  52203. var unaryOperatorsRE = new RegExp('\\b' + (
  52204. 'delete,typeof,void'
  52205. ).split(',').join('\\s*\\([^\\)]*\\)|\\b') + '\\s*\\([^\\)]*\\)');
  52206. // strip strings in expressions
  52207. var stripStringRE = /'(?:[^'\\]|\\.)*'|"(?:[^"\\]|\\.)*"|`(?:[^`\\]|\\.)*\$\{|\}(?:[^`\\]|\\.)*`|`(?:[^`\\]|\\.)*`/g;
  52208. // detect problematic expressions in a template
  52209. function detectErrors (ast, warn) {
  52210. if (ast) {
  52211. checkNode(ast, warn);
  52212. }
  52213. }
  52214. function checkNode (node, warn) {
  52215. if (node.type === 1) {
  52216. for (var name in node.attrsMap) {
  52217. if (dirRE.test(name)) {
  52218. var value = node.attrsMap[name];
  52219. if (value) {
  52220. var range = node.rawAttrsMap[name];
  52221. if (name === 'v-for') {
  52222. checkFor(node, ("v-for=\"" + value + "\""), warn, range);
  52223. } else if (name === 'v-slot' || name[0] === '#') {
  52224. checkFunctionParameterExpression(value, (name + "=\"" + value + "\""), warn, range);
  52225. } else if (onRE.test(name)) {
  52226. checkEvent(value, (name + "=\"" + value + "\""), warn, range);
  52227. } else {
  52228. checkExpression(value, (name + "=\"" + value + "\""), warn, range);
  52229. }
  52230. }
  52231. }
  52232. }
  52233. if (node.children) {
  52234. for (var i = 0; i < node.children.length; i++) {
  52235. checkNode(node.children[i], warn);
  52236. }
  52237. }
  52238. } else if (node.type === 2) {
  52239. checkExpression(node.expression, node.text, warn, node);
  52240. }
  52241. }
  52242. function checkEvent (exp, text, warn, range) {
  52243. var stripped = exp.replace(stripStringRE, '');
  52244. var keywordMatch = stripped.match(unaryOperatorsRE);
  52245. if (keywordMatch && stripped.charAt(keywordMatch.index - 1) !== '$') {
  52246. warn(
  52247. "avoid using JavaScript unary operator as property name: " +
  52248. "\"" + (keywordMatch[0]) + "\" in expression " + (text.trim()),
  52249. range
  52250. );
  52251. }
  52252. checkExpression(exp, text, warn, range);
  52253. }
  52254. function checkFor (node, text, warn, range) {
  52255. checkExpression(node.for || '', text, warn, range);
  52256. checkIdentifier(node.alias, 'v-for alias', text, warn, range);
  52257. checkIdentifier(node.iterator1, 'v-for iterator', text, warn, range);
  52258. checkIdentifier(node.iterator2, 'v-for iterator', text, warn, range);
  52259. }
  52260. function checkIdentifier (
  52261. ident,
  52262. type,
  52263. text,
  52264. warn,
  52265. range
  52266. ) {
  52267. if (typeof ident === 'string') {
  52268. try {
  52269. new Function(("var " + ident + "=_"));
  52270. } catch (e) {
  52271. warn(("invalid " + type + " \"" + ident + "\" in expression: " + (text.trim())), range);
  52272. }
  52273. }
  52274. }
  52275. function checkExpression (exp, text, warn, range) {
  52276. try {
  52277. new Function(("return " + exp));
  52278. } catch (e) {
  52279. var keywordMatch = exp.replace(stripStringRE, '').match(prohibitedKeywordRE);
  52280. if (keywordMatch) {
  52281. warn(
  52282. "avoid using JavaScript keyword as property name: " +
  52283. "\"" + (keywordMatch[0]) + "\"\n Raw expression: " + (text.trim()),
  52284. range
  52285. );
  52286. } else {
  52287. warn(
  52288. "invalid expression: " + (e.message) + " in\n\n" +
  52289. " " + exp + "\n\n" +
  52290. " Raw expression: " + (text.trim()) + "\n",
  52291. range
  52292. );
  52293. }
  52294. }
  52295. }
  52296. function checkFunctionParameterExpression (exp, text, warn, range) {
  52297. try {
  52298. new Function(exp, '');
  52299. } catch (e) {
  52300. warn(
  52301. "invalid function parameter expression: " + (e.message) + " in\n\n" +
  52302. " " + exp + "\n\n" +
  52303. " Raw expression: " + (text.trim()) + "\n",
  52304. range
  52305. );
  52306. }
  52307. }
  52308. /* */
  52309. var range = 2;
  52310. function generateCodeFrame (
  52311. source,
  52312. start,
  52313. end
  52314. ) {
  52315. if ( start === void 0 ) start = 0;
  52316. if ( end === void 0 ) end = source.length;
  52317. var lines = source.split(/\r?\n/);
  52318. var count = 0;
  52319. var res = [];
  52320. for (var i = 0; i < lines.length; i++) {
  52321. count += lines[i].length + 1;
  52322. if (count >= start) {
  52323. for (var j = i - range; j <= i + range || end > count; j++) {
  52324. if (j < 0 || j >= lines.length) { continue }
  52325. res.push(("" + (j + 1) + (repeat$1(" ", 3 - String(j + 1).length)) + "| " + (lines[j])));
  52326. var lineLength = lines[j].length;
  52327. if (j === i) {
  52328. // push underline
  52329. var pad = start - (count - lineLength) + 1;
  52330. var length = end > count ? lineLength - pad : end - start;
  52331. res.push(" | " + repeat$1(" ", pad) + repeat$1("^", length));
  52332. } else if (j > i) {
  52333. if (end > count) {
  52334. var length$1 = Math.min(end - count, lineLength);
  52335. res.push(" | " + repeat$1("^", length$1));
  52336. }
  52337. count += lineLength + 1;
  52338. }
  52339. }
  52340. break
  52341. }
  52342. }
  52343. return res.join('\n')
  52344. }
  52345. function repeat$1 (str, n) {
  52346. var result = '';
  52347. if (n > 0) {
  52348. while (true) { // eslint-disable-line
  52349. if (n & 1) { result += str; }
  52350. n >>>= 1;
  52351. if (n <= 0) { break }
  52352. str += str;
  52353. }
  52354. }
  52355. return result
  52356. }
  52357. /* */
  52358. function createFunction (code, errors) {
  52359. try {
  52360. return new Function(code)
  52361. } catch (err) {
  52362. errors.push({ err: err, code: code });
  52363. return noop
  52364. }
  52365. }
  52366. function createCompileToFunctionFn (compile) {
  52367. var cache = Object.create(null);
  52368. return function compileToFunctions (
  52369. template,
  52370. options,
  52371. vm
  52372. ) {
  52373. options = extend({}, options);
  52374. var warn$$1 = options.warn || warn;
  52375. delete options.warn;
  52376. /* istanbul ignore if */
  52377. {
  52378. // detect possible CSP restriction
  52379. try {
  52380. new Function('return 1');
  52381. } catch (e) {
  52382. if (e.toString().match(/unsafe-eval|CSP/)) {
  52383. warn$$1(
  52384. 'It seems you are using the standalone build of Vue.js in an ' +
  52385. 'environment with Content Security Policy that prohibits unsafe-eval. ' +
  52386. 'The template compiler cannot work in this environment. Consider ' +
  52387. 'relaxing the policy to allow unsafe-eval or pre-compiling your ' +
  52388. 'templates into render functions.'
  52389. );
  52390. }
  52391. }
  52392. }
  52393. // check cache
  52394. var key = options.delimiters
  52395. ? String(options.delimiters) + template
  52396. : template;
  52397. if (cache[key]) {
  52398. return cache[key]
  52399. }
  52400. // compile
  52401. var compiled = compile(template, options);
  52402. // check compilation errors/tips
  52403. {
  52404. if (compiled.errors && compiled.errors.length) {
  52405. if (options.outputSourceRange) {
  52406. compiled.errors.forEach(function (e) {
  52407. warn$$1(
  52408. "Error compiling template:\n\n" + (e.msg) + "\n\n" +
  52409. generateCodeFrame(template, e.start, e.end),
  52410. vm
  52411. );
  52412. });
  52413. } else {
  52414. warn$$1(
  52415. "Error compiling template:\n\n" + template + "\n\n" +
  52416. compiled.errors.map(function (e) { return ("- " + e); }).join('\n') + '\n',
  52417. vm
  52418. );
  52419. }
  52420. }
  52421. if (compiled.tips && compiled.tips.length) {
  52422. if (options.outputSourceRange) {
  52423. compiled.tips.forEach(function (e) { return tip(e.msg, vm); });
  52424. } else {
  52425. compiled.tips.forEach(function (msg) { return tip(msg, vm); });
  52426. }
  52427. }
  52428. }
  52429. // turn code into functions
  52430. var res = {};
  52431. var fnGenErrors = [];
  52432. res.render = createFunction(compiled.render, fnGenErrors);
  52433. res.staticRenderFns = compiled.staticRenderFns.map(function (code) {
  52434. return createFunction(code, fnGenErrors)
  52435. });
  52436. // check function generation errors.
  52437. // this should only happen if there is a bug in the compiler itself.
  52438. // mostly for codegen development use
  52439. /* istanbul ignore if */
  52440. {
  52441. if ((!compiled.errors || !compiled.errors.length) && fnGenErrors.length) {
  52442. warn$$1(
  52443. "Failed to generate render function:\n\n" +
  52444. fnGenErrors.map(function (ref) {
  52445. var err = ref.err;
  52446. var code = ref.code;
  52447. return ((err.toString()) + " in\n\n" + code + "\n");
  52448. }).join('\n'),
  52449. vm
  52450. );
  52451. }
  52452. }
  52453. return (cache[key] = res)
  52454. }
  52455. }
  52456. /* */
  52457. function createCompilerCreator (baseCompile) {
  52458. return function createCompiler (baseOptions) {
  52459. function compile (
  52460. template,
  52461. options
  52462. ) {
  52463. var finalOptions = Object.create(baseOptions);
  52464. var errors = [];
  52465. var tips = [];
  52466. var warn = function (msg, range, tip) {
  52467. (tip ? tips : errors).push(msg);
  52468. };
  52469. if (options) {
  52470. if (options.outputSourceRange) {
  52471. // $flow-disable-line
  52472. var leadingSpaceLength = template.match(/^\s*/)[0].length;
  52473. warn = function (msg, range, tip) {
  52474. var data = { msg: msg };
  52475. if (range) {
  52476. if (range.start != null) {
  52477. data.start = range.start + leadingSpaceLength;
  52478. }
  52479. if (range.end != null) {
  52480. data.end = range.end + leadingSpaceLength;
  52481. }
  52482. }
  52483. (tip ? tips : errors).push(data);
  52484. };
  52485. }
  52486. // merge custom modules
  52487. if (options.modules) {
  52488. finalOptions.modules =
  52489. (baseOptions.modules || []).concat(options.modules);
  52490. }
  52491. // merge custom directives
  52492. if (options.directives) {
  52493. finalOptions.directives = extend(
  52494. Object.create(baseOptions.directives || null),
  52495. options.directives
  52496. );
  52497. }
  52498. // copy other options
  52499. for (var key in options) {
  52500. if (key !== 'modules' && key !== 'directives') {
  52501. finalOptions[key] = options[key];
  52502. }
  52503. }
  52504. }
  52505. finalOptions.warn = warn;
  52506. var compiled = baseCompile(template.trim(), finalOptions);
  52507. {
  52508. detectErrors(compiled.ast, warn);
  52509. }
  52510. compiled.errors = errors;
  52511. compiled.tips = tips;
  52512. return compiled
  52513. }
  52514. return {
  52515. compile: compile,
  52516. compileToFunctions: createCompileToFunctionFn(compile)
  52517. }
  52518. }
  52519. }
  52520. /* */
  52521. // `createCompilerCreator` allows creating compilers that use alternative
  52522. // parser/optimizer/codegen, e.g the SSR optimizing compiler.
  52523. // Here we just export a default compiler using the default parts.
  52524. var createCompiler = createCompilerCreator(function baseCompile (
  52525. template,
  52526. options
  52527. ) {
  52528. var ast = parse(template.trim(), options);
  52529. if (options.optimize !== false) {
  52530. optimize(ast, options);
  52531. }
  52532. var code = generate(ast, options);
  52533. return {
  52534. ast: ast,
  52535. render: code.render,
  52536. staticRenderFns: code.staticRenderFns
  52537. }
  52538. });
  52539. /* */
  52540. var ref$1 = createCompiler(baseOptions);
  52541. var compile = ref$1.compile;
  52542. var compileToFunctions = ref$1.compileToFunctions;
  52543. /* */
  52544. // check whether current browser encodes a char inside attribute values
  52545. var div;
  52546. function getShouldDecode (href) {
  52547. div = div || document.createElement('div');
  52548. div.innerHTML = href ? "<a href=\"\n\"/>" : "<div a=\"\n\"/>";
  52549. return div.innerHTML.indexOf('&#10;') > 0
  52550. }
  52551. // #3663: IE encodes newlines inside attribute values while other browsers don't
  52552. var shouldDecodeNewlines = inBrowser ? getShouldDecode(false) : false;
  52553. // #6828: chrome encodes content in a[href]
  52554. var shouldDecodeNewlinesForHref = inBrowser ? getShouldDecode(true) : false;
  52555. /* */
  52556. var idToTemplate = cached(function (id) {
  52557. var el = query(id);
  52558. return el && el.innerHTML
  52559. });
  52560. var mount = Vue.prototype.$mount;
  52561. Vue.prototype.$mount = function (
  52562. el,
  52563. hydrating
  52564. ) {
  52565. el = el && query(el);
  52566. /* istanbul ignore if */
  52567. if (el === document.body || el === document.documentElement) {
  52568. warn(
  52569. "Do not mount Vue to <html> or <body> - mount to normal elements instead."
  52570. );
  52571. return this
  52572. }
  52573. var options = this.$options;
  52574. // resolve template/el and convert to render function
  52575. if (!options.render) {
  52576. var template = options.template;
  52577. if (template) {
  52578. if (typeof template === 'string') {
  52579. if (template.charAt(0) === '#') {
  52580. template = idToTemplate(template);
  52581. /* istanbul ignore if */
  52582. if (!template) {
  52583. warn(
  52584. ("Template element not found or is empty: " + (options.template)),
  52585. this
  52586. );
  52587. }
  52588. }
  52589. } else if (template.nodeType) {
  52590. template = template.innerHTML;
  52591. } else {
  52592. {
  52593. warn('invalid template option:' + template, this);
  52594. }
  52595. return this
  52596. }
  52597. } else if (el) {
  52598. template = getOuterHTML(el);
  52599. }
  52600. if (template) {
  52601. /* istanbul ignore if */
  52602. if (config.performance && mark) {
  52603. mark('compile');
  52604. }
  52605. var ref = compileToFunctions(template, {
  52606. outputSourceRange: "development" !== 'production',
  52607. shouldDecodeNewlines: shouldDecodeNewlines,
  52608. shouldDecodeNewlinesForHref: shouldDecodeNewlinesForHref,
  52609. delimiters: options.delimiters,
  52610. comments: options.comments
  52611. }, this);
  52612. var render = ref.render;
  52613. var staticRenderFns = ref.staticRenderFns;
  52614. options.render = render;
  52615. options.staticRenderFns = staticRenderFns;
  52616. /* istanbul ignore if */
  52617. if (config.performance && mark) {
  52618. mark('compile end');
  52619. measure(("vue " + (this._name) + " compile"), 'compile', 'compile end');
  52620. }
  52621. }
  52622. }
  52623. return mount.call(this, el, hydrating)
  52624. };
  52625. /**
  52626. * Get outerHTML of elements, taking care
  52627. * of SVG elements in IE as well.
  52628. */
  52629. function getOuterHTML (el) {
  52630. if (el.outerHTML) {
  52631. return el.outerHTML
  52632. } else {
  52633. var container = document.createElement('div');
  52634. container.appendChild(el.cloneNode(true));
  52635. return container.innerHTML
  52636. }
  52637. }
  52638. Vue.compile = compileToFunctions;
  52639. module.exports = Vue;
  52640. /* 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))
  52641. /***/ }),
  52642. /***/ "./node_modules/vue/dist/vue.common.js":
  52643. /*!*********************************************!*\
  52644. !*** ./node_modules/vue/dist/vue.common.js ***!
  52645. \*********************************************/
  52646. /*! no static exports found */
  52647. /***/ (function(module, exports, __webpack_require__) {
  52648. if (false) {} else {
  52649. module.exports = __webpack_require__(/*! ./vue.common.dev.js */ "./node_modules/vue/dist/vue.common.dev.js")
  52650. }
  52651. /***/ }),
  52652. /***/ "./node_modules/webpack/buildin/global.js":
  52653. /*!***********************************!*\
  52654. !*** (webpack)/buildin/global.js ***!
  52655. \***********************************/
  52656. /*! no static exports found */
  52657. /***/ (function(module, exports) {
  52658. var g;
  52659. // This works in non-strict mode
  52660. g = (function() {
  52661. return this;
  52662. })();
  52663. try {
  52664. // This works if eval is allowed (see CSP)
  52665. g = g || new Function("return this")();
  52666. } catch (e) {
  52667. // This works if the window reference is available
  52668. if (typeof window === "object") g = window;
  52669. }
  52670. // g can still be undefined, but nothing to do about it...
  52671. // We return undefined, instead of nothing here, so it's
  52672. // easier to handle this case. if(!global) { ...}
  52673. module.exports = g;
  52674. /***/ }),
  52675. /***/ "./node_modules/webpack/buildin/module.js":
  52676. /*!***********************************!*\
  52677. !*** (webpack)/buildin/module.js ***!
  52678. \***********************************/
  52679. /*! no static exports found */
  52680. /***/ (function(module, exports) {
  52681. module.exports = function(module) {
  52682. if (!module.webpackPolyfill) {
  52683. module.deprecate = function() {};
  52684. module.paths = [];
  52685. // module.parent = undefined by default
  52686. if (!module.children) module.children = [];
  52687. Object.defineProperty(module, "loaded", {
  52688. enumerable: true,
  52689. get: function() {
  52690. return module.l;
  52691. }
  52692. });
  52693. Object.defineProperty(module, "id", {
  52694. enumerable: true,
  52695. get: function() {
  52696. return module.i;
  52697. }
  52698. });
  52699. module.webpackPolyfill = 1;
  52700. }
  52701. return module;
  52702. };
  52703. /***/ }),
  52704. /***/ "./resources/js/app.js":
  52705. /*!*****************************!*\
  52706. !*** ./resources/js/app.js ***!
  52707. \*****************************/
  52708. /*! no static exports found */
  52709. /***/ (function(module, exports, __webpack_require__) {
  52710. /**
  52711. * First we will load all of this project's JavaScript dependencies which
  52712. * includes Vue and other libraries. It is a great starting point when
  52713. * building robust, powerful web applications using Vue and Laravel.
  52714. */
  52715. __webpack_require__(/*! ./bootstrap */ "./resources/js/bootstrap.js");
  52716. window.Vue = __webpack_require__(/*! vue */ "./node_modules/vue/dist/vue.common.js");
  52717. /**
  52718. * The following block of code may be used to automatically register your
  52719. * Vue components. It will recursively scan this directory for the Vue
  52720. * components and automatically register them with their "basename".
  52721. *
  52722. * Eg. ./components/ExampleComponent.vue -> <example-component></example-component>
  52723. */
  52724. // const files = require.context('./', true, /\.vue$/i)
  52725. // files.keys().map(key => Vue.component(key.split('/').pop().split('.')[0], files(key).default))
  52726. Vue.component('example-component', __webpack_require__(/*! ./components/ExampleComponent.vue */ "./resources/js/components/ExampleComponent.vue")["default"]);
  52727. Vue.component('woinfo', __webpack_require__(/*! ./components/woinfo.vue */ "./resources/js/components/woinfo.vue")["default"]);
  52728. Vue.component('assetinfo', __webpack_require__(/*! ./components/assetinfo.vue */ "./resources/js/components/assetinfo.vue")["default"]);
  52729. /**
  52730. * Next, we will create a fresh Vue application instance and attach it to
  52731. * the page. Then, you may begin adding components to this application
  52732. * or customize the JavaScript scaffolding to fit your unique needs.
  52733. */
  52734. var app = new Vue({
  52735. el: '#app'
  52736. });
  52737. $(function () {
  52738. $('[data-toggle="tooltip"]').tooltip();
  52739. });
  52740. /***/ }),
  52741. /***/ "./resources/js/bootstrap.js":
  52742. /*!***********************************!*\
  52743. !*** ./resources/js/bootstrap.js ***!
  52744. \***********************************/
  52745. /*! no exports provided */
  52746. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  52747. "use strict";
  52748. __webpack_require__.r(__webpack_exports__);
  52749. /* harmony import */ var laravel_echo__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! laravel-echo */ "./node_modules/laravel-echo/dist/echo.js");
  52750. window._ = __webpack_require__(/*! lodash */ "./node_modules/lodash/lodash.js");
  52751. /**
  52752. * We'll load jQuery and the Bootstrap jQuery plugin which provides support
  52753. * for JavaScript based Bootstrap features such as modals and tabs. This
  52754. * code may be modified to fit the specific needs of your application.
  52755. */
  52756. try {
  52757. window.Popper = __webpack_require__(/*! popper.js */ "./node_modules/popper.js/dist/esm/popper.js")["default"];
  52758. window.$ = window.jQuery = __webpack_require__(/*! jquery */ "./node_modules/jquery/dist/jquery.js");
  52759. __webpack_require__(/*! bootstrap */ "./node_modules/bootstrap/dist/js/bootstrap.js");
  52760. } catch (e) {}
  52761. /**
  52762. * We'll load the axios HTTP library which allows us to easily issue requests
  52763. * to our Laravel back-end. This library automatically handles sending the
  52764. * CSRF token as a header based on the value of the "XSRF" token cookie.
  52765. */
  52766. window.axios = __webpack_require__(/*! axios */ "./node_modules/axios/index.js");
  52767. window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';
  52768. /**
  52769. * Echo exposes an expressive API for subscribing to channels and listening
  52770. * for events that are broadcast by Laravel. Echo and event broadcasting
  52771. * allows your team to easily build robust real-time web applications.
  52772. */
  52773. window.Pusher = __webpack_require__(/*! pusher-js */ "./node_modules/pusher-js/dist/web/pusher.js");
  52774. window.Echo = new laravel_echo__WEBPACK_IMPORTED_MODULE_0__["default"]({
  52775. broadcaster: 'pusher',
  52776. key: "upccrt",
  52777. wsHost: window.location.hostname,
  52778. wsPort: 6001,
  52779. disableStats: true
  52780. });
  52781. /***/ }),
  52782. /***/ "./resources/js/components/ExampleComponent.vue":
  52783. /*!******************************************************!*\
  52784. !*** ./resources/js/components/ExampleComponent.vue ***!
  52785. \******************************************************/
  52786. /*! exports provided: default */
  52787. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  52788. "use strict";
  52789. __webpack_require__.r(__webpack_exports__);
  52790. /* 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&");
  52791. /* 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&");
  52792. /* 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");
  52793. /* normalize component */
  52794. var component = Object(_node_modules_vue_loader_lib_runtime_componentNormalizer_js__WEBPACK_IMPORTED_MODULE_2__["default"])(
  52795. _ExampleComponent_vue_vue_type_script_lang_js___WEBPACK_IMPORTED_MODULE_1__["default"],
  52796. _ExampleComponent_vue_vue_type_template_id_299e239e___WEBPACK_IMPORTED_MODULE_0__["render"],
  52797. _ExampleComponent_vue_vue_type_template_id_299e239e___WEBPACK_IMPORTED_MODULE_0__["staticRenderFns"],
  52798. false,
  52799. null,
  52800. null,
  52801. null
  52802. )
  52803. /* hot reload */
  52804. if (false) { var api; }
  52805. component.options.__file = "resources/js/components/ExampleComponent.vue"
  52806. /* harmony default export */ __webpack_exports__["default"] = (component.exports);
  52807. /***/ }),
  52808. /***/ "./resources/js/components/ExampleComponent.vue?vue&type=script&lang=js&":
  52809. /*!*******************************************************************************!*\
  52810. !*** ./resources/js/components/ExampleComponent.vue?vue&type=script&lang=js& ***!
  52811. \*******************************************************************************/
  52812. /*! exports provided: default */
  52813. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  52814. "use strict";
  52815. __webpack_require__.r(__webpack_exports__);
  52816. /* 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&");
  52817. /* 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"]);
  52818. /***/ }),
  52819. /***/ "./resources/js/components/ExampleComponent.vue?vue&type=template&id=299e239e&":
  52820. /*!*************************************************************************************!*\
  52821. !*** ./resources/js/components/ExampleComponent.vue?vue&type=template&id=299e239e& ***!
  52822. \*************************************************************************************/
  52823. /*! exports provided: render, staticRenderFns */
  52824. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  52825. "use strict";
  52826. __webpack_require__.r(__webpack_exports__);
  52827. /* 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&");
  52828. /* 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"]; });
  52829. /* 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"]; });
  52830. /***/ }),
  52831. /***/ "./resources/js/components/assetinfo.vue":
  52832. /*!***********************************************!*\
  52833. !*** ./resources/js/components/assetinfo.vue ***!
  52834. \***********************************************/
  52835. /*! exports provided: default */
  52836. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  52837. "use strict";
  52838. __webpack_require__.r(__webpack_exports__);
  52839. /* 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&");
  52840. /* 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&");
  52841. /* 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");
  52842. /* normalize component */
  52843. var component = Object(_node_modules_vue_loader_lib_runtime_componentNormalizer_js__WEBPACK_IMPORTED_MODULE_2__["default"])(
  52844. _assetinfo_vue_vue_type_script_lang_js___WEBPACK_IMPORTED_MODULE_1__["default"],
  52845. _assetinfo_vue_vue_type_template_id_4fe1d2e3___WEBPACK_IMPORTED_MODULE_0__["render"],
  52846. _assetinfo_vue_vue_type_template_id_4fe1d2e3___WEBPACK_IMPORTED_MODULE_0__["staticRenderFns"],
  52847. false,
  52848. null,
  52849. null,
  52850. null
  52851. )
  52852. /* hot reload */
  52853. if (false) { var api; }
  52854. component.options.__file = "resources/js/components/assetinfo.vue"
  52855. /* harmony default export */ __webpack_exports__["default"] = (component.exports);
  52856. /***/ }),
  52857. /***/ "./resources/js/components/assetinfo.vue?vue&type=script&lang=js&":
  52858. /*!************************************************************************!*\
  52859. !*** ./resources/js/components/assetinfo.vue?vue&type=script&lang=js& ***!
  52860. \************************************************************************/
  52861. /*! exports provided: default */
  52862. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  52863. "use strict";
  52864. __webpack_require__.r(__webpack_exports__);
  52865. /* 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&");
  52866. /* 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"]);
  52867. /***/ }),
  52868. /***/ "./resources/js/components/assetinfo.vue?vue&type=template&id=4fe1d2e3&":
  52869. /*!******************************************************************************!*\
  52870. !*** ./resources/js/components/assetinfo.vue?vue&type=template&id=4fe1d2e3& ***!
  52871. \******************************************************************************/
  52872. /*! exports provided: render, staticRenderFns */
  52873. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  52874. "use strict";
  52875. __webpack_require__.r(__webpack_exports__);
  52876. /* 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&");
  52877. /* 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"]; });
  52878. /* 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"]; });
  52879. /***/ }),
  52880. /***/ "./resources/js/components/woinfo.vue":
  52881. /*!********************************************!*\
  52882. !*** ./resources/js/components/woinfo.vue ***!
  52883. \********************************************/
  52884. /*! exports provided: default */
  52885. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  52886. "use strict";
  52887. __webpack_require__.r(__webpack_exports__);
  52888. /* 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&");
  52889. /* 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&");
  52890. /* 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");
  52891. /* normalize component */
  52892. var component = Object(_node_modules_vue_loader_lib_runtime_componentNormalizer_js__WEBPACK_IMPORTED_MODULE_2__["default"])(
  52893. _woinfo_vue_vue_type_script_lang_js___WEBPACK_IMPORTED_MODULE_1__["default"],
  52894. _woinfo_vue_vue_type_template_id_33ce32de___WEBPACK_IMPORTED_MODULE_0__["render"],
  52895. _woinfo_vue_vue_type_template_id_33ce32de___WEBPACK_IMPORTED_MODULE_0__["staticRenderFns"],
  52896. false,
  52897. null,
  52898. null,
  52899. null
  52900. )
  52901. /* hot reload */
  52902. if (false) { var api; }
  52903. component.options.__file = "resources/js/components/woinfo.vue"
  52904. /* harmony default export */ __webpack_exports__["default"] = (component.exports);
  52905. /***/ }),
  52906. /***/ "./resources/js/components/woinfo.vue?vue&type=script&lang=js&":
  52907. /*!*********************************************************************!*\
  52908. !*** ./resources/js/components/woinfo.vue?vue&type=script&lang=js& ***!
  52909. \*********************************************************************/
  52910. /*! exports provided: default */
  52911. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  52912. "use strict";
  52913. __webpack_require__.r(__webpack_exports__);
  52914. /* 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&");
  52915. /* 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"]);
  52916. /***/ }),
  52917. /***/ "./resources/js/components/woinfo.vue?vue&type=template&id=33ce32de&":
  52918. /*!***************************************************************************!*\
  52919. !*** ./resources/js/components/woinfo.vue?vue&type=template&id=33ce32de& ***!
  52920. \***************************************************************************/
  52921. /*! exports provided: render, staticRenderFns */
  52922. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  52923. "use strict";
  52924. __webpack_require__.r(__webpack_exports__);
  52925. /* 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&");
  52926. /* 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"]; });
  52927. /* 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"]; });
  52928. /***/ }),
  52929. /***/ "./resources/js/mixins/dateMixin.js":
  52930. /*!******************************************!*\
  52931. !*** ./resources/js/mixins/dateMixin.js ***!
  52932. \******************************************/
  52933. /*! exports provided: default */
  52934. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  52935. "use strict";
  52936. __webpack_require__.r(__webpack_exports__);
  52937. /* harmony default export */ __webpack_exports__["default"] = ({
  52938. methods: {
  52939. treatAsUTC: function treatAsUTC(date) {
  52940. var result = new Date(date);
  52941. result.setMinutes(result.getMinutes() - result.getTimezoneOffset());
  52942. return result;
  52943. },
  52944. daysSinceToday: function daysSinceToday(date) {
  52945. var currentDate = new Date();
  52946. var millisecondsPerDay = 24 * 60 * 60 * 1000;
  52947. return (this.treatAsUTC(currentDate) - this.treatAsUTC(date)) / millisecondsPerDay;
  52948. },
  52949. getHRDate: function getHRDate(dateString) {
  52950. var date = new Date(dateString);
  52951. var year = date.getFullYear();
  52952. var month = date.toLocaleString('default', {
  52953. month: 'short'
  52954. });
  52955. var day = date.getDate();
  52956. var hour = date.getHours() % 12;
  52957. var minute = date.getMinutes();
  52958. var period = date.getHours() < 24 ? 'AM' : 'PM';
  52959. return month + " " + day + ", " + year + " " + hour + ":" + minute + " " + period;
  52960. },
  52961. isZero: function isZero(dateString) {
  52962. return dateString === '0000-00-00 00:00:00';
  52963. }
  52964. }
  52965. });
  52966. /***/ }),
  52967. /***/ "./resources/sass/app.scss":
  52968. /*!*********************************!*\
  52969. !*** ./resources/sass/app.scss ***!
  52970. \*********************************/
  52971. /*! no static exports found */
  52972. /***/ (function(module, exports) {
  52973. // removed by extract-text-webpack-plugin
  52974. /***/ }),
  52975. /***/ 0:
  52976. /*!*************************************************************!*\
  52977. !*** multi ./resources/js/app.js ./resources/sass/app.scss ***!
  52978. \*************************************************************/
  52979. /*! no static exports found */
  52980. /***/ (function(module, exports, __webpack_require__) {
  52981. __webpack_require__(/*! /home/vagrant/upccrt/resources/js/app.js */"./resources/js/app.js");
  52982. module.exports = __webpack_require__(/*! /home/vagrant/upccrt/resources/sass/app.scss */"./resources/sass/app.scss");
  52983. /***/ })
  52984. /******/ });