app.js 1.8 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040400414004240043400444004540046400474004840049400504005140052400534005440055400564005740058400594006040061400624006340064400654006640067400684006940070400714007240073400744007540076400774007840079400804008140082400834008440085400864008740088400894009040091400924009340094400954009640097400984009940100401014010240103401044010540106401074010840109401104011140112401134011440115401164011740118401194012040121401224012340124401254012640127401284012940130401314013240133401344013540136401374013840139401404014140142401434014440145401464014740148401494015040151401524015340154401554015640157401584015940160401614016240163401644016540166401674016840169401704017140172401734017440175401764017740178401794018040181401824018340184401854018640187401884018940190401914019240193401944019540196401974019840199402004020140202402034020440205402064020740208402094021040211402124021340214402154021640217402184021940220402214022240223402244022540226402274022840229402304023140232402334023440235402364023740238402394024040241402424024340244402454024640247402484024940250402514025240253402544025540256402574025840259402604026140262402634026440265402664026740268402694027040271402724027340274402754027640277402784027940280402814028240283402844028540286402874028840289402904029140292402934029440295402964029740298402994030040301403024030340304403054030640307403084030940310403114031240313403144031540316403174031840319403204032140322403234032440325403264032740328403294033040331403324033340334403354033640337403384033940340403414034240343403444034540346403474034840349403504035140352403534035440355403564035740358403594036040361403624036340364403654036640367403684036940370403714037240373403744037540376403774037840379403804038140382403834038440385403864038740388403894039040391403924039340394403954039640397403984039940400404014040240403404044040540406404074040840409404104041140412404134041440415404164041740418404194042040421404224042340424404254042640427404284042940430404314043240433404344043540436404374043840439404404044140442404434044440445404464044740448404494045040451404524045340454404554045640457404584045940460404614046240463404644046540466404674046840469404704047140472404734047440475404764047740478404794048040481404824048340484404854048640487404884048940490404914049240493404944049540496404974049840499405004050140502405034050440505405064050740508405094051040511405124051340514405154051640517405184051940520405214052240523405244052540526405274052840529405304053140532405334053440535405364053740538405394054040541405424054340544405454054640547405484054940550405514055240553405544055540556405574055840559405604056140562405634056440565405664056740568405694057040571405724057340574405754057640577405784057940580405814058240583405844058540586405874058840589405904059140592405934059440595405964059740598405994060040601406024060340604406054060640607406084060940610406114061240613406144061540616406174061840619406204062140622406234062440625406264062740628406294063040631406324063340634406354063640637406384063940640406414064240643406444064540646406474064840649406504065140652406534065440655406564065740658406594066040661406624066340664406654066640667406684066940670406714067240673406744067540676406774067840679406804068140682406834068440685406864068740688406894069040691406924069340694406954069640697406984069940700407014070240703407044070540706407074070840709407104071140712407134071440715407164071740718407194072040721407224072340724407254072640727407284072940730407314073240733407344073540736407374073840739407404074140742407434074440745407464074740748407494075040751407524075340754407554075640757407584075940760407614076240763407644076540766407674076840769407704077140772407734077440775407764077740778407794078040781407824078340784407854078640787407884078940790407914079240793407944079540796407974079840799408004080140802408034080440805408064080740808408094081040811408124081340814408154081640817408184081940820408214082240823408244082540826408274082840829408304083140832408334083440835408364083740838408394084040841408424084340844408454084640847408484084940850408514085240853408544085540856408574085840859408604086140862408634086440865408664086740868408694087040871408724087340874408754087640877408784087940880408814088240883408844088540886408874088840889408904089140892408934089440895408964089740898408994090040901409024090340904409054090640907409084090940910409114091240913409144091540916409174091840919409204092140922409234092440925409264092740928409294093040931409324093340934409354093640937409384093940940409414094240943409444094540946409474094840949409504095140952409534095440955409564095740958409594096040961409624096340964409654096640967409684096940970409714097240973409744097540976409774097840979409804098140982409834098440985409864098740988409894099040991409924099340994409954099640997409984099941000410014100241003410044100541006410074100841009410104101141012410134101441015410164101741018410194102041021410224102341024410254102641027410284102941030410314103241033410344103541036410374103841039410404104141042410434104441045410464104741048410494105041051410524105341054410554105641057410584105941060410614106241063410644106541066410674106841069410704107141072410734107441075410764107741078410794108041081410824108341084410854108641087410884108941090410914109241093410944109541096410974109841099411004110141102411034110441105411064110741108411094111041111411124111341114411154111641117411184111941120411214112241123411244112541126411274112841129411304113141132411334113441135411364113741138411394114041141411424114341144411454114641147411484114941150411514115241153411544115541156411574115841159411604116141162411634116441165411664116741168411694117041171411724117341174411754117641177411784117941180411814118241183411844118541186411874118841189411904119141192411934119441195411964119741198411994120041201412024120341204412054120641207412084120941210412114121241213412144121541216412174121841219412204122141222412234122441225412264122741228412294123041231412324123341234412354123641237412384123941240412414124241243412444124541246412474124841249412504125141252412534125441255412564125741258412594126041261412624126341264412654126641267412684126941270412714127241273412744127541276412774127841279412804128141282412834128441285412864128741288412894129041291412924129341294412954129641297412984129941300413014130241303413044130541306413074130841309413104131141312413134131441315413164131741318413194132041321413224132341324413254132641327413284132941330413314133241333413344133541336413374133841339413404134141342413434134441345413464134741348413494135041351413524135341354413554135641357413584135941360413614136241363413644136541366413674136841369413704137141372413734137441375413764137741378413794138041381413824138341384413854138641387413884138941390413914139241393413944139541396413974139841399414004140141402414034140441405414064140741408414094141041411414124141341414414154141641417414184141941420414214142241423414244142541426414274142841429414304143141432414334143441435414364143741438414394144041441414424144341444414454144641447414484144941450414514145241453414544145541456414574145841459414604146141462414634146441465414664146741468414694147041471414724147341474414754147641477414784147941480414814148241483414844148541486414874148841489414904149141492414934149441495414964149741498414994150041501415024150341504415054150641507415084150941510415114151241513415144151541516415174151841519415204152141522415234152441525415264152741528415294153041531415324153341534415354153641537415384153941540415414154241543415444154541546415474154841549415504155141552415534155441555415564155741558415594156041561415624156341564415654156641567415684156941570415714157241573415744157541576415774157841579415804158141582415834158441585415864158741588415894159041591415924159341594415954159641597415984159941600416014160241603416044160541606416074160841609416104161141612416134161441615416164161741618416194162041621416224162341624416254162641627416284162941630416314163241633416344163541636416374163841639416404164141642416434164441645416464164741648416494165041651416524165341654416554165641657416584165941660416614166241663416644166541666416674166841669416704167141672416734167441675416764167741678416794168041681416824168341684416854168641687416884168941690416914169241693416944169541696416974169841699417004170141702417034170441705417064170741708417094171041711417124171341714417154171641717417184171941720417214172241723417244172541726417274172841729417304173141732417334173441735417364173741738417394174041741417424174341744417454174641747417484174941750417514175241753417544175541756417574175841759417604176141762417634176441765417664176741768417694177041771417724177341774417754177641777417784177941780417814178241783417844178541786417874178841789417904179141792417934179441795417964179741798417994180041801418024180341804418054180641807418084180941810418114181241813418144181541816418174181841819418204182141822418234182441825418264182741828418294183041831418324183341834418354183641837418384183941840418414184241843418444184541846418474184841849418504185141852418534185441855418564185741858418594186041861418624186341864418654186641867418684186941870418714187241873418744187541876418774187841879418804188141882418834188441885418864188741888418894189041891418924189341894418954189641897418984189941900419014190241903419044190541906419074190841909419104191141912419134191441915419164191741918419194192041921419224192341924419254192641927419284192941930419314193241933419344193541936419374193841939419404194141942419434194441945419464194741948419494195041951419524195341954419554195641957419584195941960419614196241963419644196541966419674196841969419704197141972419734197441975419764197741978419794198041981419824198341984419854198641987419884198941990419914199241993419944199541996419974199841999420004200142002420034200442005420064200742008420094201042011420124201342014420154201642017420184201942020420214202242023420244202542026420274202842029420304203142032420334203442035420364203742038420394204042041420424204342044420454204642047420484204942050420514205242053420544205542056420574205842059420604206142062420634206442065420664206742068420694207042071420724207342074420754207642077420784207942080420814208242083420844208542086420874208842089420904209142092420934209442095420964209742098420994210042101421024210342104421054210642107421084210942110421114211242113421144211542116421174211842119421204212142122421234212442125421264212742128421294213042131421324213342134421354213642137421384213942140421414214242143421444214542146421474214842149421504215142152421534215442155421564215742158421594216042161421624216342164421654216642167421684216942170421714217242173421744217542176421774217842179421804218142182421834218442185421864218742188421894219042191421924219342194421954219642197421984219942200422014220242203422044220542206422074220842209422104221142212422134221442215422164221742218422194222042221422224222342224422254222642227422284222942230422314223242233422344223542236422374223842239422404224142242422434224442245422464224742248422494225042251422524225342254422554225642257422584225942260422614226242263422644226542266422674226842269422704227142272422734227442275422764227742278422794228042281422824228342284422854228642287422884228942290422914229242293422944229542296422974229842299423004230142302423034230442305423064230742308423094231042311423124231342314423154231642317423184231942320423214232242323423244232542326423274232842329423304233142332423334233442335423364233742338423394234042341423424234342344423454234642347423484234942350423514235242353423544235542356423574235842359423604236142362423634236442365423664236742368423694237042371423724237342374423754237642377423784237942380423814238242383423844238542386423874238842389423904239142392423934239442395423964239742398423994240042401424024240342404424054240642407424084240942410424114241242413424144241542416424174241842419424204242142422424234242442425424264242742428424294243042431424324243342434424354243642437424384243942440424414244242443424444244542446424474244842449424504245142452424534245442455424564245742458424594246042461424624246342464424654246642467424684246942470424714247242473424744247542476424774247842479424804248142482424834248442485424864248742488424894249042491424924249342494424954249642497424984249942500425014250242503425044250542506425074250842509425104251142512425134251442515425164251742518425194252042521425224252342524425254252642527425284252942530425314253242533425344253542536425374253842539425404254142542425434254442545425464254742548425494255042551425524255342554425554255642557425584255942560425614256242563425644256542566425674256842569425704257142572425734257442575425764257742578425794258042581425824258342584425854258642587425884258942590425914259242593425944259542596425974259842599426004260142602426034260442605426064260742608426094261042611426124261342614426154261642617426184261942620426214262242623426244262542626426274262842629426304263142632426334263442635426364263742638426394264042641426424264342644426454264642647426484264942650426514265242653426544265542656426574265842659426604266142662426634266442665426664266742668426694267042671426724267342674426754267642677426784267942680426814268242683426844268542686426874268842689426904269142692426934269442695426964269742698426994270042701427024270342704427054270642707427084270942710427114271242713427144271542716427174271842719427204272142722427234272442725427264272742728427294273042731427324273342734427354273642737427384273942740427414274242743427444274542746427474274842749427504275142752427534275442755427564275742758427594276042761427624276342764427654276642767427684276942770427714277242773427744277542776427774277842779427804278142782427834278442785427864278742788427894279042791427924279342794427954279642797427984279942800428014280242803428044280542806428074280842809428104281142812428134281442815428164281742818428194282042821428224282342824428254282642827428284282942830428314283242833428344283542836428374283842839428404284142842428434284442845428464284742848428494285042851428524285342854428554285642857428584285942860428614286242863428644286542866428674286842869428704287142872428734287442875428764287742878428794288042881428824288342884428854288642887428884288942890428914289242893428944289542896428974289842899429004290142902429034290442905429064290742908429094291042911429124291342914429154291642917429184291942920429214292242923429244292542926429274292842929429304293142932429334293442935429364293742938429394294042941429424294342944429454294642947429484294942950429514295242953429544295542956429574295842959429604296142962429634296442965429664296742968429694297042971429724297342974429754297642977429784297942980429814298242983429844298542986429874298842989429904299142992429934299442995429964299742998429994300043001430024300343004430054300643007430084300943010430114301243013430144301543016430174301843019430204302143022430234302443025430264302743028430294303043031430324303343034430354303643037430384303943040430414304243043430444304543046430474304843049430504305143052430534305443055430564305743058430594306043061430624306343064430654306643067430684306943070430714307243073430744307543076430774307843079430804308143082430834308443085430864308743088430894309043091430924309343094430954309643097430984309943100431014310243103431044310543106431074310843109431104311143112431134311443115431164311743118431194312043121431224312343124431254312643127431284312943130431314313243133431344313543136431374313843139431404314143142431434314443145431464314743148431494315043151431524315343154431554315643157431584315943160431614316243163431644316543166431674316843169431704317143172431734317443175431764317743178431794318043181431824318343184431854318643187431884318943190431914319243193431944319543196431974319843199432004320143202432034320443205432064320743208432094321043211432124321343214432154321643217432184321943220432214322243223432244322543226432274322843229432304323143232432334323443235432364323743238432394324043241432424324343244432454324643247432484324943250432514325243253432544325543256432574325843259432604326143262432634326443265432664326743268432694327043271432724327343274432754327643277432784327943280432814328243283432844328543286432874328843289432904329143292432934329443295432964329743298432994330043301433024330343304433054330643307433084330943310433114331243313433144331543316433174331843319433204332143322433234332443325433264332743328433294333043331433324333343334433354333643337433384333943340433414334243343433444334543346433474334843349433504335143352433534335443355433564335743358433594336043361433624336343364433654336643367433684336943370433714337243373433744337543376433774337843379433804338143382433834338443385433864338743388433894339043391433924339343394433954339643397433984339943400434014340243403434044340543406434074340843409434104341143412434134341443415434164341743418434194342043421434224342343424434254342643427434284342943430434314343243433434344343543436434374343843439434404344143442434434344443445434464344743448434494345043451434524345343454434554345643457434584345943460434614346243463434644346543466434674346843469434704347143472434734347443475434764347743478434794348043481434824348343484434854348643487434884348943490434914349243493434944349543496434974349843499435004350143502435034350443505435064350743508435094351043511435124351343514435154351643517435184351943520435214352243523435244352543526435274352843529435304353143532435334353443535435364353743538435394354043541435424354343544435454354643547435484354943550435514355243553435544355543556435574355843559435604356143562435634356443565435664356743568435694357043571435724357343574435754357643577435784357943580435814358243583435844358543586435874358843589435904359143592435934359443595435964359743598435994360043601436024360343604436054360643607436084360943610436114361243613436144361543616436174361843619436204362143622436234362443625436264362743628436294363043631436324363343634436354363643637436384363943640436414364243643436444364543646436474364843649436504365143652436534365443655436564365743658436594366043661436624366343664436654366643667436684366943670436714367243673436744367543676436774367843679436804368143682436834368443685436864368743688436894369043691436924369343694436954369643697436984369943700437014370243703437044370543706437074370843709437104371143712437134371443715437164371743718437194372043721437224372343724437254372643727437284372943730437314373243733437344373543736437374373843739437404374143742437434374443745437464374743748437494375043751437524375343754437554375643757437584375943760437614376243763437644376543766437674376843769437704377143772437734377443775437764377743778437794378043781437824378343784437854378643787437884378943790437914379243793437944379543796437974379843799438004380143802438034380443805438064380743808438094381043811438124381343814438154381643817438184381943820438214382243823438244382543826438274382843829438304383143832438334383443835438364383743838438394384043841438424384343844438454384643847438484384943850438514385243853438544385543856438574385843859438604386143862438634386443865438664386743868438694387043871438724387343874438754387643877438784387943880438814388243883438844388543886438874388843889438904389143892438934389443895438964389743898438994390043901439024390343904439054390643907439084390943910439114391243913439144391543916439174391843919439204392143922439234392443925439264392743928439294393043931439324393343934439354393643937439384393943940439414394243943439444394543946439474394843949439504395143952439534395443955439564395743958439594396043961439624396343964439654396643967439684396943970439714397243973439744397543976439774397843979439804398143982439834398443985439864398743988439894399043991439924399343994439954399643997439984399944000440014400244003440044400544006440074400844009440104401144012440134401444015440164401744018440194402044021440224402344024440254402644027440284402944030440314403244033440344403544036440374403844039440404404144042440434404444045440464404744048440494405044051440524405344054440554405644057440584405944060440614406244063440644406544066440674406844069440704407144072440734407444075440764407744078440794408044081440824408344084440854408644087440884408944090440914409244093440944409544096440974409844099441004410144102441034410444105441064410744108441094411044111441124411344114441154411644117441184411944120441214412244123441244412544126441274412844129441304413144132441334413444135441364413744138441394414044141441424414344144441454414644147441484414944150441514415244153441544415544156441574415844159441604416144162441634416444165441664416744168441694417044171441724417344174441754417644177441784417944180441814418244183441844418544186441874418844189441904419144192441934419444195441964419744198441994420044201442024420344204442054420644207442084420944210442114421244213442144421544216442174421844219442204422144222442234422444225442264422744228442294423044231442324423344234442354423644237442384423944240442414424244243442444424544246442474424844249442504425144252442534425444255442564425744258442594426044261442624426344264442654426644267442684426944270442714427244273442744427544276442774427844279442804428144282442834428444285442864428744288442894429044291442924429344294442954429644297442984429944300443014430244303443044430544306443074430844309443104431144312443134431444315443164431744318443194432044321443224432344324443254432644327443284432944330443314433244333443344433544336443374433844339443404434144342443434434444345443464434744348443494435044351443524435344354443554435644357443584435944360443614436244363443644436544366443674436844369443704437144372443734437444375443764437744378443794438044381443824438344384443854438644387443884438944390443914439244393443944439544396443974439844399444004440144402444034440444405444064440744408444094441044411444124441344414444154441644417444184441944420444214442244423444244442544426444274442844429444304443144432444334443444435444364443744438444394444044441444424444344444444454444644447444484444944450444514445244453444544445544456444574445844459444604446144462444634446444465444664446744468444694447044471444724447344474444754447644477444784447944480444814448244483444844448544486444874448844489444904449144492444934449444495444964449744498444994450044501445024450344504445054450644507445084450944510445114451244513445144451544516445174451844519445204452144522445234452444525445264452744528445294453044531445324453344534445354453644537445384453944540445414454244543445444454544546445474454844549445504455144552445534455444555445564455744558445594456044561445624456344564445654456644567445684456944570445714457244573445744457544576445774457844579445804458144582445834458444585445864458744588445894459044591445924459344594445954459644597445984459944600446014460244603446044460544606446074460844609446104461144612446134461444615446164461744618446194462044621446224462344624446254462644627446284462944630446314463244633446344463544636446374463844639446404464144642446434464444645446464464744648446494465044651446524465344654446554465644657446584465944660446614466244663446644466544666446674466844669446704467144672446734467444675446764467744678446794468044681446824468344684446854468644687446884468944690446914469244693446944469544696446974469844699447004470144702447034470444705447064470744708447094471044711447124471344714447154471644717447184471944720447214472244723447244472544726447274472844729447304473144732447334473444735447364473744738447394474044741447424474344744447454474644747447484474944750447514475244753447544475544756447574475844759447604476144762447634476444765447664476744768447694477044771447724477344774447754477644777447784477944780447814478244783447844478544786447874478844789447904479144792447934479444795447964479744798447994480044801448024480344804448054480644807448084480944810448114481244813448144481544816448174481844819448204482144822448234482444825448264482744828448294483044831448324483344834448354483644837448384483944840448414484244843448444484544846448474484844849448504485144852448534485444855448564485744858448594486044861448624486344864448654486644867448684486944870448714487244873448744487544876448774487844879448804488144882448834488444885448864488744888448894489044891448924489344894448954489644897448984489944900449014490244903449044490544906449074490844909449104491144912449134491444915449164491744918449194492044921449224492344924449254492644927449284492944930449314493244933449344493544936449374493844939449404494144942449434494444945449464494744948449494495044951449524495344954449554495644957449584495944960449614496244963449644496544966449674496844969449704497144972449734497444975449764497744978449794498044981449824498344984449854498644987449884498944990449914499244993449944499544996449974499844999450004500145002450034500445005450064500745008450094501045011450124501345014450154501645017450184501945020450214502245023450244502545026450274502845029450304503145032450334503445035450364503745038450394504045041450424504345044450454504645047450484504945050450514505245053450544505545056450574505845059450604506145062450634506445065450664506745068450694507045071450724507345074450754507645077450784507945080450814508245083450844508545086450874508845089450904509145092450934509445095450964509745098450994510045101451024510345104451054510645107451084510945110451114511245113451144511545116451174511845119451204512145122451234512445125451264512745128451294513045131451324513345134451354513645137451384513945140451414514245143451444514545146451474514845149451504515145152451534515445155451564515745158451594516045161451624516345164451654516645167451684516945170451714517245173451744517545176451774517845179451804518145182451834518445185451864518745188451894519045191451924519345194451954519645197451984519945200452014520245203452044520545206452074520845209452104521145212452134521445215452164521745218452194522045221452224522345224452254522645227452284522945230452314523245233452344523545236452374523845239452404524145242452434524445245452464524745248452494525045251452524525345254452554525645257452584525945260452614526245263452644526545266452674526845269452704527145272452734527445275452764527745278452794528045281452824528345284452854528645287452884528945290452914529245293452944529545296452974529845299453004530145302453034530445305453064530745308453094531045311453124531345314453154531645317453184531945320453214532245323453244532545326453274532845329453304533145332453334533445335453364533745338453394534045341453424534345344453454534645347453484534945350453514535245353453544535545356453574535845359453604536145362453634536445365453664536745368453694537045371453724537345374453754537645377453784537945380453814538245383453844538545386453874538845389453904539145392453934539445395453964539745398453994540045401454024540345404454054540645407454084540945410454114541245413454144541545416454174541845419454204542145422454234542445425454264542745428454294543045431454324543345434454354543645437454384543945440454414544245443454444544545446454474544845449454504545145452454534545445455454564545745458454594546045461454624546345464454654546645467454684546945470454714547245473454744547545476454774547845479454804548145482454834548445485454864548745488454894549045491454924549345494454954549645497454984549945500455014550245503455044550545506455074550845509455104551145512455134551445515455164551745518455194552045521455224552345524455254552645527455284552945530455314553245533455344553545536455374553845539455404554145542455434554445545455464554745548455494555045551455524555345554455554555645557455584555945560455614556245563455644556545566455674556845569455704557145572455734557445575455764557745578455794558045581455824558345584455854558645587455884558945590455914559245593455944559545596455974559845599456004560145602456034560445605456064560745608456094561045611456124561345614456154561645617456184561945620456214562245623456244562545626456274562845629456304563145632456334563445635456364563745638456394564045641456424564345644456454564645647456484564945650456514565245653456544565545656456574565845659456604566145662456634566445665456664566745668456694567045671456724567345674456754567645677456784567945680456814568245683456844568545686456874568845689456904569145692456934569445695456964569745698456994570045701457024570345704457054570645707457084570945710457114571245713457144571545716457174571845719457204572145722457234572445725457264572745728457294573045731457324573345734457354573645737457384573945740457414574245743457444574545746457474574845749457504575145752457534575445755457564575745758457594576045761457624576345764457654576645767457684576945770457714577245773457744577545776457774577845779457804578145782457834578445785457864578745788457894579045791457924579345794457954579645797457984579945800458014580245803458044580545806458074580845809458104581145812458134581445815458164581745818458194582045821458224582345824458254582645827458284582945830458314583245833458344583545836458374583845839458404584145842458434584445845458464584745848458494585045851458524585345854458554585645857458584585945860458614586245863458644586545866458674586845869458704587145872458734587445875458764587745878458794588045881458824588345884458854588645887458884588945890458914589245893458944589545896458974589845899459004590145902459034590445905459064590745908459094591045911459124591345914459154591645917459184591945920459214592245923459244592545926459274592845929459304593145932459334593445935459364593745938459394594045941459424594345944459454594645947459484594945950459514595245953459544595545956459574595845959459604596145962459634596445965459664596745968459694597045971459724597345974459754597645977459784597945980459814598245983459844598545986459874598845989459904599145992459934599445995459964599745998459994600046001460024600346004460054600646007460084600946010460114601246013460144601546016460174601846019460204602146022460234602446025460264602746028460294603046031460324603346034460354603646037460384603946040460414604246043460444604546046460474604846049460504605146052460534605446055460564605746058460594606046061460624606346064460654606646067460684606946070460714607246073460744607546076460774607846079460804608146082460834608446085460864608746088460894609046091460924609346094460954609646097460984609946100461014610246103461044610546106461074610846109461104611146112461134611446115461164611746118461194612046121461224612346124461254612646127461284612946130461314613246133461344613546136461374613846139461404614146142461434614446145461464614746148461494615046151461524615346154461554615646157461584615946160461614616246163461644616546166461674616846169461704617146172461734617446175461764617746178461794618046181461824618346184461854618646187461884618946190461914619246193461944619546196461974619846199462004620146202462034620446205462064620746208462094621046211462124621346214462154621646217462184621946220462214622246223462244622546226462274622846229462304623146232462334623446235462364623746238462394624046241462424624346244462454624646247462484624946250462514625246253462544625546256462574625846259462604626146262462634626446265462664626746268462694627046271462724627346274462754627646277462784627946280462814628246283462844628546286462874628846289462904629146292462934629446295462964629746298462994630046301463024630346304463054630646307463084630946310463114631246313463144631546316463174631846319463204632146322463234632446325463264632746328463294633046331463324633346334463354633646337463384633946340463414634246343463444634546346463474634846349463504635146352463534635446355463564635746358463594636046361463624636346364463654636646367463684636946370463714637246373463744637546376463774637846379463804638146382463834638446385463864638746388463894639046391463924639346394463954639646397463984639946400464014640246403464044640546406464074640846409464104641146412464134641446415464164641746418464194642046421464224642346424464254642646427464284642946430464314643246433464344643546436464374643846439464404644146442464434644446445464464644746448464494645046451464524645346454464554645646457464584645946460464614646246463464644646546466464674646846469464704647146472464734647446475464764647746478464794648046481464824648346484464854648646487464884648946490464914649246493464944649546496464974649846499465004650146502465034650446505465064650746508465094651046511465124651346514465154651646517465184651946520465214652246523465244652546526465274652846529465304653146532465334653446535465364653746538465394654046541465424654346544465454654646547465484654946550465514655246553465544655546556465574655846559465604656146562465634656446565465664656746568465694657046571465724657346574465754657646577465784657946580465814658246583465844658546586465874658846589465904659146592465934659446595465964659746598465994660046601466024660346604466054660646607466084660946610466114661246613466144661546616466174661846619466204662146622466234662446625466264662746628466294663046631466324663346634466354663646637466384663946640466414664246643466444664546646466474664846649466504665146652466534665446655466564665746658466594666046661466624666346664466654666646667466684666946670466714667246673466744667546676466774667846679466804668146682466834668446685466864668746688466894669046691466924669346694466954669646697466984669946700467014670246703467044670546706467074670846709467104671146712467134671446715467164671746718467194672046721467224672346724467254672646727467284672946730467314673246733467344673546736467374673846739467404674146742467434674446745467464674746748467494675046751467524675346754467554675646757467584675946760467614676246763467644676546766467674676846769467704677146772467734677446775467764677746778467794678046781467824678346784467854678646787467884678946790467914679246793467944679546796467974679846799468004680146802468034680446805468064680746808468094681046811468124681346814468154681646817468184681946820468214682246823468244682546826468274682846829468304683146832468334683446835468364683746838468394684046841468424684346844468454684646847468484684946850468514685246853468544685546856468574685846859468604686146862468634686446865468664686746868468694687046871468724687346874468754687646877468784687946880468814688246883468844688546886468874688846889468904689146892468934689446895468964689746898468994690046901469024690346904469054690646907469084690946910469114691246913469144691546916469174691846919469204692146922469234692446925469264692746928469294693046931469324693346934469354693646937469384693946940469414694246943469444694546946469474694846949469504695146952469534695446955469564695746958469594696046961469624696346964469654696646967469684696946970469714697246973469744697546976469774697846979469804698146982469834698446985469864698746988469894699046991469924699346994469954699646997469984699947000470014700247003470044700547006470074700847009470104701147012470134701447015470164701747018470194702047021470224702347024470254702647027470284702947030470314703247033470344703547036470374703847039470404704147042470434704447045470464704747048470494705047051470524705347054470554705647057470584705947060470614706247063470644706547066470674706847069470704707147072470734707447075470764707747078470794708047081470824708347084470854708647087470884708947090470914709247093470944709547096470974709847099471004710147102471034710447105471064710747108471094711047111471124711347114471154711647117471184711947120471214712247123471244712547126471274712847129471304713147132471334713447135471364713747138471394714047141471424714347144471454714647147471484714947150471514715247153471544715547156471574715847159471604716147162471634716447165471664716747168471694717047171471724717347174471754717647177471784717947180471814718247183471844718547186471874718847189471904719147192471934719447195471964719747198471994720047201472024720347204472054720647207472084720947210472114721247213472144721547216472174721847219472204722147222472234722447225472264722747228472294723047231472324723347234472354723647237472384723947240472414724247243472444724547246472474724847249472504725147252472534725447255472564725747258472594726047261472624726347264472654726647267472684726947270472714727247273472744727547276472774727847279472804728147282472834728447285472864728747288472894729047291472924729347294472954729647297472984729947300473014730247303473044730547306473074730847309473104731147312473134731447315473164731747318473194732047321473224732347324473254732647327473284732947330473314733247333473344733547336473374733847339473404734147342473434734447345473464734747348473494735047351473524735347354473554735647357473584735947360473614736247363473644736547366473674736847369473704737147372473734737447375473764737747378473794738047381473824738347384473854738647387473884738947390473914739247393473944739547396473974739847399474004740147402474034740447405474064740747408474094741047411474124741347414474154741647417474184741947420474214742247423474244742547426474274742847429474304743147432474334743447435474364743747438474394744047441474424744347444474454744647447474484744947450474514745247453474544745547456474574745847459474604746147462474634746447465474664746747468474694747047471474724747347474474754747647477474784747947480474814748247483474844748547486474874748847489474904749147492474934749447495474964749747498474994750047501475024750347504475054750647507475084750947510475114751247513475144751547516475174751847519475204752147522475234752447525475264752747528475294753047531475324753347534475354753647537475384753947540475414754247543475444754547546475474754847549475504755147552475534755447555475564755747558475594756047561475624756347564475654756647567475684756947570475714757247573475744757547576475774757847579475804758147582475834758447585475864758747588475894759047591475924759347594475954759647597475984759947600476014760247603476044760547606476074760847609476104761147612476134761447615476164761747618476194762047621476224762347624476254762647627476284762947630476314763247633476344763547636476374763847639476404764147642476434764447645476464764747648476494765047651476524765347654476554765647657476584765947660476614766247663476644766547666476674766847669476704767147672476734767447675476764767747678476794768047681476824768347684476854768647687476884768947690476914769247693476944769547696476974769847699477004770147702477034770447705477064770747708477094771047711477124771347714477154771647717477184771947720477214772247723477244772547726477274772847729477304773147732477334773447735477364773747738477394774047741477424774347744477454774647747477484774947750477514775247753477544775547756477574775847759477604776147762477634776447765477664776747768477694777047771477724777347774477754777647777477784777947780477814778247783477844778547786477874778847789477904779147792477934779447795477964779747798477994780047801478024780347804478054780647807478084780947810478114781247813478144781547816478174781847819478204782147822478234782447825478264782747828478294783047831478324783347834478354783647837478384783947840478414784247843478444784547846478474784847849478504785147852478534785447855478564785747858478594786047861478624786347864478654786647867478684786947870478714787247873478744787547876478774787847879478804788147882478834788447885478864788747888478894789047891478924789347894478954789647897478984789947900479014790247903479044790547906479074790847909479104791147912479134791447915479164791747918479194792047921479224792347924479254792647927479284792947930479314793247933479344793547936479374793847939479404794147942479434794447945479464794747948479494795047951479524795347954479554795647957479584795947960479614796247963479644796547966479674796847969479704797147972479734797447975479764797747978479794798047981479824798347984479854798647987479884798947990479914799247993479944799547996479974799847999480004800148002480034800448005480064800748008480094801048011480124801348014480154801648017480184801948020480214802248023480244802548026480274802848029480304803148032480334803448035480364803748038480394804048041480424804348044480454804648047480484804948050480514805248053480544805548056480574805848059480604806148062480634806448065480664806748068480694807048071480724807348074480754807648077480784807948080480814808248083480844808548086480874808848089480904809148092480934809448095480964809748098480994810048101481024810348104481054810648107481084810948110481114811248113481144811548116481174811848119481204812148122481234812448125481264812748128481294813048131481324813348134481354813648137481384813948140481414814248143481444814548146481474814848149481504815148152481534815448155481564815748158481594816048161481624816348164481654816648167481684816948170481714817248173481744817548176481774817848179481804818148182481834818448185481864818748188481894819048191481924819348194481954819648197481984819948200482014820248203482044820548206482074820848209482104821148212482134821448215482164821748218482194822048221482224822348224482254822648227482284822948230482314823248233482344823548236482374823848239482404824148242482434824448245482464824748248482494825048251482524825348254482554825648257482584825948260482614826248263482644826548266482674826848269482704827148272482734827448275482764827748278482794828048281482824828348284482854828648287482884828948290482914829248293482944829548296482974829848299483004830148302483034830448305483064830748308483094831048311483124831348314483154831648317483184831948320483214832248323483244832548326483274832848329483304833148332483334833448335483364833748338483394834048341483424834348344483454834648347483484834948350483514835248353483544835548356483574835848359483604836148362483634836448365483664836748368483694837048371483724837348374483754837648377483784837948380483814838248383483844838548386483874838848389483904839148392483934839448395483964839748398483994840048401484024840348404484054840648407484084840948410484114841248413484144841548416484174841848419484204842148422484234842448425484264842748428484294843048431484324843348434484354843648437484384843948440484414844248443484444844548446484474844848449484504845148452484534845448455484564845748458484594846048461484624846348464484654846648467484684846948470484714847248473484744847548476484774847848479484804848148482484834848448485484864848748488484894849048491484924849348494484954849648497484984849948500485014850248503485044850548506485074850848509485104851148512485134851448515485164851748518485194852048521485224852348524485254852648527485284852948530485314853248533485344853548536485374853848539485404854148542485434854448545485464854748548485494855048551485524855348554485554855648557485584855948560485614856248563485644856548566485674856848569485704857148572485734857448575485764857748578485794858048581485824858348584485854858648587485884858948590485914859248593485944859548596485974859848599486004860148602486034860448605486064860748608486094861048611486124861348614486154861648617486184861948620486214862248623486244862548626486274862848629486304863148632486334863448635486364863748638486394864048641486424864348644486454864648647486484864948650486514865248653486544865548656486574865848659486604866148662486634866448665486664866748668486694867048671486724867348674486754867648677486784867948680486814868248683486844868548686486874868848689486904869148692486934869448695486964869748698486994870048701487024870348704487054870648707487084870948710487114871248713487144871548716487174871848719487204872148722487234872448725487264872748728487294873048731487324873348734487354873648737487384873948740487414874248743487444874548746487474874848749487504875148752487534875448755487564875748758487594876048761487624876348764487654876648767487684876948770487714877248773487744877548776487774877848779487804878148782487834878448785487864878748788487894879048791487924879348794487954879648797487984879948800488014880248803488044880548806488074880848809488104881148812488134881448815488164881748818488194882048821488224882348824488254882648827488284882948830488314883248833488344883548836488374883848839488404884148842488434884448845488464884748848488494885048851488524885348854488554885648857488584885948860488614886248863488644886548866488674886848869488704887148872488734887448875488764887748878488794888048881488824888348884488854888648887488884888948890488914889248893488944889548896488974889848899489004890148902489034890448905489064890748908489094891048911489124891348914489154891648917489184891948920489214892248923489244892548926489274892848929489304893148932489334893448935489364893748938489394894048941489424894348944489454894648947489484894948950489514895248953489544895548956489574895848959489604896148962489634896448965489664896748968489694897048971489724897348974489754897648977489784897948980489814898248983489844898548986489874898848989489904899148992489934899448995489964899748998489994900049001490024900349004490054900649007490084900949010490114901249013490144901549016490174901849019490204902149022490234902449025490264902749028490294903049031490324903349034490354903649037490384903949040490414904249043490444904549046490474904849049490504905149052490534905449055490564905749058490594906049061490624906349064490654906649067490684906949070490714907249073490744907549076490774907849079490804908149082490834908449085490864908749088490894909049091490924909349094490954909649097490984909949100491014910249103491044910549106491074910849109491104911149112491134911449115491164911749118491194912049121491224912349124491254912649127491284912949130491314913249133491344913549136491374913849139491404914149142491434914449145491464914749148491494915049151491524915349154491554915649157491584915949160491614916249163491644916549166491674916849169491704917149172491734917449175491764917749178491794918049181491824918349184491854918649187491884918949190491914919249193491944919549196491974919849199492004920149202492034920449205492064920749208492094921049211492124921349214492154921649217492184921949220492214922249223492244922549226492274922849229492304923149232492334923449235492364923749238492394924049241492424924349244492454924649247492484924949250492514925249253492544925549256492574925849259492604926149262492634926449265492664926749268492694927049271492724927349274492754927649277492784927949280492814928249283492844928549286492874928849289492904929149292492934929449295492964929749298492994930049301493024930349304493054930649307493084930949310493114931249313493144931549316493174931849319493204932149322493234932449325493264932749328493294933049331493324933349334493354933649337493384933949340493414934249343493444934549346493474934849349493504935149352493534935449355493564935749358493594936049361493624936349364493654936649367493684936949370493714937249373493744937549376493774937849379493804938149382493834938449385493864938749388493894939049391493924939349394493954939649397493984939949400494014940249403494044940549406494074940849409494104941149412494134941449415494164941749418494194942049421494224942349424494254942649427494284942949430494314943249433494344943549436494374943849439494404944149442494434944449445494464944749448494494945049451494524945349454494554945649457494584945949460494614946249463494644946549466494674946849469494704947149472494734947449475494764947749478494794948049481494824948349484494854948649487494884948949490494914949249493494944949549496494974949849499495004950149502495034950449505495064950749508495094951049511495124951349514495154951649517495184951949520495214952249523495244952549526495274952849529495304953149532495334953449535495364953749538495394954049541495424954349544495454954649547495484954949550495514955249553495544955549556495574955849559495604956149562495634956449565495664956749568495694957049571495724957349574495754957649577495784957949580495814958249583495844958549586495874958849589495904959149592495934959449595495964959749598495994960049601496024960349604496054960649607496084960949610496114961249613496144961549616496174961849619496204962149622496234962449625496264962749628496294963049631496324963349634496354963649637496384963949640496414964249643496444964549646496474964849649496504965149652496534965449655496564965749658496594966049661496624966349664496654966649667496684966949670496714967249673496744967549676496774967849679496804968149682496834968449685496864968749688496894969049691496924969349694496954969649697496984969949700497014970249703497044970549706497074970849709497104971149712497134971449715497164971749718497194972049721497224972349724497254972649727497284972949730497314973249733497344973549736497374973849739497404974149742497434974449745497464974749748497494975049751497524975349754497554975649757497584975949760497614976249763497644976549766497674976849769497704977149772497734977449775497764977749778497794978049781497824978349784497854978649787497884978949790497914979249793497944979549796497974979849799498004980149802498034980449805498064980749808498094981049811498124981349814498154981649817498184981949820498214982249823498244982549826498274982849829498304983149832498334983449835498364983749838498394984049841498424984349844498454984649847498484984949850498514985249853498544985549856498574985849859498604986149862498634986449865498664986749868498694987049871498724987349874498754987649877498784987949880498814988249883498844988549886498874988849889498904989149892498934989449895498964989749898498994990049901499024990349904499054990649907499084990949910499114991249913499144991549916499174991849919499204992149922499234992449925499264992749928499294993049931499324993349934499354993649937499384993949940499414994249943499444994549946499474994849949499504995149952499534995449955499564995749958499594996049961499624996349964499654996649967499684996949970499714997249973499744997549976499774997849979499804998149982499834998449985499864998749988499894999049991499924999349994499954999649997499984999950000500015000250003500045000550006500075000850009500105001150012500135001450015500165001750018500195002050021500225002350024500255002650027500285002950030500315003250033500345003550036500375003850039500405004150042500435004450045500465004750048500495005050051500525005350054500555005650057500585005950060500615006250063500645006550066500675006850069500705007150072500735007450075500765007750078500795008050081500825008350084500855008650087500885008950090500915009250093500945009550096500975009850099501005010150102501035010450105501065010750108501095011050111501125011350114501155011650117501185011950120501215012250123501245012550126501275012850129501305013150132501335013450135501365013750138501395014050141501425014350144501455014650147501485014950150501515015250153501545015550156501575015850159501605016150162501635016450165501665016750168501695017050171501725017350174501755017650177501785017950180501815018250183501845018550186501875018850189501905019150192501935019450195501965019750198501995020050201502025020350204502055020650207502085020950210502115021250213502145021550216502175021850219502205022150222502235022450225502265022750228502295023050231502325023350234502355023650237502385023950240502415024250243502445024550246502475024850249502505025150252502535025450255502565025750258502595026050261502625026350264502655026650267502685026950270502715027250273502745027550276502775027850279502805028150282502835028450285502865028750288502895029050291502925029350294502955029650297502985029950300503015030250303503045030550306503075030850309503105031150312503135031450315503165031750318503195032050321503225032350324503255032650327503285032950330503315033250333503345033550336503375033850339503405034150342503435034450345503465034750348503495035050351503525035350354503555035650357503585035950360503615036250363503645036550366503675036850369503705037150372503735037450375503765037750378503795038050381503825038350384503855038650387503885038950390503915039250393503945039550396503975039850399504005040150402504035040450405504065040750408504095041050411504125041350414504155041650417504185041950420504215042250423504245042550426504275042850429504305043150432504335043450435504365043750438504395044050441504425044350444504455044650447504485044950450504515045250453504545045550456504575045850459504605046150462504635046450465504665046750468504695047050471504725047350474504755047650477504785047950480504815048250483504845048550486504875048850489504905049150492504935049450495504965049750498504995050050501505025050350504505055050650507505085050950510505115051250513505145051550516505175051850519505205052150522505235052450525505265052750528505295053050531505325053350534505355053650537505385053950540505415054250543505445054550546505475054850549505505055150552505535055450555505565055750558505595056050561505625056350564505655056650567505685056950570505715057250573505745057550576505775057850579505805058150582505835058450585505865058750588505895059050591505925059350594505955059650597505985059950600506015060250603506045060550606506075060850609506105061150612506135061450615506165061750618506195062050621506225062350624506255062650627506285062950630506315063250633506345063550636506375063850639506405064150642506435064450645506465064750648506495065050651506525065350654506555065650657506585065950660506615066250663506645066550666506675066850669506705067150672506735067450675506765067750678506795068050681506825068350684506855068650687506885068950690506915069250693506945069550696506975069850699507005070150702507035070450705507065070750708507095071050711507125071350714507155071650717507185071950720507215072250723507245072550726507275072850729507305073150732507335073450735507365073750738507395074050741507425074350744507455074650747507485074950750507515075250753507545075550756507575075850759507605076150762507635076450765507665076750768507695077050771507725077350774507755077650777507785077950780507815078250783507845078550786507875078850789507905079150792507935079450795507965079750798507995080050801508025080350804508055080650807508085080950810508115081250813508145081550816508175081850819508205082150822508235082450825508265082750828508295083050831508325083350834508355083650837508385083950840508415084250843508445084550846508475084850849508505085150852508535085450855508565085750858508595086050861508625086350864508655086650867508685086950870508715087250873508745087550876508775087850879508805088150882508835088450885508865088750888508895089050891508925089350894508955089650897508985089950900509015090250903509045090550906509075090850909509105091150912509135091450915509165091750918509195092050921509225092350924509255092650927509285092950930509315093250933509345093550936509375093850939509405094150942509435094450945509465094750948509495095050951509525095350954509555095650957509585095950960509615096250963509645096550966509675096850969509705097150972509735097450975509765097750978509795098050981509825098350984509855098650987509885098950990509915099250993509945099550996509975099850999510005100151002510035100451005510065100751008510095101051011510125101351014510155101651017510185101951020510215102251023510245102551026510275102851029510305103151032510335103451035510365103751038510395104051041510425104351044510455104651047510485104951050510515105251053510545105551056510575105851059510605106151062510635106451065510665106751068510695107051071510725107351074510755107651077510785107951080510815108251083510845108551086510875108851089510905109151092510935109451095510965109751098510995110051101511025110351104511055110651107511085110951110511115111251113511145111551116511175111851119511205112151122511235112451125511265112751128511295113051131511325113351134511355113651137511385113951140511415114251143511445114551146511475114851149511505115151152511535115451155511565115751158511595116051161511625116351164511655116651167511685116951170511715117251173511745117551176511775117851179511805118151182511835118451185511865118751188511895119051191511925119351194511955119651197511985119951200512015120251203512045120551206512075120851209512105121151212512135121451215512165121751218512195122051221512225122351224512255122651227512285122951230512315123251233512345123551236512375123851239512405124151242512435124451245512465124751248512495125051251512525125351254512555125651257512585125951260512615126251263512645126551266512675126851269512705127151272512735127451275512765127751278512795128051281512825128351284512855128651287512885128951290512915129251293512945129551296512975129851299513005130151302513035130451305513065130751308513095131051311513125131351314513155131651317513185131951320513215132251323513245132551326513275132851329513305133151332513335133451335513365133751338513395134051341513425134351344513455134651347513485134951350513515135251353513545135551356513575135851359513605136151362513635136451365513665136751368513695137051371513725137351374513755137651377513785137951380513815138251383513845138551386513875138851389513905139151392513935139451395513965139751398513995140051401514025140351404514055140651407514085140951410514115141251413514145141551416514175141851419514205142151422514235142451425514265142751428514295143051431514325143351434514355143651437514385143951440514415144251443514445144551446514475144851449514505145151452514535145451455514565145751458514595146051461514625146351464514655146651467514685146951470514715147251473514745147551476514775147851479514805148151482514835148451485514865148751488514895149051491514925149351494514955149651497514985149951500515015150251503515045150551506515075150851509515105151151512515135151451515515165151751518515195152051521515225152351524515255152651527515285152951530515315153251533515345153551536515375153851539515405154151542515435154451545515465154751548515495155051551515525155351554515555155651557515585155951560515615156251563515645156551566515675156851569515705157151572515735157451575515765157751578515795158051581515825158351584515855158651587515885158951590515915159251593515945159551596515975159851599516005160151602516035160451605516065160751608516095161051611516125161351614516155161651617516185161951620516215162251623516245162551626516275162851629516305163151632516335163451635516365163751638516395164051641516425164351644516455164651647516485164951650516515165251653516545165551656516575165851659516605166151662516635166451665516665166751668516695167051671516725167351674516755167651677516785167951680516815168251683516845168551686516875168851689516905169151692516935169451695516965169751698516995170051701517025170351704517055170651707517085170951710517115171251713517145171551716517175171851719517205172151722517235172451725517265172751728517295173051731517325173351734517355173651737517385173951740517415174251743517445174551746517475174851749517505175151752517535175451755517565175751758517595176051761517625176351764517655176651767517685176951770517715177251773517745177551776517775177851779517805178151782517835178451785517865178751788517895179051791517925179351794517955179651797517985179951800518015180251803518045180551806518075180851809518105181151812518135181451815518165181751818518195182051821518225182351824518255182651827518285182951830518315183251833518345183551836518375183851839518405184151842518435184451845518465184751848518495185051851518525185351854518555185651857518585185951860518615186251863518645186551866518675186851869518705187151872518735187451875518765187751878518795188051881518825188351884518855188651887518885188951890518915189251893518945189551896518975189851899519005190151902519035190451905519065190751908519095191051911519125191351914519155191651917519185191951920519215192251923519245192551926519275192851929519305193151932519335193451935519365193751938519395194051941519425194351944519455194651947519485194951950519515195251953519545195551956519575195851959519605196151962519635196451965519665196751968519695197051971519725197351974519755197651977519785197951980519815198251983519845198551986519875198851989519905199151992519935199451995519965199751998519995200052001520025200352004520055200652007520085200952010520115201252013520145201552016520175201852019520205202152022520235202452025520265202752028520295203052031520325203352034520355203652037520385203952040520415204252043520445204552046520475204852049520505205152052520535205452055520565205752058520595206052061520625206352064520655206652067520685206952070520715207252073520745207552076520775207852079520805208152082520835208452085520865208752088520895209052091520925209352094520955209652097520985209952100521015210252103521045210552106521075210852109521105211152112521135211452115521165211752118521195212052121521225212352124521255212652127521285212952130521315213252133521345213552136521375213852139521405214152142521435214452145521465214752148521495215052151521525215352154521555215652157521585215952160521615216252163521645216552166521675216852169521705217152172521735217452175521765217752178521795218052181521825218352184521855218652187521885218952190521915219252193521945219552196521975219852199522005220152202522035220452205522065220752208522095221052211522125221352214522155221652217522185221952220522215222252223522245222552226522275222852229522305223152232522335223452235522365223752238522395224052241522425224352244522455224652247522485224952250522515225252253522545225552256522575225852259522605226152262522635226452265522665226752268522695227052271522725227352274522755227652277522785227952280522815228252283522845228552286522875228852289522905229152292522935229452295522965229752298522995230052301523025230352304523055230652307523085230952310523115231252313523145231552316523175231852319523205232152322523235232452325523265232752328523295233052331523325233352334523355233652337523385233952340523415234252343523445234552346523475234852349523505235152352523535235452355523565235752358523595236052361523625236352364523655236652367523685236952370523715237252373523745237552376523775237852379523805238152382523835238452385523865238752388523895239052391523925239352394523955239652397523985239952400524015240252403524045240552406524075240852409524105241152412524135241452415524165241752418524195242052421524225242352424524255242652427524285242952430524315243252433524345243552436524375243852439524405244152442524435244452445524465244752448524495245052451524525245352454524555245652457524585245952460524615246252463524645246552466524675246852469524705247152472524735247452475524765247752478524795248052481524825248352484524855248652487524885248952490524915249252493524945249552496524975249852499525005250152502525035250452505525065250752508525095251052511525125251352514525155251652517525185251952520525215252252523525245252552526525275252852529525305253152532525335253452535525365253752538525395254052541525425254352544525455254652547525485254952550525515255252553525545255552556525575255852559525605256152562525635256452565525665256752568525695257052571525725257352574525755257652577525785257952580525815258252583525845258552586525875258852589525905259152592525935259452595525965259752598525995260052601526025260352604526055260652607526085260952610526115261252613526145261552616526175261852619526205262152622526235262452625526265262752628526295263052631526325263352634526355263652637526385263952640526415264252643526445264552646526475264852649526505265152652526535265452655526565265752658526595266052661526625266352664526655266652667526685266952670526715267252673526745267552676526775267852679526805268152682526835268452685526865268752688526895269052691526925269352694526955269652697526985269952700527015270252703527045270552706527075270852709527105271152712527135271452715527165271752718527195272052721527225272352724527255272652727527285272952730527315273252733527345273552736527375273852739527405274152742527435274452745527465274752748527495275052751527525275352754527555275652757527585275952760527615276252763527645276552766527675276852769527705277152772527735277452775527765277752778527795278052781527825278352784527855278652787527885278952790527915279252793527945279552796527975279852799528005280152802528035280452805528065280752808528095281052811528125281352814528155281652817528185281952820528215282252823528245282552826528275282852829528305283152832528335283452835528365283752838528395284052841528425284352844528455284652847528485284952850528515285252853528545285552856528575285852859528605286152862528635286452865528665286752868528695287052871528725287352874528755287652877528785287952880528815288252883528845288552886528875288852889528905289152892528935289452895528965289752898528995290052901529025290352904529055290652907529085290952910529115291252913529145291552916529175291852919529205292152922529235292452925529265292752928529295293052931529325293352934529355293652937529385293952940529415294252943529445294552946529475294852949529505295152952529535295452955529565295752958529595296052961529625296352964529655296652967529685296952970529715297252973529745297552976529775297852979529805298152982529835298452985529865298752988529895299052991529925299352994529955299652997529985299953000530015300253003530045300553006530075300853009530105301153012530135301453015530165301753018530195302053021530225302353024530255302653027530285302953030530315303253033530345303553036530375303853039530405304153042530435304453045530465304753048530495305053051530525305353054530555305653057530585305953060530615306253063530645306553066530675306853069530705307153072530735307453075530765307753078530795308053081530825308353084530855308653087530885308953090530915309253093530945309553096530975309853099531005310153102531035310453105531065310753108531095311053111531125311353114531155311653117531185311953120531215312253123531245312553126531275312853129531305313153132531335313453135531365313753138531395314053141531425314353144531455314653147531485314953150531515315253153531545315553156531575315853159531605316153162531635316453165531665316753168531695317053171531725317353174531755317653177531785317953180531815318253183531845318553186531875318853189531905319153192531935319453195531965319753198531995320053201532025320353204532055320653207532085320953210532115321253213532145321553216532175321853219532205322153222532235322453225532265322753228532295323053231532325323353234532355323653237532385323953240532415324253243532445324553246532475324853249532505325153252532535325453255532565325753258532595326053261532625326353264532655326653267532685326953270532715327253273532745327553276532775327853279532805328153282532835328453285532865328753288532895329053291532925329353294532955329653297532985329953300533015330253303533045330553306533075330853309533105331153312533135331453315533165331753318533195332053321533225332353324533255332653327533285332953330533315333253333533345333553336533375333853339533405334153342533435334453345533465334753348533495335053351533525335353354533555335653357533585335953360533615336253363533645336553366533675336853369533705337153372533735337453375533765337753378533795338053381533825338353384533855338653387533885338953390533915339253393533945339553396533975339853399534005340153402534035340453405534065340753408534095341053411534125341353414534155341653417534185341953420534215342253423534245342553426534275342853429534305343153432534335343453435534365343753438534395344053441534425344353444534455344653447534485344953450534515345253453534545345553456534575345853459534605346153462534635346453465534665346753468534695347053471534725347353474534755347653477534785347953480534815348253483534845348553486534875348853489534905349153492534935349453495534965349753498534995350053501535025350353504535055350653507535085350953510535115351253513535145351553516535175351853519535205352153522535235352453525535265352753528535295353053531535325353353534535355353653537535385353953540535415354253543535445354553546535475354853549535505355153552535535355453555535565355753558535595356053561535625356353564535655356653567535685356953570535715357253573535745357553576535775357853579535805358153582535835358453585535865358753588535895359053591535925359353594535955359653597535985359953600536015360253603536045360553606536075360853609536105361153612536135361453615536165361753618536195362053621536225362353624536255362653627536285362953630536315363253633536345363553636536375363853639536405364153642536435364453645536465364753648536495365053651536525365353654536555365653657536585365953660536615366253663536645366553666536675366853669536705367153672536735367453675536765367753678536795368053681536825368353684536855368653687536885368953690536915369253693536945369553696536975369853699537005370153702537035370453705537065370753708537095371053711537125371353714537155371653717537185371953720537215372253723537245372553726537275372853729537305373153732537335373453735537365373753738537395374053741537425374353744537455374653747537485374953750537515375253753537545375553756537575375853759537605376153762537635376453765537665376753768537695377053771537725377353774537755377653777537785377953780537815378253783537845378553786537875378853789537905379153792537935379453795537965379753798537995380053801538025380353804538055380653807538085380953810538115381253813538145381553816538175381853819538205382153822538235382453825538265382753828538295383053831538325383353834538355383653837538385383953840538415384253843538445384553846538475384853849538505385153852538535385453855538565385753858538595386053861538625386353864538655386653867538685386953870538715387253873538745387553876538775387853879538805388153882538835388453885538865388753888538895389053891538925389353894538955389653897538985389953900539015390253903539045390553906539075390853909539105391153912539135391453915539165391753918539195392053921539225392353924539255392653927539285392953930539315393253933539345393553936539375393853939539405394153942539435394453945539465394753948539495395053951539525395353954539555395653957539585395953960539615396253963539645396553966539675396853969539705397153972539735397453975539765397753978539795398053981539825398353984539855398653987539885398953990539915399253993539945399553996539975399853999540005400154002540035400454005540065400754008540095401054011540125401354014540155401654017540185401954020540215402254023540245402554026540275402854029540305403154032540335403454035540365403754038540395404054041540425404354044540455404654047540485404954050540515405254053540545405554056540575405854059540605406154062540635406454065540665406754068540695407054071540725407354074540755407654077540785407954080540815408254083540845408554086540875408854089540905409154092540935409454095540965409754098540995410054101541025410354104541055410654107541085410954110541115411254113541145411554116541175411854119541205412154122541235412454125541265412754128541295413054131541325413354134541355413654137541385413954140541415414254143541445414554146541475414854149541505415154152541535415454155541565415754158541595416054161541625416354164541655416654167541685416954170541715417254173541745417554176541775417854179541805418154182541835418454185541865418754188541895419054191541925419354194541955419654197541985419954200542015420254203542045420554206542075420854209542105421154212542135421454215542165421754218542195422054221542225422354224542255422654227542285422954230542315423254233542345423554236542375423854239542405424154242542435424454245542465424754248542495425054251542525425354254542555425654257542585425954260542615426254263542645426554266542675426854269542705427154272542735427454275542765427754278542795428054281542825428354284542855428654287542885428954290542915429254293542945429554296542975429854299543005430154302543035430454305543065430754308543095431054311543125431354314543155431654317543185431954320543215432254323543245432554326543275432854329543305433154332543335433454335543365433754338543395434054341543425434354344543455434654347543485434954350543515435254353543545435554356543575435854359543605436154362543635436454365543665436754368543695437054371543725437354374543755437654377543785437954380543815438254383543845438554386543875438854389543905439154392543935439454395543965439754398543995440054401544025440354404544055440654407544085440954410544115441254413544145441554416544175441854419544205442154422544235442454425544265442754428544295443054431544325443354434544355443654437544385443954440544415444254443544445444554446544475444854449544505445154452544535445454455544565445754458544595446054461544625446354464544655446654467544685446954470544715447254473544745447554476544775447854479544805448154482544835448454485544865448754488544895449054491544925449354494544955449654497544985449954500545015450254503545045450554506545075450854509545105451154512545135451454515545165451754518545195452054521545225452354524545255452654527545285452954530545315453254533545345453554536545375453854539545405454154542545435454454545545465454754548545495455054551545525455354554545555455654557545585455954560545615456254563545645456554566545675456854569545705457154572545735457454575545765457754578545795458054581545825458354584545855458654587545885458954590545915459254593545945459554596545975459854599546005460154602546035460454605546065460754608546095461054611546125461354614546155461654617546185461954620546215462254623546245462554626546275462854629546305463154632546335463454635546365463754638546395464054641546425464354644546455464654647546485464954650546515465254653546545465554656546575465854659546605466154662546635466454665546665466754668546695467054671546725467354674546755467654677546785467954680546815468254683546845468554686546875468854689546905469154692546935469454695546965469754698546995470054701547025470354704547055470654707547085470954710547115471254713547145471554716547175471854719547205472154722547235472454725547265472754728547295473054731547325473354734547355473654737547385473954740547415474254743547445474554746547475474854749547505475154752547535475454755547565475754758547595476054761547625476354764547655476654767547685476954770547715477254773547745477554776547775477854779547805478154782547835478454785547865478754788547895479054791547925479354794547955479654797547985479954800548015480254803548045480554806548075480854809548105481154812548135481454815548165481754818548195482054821548225482354824548255482654827548285482954830548315483254833548345483554836548375483854839548405484154842548435484454845548465484754848548495485054851548525485354854548555485654857548585485954860548615486254863548645486554866548675486854869548705487154872548735487454875548765487754878548795488054881548825488354884548855488654887548885488954890548915489254893548945489554896548975489854899549005490154902549035490454905549065490754908549095491054911549125491354914549155491654917549185491954920549215492254923549245492554926549275492854929549305493154932549335493454935549365493754938549395494054941549425494354944549455494654947549485494954950549515495254953549545495554956549575495854959549605496154962549635496454965549665496754968549695497054971549725497354974549755497654977549785497954980549815498254983549845498554986549875498854989549905499154992549935499454995549965499754998549995500055001550025500355004550055500655007550085500955010550115501255013550145501555016550175501855019550205502155022550235502455025550265502755028550295503055031550325503355034550355503655037550385503955040550415504255043550445504555046550475504855049550505505155052550535505455055550565505755058550595506055061550625506355064550655506655067550685506955070550715507255073550745507555076550775507855079550805508155082550835508455085550865508755088550895509055091550925509355094550955509655097550985509955100551015510255103551045510555106551075510855109551105511155112551135511455115551165511755118551195512055121551225512355124551255512655127551285512955130551315513255133551345513555136551375513855139551405514155142551435514455145551465514755148551495515055151551525515355154551555515655157551585515955160551615516255163551645516555166551675516855169551705517155172551735517455175551765517755178551795518055181551825518355184551855518655187551885518955190551915519255193551945519555196551975519855199552005520155202552035520455205552065520755208552095521055211552125521355214552155521655217552185521955220552215522255223552245522555226552275522855229552305523155232552335523455235552365523755238552395524055241552425524355244552455524655247552485524955250552515525255253552545525555256552575525855259552605526155262552635526455265552665526755268552695527055271552725527355274552755527655277552785527955280552815528255283552845528555286552875528855289552905529155292552935529455295552965529755298552995530055301553025530355304553055530655307553085530955310553115531255313553145531555316553175531855319553205532155322553235532455325553265532755328553295533055331553325533355334553355533655337553385533955340553415534255343553445534555346553475534855349553505535155352553535535455355553565535755358553595536055361553625536355364553655536655367553685536955370553715537255373553745537555376553775537855379553805538155382553835538455385553865538755388553895539055391553925539355394553955539655397553985539955400554015540255403554045540555406554075540855409554105541155412554135541455415554165541755418554195542055421554225542355424554255542655427554285542955430554315543255433554345543555436554375543855439554405544155442554435544455445554465544755448554495545055451554525545355454554555545655457554585545955460554615546255463554645546555466554675546855469554705547155472554735547455475554765547755478554795548055481554825548355484554855548655487554885548955490554915549255493554945549555496554975549855499555005550155502555035550455505555065550755508555095551055511555125551355514555155551655517555185551955520555215552255523555245552555526555275552855529555305553155532555335553455535555365553755538555395554055541555425554355544555455554655547555485554955550555515555255553555545555555556555575555855559555605556155562555635556455565555665556755568555695557055571555725557355574555755557655577555785557955580555815558255583555845558555586555875558855589555905559155592555935559455595555965559755598555995560055601556025560355604556055560655607556085560955610556115561255613556145561555616556175561855619556205562155622556235562455625556265562755628556295563055631556325563355634556355563655637556385563955640556415564255643556445564555646556475564855649556505565155652556535565455655556565565755658556595566055661556625566355664556655566655667556685566955670556715567255673556745567555676556775567855679556805568155682556835568455685556865568755688556895569055691556925569355694556955569655697556985569955700557015570255703557045570555706557075570855709557105571155712557135571455715557165571755718557195572055721557225572355724557255572655727557285572955730557315573255733557345573555736557375573855739557405574155742557435574455745557465574755748557495575055751557525575355754557555575655757557585575955760557615576255763557645576555766557675576855769557705577155772557735577455775557765577755778557795578055781557825578355784557855578655787557885578955790557915579255793557945579555796557975579855799558005580155802558035580455805558065580755808558095581055811558125581355814558155581655817558185581955820558215582255823558245582555826558275582855829558305583155832558335583455835558365583755838558395584055841558425584355844558455584655847558485584955850558515585255853558545585555856558575585855859558605586155862558635586455865558665586755868558695587055871558725587355874558755587655877558785587955880558815588255883558845588555886558875588855889558905589155892558935589455895558965589755898558995590055901559025590355904559055590655907559085590955910559115591255913559145591555916559175591855919559205592155922559235592455925559265592755928559295593055931559325593355934559355593655937559385593955940559415594255943559445594555946559475594855949559505595155952559535595455955559565595755958559595596055961559625596355964559655596655967559685596955970559715597255973559745597555976559775597855979559805598155982559835598455985559865598755988559895599055991559925599355994559955599655997559985599956000560015600256003560045600556006560075600856009560105601156012560135601456015560165601756018560195602056021560225602356024560255602656027560285602956030560315603256033560345603556036560375603856039560405604156042560435604456045560465604756048560495605056051560525605356054560555605656057560585605956060560615606256063560645606556066560675606856069560705607156072560735607456075560765607756078560795608056081560825608356084560855608656087560885608956090560915609256093560945609556096560975609856099561005610156102561035610456105561065610756108561095611056111561125611356114561155611656117561185611956120561215612256123561245612556126561275612856129561305613156132561335613456135561365613756138561395614056141561425614356144561455614656147561485614956150561515615256153561545615556156561575615856159561605616156162561635616456165561665616756168561695617056171561725617356174561755617656177561785617956180561815618256183561845618556186561875618856189561905619156192561935619456195561965619756198561995620056201562025620356204562055620656207562085620956210562115621256213562145621556216562175621856219562205622156222562235622456225562265622756228562295623056231562325623356234562355623656237562385623956240562415624256243562445624556246562475624856249562505625156252562535625456255562565625756258562595626056261562625626356264562655626656267562685626956270562715627256273562745627556276562775627856279562805628156282562835628456285562865628756288562895629056291562925629356294562955629656297562985629956300563015630256303563045630556306563075630856309563105631156312563135631456315563165631756318563195632056321563225632356324563255632656327563285632956330563315633256333563345633556336563375633856339563405634156342563435634456345563465634756348563495635056351563525635356354563555635656357563585635956360563615636256363563645636556366563675636856369563705637156372563735637456375563765637756378563795638056381563825638356384563855638656387563885638956390563915639256393563945639556396563975639856399564005640156402564035640456405564065640756408564095641056411564125641356414564155641656417564185641956420564215642256423564245642556426564275642856429564305643156432564335643456435564365643756438564395644056441564425644356444564455644656447564485644956450564515645256453564545645556456564575645856459564605646156462564635646456465564665646756468564695647056471564725647356474564755647656477564785647956480564815648256483564845648556486564875648856489564905649156492564935649456495564965649756498564995650056501565025650356504565055650656507565085650956510565115651256513565145651556516565175651856519565205652156522565235652456525565265652756528565295653056531565325653356534565355653656537565385653956540565415654256543565445654556546565475654856549565505655156552565535655456555565565655756558565595656056561565625656356564565655656656567565685656956570565715657256573565745657556576565775657856579565805658156582565835658456585565865658756588565895659056591565925659356594565955659656597565985659956600566015660256603566045660556606566075660856609566105661156612566135661456615566165661756618566195662056621566225662356624566255662656627566285662956630566315663256633566345663556636566375663856639566405664156642566435664456645566465664756648566495665056651566525665356654566555665656657566585665956660566615666256663566645666556666566675666856669566705667156672566735667456675566765667756678566795668056681566825668356684566855668656687566885668956690566915669256693566945669556696566975669856699567005670156702567035670456705567065670756708567095671056711567125671356714567155671656717567185671956720567215672256723567245672556726567275672856729567305673156732567335673456735567365673756738567395674056741567425674356744567455674656747567485674956750567515675256753567545675556756567575675856759567605676156762567635676456765567665676756768567695677056771567725677356774567755677656777567785677956780567815678256783567845678556786567875678856789567905679156792567935679456795567965679756798567995680056801568025680356804568055680656807568085680956810568115681256813568145681556816568175681856819568205682156822568235682456825568265682756828568295683056831568325683356834568355683656837568385683956840568415684256843568445684556846568475684856849568505685156852568535685456855568565685756858568595686056861568625686356864568655686656867568685686956870568715687256873568745687556876568775687856879568805688156882568835688456885568865688756888568895689056891568925689356894568955689656897568985689956900569015690256903569045690556906569075690856909569105691156912569135691456915569165691756918569195692056921569225692356924569255692656927569285692956930569315693256933569345693556936569375693856939569405694156942569435694456945569465694756948569495695056951569525695356954569555695656957569585695956960569615696256963569645696556966569675696856969569705697156972569735697456975569765697756978569795698056981569825698356984569855698656987569885698956990569915699256993569945699556996569975699856999570005700157002570035700457005570065700757008570095701057011570125701357014570155701657017570185701957020570215702257023570245702557026570275702857029570305703157032570335703457035570365703757038570395704057041570425704357044570455704657047570485704957050570515705257053570545705557056570575705857059570605706157062570635706457065570665706757068570695707057071570725707357074570755707657077570785707957080570815708257083570845708557086570875708857089570905709157092570935709457095570965709757098570995710057101571025710357104571055710657107571085710957110571115711257113571145711557116571175711857119571205712157122571235712457125571265712757128571295713057131571325713357134571355713657137571385713957140571415714257143571445714557146571475714857149571505715157152571535715457155571565715757158571595716057161571625716357164571655716657167571685716957170571715717257173571745717557176571775717857179571805718157182571835718457185571865718757188571895719057191571925719357194571955719657197571985719957200572015720257203572045720557206572075720857209572105721157212572135721457215572165721757218572195722057221572225722357224572255722657227572285722957230572315723257233572345723557236572375723857239572405724157242572435724457245572465724757248572495725057251572525725357254572555725657257572585725957260572615726257263572645726557266572675726857269572705727157272572735727457275572765727757278572795728057281572825728357284572855728657287572885728957290572915729257293572945729557296572975729857299573005730157302573035730457305573065730757308573095731057311573125731357314573155731657317573185731957320573215732257323573245732557326573275732857329573305733157332573335733457335573365733757338573395734057341573425734357344573455734657347573485734957350573515735257353573545735557356573575735857359573605736157362573635736457365573665736757368573695737057371573725737357374573755737657377573785737957380573815738257383573845738557386573875738857389573905739157392573935739457395573965739757398573995740057401574025740357404574055740657407574085740957410574115741257413574145741557416574175741857419574205742157422574235742457425574265742757428574295743057431574325743357434574355743657437574385743957440574415744257443574445744557446574475744857449574505745157452574535745457455574565745757458574595746057461574625746357464574655746657467574685746957470574715747257473574745747557476574775747857479574805748157482574835748457485574865748757488574895749057491574925749357494574955749657497574985749957500575015750257503575045750557506575075750857509575105751157512575135751457515575165751757518575195752057521575225752357524575255752657527575285752957530575315753257533575345753557536575375753857539575405754157542575435754457545575465754757548575495755057551575525755357554575555755657557575585755957560575615756257563575645756557566575675756857569575705757157572575735757457575575765757757578575795758057581575825758357584575855758657587575885758957590575915759257593575945759557596575975759857599576005760157602576035760457605576065760757608576095761057611576125761357614576155761657617576185761957620576215762257623576245762557626576275762857629576305763157632576335763457635576365763757638576395764057641576425764357644576455764657647576485764957650576515765257653576545765557656576575765857659576605766157662576635766457665576665766757668576695767057671576725767357674576755767657677576785767957680576815768257683576845768557686576875768857689576905769157692576935769457695576965769757698576995770057701577025770357704577055770657707577085770957710577115771257713577145771557716577175771857719577205772157722577235772457725577265772757728577295773057731577325773357734577355773657737577385773957740577415774257743577445774557746577475774857749577505775157752577535775457755577565775757758577595776057761577625776357764577655776657767577685776957770577715777257773577745777557776577775777857779577805778157782577835778457785577865778757788577895779057791577925779357794577955779657797577985779957800578015780257803578045780557806578075780857809578105781157812578135781457815578165781757818578195782057821578225782357824578255782657827578285782957830578315783257833578345783557836578375783857839578405784157842578435784457845578465784757848578495785057851578525785357854578555785657857578585785957860578615786257863578645786557866578675786857869578705787157872578735787457875578765787757878578795788057881578825788357884578855788657887578885788957890578915789257893578945789557896578975789857899579005790157902579035790457905579065790757908579095791057911579125791357914579155791657917579185791957920579215792257923579245792557926579275792857929579305793157932579335793457935579365793757938579395794057941579425794357944579455794657947579485794957950579515795257953579545795557956579575795857959579605796157962579635796457965579665796757968579695797057971579725797357974579755797657977579785797957980579815798257983579845798557986579875798857989579905799157992579935799457995579965799757998579995800058001580025800358004580055800658007580085800958010580115801258013580145801558016580175801858019580205802158022580235802458025580265802758028580295803058031580325803358034580355803658037580385803958040580415804258043580445804558046580475804858049580505805158052580535805458055580565805758058580595806058061580625806358064580655806658067580685806958070580715807258073580745807558076580775807858079580805808158082580835808458085580865808758088580895809058091580925809358094580955809658097580985809958100581015810258103581045810558106581075810858109581105811158112581135811458115581165811758118581195812058121581225812358124581255812658127581285812958130581315813258133581345813558136581375813858139581405814158142581435814458145581465814758148581495815058151581525815358154581555815658157581585815958160581615816258163581645816558166581675816858169581705817158172581735817458175581765817758178581795818058181581825818358184581855818658187581885818958190581915819258193581945819558196581975819858199582005820158202582035820458205582065820758208582095821058211582125821358214582155821658217582185821958220582215822258223582245822558226582275822858229582305823158232582335823458235582365823758238582395824058241582425824358244582455824658247582485824958250582515825258253582545825558256582575825858259582605826158262582635826458265582665826758268582695827058271582725827358274582755827658277582785827958280582815828258283582845828558286582875828858289582905829158292582935829458295582965829758298582995830058301583025830358304583055830658307583085830958310583115831258313583145831558316583175831858319583205832158322583235832458325583265832758328583295833058331583325833358334583355833658337583385833958340583415834258343583445834558346583475834858349583505835158352583535835458355583565835758358583595836058361583625836358364583655836658367583685836958370583715837258373583745837558376583775837858379583805838158382583835838458385583865838758388583895839058391583925839358394583955839658397583985839958400584015840258403584045840558406584075840858409584105841158412584135841458415584165841758418584195842058421584225842358424584255842658427584285842958430584315843258433584345843558436584375843858439584405844158442584435844458445584465844758448584495845058451584525845358454584555845658457584585845958460584615846258463584645846558466584675846858469584705847158472584735847458475584765847758478584795848058481584825848358484584855848658487584885848958490584915849258493584945849558496584975849858499585005850158502585035850458505585065850758508585095851058511585125851358514585155851658517585185851958520585215852258523585245852558526585275852858529585305853158532585335853458535585365853758538585395854058541585425854358544585455854658547585485854958550585515855258553585545855558556585575855858559585605856158562585635856458565585665856758568585695857058571585725857358574585755857658577585785857958580585815858258583585845858558586585875858858589585905859158592585935859458595585965859758598585995860058601586025860358604586055860658607586085860958610586115861258613586145861558616586175861858619586205862158622586235862458625586265862758628586295863058631586325863358634586355863658637586385863958640586415864258643586445864558646586475864858649586505865158652586535865458655586565865758658586595866058661586625866358664586655866658667586685866958670586715867258673586745867558676586775867858679586805868158682586835868458685586865868758688586895869058691586925869358694586955869658697586985869958700587015870258703587045870558706587075870858709587105871158712587135871458715587165871758718587195872058721587225872358724587255872658727587285872958730587315873258733587345873558736587375873858739587405874158742587435874458745587465874758748587495875058751587525875358754587555875658757587585875958760587615876258763587645876558766587675876858769587705877158772587735877458775587765877758778587795878058781587825878358784587855878658787587885878958790587915879258793587945879558796587975879858799588005880158802588035880458805588065880758808588095881058811588125881358814588155881658817588185881958820588215882258823588245882558826588275882858829588305883158832588335883458835588365883758838588395884058841588425884358844588455884658847588485884958850588515885258853588545885558856588575885858859588605886158862588635886458865588665886758868588695887058871588725887358874588755887658877588785887958880588815888258883588845888558886588875888858889588905889158892588935889458895588965889758898588995890058901589025890358904589055890658907589085890958910589115891258913589145891558916589175891858919589205892158922589235892458925589265892758928589295893058931589325893358934589355893658937589385893958940589415894258943589445894558946589475894858949589505895158952589535895458955589565895758958589595896058961589625896358964589655896658967589685896958970589715897258973589745897558976589775897858979589805898158982589835898458985589865898758988589895899058991589925899358994589955899658997589985899959000590015900259003590045900559006590075900859009590105901159012590135901459015590165901759018590195902059021590225902359024590255902659027590285902959030590315903259033590345903559036590375903859039590405904159042590435904459045590465904759048590495905059051590525905359054590555905659057590585905959060590615906259063590645906559066590675906859069590705907159072590735907459075590765907759078590795908059081590825908359084590855908659087590885908959090590915909259093590945909559096590975909859099591005910159102591035910459105591065910759108591095911059111591125911359114591155911659117591185911959120591215912259123591245912559126591275912859129591305913159132591335913459135591365913759138591395914059141591425914359144591455914659147591485914959150591515915259153591545915559156591575915859159591605916159162591635916459165591665916759168591695917059171591725917359174591755917659177591785917959180591815918259183591845918559186591875918859189591905919159192591935919459195591965919759198591995920059201592025920359204592055920659207592085920959210592115921259213592145921559216592175921859219592205922159222592235922459225592265922759228592295923059231592325923359234592355923659237592385923959240592415924259243592445924559246592475924859249592505925159252592535925459255592565925759258592595926059261592625926359264592655926659267592685926959270592715927259273592745927559276592775927859279592805928159282592835928459285592865928759288592895929059291592925929359294592955929659297592985929959300593015930259303593045930559306593075930859309593105931159312593135931459315593165931759318593195932059321593225932359324593255932659327593285932959330593315933259333593345933559336593375933859339593405934159342593435934459345593465934759348593495935059351593525935359354593555935659357593585935959360593615936259363593645936559366593675936859369593705937159372593735937459375593765937759378593795938059381593825938359384593855938659387593885938959390593915939259393593945939559396593975939859399594005940159402594035940459405594065940759408594095941059411594125941359414594155941659417594185941959420594215942259423594245942559426594275942859429594305943159432594335943459435594365943759438594395944059441594425944359444594455944659447594485944959450594515945259453594545945559456594575945859459594605946159462594635946459465594665946759468594695947059471594725947359474594755947659477594785947959480594815948259483594845948559486594875948859489594905949159492594935949459495594965949759498594995950059501595025950359504595055950659507595085950959510595115951259513595145951559516595175951859519595205952159522595235952459525595265952759528595295953059531595325953359534595355953659537595385953959540595415954259543595445954559546595475954859549595505955159552595535955459555595565955759558595595956059561595625956359564595655956659567595685956959570595715957259573595745957559576595775957859579595805958159582595835958459585595865958759588595895959059591595925959359594595955959659597595985959959600596015960259603596045960559606596075960859609596105961159612596135961459615596165961759618596195962059621596225962359624596255962659627596285962959630596315963259633596345963559636596375963859639596405964159642596435964459645596465964759648596495965059651596525965359654596555965659657596585965959660596615966259663596645966559666596675966859669596705967159672596735967459675596765967759678596795968059681596825968359684596855968659687596885968959690596915969259693596945969559696596975969859699597005970159702597035970459705597065970759708597095971059711597125971359714597155971659717597185971959720597215972259723597245972559726597275972859729597305973159732597335973459735597365973759738597395974059741597425974359744597455974659747597485974959750597515975259753597545975559756597575975859759597605976159762597635976459765597665976759768597695977059771597725977359774597755977659777597785977959780597815978259783597845978559786597875978859789597905979159792597935979459795597965979759798597995980059801598025980359804598055980659807598085980959810598115981259813598145981559816598175981859819598205982159822598235982459825598265982759828598295983059831598325983359834598355983659837598385983959840598415984259843598445984559846598475984859849598505985159852598535985459855598565985759858598595986059861598625986359864598655986659867598685986959870598715987259873598745987559876598775987859879598805988159882598835988459885598865988759888598895989059891598925989359894598955989659897598985989959900599015990259903599045990559906599075990859909599105991159912599135991459915599165991759918599195992059921599225992359924599255992659927599285992959930599315993259933599345993559936599375993859939599405994159942599435994459945599465994759948599495995059951599525995359954599555995659957599585995959960599615996259963599645996559966599675996859969599705997159972599735997459975599765997759978599795998059981599825998359984599855998659987599885998959990599915999259993599945999559996599975999859999600006000160002600036000460005600066000760008600096001060011600126001360014600156001660017600186001960020600216002260023600246002560026600276002860029600306003160032600336003460035600366003760038600396004060041600426004360044600456004660047600486004960050600516005260053600546005560056600576005860059600606006160062600636006460065600666006760068600696007060071600726007360074600756007660077600786007960080600816008260083600846008560086600876008860089600906009160092600936009460095600966009760098600996010060101601026010360104601056010660107601086010960110601116011260113601146011560116601176011860119601206012160122601236012460125601266012760128601296013060131601326013360134601356013660137601386013960140601416014260143601446014560146601476014860149601506015160152601536015460155601566015760158601596016060161601626016360164601656016660167601686016960170601716017260173601746017560176601776017860179601806018160182601836018460185601866018760188601896019060191601926019360194601956019660197601986019960200602016020260203602046020560206602076020860209602106021160212602136021460215602166021760218602196022060221602226022360224602256022660227602286022960230602316023260233602346023560236602376023860239602406024160242602436024460245602466024760248602496025060251602526025360254602556025660257602586025960260602616026260263602646026560266602676026860269602706027160272602736027460275602766027760278602796028060281602826028360284602856028660287602886028960290602916029260293602946029560296602976029860299603006030160302603036030460305603066030760308603096031060311603126031360314603156031660317603186031960320603216032260323603246032560326603276032860329603306033160332603336033460335603366033760338603396034060341603426034360344603456034660347603486034960350603516035260353603546035560356603576035860359603606036160362603636036460365603666036760368603696037060371603726037360374603756037660377603786037960380603816038260383603846038560386603876038860389603906039160392603936039460395603966039760398603996040060401604026040360404604056040660407604086040960410604116041260413604146041560416604176041860419604206042160422604236042460425604266042760428604296043060431604326043360434604356043660437604386043960440604416044260443604446044560446604476044860449604506045160452604536045460455604566045760458604596046060461604626046360464604656046660467604686046960470604716047260473604746047560476604776047860479604806048160482604836048460485604866048760488604896049060491604926049360494604956049660497604986049960500605016050260503605046050560506605076050860509605106051160512605136051460515605166051760518605196052060521605226052360524605256052660527605286052960530605316053260533605346053560536605376053860539605406054160542605436054460545605466054760548605496055060551605526055360554605556055660557605586055960560605616056260563605646056560566605676056860569605706057160572605736057460575605766057760578605796058060581605826058360584605856058660587605886058960590605916059260593605946059560596605976059860599606006060160602606036060460605606066060760608606096061060611606126061360614606156061660617606186061960620606216062260623606246062560626606276062860629606306063160632606336063460635606366063760638606396064060641606426064360644606456064660647606486064960650606516065260653606546065560656606576065860659606606066160662606636066460665606666066760668606696067060671606726067360674606756067660677606786067960680606816068260683606846068560686606876068860689606906069160692606936069460695606966069760698606996070060701607026070360704607056070660707607086070960710607116071260713607146071560716607176071860719607206072160722607236072460725607266072760728607296073060731607326073360734607356073660737607386073960740607416074260743607446074560746607476074860749607506075160752607536075460755607566075760758607596076060761607626076360764607656076660767607686076960770607716077260773607746077560776607776077860779607806078160782607836078460785607866078760788607896079060791607926079360794607956079660797607986079960800608016080260803608046080560806608076080860809608106081160812608136081460815608166081760818608196082060821608226082360824608256082660827608286082960830608316083260833608346083560836608376083860839608406084160842608436084460845608466084760848608496085060851608526085360854608556085660857608586085960860608616086260863608646086560866608676086860869608706087160872608736087460875608766087760878608796088060881608826088360884608856088660887608886088960890608916089260893608946089560896608976089860899609006090160902609036090460905609066090760908609096091060911609126091360914609156091660917609186091960920609216092260923609246092560926609276092860929609306093160932609336093460935609366093760938609396094060941609426094360944609456094660947609486094960950609516095260953609546095560956609576095860959609606096160962609636096460965609666096760968609696097060971609726097360974609756097660977609786097960980609816098260983609846098560986609876098860989609906099160992609936099460995609966099760998609996100061001610026100361004610056100661007610086100961010610116101261013610146101561016610176101861019610206102161022610236102461025610266102761028610296103061031610326103361034610356103661037610386103961040610416104261043610446104561046610476104861049610506105161052610536105461055610566105761058610596106061061610626106361064610656106661067610686106961070610716107261073610746107561076610776107861079610806108161082610836108461085610866108761088610896109061091610926109361094610956109661097610986109961100611016110261103611046110561106611076110861109611106111161112611136111461115611166111761118611196112061121611226112361124611256112661127611286112961130611316113261133611346113561136611376113861139611406114161142611436114461145611466114761148611496115061151611526115361154611556115661157611586115961160611616116261163611646116561166611676116861169611706117161172611736117461175611766117761178611796118061181611826118361184611856118661187611886118961190611916119261193611946119561196611976119861199612006120161202612036120461205612066120761208612096121061211612126121361214612156121661217612186121961220612216122261223612246122561226612276122861229612306123161232612336123461235612366123761238612396124061241612426124361244612456124661247612486124961250612516125261253612546125561256612576125861259612606126161262612636126461265612666126761268612696127061271612726127361274612756127661277612786127961280612816128261283612846128561286612876128861289612906129161292612936129461295612966129761298612996130061301613026130361304613056130661307613086130961310613116131261313613146131561316613176131861319613206132161322613236132461325613266132761328613296133061331613326133361334613356133661337613386133961340613416134261343613446134561346613476134861349613506135161352613536135461355613566135761358613596136061361613626136361364613656136661367613686136961370613716137261373613746137561376613776137861379613806138161382613836138461385613866138761388613896139061391613926139361394613956139661397613986139961400614016140261403614046140561406614076140861409614106141161412614136141461415614166141761418614196142061421614226142361424614256142661427614286142961430614316143261433614346143561436614376143861439614406144161442614436144461445614466144761448614496145061451614526145361454614556145661457614586145961460614616146261463614646146561466614676146861469614706147161472614736147461475614766147761478614796148061481614826148361484614856148661487614886148961490614916149261493614946149561496614976149861499615006150161502615036150461505615066150761508615096151061511615126151361514615156151661517615186151961520615216152261523615246152561526615276152861529615306153161532615336153461535615366153761538615396154061541615426154361544615456154661547615486154961550615516155261553615546155561556615576155861559615606156161562615636156461565615666156761568615696157061571615726157361574615756157661577615786157961580615816158261583615846158561586615876158861589615906159161592615936159461595615966159761598615996160061601616026160361604616056160661607616086160961610616116161261613616146161561616616176161861619616206162161622616236162461625616266162761628616296163061631616326163361634616356163661637616386163961640616416164261643616446164561646616476164861649616506165161652616536165461655616566165761658616596166061661616626166361664616656166661667616686166961670616716167261673616746167561676616776167861679616806168161682616836168461685616866168761688616896169061691616926169361694616956169661697616986169961700617016170261703617046170561706617076170861709617106171161712617136171461715617166171761718617196172061721617226172361724617256172661727617286172961730617316173261733617346173561736617376173861739617406174161742617436174461745617466174761748617496175061751617526175361754617556175661757617586175961760617616176261763617646176561766617676176861769617706177161772617736177461775617766177761778617796178061781617826178361784617856178661787617886178961790617916179261793617946179561796617976179861799618006180161802618036180461805618066180761808618096181061811618126181361814618156181661817618186181961820618216182261823618246182561826618276182861829618306183161832618336183461835618366183761838618396184061841618426184361844618456184661847618486184961850618516185261853618546185561856618576185861859618606186161862618636186461865618666186761868618696187061871618726187361874618756187661877618786187961880618816188261883618846188561886618876188861889618906189161892618936189461895618966189761898618996190061901619026190361904619056190661907619086190961910619116191261913619146191561916619176191861919619206192161922619236192461925619266192761928619296193061931619326193361934619356193661937619386193961940619416194261943619446194561946619476194861949619506195161952619536195461955619566195761958619596196061961619626196361964619656196661967619686196961970619716197261973619746197561976619776197861979619806198161982619836198461985619866198761988619896199061991619926199361994619956199661997619986199962000620016200262003620046200562006620076200862009620106201162012620136201462015620166201762018620196202062021620226202362024620256202662027620286202962030620316203262033620346203562036620376203862039620406204162042620436204462045620466204762048620496205062051620526205362054620556205662057620586205962060620616206262063620646206562066620676206862069620706207162072620736207462075620766207762078620796208062081620826208362084620856208662087620886208962090620916209262093620946209562096620976209862099621006210162102621036210462105621066210762108621096211062111621126211362114621156211662117621186211962120621216212262123621246212562126621276212862129621306213162132621336213462135621366213762138621396214062141621426214362144621456214662147621486214962150621516215262153621546215562156621576215862159621606216162162621636216462165621666216762168621696217062171621726217362174621756217662177621786217962180621816218262183621846218562186621876218862189621906219162192621936219462195621966219762198621996220062201622026220362204622056220662207622086220962210622116221262213622146221562216622176221862219622206222162222622236222462225622266222762228622296223062231622326223362234622356223662237622386223962240622416224262243622446224562246622476224862249622506225162252622536225462255622566225762258622596226062261622626226362264622656226662267622686226962270622716227262273622746227562276622776227862279622806228162282622836228462285622866228762288622896229062291622926229362294622956229662297622986229962300623016230262303623046230562306623076230862309623106231162312623136231462315623166231762318623196232062321623226232362324623256232662327623286232962330623316233262333623346233562336623376233862339623406234162342623436234462345623466234762348623496235062351623526235362354623556235662357
  1. /******/ (function(modules) { // webpackBootstrap
  2. /******/ // The module cache
  3. /******/ var installedModules = {};
  4. /******/
  5. /******/ // The require function
  6. /******/ function __webpack_require__(moduleId) {
  7. /******/
  8. /******/ // Check if module is in cache
  9. /******/ if(installedModules[moduleId]) {
  10. /******/ return installedModules[moduleId].exports;
  11. /******/ }
  12. /******/ // Create a new module (and put it into the cache)
  13. /******/ var module = installedModules[moduleId] = {
  14. /******/ i: moduleId,
  15. /******/ l: false,
  16. /******/ exports: {}
  17. /******/ };
  18. /******/
  19. /******/ // Execute the module function
  20. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  21. /******/
  22. /******/ // Flag the module as loaded
  23. /******/ module.l = true;
  24. /******/
  25. /******/ // Return the exports of the module
  26. /******/ return module.exports;
  27. /******/ }
  28. /******/
  29. /******/
  30. /******/ // expose the modules object (__webpack_modules__)
  31. /******/ __webpack_require__.m = modules;
  32. /******/
  33. /******/ // expose the module cache
  34. /******/ __webpack_require__.c = installedModules;
  35. /******/
  36. /******/ // define getter function for harmony exports
  37. /******/ __webpack_require__.d = function(exports, name, getter) {
  38. /******/ if(!__webpack_require__.o(exports, name)) {
  39. /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
  40. /******/ }
  41. /******/ };
  42. /******/
  43. /******/ // define __esModule on exports
  44. /******/ __webpack_require__.r = function(exports) {
  45. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  46. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  47. /******/ }
  48. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  49. /******/ };
  50. /******/
  51. /******/ // create a fake namespace object
  52. /******/ // mode & 1: value is a module id, require it
  53. /******/ // mode & 2: merge all properties of value into the ns
  54. /******/ // mode & 4: return value when already ns object
  55. /******/ // mode & 8|1: behave like require
  56. /******/ __webpack_require__.t = function(value, mode) {
  57. /******/ if(mode & 1) value = __webpack_require__(value);
  58. /******/ if(mode & 8) return value;
  59. /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
  60. /******/ var ns = Object.create(null);
  61. /******/ __webpack_require__.r(ns);
  62. /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
  63. /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
  64. /******/ return ns;
  65. /******/ };
  66. /******/
  67. /******/ // getDefaultExport function for compatibility with non-harmony modules
  68. /******/ __webpack_require__.n = function(module) {
  69. /******/ var getter = module && module.__esModule ?
  70. /******/ function getDefault() { return module['default']; } :
  71. /******/ function getModuleExports() { return module; };
  72. /******/ __webpack_require__.d(getter, 'a', getter);
  73. /******/ return getter;
  74. /******/ };
  75. /******/
  76. /******/ // Object.prototype.hasOwnProperty.call
  77. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  78. /******/
  79. /******/ // __webpack_public_path__
  80. /******/ __webpack_require__.p = "/";
  81. /******/
  82. /******/
  83. /******/ // Load entry module and return exports
  84. /******/ return __webpack_require__(__webpack_require__.s = 0);
  85. /******/ })
  86. /************************************************************************/
  87. /******/ ({
  88. /***/ "./node_modules/axios/index.js":
  89. /*!*************************************!*\
  90. !*** ./node_modules/axios/index.js ***!
  91. \*************************************/
  92. /*! no static exports found */
  93. /***/ (function(module, exports, __webpack_require__) {
  94. module.exports = __webpack_require__(/*! ./lib/axios */ "./node_modules/axios/lib/axios.js");
  95. /***/ }),
  96. /***/ "./node_modules/axios/lib/adapters/xhr.js":
  97. /*!************************************************!*\
  98. !*** ./node_modules/axios/lib/adapters/xhr.js ***!
  99. \************************************************/
  100. /*! no static exports found */
  101. /***/ (function(module, exports, __webpack_require__) {
  102. "use strict";
  103. var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
  104. var settle = __webpack_require__(/*! ./../core/settle */ "./node_modules/axios/lib/core/settle.js");
  105. var buildURL = __webpack_require__(/*! ./../helpers/buildURL */ "./node_modules/axios/lib/helpers/buildURL.js");
  106. var buildFullPath = __webpack_require__(/*! ../core/buildFullPath */ "./node_modules/axios/lib/core/buildFullPath.js");
  107. var parseHeaders = __webpack_require__(/*! ./../helpers/parseHeaders */ "./node_modules/axios/lib/helpers/parseHeaders.js");
  108. var isURLSameOrigin = __webpack_require__(/*! ./../helpers/isURLSameOrigin */ "./node_modules/axios/lib/helpers/isURLSameOrigin.js");
  109. var createError = __webpack_require__(/*! ../core/createError */ "./node_modules/axios/lib/core/createError.js");
  110. module.exports = function xhrAdapter(config) {
  111. return new Promise(function dispatchXhrRequest(resolve, reject) {
  112. var requestData = config.data;
  113. var requestHeaders = config.headers;
  114. if (utils.isFormData(requestData)) {
  115. delete requestHeaders['Content-Type']; // Let the browser set it
  116. }
  117. var request = new XMLHttpRequest();
  118. // HTTP basic authentication
  119. if (config.auth) {
  120. var username = config.auth.username || '';
  121. var password = config.auth.password || '';
  122. requestHeaders.Authorization = 'Basic ' + btoa(username + ':' + password);
  123. }
  124. var fullPath = buildFullPath(config.baseURL, config.url);
  125. request.open(config.method.toUpperCase(), buildURL(fullPath, config.params, config.paramsSerializer), true);
  126. // Set the request timeout in MS
  127. request.timeout = config.timeout;
  128. // Listen for ready state
  129. request.onreadystatechange = function handleLoad() {
  130. if (!request || request.readyState !== 4) {
  131. return;
  132. }
  133. // The request errored out and we didn't get a response, this will be
  134. // handled by onerror instead
  135. // With one exception: request that using file: protocol, most browsers
  136. // will return status as 0 even though it's a successful request
  137. if (request.status === 0 && !(request.responseURL && request.responseURL.indexOf('file:') === 0)) {
  138. return;
  139. }
  140. // Prepare the response
  141. var responseHeaders = 'getAllResponseHeaders' in request ? parseHeaders(request.getAllResponseHeaders()) : null;
  142. var responseData = !config.responseType || config.responseType === 'text' ? request.responseText : request.response;
  143. var response = {
  144. data: responseData,
  145. status: request.status,
  146. statusText: request.statusText,
  147. headers: responseHeaders,
  148. config: config,
  149. request: request
  150. };
  151. settle(resolve, reject, response);
  152. // Clean up request
  153. request = null;
  154. };
  155. // Handle browser request cancellation (as opposed to a manual cancellation)
  156. request.onabort = function handleAbort() {
  157. if (!request) {
  158. return;
  159. }
  160. reject(createError('Request aborted', config, 'ECONNABORTED', request));
  161. // Clean up request
  162. request = null;
  163. };
  164. // Handle low level network errors
  165. request.onerror = function handleError() {
  166. // Real errors are hidden from us by the browser
  167. // onerror should only fire if it's a network error
  168. reject(createError('Network Error', config, null, request));
  169. // Clean up request
  170. request = null;
  171. };
  172. // Handle timeout
  173. request.ontimeout = function handleTimeout() {
  174. var timeoutErrorMessage = 'timeout of ' + config.timeout + 'ms exceeded';
  175. if (config.timeoutErrorMessage) {
  176. timeoutErrorMessage = config.timeoutErrorMessage;
  177. }
  178. reject(createError(timeoutErrorMessage, config, 'ECONNABORTED',
  179. request));
  180. // Clean up request
  181. request = null;
  182. };
  183. // Add xsrf header
  184. // This is only done if running in a standard browser environment.
  185. // Specifically not if we're in a web worker, or react-native.
  186. if (utils.isStandardBrowserEnv()) {
  187. var cookies = __webpack_require__(/*! ./../helpers/cookies */ "./node_modules/axios/lib/helpers/cookies.js");
  188. // Add xsrf header
  189. var xsrfValue = (config.withCredentials || isURLSameOrigin(fullPath)) && config.xsrfCookieName ?
  190. cookies.read(config.xsrfCookieName) :
  191. undefined;
  192. if (xsrfValue) {
  193. requestHeaders[config.xsrfHeaderName] = xsrfValue;
  194. }
  195. }
  196. // Add headers to the request
  197. if ('setRequestHeader' in request) {
  198. utils.forEach(requestHeaders, function setRequestHeader(val, key) {
  199. if (typeof requestData === 'undefined' && key.toLowerCase() === 'content-type') {
  200. // Remove Content-Type if data is undefined
  201. delete requestHeaders[key];
  202. } else {
  203. // Otherwise add header to the request
  204. request.setRequestHeader(key, val);
  205. }
  206. });
  207. }
  208. // Add withCredentials to request if needed
  209. if (!utils.isUndefined(config.withCredentials)) {
  210. request.withCredentials = !!config.withCredentials;
  211. }
  212. // Add responseType to request if needed
  213. if (config.responseType) {
  214. try {
  215. request.responseType = config.responseType;
  216. } catch (e) {
  217. // Expected DOMException thrown by browsers not compatible XMLHttpRequest Level 2.
  218. // But, this can be suppressed for 'json' type as it can be parsed by default 'transformResponse' function.
  219. if (config.responseType !== 'json') {
  220. throw e;
  221. }
  222. }
  223. }
  224. // Handle progress if needed
  225. if (typeof config.onDownloadProgress === 'function') {
  226. request.addEventListener('progress', config.onDownloadProgress);
  227. }
  228. // Not all browsers support upload events
  229. if (typeof config.onUploadProgress === 'function' && request.upload) {
  230. request.upload.addEventListener('progress', config.onUploadProgress);
  231. }
  232. if (config.cancelToken) {
  233. // Handle cancellation
  234. config.cancelToken.promise.then(function onCanceled(cancel) {
  235. if (!request) {
  236. return;
  237. }
  238. request.abort();
  239. reject(cancel);
  240. // Clean up request
  241. request = null;
  242. });
  243. }
  244. if (requestData === undefined) {
  245. requestData = null;
  246. }
  247. // Send the request
  248. request.send(requestData);
  249. });
  250. };
  251. /***/ }),
  252. /***/ "./node_modules/axios/lib/axios.js":
  253. /*!*****************************************!*\
  254. !*** ./node_modules/axios/lib/axios.js ***!
  255. \*****************************************/
  256. /*! no static exports found */
  257. /***/ (function(module, exports, __webpack_require__) {
  258. "use strict";
  259. var utils = __webpack_require__(/*! ./utils */ "./node_modules/axios/lib/utils.js");
  260. var bind = __webpack_require__(/*! ./helpers/bind */ "./node_modules/axios/lib/helpers/bind.js");
  261. var Axios = __webpack_require__(/*! ./core/Axios */ "./node_modules/axios/lib/core/Axios.js");
  262. var mergeConfig = __webpack_require__(/*! ./core/mergeConfig */ "./node_modules/axios/lib/core/mergeConfig.js");
  263. var defaults = __webpack_require__(/*! ./defaults */ "./node_modules/axios/lib/defaults.js");
  264. /**
  265. * Create an instance of Axios
  266. *
  267. * @param {Object} defaultConfig The default config for the instance
  268. * @return {Axios} A new instance of Axios
  269. */
  270. function createInstance(defaultConfig) {
  271. var context = new Axios(defaultConfig);
  272. var instance = bind(Axios.prototype.request, context);
  273. // Copy axios.prototype to instance
  274. utils.extend(instance, Axios.prototype, context);
  275. // Copy context to instance
  276. utils.extend(instance, context);
  277. return instance;
  278. }
  279. // Create the default instance to be exported
  280. var axios = createInstance(defaults);
  281. // Expose Axios class to allow class inheritance
  282. axios.Axios = Axios;
  283. // Factory for creating new instances
  284. axios.create = function create(instanceConfig) {
  285. return createInstance(mergeConfig(axios.defaults, instanceConfig));
  286. };
  287. // Expose Cancel & CancelToken
  288. axios.Cancel = __webpack_require__(/*! ./cancel/Cancel */ "./node_modules/axios/lib/cancel/Cancel.js");
  289. axios.CancelToken = __webpack_require__(/*! ./cancel/CancelToken */ "./node_modules/axios/lib/cancel/CancelToken.js");
  290. axios.isCancel = __webpack_require__(/*! ./cancel/isCancel */ "./node_modules/axios/lib/cancel/isCancel.js");
  291. // Expose all/spread
  292. axios.all = function all(promises) {
  293. return Promise.all(promises);
  294. };
  295. axios.spread = __webpack_require__(/*! ./helpers/spread */ "./node_modules/axios/lib/helpers/spread.js");
  296. module.exports = axios;
  297. // Allow use of default import syntax in TypeScript
  298. module.exports.default = axios;
  299. /***/ }),
  300. /***/ "./node_modules/axios/lib/cancel/Cancel.js":
  301. /*!*************************************************!*\
  302. !*** ./node_modules/axios/lib/cancel/Cancel.js ***!
  303. \*************************************************/
  304. /*! no static exports found */
  305. /***/ (function(module, exports, __webpack_require__) {
  306. "use strict";
  307. /**
  308. * A `Cancel` is an object that is thrown when an operation is canceled.
  309. *
  310. * @class
  311. * @param {string=} message The message.
  312. */
  313. function Cancel(message) {
  314. this.message = message;
  315. }
  316. Cancel.prototype.toString = function toString() {
  317. return 'Cancel' + (this.message ? ': ' + this.message : '');
  318. };
  319. Cancel.prototype.__CANCEL__ = true;
  320. module.exports = Cancel;
  321. /***/ }),
  322. /***/ "./node_modules/axios/lib/cancel/CancelToken.js":
  323. /*!******************************************************!*\
  324. !*** ./node_modules/axios/lib/cancel/CancelToken.js ***!
  325. \******************************************************/
  326. /*! no static exports found */
  327. /***/ (function(module, exports, __webpack_require__) {
  328. "use strict";
  329. var Cancel = __webpack_require__(/*! ./Cancel */ "./node_modules/axios/lib/cancel/Cancel.js");
  330. /**
  331. * A `CancelToken` is an object that can be used to request cancellation of an operation.
  332. *
  333. * @class
  334. * @param {Function} executor The executor function.
  335. */
  336. function CancelToken(executor) {
  337. if (typeof executor !== 'function') {
  338. throw new TypeError('executor must be a function.');
  339. }
  340. var resolvePromise;
  341. this.promise = new Promise(function promiseExecutor(resolve) {
  342. resolvePromise = resolve;
  343. });
  344. var token = this;
  345. executor(function cancel(message) {
  346. if (token.reason) {
  347. // Cancellation has already been requested
  348. return;
  349. }
  350. token.reason = new Cancel(message);
  351. resolvePromise(token.reason);
  352. });
  353. }
  354. /**
  355. * Throws a `Cancel` if cancellation has been requested.
  356. */
  357. CancelToken.prototype.throwIfRequested = function throwIfRequested() {
  358. if (this.reason) {
  359. throw this.reason;
  360. }
  361. };
  362. /**
  363. * Returns an object that contains a new `CancelToken` and a function that, when called,
  364. * cancels the `CancelToken`.
  365. */
  366. CancelToken.source = function source() {
  367. var cancel;
  368. var token = new CancelToken(function executor(c) {
  369. cancel = c;
  370. });
  371. return {
  372. token: token,
  373. cancel: cancel
  374. };
  375. };
  376. module.exports = CancelToken;
  377. /***/ }),
  378. /***/ "./node_modules/axios/lib/cancel/isCancel.js":
  379. /*!***************************************************!*\
  380. !*** ./node_modules/axios/lib/cancel/isCancel.js ***!
  381. \***************************************************/
  382. /*! no static exports found */
  383. /***/ (function(module, exports, __webpack_require__) {
  384. "use strict";
  385. module.exports = function isCancel(value) {
  386. return !!(value && value.__CANCEL__);
  387. };
  388. /***/ }),
  389. /***/ "./node_modules/axios/lib/core/Axios.js":
  390. /*!**********************************************!*\
  391. !*** ./node_modules/axios/lib/core/Axios.js ***!
  392. \**********************************************/
  393. /*! no static exports found */
  394. /***/ (function(module, exports, __webpack_require__) {
  395. "use strict";
  396. var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
  397. var buildURL = __webpack_require__(/*! ../helpers/buildURL */ "./node_modules/axios/lib/helpers/buildURL.js");
  398. var InterceptorManager = __webpack_require__(/*! ./InterceptorManager */ "./node_modules/axios/lib/core/InterceptorManager.js");
  399. var dispatchRequest = __webpack_require__(/*! ./dispatchRequest */ "./node_modules/axios/lib/core/dispatchRequest.js");
  400. var mergeConfig = __webpack_require__(/*! ./mergeConfig */ "./node_modules/axios/lib/core/mergeConfig.js");
  401. /**
  402. * Create a new instance of Axios
  403. *
  404. * @param {Object} instanceConfig The default config for the instance
  405. */
  406. function Axios(instanceConfig) {
  407. this.defaults = instanceConfig;
  408. this.interceptors = {
  409. request: new InterceptorManager(),
  410. response: new InterceptorManager()
  411. };
  412. }
  413. /**
  414. * Dispatch a request
  415. *
  416. * @param {Object} config The config specific for this request (merged with this.defaults)
  417. */
  418. Axios.prototype.request = function request(config) {
  419. /*eslint no-param-reassign:0*/
  420. // Allow for axios('example/url'[, config]) a la fetch API
  421. if (typeof config === 'string') {
  422. config = arguments[1] || {};
  423. config.url = arguments[0];
  424. } else {
  425. config = config || {};
  426. }
  427. config = mergeConfig(this.defaults, config);
  428. // Set config.method
  429. if (config.method) {
  430. config.method = config.method.toLowerCase();
  431. } else if (this.defaults.method) {
  432. config.method = this.defaults.method.toLowerCase();
  433. } else {
  434. config.method = 'get';
  435. }
  436. // Hook up interceptors middleware
  437. var chain = [dispatchRequest, undefined];
  438. var promise = Promise.resolve(config);
  439. this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) {
  440. chain.unshift(interceptor.fulfilled, interceptor.rejected);
  441. });
  442. this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) {
  443. chain.push(interceptor.fulfilled, interceptor.rejected);
  444. });
  445. while (chain.length) {
  446. promise = promise.then(chain.shift(), chain.shift());
  447. }
  448. return promise;
  449. };
  450. Axios.prototype.getUri = function getUri(config) {
  451. config = mergeConfig(this.defaults, config);
  452. return buildURL(config.url, config.params, config.paramsSerializer).replace(/^\?/, '');
  453. };
  454. // Provide aliases for supported request methods
  455. utils.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) {
  456. /*eslint func-names:0*/
  457. Axios.prototype[method] = function(url, config) {
  458. return this.request(utils.merge(config || {}, {
  459. method: method,
  460. url: url
  461. }));
  462. };
  463. });
  464. utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
  465. /*eslint func-names:0*/
  466. Axios.prototype[method] = function(url, data, config) {
  467. return this.request(utils.merge(config || {}, {
  468. method: method,
  469. url: url,
  470. data: data
  471. }));
  472. };
  473. });
  474. module.exports = Axios;
  475. /***/ }),
  476. /***/ "./node_modules/axios/lib/core/InterceptorManager.js":
  477. /*!***********************************************************!*\
  478. !*** ./node_modules/axios/lib/core/InterceptorManager.js ***!
  479. \***********************************************************/
  480. /*! no static exports found */
  481. /***/ (function(module, exports, __webpack_require__) {
  482. "use strict";
  483. var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
  484. function InterceptorManager() {
  485. this.handlers = [];
  486. }
  487. /**
  488. * Add a new interceptor to the stack
  489. *
  490. * @param {Function} fulfilled The function to handle `then` for a `Promise`
  491. * @param {Function} rejected The function to handle `reject` for a `Promise`
  492. *
  493. * @return {Number} An ID used to remove interceptor later
  494. */
  495. InterceptorManager.prototype.use = function use(fulfilled, rejected) {
  496. this.handlers.push({
  497. fulfilled: fulfilled,
  498. rejected: rejected
  499. });
  500. return this.handlers.length - 1;
  501. };
  502. /**
  503. * Remove an interceptor from the stack
  504. *
  505. * @param {Number} id The ID that was returned by `use`
  506. */
  507. InterceptorManager.prototype.eject = function eject(id) {
  508. if (this.handlers[id]) {
  509. this.handlers[id] = null;
  510. }
  511. };
  512. /**
  513. * Iterate over all the registered interceptors
  514. *
  515. * This method is particularly useful for skipping over any
  516. * interceptors that may have become `null` calling `eject`.
  517. *
  518. * @param {Function} fn The function to call for each interceptor
  519. */
  520. InterceptorManager.prototype.forEach = function forEach(fn) {
  521. utils.forEach(this.handlers, function forEachHandler(h) {
  522. if (h !== null) {
  523. fn(h);
  524. }
  525. });
  526. };
  527. module.exports = InterceptorManager;
  528. /***/ }),
  529. /***/ "./node_modules/axios/lib/core/buildFullPath.js":
  530. /*!******************************************************!*\
  531. !*** ./node_modules/axios/lib/core/buildFullPath.js ***!
  532. \******************************************************/
  533. /*! no static exports found */
  534. /***/ (function(module, exports, __webpack_require__) {
  535. "use strict";
  536. var isAbsoluteURL = __webpack_require__(/*! ../helpers/isAbsoluteURL */ "./node_modules/axios/lib/helpers/isAbsoluteURL.js");
  537. var combineURLs = __webpack_require__(/*! ../helpers/combineURLs */ "./node_modules/axios/lib/helpers/combineURLs.js");
  538. /**
  539. * Creates a new URL by combining the baseURL with the requestedURL,
  540. * only when the requestedURL is not already an absolute URL.
  541. * If the requestURL is absolute, this function returns the requestedURL untouched.
  542. *
  543. * @param {string} baseURL The base URL
  544. * @param {string} requestedURL Absolute or relative URL to combine
  545. * @returns {string} The combined full path
  546. */
  547. module.exports = function buildFullPath(baseURL, requestedURL) {
  548. if (baseURL && !isAbsoluteURL(requestedURL)) {
  549. return combineURLs(baseURL, requestedURL);
  550. }
  551. return requestedURL;
  552. };
  553. /***/ }),
  554. /***/ "./node_modules/axios/lib/core/createError.js":
  555. /*!****************************************************!*\
  556. !*** ./node_modules/axios/lib/core/createError.js ***!
  557. \****************************************************/
  558. /*! no static exports found */
  559. /***/ (function(module, exports, __webpack_require__) {
  560. "use strict";
  561. var enhanceError = __webpack_require__(/*! ./enhanceError */ "./node_modules/axios/lib/core/enhanceError.js");
  562. /**
  563. * Create an Error with the specified message, config, error code, request and response.
  564. *
  565. * @param {string} message The error message.
  566. * @param {Object} config The config.
  567. * @param {string} [code] The error code (for example, 'ECONNABORTED').
  568. * @param {Object} [request] The request.
  569. * @param {Object} [response] The response.
  570. * @returns {Error} The created error.
  571. */
  572. module.exports = function createError(message, config, code, request, response) {
  573. var error = new Error(message);
  574. return enhanceError(error, config, code, request, response);
  575. };
  576. /***/ }),
  577. /***/ "./node_modules/axios/lib/core/dispatchRequest.js":
  578. /*!********************************************************!*\
  579. !*** ./node_modules/axios/lib/core/dispatchRequest.js ***!
  580. \********************************************************/
  581. /*! no static exports found */
  582. /***/ (function(module, exports, __webpack_require__) {
  583. "use strict";
  584. var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
  585. var transformData = __webpack_require__(/*! ./transformData */ "./node_modules/axios/lib/core/transformData.js");
  586. var isCancel = __webpack_require__(/*! ../cancel/isCancel */ "./node_modules/axios/lib/cancel/isCancel.js");
  587. var defaults = __webpack_require__(/*! ../defaults */ "./node_modules/axios/lib/defaults.js");
  588. /**
  589. * Throws a `Cancel` if cancellation has been requested.
  590. */
  591. function throwIfCancellationRequested(config) {
  592. if (config.cancelToken) {
  593. config.cancelToken.throwIfRequested();
  594. }
  595. }
  596. /**
  597. * Dispatch a request to the server using the configured adapter.
  598. *
  599. * @param {object} config The config that is to be used for the request
  600. * @returns {Promise} The Promise to be fulfilled
  601. */
  602. module.exports = function dispatchRequest(config) {
  603. throwIfCancellationRequested(config);
  604. // Ensure headers exist
  605. config.headers = config.headers || {};
  606. // Transform request data
  607. config.data = transformData(
  608. config.data,
  609. config.headers,
  610. config.transformRequest
  611. );
  612. // Flatten headers
  613. config.headers = utils.merge(
  614. config.headers.common || {},
  615. config.headers[config.method] || {},
  616. config.headers
  617. );
  618. utils.forEach(
  619. ['delete', 'get', 'head', 'post', 'put', 'patch', 'common'],
  620. function cleanHeaderConfig(method) {
  621. delete config.headers[method];
  622. }
  623. );
  624. var adapter = config.adapter || defaults.adapter;
  625. return adapter(config).then(function onAdapterResolution(response) {
  626. throwIfCancellationRequested(config);
  627. // Transform response data
  628. response.data = transformData(
  629. response.data,
  630. response.headers,
  631. config.transformResponse
  632. );
  633. return response;
  634. }, function onAdapterRejection(reason) {
  635. if (!isCancel(reason)) {
  636. throwIfCancellationRequested(config);
  637. // Transform response data
  638. if (reason && reason.response) {
  639. reason.response.data = transformData(
  640. reason.response.data,
  641. reason.response.headers,
  642. config.transformResponse
  643. );
  644. }
  645. }
  646. return Promise.reject(reason);
  647. });
  648. };
  649. /***/ }),
  650. /***/ "./node_modules/axios/lib/core/enhanceError.js":
  651. /*!*****************************************************!*\
  652. !*** ./node_modules/axios/lib/core/enhanceError.js ***!
  653. \*****************************************************/
  654. /*! no static exports found */
  655. /***/ (function(module, exports, __webpack_require__) {
  656. "use strict";
  657. /**
  658. * Update an Error with the specified config, error code, and response.
  659. *
  660. * @param {Error} error The error to update.
  661. * @param {Object} config The config.
  662. * @param {string} [code] The error code (for example, 'ECONNABORTED').
  663. * @param {Object} [request] The request.
  664. * @param {Object} [response] The response.
  665. * @returns {Error} The error.
  666. */
  667. module.exports = function enhanceError(error, config, code, request, response) {
  668. error.config = config;
  669. if (code) {
  670. error.code = code;
  671. }
  672. error.request = request;
  673. error.response = response;
  674. error.isAxiosError = true;
  675. error.toJSON = function() {
  676. return {
  677. // Standard
  678. message: this.message,
  679. name: this.name,
  680. // Microsoft
  681. description: this.description,
  682. number: this.number,
  683. // Mozilla
  684. fileName: this.fileName,
  685. lineNumber: this.lineNumber,
  686. columnNumber: this.columnNumber,
  687. stack: this.stack,
  688. // Axios
  689. config: this.config,
  690. code: this.code
  691. };
  692. };
  693. return error;
  694. };
  695. /***/ }),
  696. /***/ "./node_modules/axios/lib/core/mergeConfig.js":
  697. /*!****************************************************!*\
  698. !*** ./node_modules/axios/lib/core/mergeConfig.js ***!
  699. \****************************************************/
  700. /*! no static exports found */
  701. /***/ (function(module, exports, __webpack_require__) {
  702. "use strict";
  703. var utils = __webpack_require__(/*! ../utils */ "./node_modules/axios/lib/utils.js");
  704. /**
  705. * Config-specific merge-function which creates a new config-object
  706. * by merging two configuration objects together.
  707. *
  708. * @param {Object} config1
  709. * @param {Object} config2
  710. * @returns {Object} New object resulting from merging config2 to config1
  711. */
  712. module.exports = function mergeConfig(config1, config2) {
  713. // eslint-disable-next-line no-param-reassign
  714. config2 = config2 || {};
  715. var config = {};
  716. var valueFromConfig2Keys = ['url', 'method', 'params', 'data'];
  717. var mergeDeepPropertiesKeys = ['headers', 'auth', 'proxy'];
  718. var defaultToConfig2Keys = [
  719. 'baseURL', 'url', 'transformRequest', 'transformResponse', 'paramsSerializer',
  720. 'timeout', 'withCredentials', 'adapter', 'responseType', 'xsrfCookieName',
  721. 'xsrfHeaderName', 'onUploadProgress', 'onDownloadProgress',
  722. 'maxContentLength', 'validateStatus', 'maxRedirects', 'httpAgent',
  723. 'httpsAgent', 'cancelToken', 'socketPath'
  724. ];
  725. utils.forEach(valueFromConfig2Keys, function valueFromConfig2(prop) {
  726. if (typeof config2[prop] !== 'undefined') {
  727. config[prop] = config2[prop];
  728. }
  729. });
  730. utils.forEach(mergeDeepPropertiesKeys, function mergeDeepProperties(prop) {
  731. if (utils.isObject(config2[prop])) {
  732. config[prop] = utils.deepMerge(config1[prop], config2[prop]);
  733. } else if (typeof config2[prop] !== 'undefined') {
  734. config[prop] = config2[prop];
  735. } else if (utils.isObject(config1[prop])) {
  736. config[prop] = utils.deepMerge(config1[prop]);
  737. } else if (typeof config1[prop] !== 'undefined') {
  738. config[prop] = config1[prop];
  739. }
  740. });
  741. utils.forEach(defaultToConfig2Keys, function defaultToConfig2(prop) {
  742. if (typeof config2[prop] !== 'undefined') {
  743. config[prop] = config2[prop];
  744. } else if (typeof config1[prop] !== 'undefined') {
  745. config[prop] = config1[prop];
  746. }
  747. });
  748. var axiosKeys = valueFromConfig2Keys
  749. .concat(mergeDeepPropertiesKeys)
  750. .concat(defaultToConfig2Keys);
  751. var otherKeys = Object
  752. .keys(config2)
  753. .filter(function filterAxiosKeys(key) {
  754. return axiosKeys.indexOf(key) === -1;
  755. });
  756. utils.forEach(otherKeys, function otherKeysDefaultToConfig2(prop) {
  757. if (typeof config2[prop] !== 'undefined') {
  758. config[prop] = config2[prop];
  759. } else if (typeof config1[prop] !== 'undefined') {
  760. config[prop] = config1[prop];
  761. }
  762. });
  763. return config;
  764. };
  765. /***/ }),
  766. /***/ "./node_modules/axios/lib/core/settle.js":
  767. /*!***********************************************!*\
  768. !*** ./node_modules/axios/lib/core/settle.js ***!
  769. \***********************************************/
  770. /*! no static exports found */
  771. /***/ (function(module, exports, __webpack_require__) {
  772. "use strict";
  773. var createError = __webpack_require__(/*! ./createError */ "./node_modules/axios/lib/core/createError.js");
  774. /**
  775. * Resolve or reject a Promise based on response status.
  776. *
  777. * @param {Function} resolve A function that resolves the promise.
  778. * @param {Function} reject A function that rejects the promise.
  779. * @param {object} response The response.
  780. */
  781. module.exports = function settle(resolve, reject, response) {
  782. var validateStatus = response.config.validateStatus;
  783. if (!validateStatus || validateStatus(response.status)) {
  784. resolve(response);
  785. } else {
  786. reject(createError(
  787. 'Request failed with status code ' + response.status,
  788. response.config,
  789. null,
  790. response.request,
  791. response
  792. ));
  793. }
  794. };
  795. /***/ }),
  796. /***/ "./node_modules/axios/lib/core/transformData.js":
  797. /*!******************************************************!*\
  798. !*** ./node_modules/axios/lib/core/transformData.js ***!
  799. \******************************************************/
  800. /*! no static exports found */
  801. /***/ (function(module, exports, __webpack_require__) {
  802. "use strict";
  803. var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
  804. /**
  805. * Transform the data for a request or a response
  806. *
  807. * @param {Object|String} data The data to be transformed
  808. * @param {Array} headers The headers for the request or response
  809. * @param {Array|Function} fns A single function or Array of functions
  810. * @returns {*} The resulting transformed data
  811. */
  812. module.exports = function transformData(data, headers, fns) {
  813. /*eslint no-param-reassign:0*/
  814. utils.forEach(fns, function transform(fn) {
  815. data = fn(data, headers);
  816. });
  817. return data;
  818. };
  819. /***/ }),
  820. /***/ "./node_modules/axios/lib/defaults.js":
  821. /*!********************************************!*\
  822. !*** ./node_modules/axios/lib/defaults.js ***!
  823. \********************************************/
  824. /*! no static exports found */
  825. /***/ (function(module, exports, __webpack_require__) {
  826. "use strict";
  827. /* WEBPACK VAR INJECTION */(function(process) {
  828. var utils = __webpack_require__(/*! ./utils */ "./node_modules/axios/lib/utils.js");
  829. var normalizeHeaderName = __webpack_require__(/*! ./helpers/normalizeHeaderName */ "./node_modules/axios/lib/helpers/normalizeHeaderName.js");
  830. var DEFAULT_CONTENT_TYPE = {
  831. 'Content-Type': 'application/x-www-form-urlencoded'
  832. };
  833. function setContentTypeIfUnset(headers, value) {
  834. if (!utils.isUndefined(headers) && utils.isUndefined(headers['Content-Type'])) {
  835. headers['Content-Type'] = value;
  836. }
  837. }
  838. function getDefaultAdapter() {
  839. var adapter;
  840. if (typeof XMLHttpRequest !== 'undefined') {
  841. // For browsers use XHR adapter
  842. adapter = __webpack_require__(/*! ./adapters/xhr */ "./node_modules/axios/lib/adapters/xhr.js");
  843. } else if (typeof process !== 'undefined' && Object.prototype.toString.call(process) === '[object process]') {
  844. // For node use HTTP adapter
  845. adapter = __webpack_require__(/*! ./adapters/http */ "./node_modules/axios/lib/adapters/xhr.js");
  846. }
  847. return adapter;
  848. }
  849. var defaults = {
  850. adapter: getDefaultAdapter(),
  851. transformRequest: [function transformRequest(data, headers) {
  852. normalizeHeaderName(headers, 'Accept');
  853. normalizeHeaderName(headers, 'Content-Type');
  854. if (utils.isFormData(data) ||
  855. utils.isArrayBuffer(data) ||
  856. utils.isBuffer(data) ||
  857. utils.isStream(data) ||
  858. utils.isFile(data) ||
  859. utils.isBlob(data)
  860. ) {
  861. return data;
  862. }
  863. if (utils.isArrayBufferView(data)) {
  864. return data.buffer;
  865. }
  866. if (utils.isURLSearchParams(data)) {
  867. setContentTypeIfUnset(headers, 'application/x-www-form-urlencoded;charset=utf-8');
  868. return data.toString();
  869. }
  870. if (utils.isObject(data)) {
  871. setContentTypeIfUnset(headers, 'application/json;charset=utf-8');
  872. return JSON.stringify(data);
  873. }
  874. return data;
  875. }],
  876. transformResponse: [function transformResponse(data) {
  877. /*eslint no-param-reassign:0*/
  878. if (typeof data === 'string') {
  879. try {
  880. data = JSON.parse(data);
  881. } catch (e) { /* Ignore */ }
  882. }
  883. return data;
  884. }],
  885. /**
  886. * A timeout in milliseconds to abort a request. If set to 0 (default) a
  887. * timeout is not created.
  888. */
  889. timeout: 0,
  890. xsrfCookieName: 'XSRF-TOKEN',
  891. xsrfHeaderName: 'X-XSRF-TOKEN',
  892. maxContentLength: -1,
  893. validateStatus: function validateStatus(status) {
  894. return status >= 200 && status < 300;
  895. }
  896. };
  897. defaults.headers = {
  898. common: {
  899. 'Accept': 'application/json, text/plain, */*'
  900. }
  901. };
  902. utils.forEach(['delete', 'get', 'head'], function forEachMethodNoData(method) {
  903. defaults.headers[method] = {};
  904. });
  905. utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
  906. defaults.headers[method] = utils.merge(DEFAULT_CONTENT_TYPE);
  907. });
  908. module.exports = defaults;
  909. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../process/browser.js */ "./node_modules/process/browser.js")))
  910. /***/ }),
  911. /***/ "./node_modules/axios/lib/helpers/bind.js":
  912. /*!************************************************!*\
  913. !*** ./node_modules/axios/lib/helpers/bind.js ***!
  914. \************************************************/
  915. /*! no static exports found */
  916. /***/ (function(module, exports, __webpack_require__) {
  917. "use strict";
  918. module.exports = function bind(fn, thisArg) {
  919. return function wrap() {
  920. var args = new Array(arguments.length);
  921. for (var i = 0; i < args.length; i++) {
  922. args[i] = arguments[i];
  923. }
  924. return fn.apply(thisArg, args);
  925. };
  926. };
  927. /***/ }),
  928. /***/ "./node_modules/axios/lib/helpers/buildURL.js":
  929. /*!****************************************************!*\
  930. !*** ./node_modules/axios/lib/helpers/buildURL.js ***!
  931. \****************************************************/
  932. /*! no static exports found */
  933. /***/ (function(module, exports, __webpack_require__) {
  934. "use strict";
  935. var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
  936. function encode(val) {
  937. return encodeURIComponent(val).
  938. replace(/%40/gi, '@').
  939. replace(/%3A/gi, ':').
  940. replace(/%24/g, '$').
  941. replace(/%2C/gi, ',').
  942. replace(/%20/g, '+').
  943. replace(/%5B/gi, '[').
  944. replace(/%5D/gi, ']');
  945. }
  946. /**
  947. * Build a URL by appending params to the end
  948. *
  949. * @param {string} url The base of the url (e.g., http://www.google.com)
  950. * @param {object} [params] The params to be appended
  951. * @returns {string} The formatted url
  952. */
  953. module.exports = function buildURL(url, params, paramsSerializer) {
  954. /*eslint no-param-reassign:0*/
  955. if (!params) {
  956. return url;
  957. }
  958. var serializedParams;
  959. if (paramsSerializer) {
  960. serializedParams = paramsSerializer(params);
  961. } else if (utils.isURLSearchParams(params)) {
  962. serializedParams = params.toString();
  963. } else {
  964. var parts = [];
  965. utils.forEach(params, function serialize(val, key) {
  966. if (val === null || typeof val === 'undefined') {
  967. return;
  968. }
  969. if (utils.isArray(val)) {
  970. key = key + '[]';
  971. } else {
  972. val = [val];
  973. }
  974. utils.forEach(val, function parseValue(v) {
  975. if (utils.isDate(v)) {
  976. v = v.toISOString();
  977. } else if (utils.isObject(v)) {
  978. v = JSON.stringify(v);
  979. }
  980. parts.push(encode(key) + '=' + encode(v));
  981. });
  982. });
  983. serializedParams = parts.join('&');
  984. }
  985. if (serializedParams) {
  986. var hashmarkIndex = url.indexOf('#');
  987. if (hashmarkIndex !== -1) {
  988. url = url.slice(0, hashmarkIndex);
  989. }
  990. url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams;
  991. }
  992. return url;
  993. };
  994. /***/ }),
  995. /***/ "./node_modules/axios/lib/helpers/combineURLs.js":
  996. /*!*******************************************************!*\
  997. !*** ./node_modules/axios/lib/helpers/combineURLs.js ***!
  998. \*******************************************************/
  999. /*! no static exports found */
  1000. /***/ (function(module, exports, __webpack_require__) {
  1001. "use strict";
  1002. /**
  1003. * Creates a new URL by combining the specified URLs
  1004. *
  1005. * @param {string} baseURL The base URL
  1006. * @param {string} relativeURL The relative URL
  1007. * @returns {string} The combined URL
  1008. */
  1009. module.exports = function combineURLs(baseURL, relativeURL) {
  1010. return relativeURL
  1011. ? baseURL.replace(/\/+$/, '') + '/' + relativeURL.replace(/^\/+/, '')
  1012. : baseURL;
  1013. };
  1014. /***/ }),
  1015. /***/ "./node_modules/axios/lib/helpers/cookies.js":
  1016. /*!***************************************************!*\
  1017. !*** ./node_modules/axios/lib/helpers/cookies.js ***!
  1018. \***************************************************/
  1019. /*! no static exports found */
  1020. /***/ (function(module, exports, __webpack_require__) {
  1021. "use strict";
  1022. var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
  1023. module.exports = (
  1024. utils.isStandardBrowserEnv() ?
  1025. // Standard browser envs support document.cookie
  1026. (function standardBrowserEnv() {
  1027. return {
  1028. write: function write(name, value, expires, path, domain, secure) {
  1029. var cookie = [];
  1030. cookie.push(name + '=' + encodeURIComponent(value));
  1031. if (utils.isNumber(expires)) {
  1032. cookie.push('expires=' + new Date(expires).toGMTString());
  1033. }
  1034. if (utils.isString(path)) {
  1035. cookie.push('path=' + path);
  1036. }
  1037. if (utils.isString(domain)) {
  1038. cookie.push('domain=' + domain);
  1039. }
  1040. if (secure === true) {
  1041. cookie.push('secure');
  1042. }
  1043. document.cookie = cookie.join('; ');
  1044. },
  1045. read: function read(name) {
  1046. var match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
  1047. return (match ? decodeURIComponent(match[3]) : null);
  1048. },
  1049. remove: function remove(name) {
  1050. this.write(name, '', Date.now() - 86400000);
  1051. }
  1052. };
  1053. })() :
  1054. // Non standard browser env (web workers, react-native) lack needed support.
  1055. (function nonStandardBrowserEnv() {
  1056. return {
  1057. write: function write() {},
  1058. read: function read() { return null; },
  1059. remove: function remove() {}
  1060. };
  1061. })()
  1062. );
  1063. /***/ }),
  1064. /***/ "./node_modules/axios/lib/helpers/isAbsoluteURL.js":
  1065. /*!*********************************************************!*\
  1066. !*** ./node_modules/axios/lib/helpers/isAbsoluteURL.js ***!
  1067. \*********************************************************/
  1068. /*! no static exports found */
  1069. /***/ (function(module, exports, __webpack_require__) {
  1070. "use strict";
  1071. /**
  1072. * Determines whether the specified URL is absolute
  1073. *
  1074. * @param {string} url The URL to test
  1075. * @returns {boolean} True if the specified URL is absolute, otherwise false
  1076. */
  1077. module.exports = function isAbsoluteURL(url) {
  1078. // A URL is considered absolute if it begins with "<scheme>://" or "//" (protocol-relative URL).
  1079. // RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed
  1080. // by any combination of letters, digits, plus, period, or hyphen.
  1081. return /^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(url);
  1082. };
  1083. /***/ }),
  1084. /***/ "./node_modules/axios/lib/helpers/isURLSameOrigin.js":
  1085. /*!***********************************************************!*\
  1086. !*** ./node_modules/axios/lib/helpers/isURLSameOrigin.js ***!
  1087. \***********************************************************/
  1088. /*! no static exports found */
  1089. /***/ (function(module, exports, __webpack_require__) {
  1090. "use strict";
  1091. var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
  1092. module.exports = (
  1093. utils.isStandardBrowserEnv() ?
  1094. // Standard browser envs have full support of the APIs needed to test
  1095. // whether the request URL is of the same origin as current location.
  1096. (function standardBrowserEnv() {
  1097. var msie = /(msie|trident)/i.test(navigator.userAgent);
  1098. var urlParsingNode = document.createElement('a');
  1099. var originURL;
  1100. /**
  1101. * Parse a URL to discover it's components
  1102. *
  1103. * @param {String} url The URL to be parsed
  1104. * @returns {Object}
  1105. */
  1106. function resolveURL(url) {
  1107. var href = url;
  1108. if (msie) {
  1109. // IE needs attribute set twice to normalize properties
  1110. urlParsingNode.setAttribute('href', href);
  1111. href = urlParsingNode.href;
  1112. }
  1113. urlParsingNode.setAttribute('href', href);
  1114. // urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils
  1115. return {
  1116. href: urlParsingNode.href,
  1117. protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '',
  1118. host: urlParsingNode.host,
  1119. search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, '') : '',
  1120. hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '',
  1121. hostname: urlParsingNode.hostname,
  1122. port: urlParsingNode.port,
  1123. pathname: (urlParsingNode.pathname.charAt(0) === '/') ?
  1124. urlParsingNode.pathname :
  1125. '/' + urlParsingNode.pathname
  1126. };
  1127. }
  1128. originURL = resolveURL(window.location.href);
  1129. /**
  1130. * Determine if a URL shares the same origin as the current location
  1131. *
  1132. * @param {String} requestURL The URL to test
  1133. * @returns {boolean} True if URL shares the same origin, otherwise false
  1134. */
  1135. return function isURLSameOrigin(requestURL) {
  1136. var parsed = (utils.isString(requestURL)) ? resolveURL(requestURL) : requestURL;
  1137. return (parsed.protocol === originURL.protocol &&
  1138. parsed.host === originURL.host);
  1139. };
  1140. })() :
  1141. // Non standard browser envs (web workers, react-native) lack needed support.
  1142. (function nonStandardBrowserEnv() {
  1143. return function isURLSameOrigin() {
  1144. return true;
  1145. };
  1146. })()
  1147. );
  1148. /***/ }),
  1149. /***/ "./node_modules/axios/lib/helpers/normalizeHeaderName.js":
  1150. /*!***************************************************************!*\
  1151. !*** ./node_modules/axios/lib/helpers/normalizeHeaderName.js ***!
  1152. \***************************************************************/
  1153. /*! no static exports found */
  1154. /***/ (function(module, exports, __webpack_require__) {
  1155. "use strict";
  1156. var utils = __webpack_require__(/*! ../utils */ "./node_modules/axios/lib/utils.js");
  1157. module.exports = function normalizeHeaderName(headers, normalizedName) {
  1158. utils.forEach(headers, function processHeader(value, name) {
  1159. if (name !== normalizedName && name.toUpperCase() === normalizedName.toUpperCase()) {
  1160. headers[normalizedName] = value;
  1161. delete headers[name];
  1162. }
  1163. });
  1164. };
  1165. /***/ }),
  1166. /***/ "./node_modules/axios/lib/helpers/parseHeaders.js":
  1167. /*!********************************************************!*\
  1168. !*** ./node_modules/axios/lib/helpers/parseHeaders.js ***!
  1169. \********************************************************/
  1170. /*! no static exports found */
  1171. /***/ (function(module, exports, __webpack_require__) {
  1172. "use strict";
  1173. var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
  1174. // Headers whose duplicates are ignored by node
  1175. // c.f. https://nodejs.org/api/http.html#http_message_headers
  1176. var ignoreDuplicateOf = [
  1177. 'age', 'authorization', 'content-length', 'content-type', 'etag',
  1178. 'expires', 'from', 'host', 'if-modified-since', 'if-unmodified-since',
  1179. 'last-modified', 'location', 'max-forwards', 'proxy-authorization',
  1180. 'referer', 'retry-after', 'user-agent'
  1181. ];
  1182. /**
  1183. * Parse headers into an object
  1184. *
  1185. * ```
  1186. * Date: Wed, 27 Aug 2014 08:58:49 GMT
  1187. * Content-Type: application/json
  1188. * Connection: keep-alive
  1189. * Transfer-Encoding: chunked
  1190. * ```
  1191. *
  1192. * @param {String} headers Headers needing to be parsed
  1193. * @returns {Object} Headers parsed into an object
  1194. */
  1195. module.exports = function parseHeaders(headers) {
  1196. var parsed = {};
  1197. var key;
  1198. var val;
  1199. var i;
  1200. if (!headers) { return parsed; }
  1201. utils.forEach(headers.split('\n'), function parser(line) {
  1202. i = line.indexOf(':');
  1203. key = utils.trim(line.substr(0, i)).toLowerCase();
  1204. val = utils.trim(line.substr(i + 1));
  1205. if (key) {
  1206. if (parsed[key] && ignoreDuplicateOf.indexOf(key) >= 0) {
  1207. return;
  1208. }
  1209. if (key === 'set-cookie') {
  1210. parsed[key] = (parsed[key] ? parsed[key] : []).concat([val]);
  1211. } else {
  1212. parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;
  1213. }
  1214. }
  1215. });
  1216. return parsed;
  1217. };
  1218. /***/ }),
  1219. /***/ "./node_modules/axios/lib/helpers/spread.js":
  1220. /*!**************************************************!*\
  1221. !*** ./node_modules/axios/lib/helpers/spread.js ***!
  1222. \**************************************************/
  1223. /*! no static exports found */
  1224. /***/ (function(module, exports, __webpack_require__) {
  1225. "use strict";
  1226. /**
  1227. * Syntactic sugar for invoking a function and expanding an array for arguments.
  1228. *
  1229. * Common use case would be to use `Function.prototype.apply`.
  1230. *
  1231. * ```js
  1232. * function f(x, y, z) {}
  1233. * var args = [1, 2, 3];
  1234. * f.apply(null, args);
  1235. * ```
  1236. *
  1237. * With `spread` this example can be re-written.
  1238. *
  1239. * ```js
  1240. * spread(function(x, y, z) {})([1, 2, 3]);
  1241. * ```
  1242. *
  1243. * @param {Function} callback
  1244. * @returns {Function}
  1245. */
  1246. module.exports = function spread(callback) {
  1247. return function wrap(arr) {
  1248. return callback.apply(null, arr);
  1249. };
  1250. };
  1251. /***/ }),
  1252. /***/ "./node_modules/axios/lib/utils.js":
  1253. /*!*****************************************!*\
  1254. !*** ./node_modules/axios/lib/utils.js ***!
  1255. \*****************************************/
  1256. /*! no static exports found */
  1257. /***/ (function(module, exports, __webpack_require__) {
  1258. "use strict";
  1259. var bind = __webpack_require__(/*! ./helpers/bind */ "./node_modules/axios/lib/helpers/bind.js");
  1260. /*global toString:true*/
  1261. // utils is a library of generic helper functions non-specific to axios
  1262. var toString = Object.prototype.toString;
  1263. /**
  1264. * Determine if a value is an Array
  1265. *
  1266. * @param {Object} val The value to test
  1267. * @returns {boolean} True if value is an Array, otherwise false
  1268. */
  1269. function isArray(val) {
  1270. return toString.call(val) === '[object Array]';
  1271. }
  1272. /**
  1273. * Determine if a value is undefined
  1274. *
  1275. * @param {Object} val The value to test
  1276. * @returns {boolean} True if the value is undefined, otherwise false
  1277. */
  1278. function isUndefined(val) {
  1279. return typeof val === 'undefined';
  1280. }
  1281. /**
  1282. * Determine if a value is a Buffer
  1283. *
  1284. * @param {Object} val The value to test
  1285. * @returns {boolean} True if value is a Buffer, otherwise false
  1286. */
  1287. function isBuffer(val) {
  1288. return val !== null && !isUndefined(val) && val.constructor !== null && !isUndefined(val.constructor)
  1289. && typeof val.constructor.isBuffer === 'function' && val.constructor.isBuffer(val);
  1290. }
  1291. /**
  1292. * Determine if a value is an ArrayBuffer
  1293. *
  1294. * @param {Object} val The value to test
  1295. * @returns {boolean} True if value is an ArrayBuffer, otherwise false
  1296. */
  1297. function isArrayBuffer(val) {
  1298. return toString.call(val) === '[object ArrayBuffer]';
  1299. }
  1300. /**
  1301. * Determine if a value is a FormData
  1302. *
  1303. * @param {Object} val The value to test
  1304. * @returns {boolean} True if value is an FormData, otherwise false
  1305. */
  1306. function isFormData(val) {
  1307. return (typeof FormData !== 'undefined') && (val instanceof FormData);
  1308. }
  1309. /**
  1310. * Determine if a value is a view on an ArrayBuffer
  1311. *
  1312. * @param {Object} val The value to test
  1313. * @returns {boolean} True if value is a view on an ArrayBuffer, otherwise false
  1314. */
  1315. function isArrayBufferView(val) {
  1316. var result;
  1317. if ((typeof ArrayBuffer !== 'undefined') && (ArrayBuffer.isView)) {
  1318. result = ArrayBuffer.isView(val);
  1319. } else {
  1320. result = (val) && (val.buffer) && (val.buffer instanceof ArrayBuffer);
  1321. }
  1322. return result;
  1323. }
  1324. /**
  1325. * Determine if a value is a String
  1326. *
  1327. * @param {Object} val The value to test
  1328. * @returns {boolean} True if value is a String, otherwise false
  1329. */
  1330. function isString(val) {
  1331. return typeof val === 'string';
  1332. }
  1333. /**
  1334. * Determine if a value is a Number
  1335. *
  1336. * @param {Object} val The value to test
  1337. * @returns {boolean} True if value is a Number, otherwise false
  1338. */
  1339. function isNumber(val) {
  1340. return typeof val === 'number';
  1341. }
  1342. /**
  1343. * Determine if a value is an Object
  1344. *
  1345. * @param {Object} val The value to test
  1346. * @returns {boolean} True if value is an Object, otherwise false
  1347. */
  1348. function isObject(val) {
  1349. return val !== null && typeof val === 'object';
  1350. }
  1351. /**
  1352. * Determine if a value is a Date
  1353. *
  1354. * @param {Object} val The value to test
  1355. * @returns {boolean} True if value is a Date, otherwise false
  1356. */
  1357. function isDate(val) {
  1358. return toString.call(val) === '[object Date]';
  1359. }
  1360. /**
  1361. * Determine if a value is a File
  1362. *
  1363. * @param {Object} val The value to test
  1364. * @returns {boolean} True if value is a File, otherwise false
  1365. */
  1366. function isFile(val) {
  1367. return toString.call(val) === '[object File]';
  1368. }
  1369. /**
  1370. * Determine if a value is a Blob
  1371. *
  1372. * @param {Object} val The value to test
  1373. * @returns {boolean} True if value is a Blob, otherwise false
  1374. */
  1375. function isBlob(val) {
  1376. return toString.call(val) === '[object Blob]';
  1377. }
  1378. /**
  1379. * Determine if a value is a Function
  1380. *
  1381. * @param {Object} val The value to test
  1382. * @returns {boolean} True if value is a Function, otherwise false
  1383. */
  1384. function isFunction(val) {
  1385. return toString.call(val) === '[object Function]';
  1386. }
  1387. /**
  1388. * Determine if a value is a Stream
  1389. *
  1390. * @param {Object} val The value to test
  1391. * @returns {boolean} True if value is a Stream, otherwise false
  1392. */
  1393. function isStream(val) {
  1394. return isObject(val) && isFunction(val.pipe);
  1395. }
  1396. /**
  1397. * Determine if a value is a URLSearchParams object
  1398. *
  1399. * @param {Object} val The value to test
  1400. * @returns {boolean} True if value is a URLSearchParams object, otherwise false
  1401. */
  1402. function isURLSearchParams(val) {
  1403. return typeof URLSearchParams !== 'undefined' && val instanceof URLSearchParams;
  1404. }
  1405. /**
  1406. * Trim excess whitespace off the beginning and end of a string
  1407. *
  1408. * @param {String} str The String to trim
  1409. * @returns {String} The String freed of excess whitespace
  1410. */
  1411. function trim(str) {
  1412. return str.replace(/^\s*/, '').replace(/\s*$/, '');
  1413. }
  1414. /**
  1415. * Determine if we're running in a standard browser environment
  1416. *
  1417. * This allows axios to run in a web worker, and react-native.
  1418. * Both environments support XMLHttpRequest, but not fully standard globals.
  1419. *
  1420. * web workers:
  1421. * typeof window -> undefined
  1422. * typeof document -> undefined
  1423. *
  1424. * react-native:
  1425. * navigator.product -> 'ReactNative'
  1426. * nativescript
  1427. * navigator.product -> 'NativeScript' or 'NS'
  1428. */
  1429. function isStandardBrowserEnv() {
  1430. if (typeof navigator !== 'undefined' && (navigator.product === 'ReactNative' ||
  1431. navigator.product === 'NativeScript' ||
  1432. navigator.product === 'NS')) {
  1433. return false;
  1434. }
  1435. return (
  1436. typeof window !== 'undefined' &&
  1437. typeof document !== 'undefined'
  1438. );
  1439. }
  1440. /**
  1441. * Iterate over an Array or an Object invoking a function for each item.
  1442. *
  1443. * If `obj` is an Array callback will be called passing
  1444. * the value, index, and complete array for each item.
  1445. *
  1446. * If 'obj' is an Object callback will be called passing
  1447. * the value, key, and complete object for each property.
  1448. *
  1449. * @param {Object|Array} obj The object to iterate
  1450. * @param {Function} fn The callback to invoke for each item
  1451. */
  1452. function forEach(obj, fn) {
  1453. // Don't bother if no value provided
  1454. if (obj === null || typeof obj === 'undefined') {
  1455. return;
  1456. }
  1457. // Force an array if not already something iterable
  1458. if (typeof obj !== 'object') {
  1459. /*eslint no-param-reassign:0*/
  1460. obj = [obj];
  1461. }
  1462. if (isArray(obj)) {
  1463. // Iterate over array values
  1464. for (var i = 0, l = obj.length; i < l; i++) {
  1465. fn.call(null, obj[i], i, obj);
  1466. }
  1467. } else {
  1468. // Iterate over object keys
  1469. for (var key in obj) {
  1470. if (Object.prototype.hasOwnProperty.call(obj, key)) {
  1471. fn.call(null, obj[key], key, obj);
  1472. }
  1473. }
  1474. }
  1475. }
  1476. /**
  1477. * Accepts varargs expecting each argument to be an object, then
  1478. * immutably merges the properties of each object and returns result.
  1479. *
  1480. * When multiple objects contain the same key the later object in
  1481. * the arguments list will take precedence.
  1482. *
  1483. * Example:
  1484. *
  1485. * ```js
  1486. * var result = merge({foo: 123}, {foo: 456});
  1487. * console.log(result.foo); // outputs 456
  1488. * ```
  1489. *
  1490. * @param {Object} obj1 Object to merge
  1491. * @returns {Object} Result of all merge properties
  1492. */
  1493. function merge(/* obj1, obj2, obj3, ... */) {
  1494. var result = {};
  1495. function assignValue(val, key) {
  1496. if (typeof result[key] === 'object' && typeof val === 'object') {
  1497. result[key] = merge(result[key], val);
  1498. } else {
  1499. result[key] = val;
  1500. }
  1501. }
  1502. for (var i = 0, l = arguments.length; i < l; i++) {
  1503. forEach(arguments[i], assignValue);
  1504. }
  1505. return result;
  1506. }
  1507. /**
  1508. * Function equal to merge with the difference being that no reference
  1509. * to original objects is kept.
  1510. *
  1511. * @see merge
  1512. * @param {Object} obj1 Object to merge
  1513. * @returns {Object} Result of all merge properties
  1514. */
  1515. function deepMerge(/* obj1, obj2, obj3, ... */) {
  1516. var result = {};
  1517. function assignValue(val, key) {
  1518. if (typeof result[key] === 'object' && typeof val === 'object') {
  1519. result[key] = deepMerge(result[key], val);
  1520. } else if (typeof val === 'object') {
  1521. result[key] = deepMerge({}, val);
  1522. } else {
  1523. result[key] = val;
  1524. }
  1525. }
  1526. for (var i = 0, l = arguments.length; i < l; i++) {
  1527. forEach(arguments[i], assignValue);
  1528. }
  1529. return result;
  1530. }
  1531. /**
  1532. * Extends object a by mutably adding to it the properties of object b.
  1533. *
  1534. * @param {Object} a The object to be extended
  1535. * @param {Object} b The object to copy properties from
  1536. * @param {Object} thisArg The object to bind function to
  1537. * @return {Object} The resulting value of object a
  1538. */
  1539. function extend(a, b, thisArg) {
  1540. forEach(b, function assignValue(val, key) {
  1541. if (thisArg && typeof val === 'function') {
  1542. a[key] = bind(val, thisArg);
  1543. } else {
  1544. a[key] = val;
  1545. }
  1546. });
  1547. return a;
  1548. }
  1549. module.exports = {
  1550. isArray: isArray,
  1551. isArrayBuffer: isArrayBuffer,
  1552. isBuffer: isBuffer,
  1553. isFormData: isFormData,
  1554. isArrayBufferView: isArrayBufferView,
  1555. isString: isString,
  1556. isNumber: isNumber,
  1557. isObject: isObject,
  1558. isUndefined: isUndefined,
  1559. isDate: isDate,
  1560. isFile: isFile,
  1561. isBlob: isBlob,
  1562. isFunction: isFunction,
  1563. isStream: isStream,
  1564. isURLSearchParams: isURLSearchParams,
  1565. isStandardBrowserEnv: isStandardBrowserEnv,
  1566. forEach: forEach,
  1567. merge: merge,
  1568. deepMerge: deepMerge,
  1569. extend: extend,
  1570. trim: trim
  1571. };
  1572. /***/ }),
  1573. /***/ "./node_modules/babel-loader/lib/index.js?!./node_modules/vue-loader/lib/index.js?!./resources/js/components/ExampleComponent.vue?vue&type=script&lang=js&":
  1574. /*!***************************************************************************************************************************************************************************!*\
  1575. !*** ./node_modules/babel-loader/lib??ref--4-0!./node_modules/vue-loader/lib??vue-loader-options!./resources/js/components/ExampleComponent.vue?vue&type=script&lang=js& ***!
  1576. \***************************************************************************************************************************************************************************/
  1577. /*! exports provided: default */
  1578. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1579. "use strict";
  1580. __webpack_require__.r(__webpack_exports__);
  1581. //
  1582. //
  1583. //
  1584. //
  1585. //
  1586. //
  1587. //
  1588. //
  1589. //
  1590. //
  1591. //
  1592. //
  1593. //
  1594. //
  1595. //
  1596. //
  1597. /* harmony default export */ __webpack_exports__["default"] = ({
  1598. mounted: function mounted() {
  1599. console.log('Component mounted.');
  1600. }
  1601. });
  1602. /***/ }),
  1603. /***/ "./node_modules/babel-loader/lib/index.js?!./node_modules/vue-loader/lib/index.js?!./resources/js/components/assetinfo.vue?vue&type=script&lang=js&":
  1604. /*!********************************************************************************************************************************************************************!*\
  1605. !*** ./node_modules/babel-loader/lib??ref--4-0!./node_modules/vue-loader/lib??vue-loader-options!./resources/js/components/assetinfo.vue?vue&type=script&lang=js& ***!
  1606. \********************************************************************************************************************************************************************/
  1607. /*! exports provided: default */
  1608. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1609. "use strict";
  1610. __webpack_require__.r(__webpack_exports__);
  1611. //
  1612. //
  1613. //
  1614. //
  1615. //
  1616. //
  1617. //
  1618. //
  1619. //
  1620. //
  1621. //
  1622. //
  1623. //
  1624. //
  1625. //
  1626. //
  1627. //
  1628. //
  1629. //
  1630. //
  1631. //
  1632. //
  1633. //
  1634. //
  1635. //
  1636. //
  1637. //
  1638. //
  1639. //
  1640. //
  1641. //
  1642. //
  1643. //
  1644. //
  1645. //
  1646. //
  1647. //
  1648. //
  1649. //
  1650. //
  1651. //
  1652. //
  1653. //
  1654. //
  1655. //
  1656. //
  1657. //
  1658. //
  1659. //
  1660. //
  1661. //
  1662. //
  1663. //
  1664. //
  1665. //
  1666. //
  1667. /* harmony default export */ __webpack_exports__["default"] = ({
  1668. props: ['asset', 'pcextraStart'],
  1669. data: function data() {
  1670. return {
  1671. data: JSON.parse(this.asset),
  1672. pcextra: JSON.parse(this.pcextraStart)
  1673. };
  1674. },
  1675. mounted: function mounted() {
  1676. var _this = this;
  1677. Echo.channel('assets').listen('AssetUpdated', function (e) {
  1678. _this.data = JSON.parse(e.data);
  1679. _this.pcextra = JSON.parse(e.pcextra);
  1680. });
  1681. },
  1682. methods: {
  1683. updateAsset: function updateAsset() {
  1684. this.data.pcextra = this.pcextra;
  1685. axios.put('/api/asset/' + this.data.pcid, this.data).then(function (response) {})["catch"](function (error) {});
  1686. $('#asseteditModal').modal('hide');
  1687. }
  1688. }
  1689. });
  1690. /***/ }),
  1691. /***/ "./node_modules/babel-loader/lib/index.js?!./node_modules/vue-loader/lib/index.js?!./resources/js/components/credential.vue?vue&type=script&lang=js&":
  1692. /*!*********************************************************************************************************************************************************************!*\
  1693. !*** ./node_modules/babel-loader/lib??ref--4-0!./node_modules/vue-loader/lib??vue-loader-options!./resources/js/components/credential.vue?vue&type=script&lang=js& ***!
  1694. \*********************************************************************************************************************************************************************/
  1695. /*! exports provided: default */
  1696. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1697. "use strict";
  1698. __webpack_require__.r(__webpack_exports__);
  1699. //
  1700. //
  1701. //
  1702. //
  1703. //
  1704. //
  1705. //
  1706. //
  1707. //
  1708. //
  1709. //
  1710. //
  1711. //
  1712. //
  1713. //
  1714. //
  1715. //
  1716. //
  1717. //
  1718. //
  1719. //
  1720. //
  1721. //
  1722. //
  1723. //
  1724. //
  1725. //
  1726. //
  1727. //
  1728. //
  1729. /* harmony default export */ __webpack_exports__["default"] = ({
  1730. props: ['credential'],
  1731. data: function data() {
  1732. return {
  1733. data: JSON.parse(this.credential)
  1734. };
  1735. },
  1736. mounted: function mounted() {
  1737. var _this = this;
  1738. Echo.channel('credentials').listen('CredentialUpdated', function (e) {
  1739. _this.data = JSON.parse(e.data);
  1740. });
  1741. }
  1742. });
  1743. /***/ }),
  1744. /***/ "./node_modules/babel-loader/lib/index.js?!./node_modules/vue-loader/lib/index.js?!./resources/js/components/notes.vue?vue&type=script&lang=js&":
  1745. /*!****************************************************************************************************************************************************************!*\
  1746. !*** ./node_modules/babel-loader/lib??ref--4-0!./node_modules/vue-loader/lib??vue-loader-options!./resources/js/components/notes.vue?vue&type=script&lang=js& ***!
  1747. \****************************************************************************************************************************************************************/
  1748. /*! exports provided: default */
  1749. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1750. "use strict";
  1751. __webpack_require__.r(__webpack_exports__);
  1752. /* harmony import */ var _mixins_dateMixin__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../mixins/dateMixin */ "./resources/js/mixins/dateMixin.js");
  1753. //
  1754. //
  1755. //
  1756. //
  1757. //
  1758. //
  1759. //
  1760. //
  1761. //
  1762. //
  1763. //
  1764. //
  1765. //
  1766. //
  1767. //
  1768. //
  1769. //
  1770. //
  1771. //
  1772. //
  1773. //
  1774. //
  1775. //
  1776. //
  1777. /* harmony default export */ __webpack_exports__["default"] = ({
  1778. mixins: [_mixins_dateMixin__WEBPACK_IMPORTED_MODULE_0__["default"]],
  1779. props: ['initialnotes', 'authusername'],
  1780. data: function data() {
  1781. return {
  1782. notes: this.initialnotes
  1783. };
  1784. }
  1785. });
  1786. /***/ }),
  1787. /***/ "./node_modules/babel-loader/lib/index.js?!./node_modules/vue-loader/lib/index.js?!./resources/js/components/woinfo.vue?vue&type=script&lang=js&":
  1788. /*!*****************************************************************************************************************************************************************!*\
  1789. !*** ./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& ***!
  1790. \*****************************************************************************************************************************************************************/
  1791. /*! exports provided: default */
  1792. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1793. "use strict";
  1794. __webpack_require__.r(__webpack_exports__);
  1795. /* harmony import */ var _mixins_dateMixin__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../mixins/dateMixin */ "./resources/js/mixins/dateMixin.js");
  1796. //
  1797. //
  1798. //
  1799. //
  1800. //
  1801. //
  1802. //
  1803. //
  1804. //
  1805. //
  1806. //
  1807. //
  1808. //
  1809. //
  1810. //
  1811. //
  1812. //
  1813. //
  1814. //
  1815. //
  1816. //
  1817. //
  1818. //
  1819. //
  1820. //
  1821. //
  1822. //
  1823. //
  1824. //
  1825. //
  1826. //
  1827. //
  1828. //
  1829. //
  1830. //
  1831. //
  1832. //
  1833. //
  1834. //
  1835. /* harmony default export */ __webpack_exports__["default"] = ({
  1836. mixins: [_mixins_dateMixin__WEBPACK_IMPORTED_MODULE_0__["default"]],
  1837. props: ['workOrder'],
  1838. data: function data() {
  1839. return {
  1840. data: JSON.parse(this.workOrder),
  1841. showModal: false
  1842. };
  1843. },
  1844. mounted: function mounted() {
  1845. var _this = this;
  1846. Echo.channel('work-orders').listen('WorkOrderUpdated', function (e) {
  1847. _this.data = JSON.parse(e.data);
  1848. });
  1849. },
  1850. methods: {
  1851. updateWorkOrder: function updateWorkOrder() {
  1852. axios.put('/api/workorder/' + this.data.woid, this.data).then(function (response) {})["catch"](function (error) {});
  1853. $('#workordereditModal').modal('hide');
  1854. }
  1855. }
  1856. });
  1857. /***/ }),
  1858. /***/ "./node_modules/base64-js/index.js":
  1859. /*!*****************************************!*\
  1860. !*** ./node_modules/base64-js/index.js ***!
  1861. \*****************************************/
  1862. /*! no static exports found */
  1863. /***/ (function(module, exports, __webpack_require__) {
  1864. "use strict";
  1865. exports.byteLength = byteLength
  1866. exports.toByteArray = toByteArray
  1867. exports.fromByteArray = fromByteArray
  1868. var lookup = []
  1869. var revLookup = []
  1870. var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array
  1871. var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
  1872. for (var i = 0, len = code.length; i < len; ++i) {
  1873. lookup[i] = code[i]
  1874. revLookup[code.charCodeAt(i)] = i
  1875. }
  1876. // Support decoding URL-safe base64 strings, as Node.js does.
  1877. // See: https://en.wikipedia.org/wiki/Base64#URL_applications
  1878. revLookup['-'.charCodeAt(0)] = 62
  1879. revLookup['_'.charCodeAt(0)] = 63
  1880. function getLens (b64) {
  1881. var len = b64.length
  1882. if (len % 4 > 0) {
  1883. throw new Error('Invalid string. Length must be a multiple of 4')
  1884. }
  1885. // Trim off extra bytes after placeholder bytes are found
  1886. // See: https://github.com/beatgammit/base64-js/issues/42
  1887. var validLen = b64.indexOf('=')
  1888. if (validLen === -1) validLen = len
  1889. var placeHoldersLen = validLen === len
  1890. ? 0
  1891. : 4 - (validLen % 4)
  1892. return [validLen, placeHoldersLen]
  1893. }
  1894. // base64 is 4/3 + up to two characters of the original data
  1895. function byteLength (b64) {
  1896. var lens = getLens(b64)
  1897. var validLen = lens[0]
  1898. var placeHoldersLen = lens[1]
  1899. return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
  1900. }
  1901. function _byteLength (b64, validLen, placeHoldersLen) {
  1902. return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
  1903. }
  1904. function toByteArray (b64) {
  1905. var tmp
  1906. var lens = getLens(b64)
  1907. var validLen = lens[0]
  1908. var placeHoldersLen = lens[1]
  1909. var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen))
  1910. var curByte = 0
  1911. // if there are placeholders, only get up to the last complete 4 chars
  1912. var len = placeHoldersLen > 0
  1913. ? validLen - 4
  1914. : validLen
  1915. var i
  1916. for (i = 0; i < len; i += 4) {
  1917. tmp =
  1918. (revLookup[b64.charCodeAt(i)] << 18) |
  1919. (revLookup[b64.charCodeAt(i + 1)] << 12) |
  1920. (revLookup[b64.charCodeAt(i + 2)] << 6) |
  1921. revLookup[b64.charCodeAt(i + 3)]
  1922. arr[curByte++] = (tmp >> 16) & 0xFF
  1923. arr[curByte++] = (tmp >> 8) & 0xFF
  1924. arr[curByte++] = tmp & 0xFF
  1925. }
  1926. if (placeHoldersLen === 2) {
  1927. tmp =
  1928. (revLookup[b64.charCodeAt(i)] << 2) |
  1929. (revLookup[b64.charCodeAt(i + 1)] >> 4)
  1930. arr[curByte++] = tmp & 0xFF
  1931. }
  1932. if (placeHoldersLen === 1) {
  1933. tmp =
  1934. (revLookup[b64.charCodeAt(i)] << 10) |
  1935. (revLookup[b64.charCodeAt(i + 1)] << 4) |
  1936. (revLookup[b64.charCodeAt(i + 2)] >> 2)
  1937. arr[curByte++] = (tmp >> 8) & 0xFF
  1938. arr[curByte++] = tmp & 0xFF
  1939. }
  1940. return arr
  1941. }
  1942. function tripletToBase64 (num) {
  1943. return lookup[num >> 18 & 0x3F] +
  1944. lookup[num >> 12 & 0x3F] +
  1945. lookup[num >> 6 & 0x3F] +
  1946. lookup[num & 0x3F]
  1947. }
  1948. function encodeChunk (uint8, start, end) {
  1949. var tmp
  1950. var output = []
  1951. for (var i = start; i < end; i += 3) {
  1952. tmp =
  1953. ((uint8[i] << 16) & 0xFF0000) +
  1954. ((uint8[i + 1] << 8) & 0xFF00) +
  1955. (uint8[i + 2] & 0xFF)
  1956. output.push(tripletToBase64(tmp))
  1957. }
  1958. return output.join('')
  1959. }
  1960. function fromByteArray (uint8) {
  1961. var tmp
  1962. var len = uint8.length
  1963. var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes
  1964. var parts = []
  1965. var maxChunkLength = 16383 // must be multiple of 3
  1966. // go through the array every three bytes, we'll deal with trailing stuff later
  1967. for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {
  1968. parts.push(encodeChunk(
  1969. uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength)
  1970. ))
  1971. }
  1972. // pad the end with zeros, but make sure to not forget the extra bytes
  1973. if (extraBytes === 1) {
  1974. tmp = uint8[len - 1]
  1975. parts.push(
  1976. lookup[tmp >> 2] +
  1977. lookup[(tmp << 4) & 0x3F] +
  1978. '=='
  1979. )
  1980. } else if (extraBytes === 2) {
  1981. tmp = (uint8[len - 2] << 8) + uint8[len - 1]
  1982. parts.push(
  1983. lookup[tmp >> 10] +
  1984. lookup[(tmp >> 4) & 0x3F] +
  1985. lookup[(tmp << 2) & 0x3F] +
  1986. '='
  1987. )
  1988. }
  1989. return parts.join('')
  1990. }
  1991. /***/ }),
  1992. /***/ "./node_modules/bootstrap/dist/js/bootstrap.js":
  1993. /*!*****************************************************!*\
  1994. !*** ./node_modules/bootstrap/dist/js/bootstrap.js ***!
  1995. \*****************************************************/
  1996. /*! no static exports found */
  1997. /***/ (function(module, exports, __webpack_require__) {
  1998. /*!
  1999. * Bootstrap v4.4.1 (https://getbootstrap.com/)
  2000. * Copyright 2011-2019 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
  2001. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
  2002. */
  2003. (function (global, factory) {
  2004. true ? factory(exports, __webpack_require__(/*! jquery */ "./node_modules/jquery/dist/jquery.js"), __webpack_require__(/*! popper.js */ "./node_modules/popper.js/dist/esm/popper.js")) :
  2005. undefined;
  2006. }(this, (function (exports, $, Popper) { 'use strict';
  2007. $ = $ && $.hasOwnProperty('default') ? $['default'] : $;
  2008. Popper = Popper && Popper.hasOwnProperty('default') ? Popper['default'] : Popper;
  2009. function _defineProperties(target, props) {
  2010. for (var i = 0; i < props.length; i++) {
  2011. var descriptor = props[i];
  2012. descriptor.enumerable = descriptor.enumerable || false;
  2013. descriptor.configurable = true;
  2014. if ("value" in descriptor) descriptor.writable = true;
  2015. Object.defineProperty(target, descriptor.key, descriptor);
  2016. }
  2017. }
  2018. function _createClass(Constructor, protoProps, staticProps) {
  2019. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  2020. if (staticProps) _defineProperties(Constructor, staticProps);
  2021. return Constructor;
  2022. }
  2023. function _defineProperty(obj, key, value) {
  2024. if (key in obj) {
  2025. Object.defineProperty(obj, key, {
  2026. value: value,
  2027. enumerable: true,
  2028. configurable: true,
  2029. writable: true
  2030. });
  2031. } else {
  2032. obj[key] = value;
  2033. }
  2034. return obj;
  2035. }
  2036. function ownKeys(object, enumerableOnly) {
  2037. var keys = Object.keys(object);
  2038. if (Object.getOwnPropertySymbols) {
  2039. var symbols = Object.getOwnPropertySymbols(object);
  2040. if (enumerableOnly) symbols = symbols.filter(function (sym) {
  2041. return Object.getOwnPropertyDescriptor(object, sym).enumerable;
  2042. });
  2043. keys.push.apply(keys, symbols);
  2044. }
  2045. return keys;
  2046. }
  2047. function _objectSpread2(target) {
  2048. for (var i = 1; i < arguments.length; i++) {
  2049. var source = arguments[i] != null ? arguments[i] : {};
  2050. if (i % 2) {
  2051. ownKeys(Object(source), true).forEach(function (key) {
  2052. _defineProperty(target, key, source[key]);
  2053. });
  2054. } else if (Object.getOwnPropertyDescriptors) {
  2055. Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
  2056. } else {
  2057. ownKeys(Object(source)).forEach(function (key) {
  2058. Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
  2059. });
  2060. }
  2061. }
  2062. return target;
  2063. }
  2064. function _inheritsLoose(subClass, superClass) {
  2065. subClass.prototype = Object.create(superClass.prototype);
  2066. subClass.prototype.constructor = subClass;
  2067. subClass.__proto__ = superClass;
  2068. }
  2069. /**
  2070. * --------------------------------------------------------------------------
  2071. * Bootstrap (v4.4.1): util.js
  2072. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
  2073. * --------------------------------------------------------------------------
  2074. */
  2075. /**
  2076. * ------------------------------------------------------------------------
  2077. * Private TransitionEnd Helpers
  2078. * ------------------------------------------------------------------------
  2079. */
  2080. var TRANSITION_END = 'transitionend';
  2081. var MAX_UID = 1000000;
  2082. var MILLISECONDS_MULTIPLIER = 1000; // Shoutout AngusCroll (https://goo.gl/pxwQGp)
  2083. function toType(obj) {
  2084. return {}.toString.call(obj).match(/\s([a-z]+)/i)[1].toLowerCase();
  2085. }
  2086. function getSpecialTransitionEndEvent() {
  2087. return {
  2088. bindType: TRANSITION_END,
  2089. delegateType: TRANSITION_END,
  2090. handle: function handle(event) {
  2091. if ($(event.target).is(this)) {
  2092. return event.handleObj.handler.apply(this, arguments); // eslint-disable-line prefer-rest-params
  2093. }
  2094. return undefined; // eslint-disable-line no-undefined
  2095. }
  2096. };
  2097. }
  2098. function transitionEndEmulator(duration) {
  2099. var _this = this;
  2100. var called = false;
  2101. $(this).one(Util.TRANSITION_END, function () {
  2102. called = true;
  2103. });
  2104. setTimeout(function () {
  2105. if (!called) {
  2106. Util.triggerTransitionEnd(_this);
  2107. }
  2108. }, duration);
  2109. return this;
  2110. }
  2111. function setTransitionEndSupport() {
  2112. $.fn.emulateTransitionEnd = transitionEndEmulator;
  2113. $.event.special[Util.TRANSITION_END] = getSpecialTransitionEndEvent();
  2114. }
  2115. /**
  2116. * --------------------------------------------------------------------------
  2117. * Public Util Api
  2118. * --------------------------------------------------------------------------
  2119. */
  2120. var Util = {
  2121. TRANSITION_END: 'bsTransitionEnd',
  2122. getUID: function getUID(prefix) {
  2123. do {
  2124. // eslint-disable-next-line no-bitwise
  2125. prefix += ~~(Math.random() * MAX_UID); // "~~" acts like a faster Math.floor() here
  2126. } while (document.getElementById(prefix));
  2127. return prefix;
  2128. },
  2129. getSelectorFromElement: function getSelectorFromElement(element) {
  2130. var selector = element.getAttribute('data-target');
  2131. if (!selector || selector === '#') {
  2132. var hrefAttr = element.getAttribute('href');
  2133. selector = hrefAttr && hrefAttr !== '#' ? hrefAttr.trim() : '';
  2134. }
  2135. try {
  2136. return document.querySelector(selector) ? selector : null;
  2137. } catch (err) {
  2138. return null;
  2139. }
  2140. },
  2141. getTransitionDurationFromElement: function getTransitionDurationFromElement(element) {
  2142. if (!element) {
  2143. return 0;
  2144. } // Get transition-duration of the element
  2145. var transitionDuration = $(element).css('transition-duration');
  2146. var transitionDelay = $(element).css('transition-delay');
  2147. var floatTransitionDuration = parseFloat(transitionDuration);
  2148. var floatTransitionDelay = parseFloat(transitionDelay); // Return 0 if element or transition duration is not found
  2149. if (!floatTransitionDuration && !floatTransitionDelay) {
  2150. return 0;
  2151. } // If multiple durations are defined, take the first
  2152. transitionDuration = transitionDuration.split(',')[0];
  2153. transitionDelay = transitionDelay.split(',')[0];
  2154. return (parseFloat(transitionDuration) + parseFloat(transitionDelay)) * MILLISECONDS_MULTIPLIER;
  2155. },
  2156. reflow: function reflow(element) {
  2157. return element.offsetHeight;
  2158. },
  2159. triggerTransitionEnd: function triggerTransitionEnd(element) {
  2160. $(element).trigger(TRANSITION_END);
  2161. },
  2162. // TODO: Remove in v5
  2163. supportsTransitionEnd: function supportsTransitionEnd() {
  2164. return Boolean(TRANSITION_END);
  2165. },
  2166. isElement: function isElement(obj) {
  2167. return (obj[0] || obj).nodeType;
  2168. },
  2169. typeCheckConfig: function typeCheckConfig(componentName, config, configTypes) {
  2170. for (var property in configTypes) {
  2171. if (Object.prototype.hasOwnProperty.call(configTypes, property)) {
  2172. var expectedTypes = configTypes[property];
  2173. var value = config[property];
  2174. var valueType = value && Util.isElement(value) ? 'element' : toType(value);
  2175. if (!new RegExp(expectedTypes).test(valueType)) {
  2176. throw new Error(componentName.toUpperCase() + ": " + ("Option \"" + property + "\" provided type \"" + valueType + "\" ") + ("but expected type \"" + expectedTypes + "\"."));
  2177. }
  2178. }
  2179. }
  2180. },
  2181. findShadowRoot: function findShadowRoot(element) {
  2182. if (!document.documentElement.attachShadow) {
  2183. return null;
  2184. } // Can find the shadow root otherwise it'll return the document
  2185. if (typeof element.getRootNode === 'function') {
  2186. var root = element.getRootNode();
  2187. return root instanceof ShadowRoot ? root : null;
  2188. }
  2189. if (element instanceof ShadowRoot) {
  2190. return element;
  2191. } // when we don't find a shadow root
  2192. if (!element.parentNode) {
  2193. return null;
  2194. }
  2195. return Util.findShadowRoot(element.parentNode);
  2196. },
  2197. jQueryDetection: function jQueryDetection() {
  2198. if (typeof $ === 'undefined') {
  2199. throw new TypeError('Bootstrap\'s JavaScript requires jQuery. jQuery must be included before Bootstrap\'s JavaScript.');
  2200. }
  2201. var version = $.fn.jquery.split(' ')[0].split('.');
  2202. var minMajor = 1;
  2203. var ltMajor = 2;
  2204. var minMinor = 9;
  2205. var minPatch = 1;
  2206. var maxMajor = 4;
  2207. if (version[0] < ltMajor && version[1] < minMinor || version[0] === minMajor && version[1] === minMinor && version[2] < minPatch || version[0] >= maxMajor) {
  2208. throw new Error('Bootstrap\'s JavaScript requires at least jQuery v1.9.1 but less than v4.0.0');
  2209. }
  2210. }
  2211. };
  2212. Util.jQueryDetection();
  2213. setTransitionEndSupport();
  2214. /**
  2215. * ------------------------------------------------------------------------
  2216. * Constants
  2217. * ------------------------------------------------------------------------
  2218. */
  2219. var NAME = 'alert';
  2220. var VERSION = '4.4.1';
  2221. var DATA_KEY = 'bs.alert';
  2222. var EVENT_KEY = "." + DATA_KEY;
  2223. var DATA_API_KEY = '.data-api';
  2224. var JQUERY_NO_CONFLICT = $.fn[NAME];
  2225. var Selector = {
  2226. DISMISS: '[data-dismiss="alert"]'
  2227. };
  2228. var Event = {
  2229. CLOSE: "close" + EVENT_KEY,
  2230. CLOSED: "closed" + EVENT_KEY,
  2231. CLICK_DATA_API: "click" + EVENT_KEY + DATA_API_KEY
  2232. };
  2233. var ClassName = {
  2234. ALERT: 'alert',
  2235. FADE: 'fade',
  2236. SHOW: 'show'
  2237. };
  2238. /**
  2239. * ------------------------------------------------------------------------
  2240. * Class Definition
  2241. * ------------------------------------------------------------------------
  2242. */
  2243. var Alert =
  2244. /*#__PURE__*/
  2245. function () {
  2246. function Alert(element) {
  2247. this._element = element;
  2248. } // Getters
  2249. var _proto = Alert.prototype;
  2250. // Public
  2251. _proto.close = function close(element) {
  2252. var rootElement = this._element;
  2253. if (element) {
  2254. rootElement = this._getRootElement(element);
  2255. }
  2256. var customEvent = this._triggerCloseEvent(rootElement);
  2257. if (customEvent.isDefaultPrevented()) {
  2258. return;
  2259. }
  2260. this._removeElement(rootElement);
  2261. };
  2262. _proto.dispose = function dispose() {
  2263. $.removeData(this._element, DATA_KEY);
  2264. this._element = null;
  2265. } // Private
  2266. ;
  2267. _proto._getRootElement = function _getRootElement(element) {
  2268. var selector = Util.getSelectorFromElement(element);
  2269. var parent = false;
  2270. if (selector) {
  2271. parent = document.querySelector(selector);
  2272. }
  2273. if (!parent) {
  2274. parent = $(element).closest("." + ClassName.ALERT)[0];
  2275. }
  2276. return parent;
  2277. };
  2278. _proto._triggerCloseEvent = function _triggerCloseEvent(element) {
  2279. var closeEvent = $.Event(Event.CLOSE);
  2280. $(element).trigger(closeEvent);
  2281. return closeEvent;
  2282. };
  2283. _proto._removeElement = function _removeElement(element) {
  2284. var _this = this;
  2285. $(element).removeClass(ClassName.SHOW);
  2286. if (!$(element).hasClass(ClassName.FADE)) {
  2287. this._destroyElement(element);
  2288. return;
  2289. }
  2290. var transitionDuration = Util.getTransitionDurationFromElement(element);
  2291. $(element).one(Util.TRANSITION_END, function (event) {
  2292. return _this._destroyElement(element, event);
  2293. }).emulateTransitionEnd(transitionDuration);
  2294. };
  2295. _proto._destroyElement = function _destroyElement(element) {
  2296. $(element).detach().trigger(Event.CLOSED).remove();
  2297. } // Static
  2298. ;
  2299. Alert._jQueryInterface = function _jQueryInterface(config) {
  2300. return this.each(function () {
  2301. var $element = $(this);
  2302. var data = $element.data(DATA_KEY);
  2303. if (!data) {
  2304. data = new Alert(this);
  2305. $element.data(DATA_KEY, data);
  2306. }
  2307. if (config === 'close') {
  2308. data[config](this);
  2309. }
  2310. });
  2311. };
  2312. Alert._handleDismiss = function _handleDismiss(alertInstance) {
  2313. return function (event) {
  2314. if (event) {
  2315. event.preventDefault();
  2316. }
  2317. alertInstance.close(this);
  2318. };
  2319. };
  2320. _createClass(Alert, null, [{
  2321. key: "VERSION",
  2322. get: function get() {
  2323. return VERSION;
  2324. }
  2325. }]);
  2326. return Alert;
  2327. }();
  2328. /**
  2329. * ------------------------------------------------------------------------
  2330. * Data Api implementation
  2331. * ------------------------------------------------------------------------
  2332. */
  2333. $(document).on(Event.CLICK_DATA_API, Selector.DISMISS, Alert._handleDismiss(new Alert()));
  2334. /**
  2335. * ------------------------------------------------------------------------
  2336. * jQuery
  2337. * ------------------------------------------------------------------------
  2338. */
  2339. $.fn[NAME] = Alert._jQueryInterface;
  2340. $.fn[NAME].Constructor = Alert;
  2341. $.fn[NAME].noConflict = function () {
  2342. $.fn[NAME] = JQUERY_NO_CONFLICT;
  2343. return Alert._jQueryInterface;
  2344. };
  2345. /**
  2346. * ------------------------------------------------------------------------
  2347. * Constants
  2348. * ------------------------------------------------------------------------
  2349. */
  2350. var NAME$1 = 'button';
  2351. var VERSION$1 = '4.4.1';
  2352. var DATA_KEY$1 = 'bs.button';
  2353. var EVENT_KEY$1 = "." + DATA_KEY$1;
  2354. var DATA_API_KEY$1 = '.data-api';
  2355. var JQUERY_NO_CONFLICT$1 = $.fn[NAME$1];
  2356. var ClassName$1 = {
  2357. ACTIVE: 'active',
  2358. BUTTON: 'btn',
  2359. FOCUS: 'focus'
  2360. };
  2361. var Selector$1 = {
  2362. DATA_TOGGLE_CARROT: '[data-toggle^="button"]',
  2363. DATA_TOGGLES: '[data-toggle="buttons"]',
  2364. DATA_TOGGLE: '[data-toggle="button"]',
  2365. DATA_TOGGLES_BUTTONS: '[data-toggle="buttons"] .btn',
  2366. INPUT: 'input:not([type="hidden"])',
  2367. ACTIVE: '.active',
  2368. BUTTON: '.btn'
  2369. };
  2370. var Event$1 = {
  2371. CLICK_DATA_API: "click" + EVENT_KEY$1 + DATA_API_KEY$1,
  2372. FOCUS_BLUR_DATA_API: "focus" + EVENT_KEY$1 + DATA_API_KEY$1 + " " + ("blur" + EVENT_KEY$1 + DATA_API_KEY$1),
  2373. LOAD_DATA_API: "load" + EVENT_KEY$1 + DATA_API_KEY$1
  2374. };
  2375. /**
  2376. * ------------------------------------------------------------------------
  2377. * Class Definition
  2378. * ------------------------------------------------------------------------
  2379. */
  2380. var Button =
  2381. /*#__PURE__*/
  2382. function () {
  2383. function Button(element) {
  2384. this._element = element;
  2385. } // Getters
  2386. var _proto = Button.prototype;
  2387. // Public
  2388. _proto.toggle = function toggle() {
  2389. var triggerChangeEvent = true;
  2390. var addAriaPressed = true;
  2391. var rootElement = $(this._element).closest(Selector$1.DATA_TOGGLES)[0];
  2392. if (rootElement) {
  2393. var input = this._element.querySelector(Selector$1.INPUT);
  2394. if (input) {
  2395. if (input.type === 'radio') {
  2396. if (input.checked && this._element.classList.contains(ClassName$1.ACTIVE)) {
  2397. triggerChangeEvent = false;
  2398. } else {
  2399. var activeElement = rootElement.querySelector(Selector$1.ACTIVE);
  2400. if (activeElement) {
  2401. $(activeElement).removeClass(ClassName$1.ACTIVE);
  2402. }
  2403. }
  2404. } else if (input.type === 'checkbox') {
  2405. if (this._element.tagName === 'LABEL' && input.checked === this._element.classList.contains(ClassName$1.ACTIVE)) {
  2406. triggerChangeEvent = false;
  2407. }
  2408. } else {
  2409. // if it's not a radio button or checkbox don't add a pointless/invalid checked property to the input
  2410. triggerChangeEvent = false;
  2411. }
  2412. if (triggerChangeEvent) {
  2413. input.checked = !this._element.classList.contains(ClassName$1.ACTIVE);
  2414. $(input).trigger('change');
  2415. }
  2416. input.focus();
  2417. addAriaPressed = false;
  2418. }
  2419. }
  2420. if (!(this._element.hasAttribute('disabled') || this._element.classList.contains('disabled'))) {
  2421. if (addAriaPressed) {
  2422. this._element.setAttribute('aria-pressed', !this._element.classList.contains(ClassName$1.ACTIVE));
  2423. }
  2424. if (triggerChangeEvent) {
  2425. $(this._element).toggleClass(ClassName$1.ACTIVE);
  2426. }
  2427. }
  2428. };
  2429. _proto.dispose = function dispose() {
  2430. $.removeData(this._element, DATA_KEY$1);
  2431. this._element = null;
  2432. } // Static
  2433. ;
  2434. Button._jQueryInterface = function _jQueryInterface(config) {
  2435. return this.each(function () {
  2436. var data = $(this).data(DATA_KEY$1);
  2437. if (!data) {
  2438. data = new Button(this);
  2439. $(this).data(DATA_KEY$1, data);
  2440. }
  2441. if (config === 'toggle') {
  2442. data[config]();
  2443. }
  2444. });
  2445. };
  2446. _createClass(Button, null, [{
  2447. key: "VERSION",
  2448. get: function get() {
  2449. return VERSION$1;
  2450. }
  2451. }]);
  2452. return Button;
  2453. }();
  2454. /**
  2455. * ------------------------------------------------------------------------
  2456. * Data Api implementation
  2457. * ------------------------------------------------------------------------
  2458. */
  2459. $(document).on(Event$1.CLICK_DATA_API, Selector$1.DATA_TOGGLE_CARROT, function (event) {
  2460. var button = event.target;
  2461. if (!$(button).hasClass(ClassName$1.BUTTON)) {
  2462. button = $(button).closest(Selector$1.BUTTON)[0];
  2463. }
  2464. if (!button || button.hasAttribute('disabled') || button.classList.contains('disabled')) {
  2465. event.preventDefault(); // work around Firefox bug #1540995
  2466. } else {
  2467. var inputBtn = button.querySelector(Selector$1.INPUT);
  2468. if (inputBtn && (inputBtn.hasAttribute('disabled') || inputBtn.classList.contains('disabled'))) {
  2469. event.preventDefault(); // work around Firefox bug #1540995
  2470. return;
  2471. }
  2472. Button._jQueryInterface.call($(button), 'toggle');
  2473. }
  2474. }).on(Event$1.FOCUS_BLUR_DATA_API, Selector$1.DATA_TOGGLE_CARROT, function (event) {
  2475. var button = $(event.target).closest(Selector$1.BUTTON)[0];
  2476. $(button).toggleClass(ClassName$1.FOCUS, /^focus(in)?$/.test(event.type));
  2477. });
  2478. $(window).on(Event$1.LOAD_DATA_API, function () {
  2479. // ensure correct active class is set to match the controls' actual values/states
  2480. // find all checkboxes/readio buttons inside data-toggle groups
  2481. var buttons = [].slice.call(document.querySelectorAll(Selector$1.DATA_TOGGLES_BUTTONS));
  2482. for (var i = 0, len = buttons.length; i < len; i++) {
  2483. var button = buttons[i];
  2484. var input = button.querySelector(Selector$1.INPUT);
  2485. if (input.checked || input.hasAttribute('checked')) {
  2486. button.classList.add(ClassName$1.ACTIVE);
  2487. } else {
  2488. button.classList.remove(ClassName$1.ACTIVE);
  2489. }
  2490. } // find all button toggles
  2491. buttons = [].slice.call(document.querySelectorAll(Selector$1.DATA_TOGGLE));
  2492. for (var _i = 0, _len = buttons.length; _i < _len; _i++) {
  2493. var _button = buttons[_i];
  2494. if (_button.getAttribute('aria-pressed') === 'true') {
  2495. _button.classList.add(ClassName$1.ACTIVE);
  2496. } else {
  2497. _button.classList.remove(ClassName$1.ACTIVE);
  2498. }
  2499. }
  2500. });
  2501. /**
  2502. * ------------------------------------------------------------------------
  2503. * jQuery
  2504. * ------------------------------------------------------------------------
  2505. */
  2506. $.fn[NAME$1] = Button._jQueryInterface;
  2507. $.fn[NAME$1].Constructor = Button;
  2508. $.fn[NAME$1].noConflict = function () {
  2509. $.fn[NAME$1] = JQUERY_NO_CONFLICT$1;
  2510. return Button._jQueryInterface;
  2511. };
  2512. /**
  2513. * ------------------------------------------------------------------------
  2514. * Constants
  2515. * ------------------------------------------------------------------------
  2516. */
  2517. var NAME$2 = 'carousel';
  2518. var VERSION$2 = '4.4.1';
  2519. var DATA_KEY$2 = 'bs.carousel';
  2520. var EVENT_KEY$2 = "." + DATA_KEY$2;
  2521. var DATA_API_KEY$2 = '.data-api';
  2522. var JQUERY_NO_CONFLICT$2 = $.fn[NAME$2];
  2523. var ARROW_LEFT_KEYCODE = 37; // KeyboardEvent.which value for left arrow key
  2524. var ARROW_RIGHT_KEYCODE = 39; // KeyboardEvent.which value for right arrow key
  2525. var TOUCHEVENT_COMPAT_WAIT = 500; // Time for mouse compat events to fire after touch
  2526. var SWIPE_THRESHOLD = 40;
  2527. var Default = {
  2528. interval: 5000,
  2529. keyboard: true,
  2530. slide: false,
  2531. pause: 'hover',
  2532. wrap: true,
  2533. touch: true
  2534. };
  2535. var DefaultType = {
  2536. interval: '(number|boolean)',
  2537. keyboard: 'boolean',
  2538. slide: '(boolean|string)',
  2539. pause: '(string|boolean)',
  2540. wrap: 'boolean',
  2541. touch: 'boolean'
  2542. };
  2543. var Direction = {
  2544. NEXT: 'next',
  2545. PREV: 'prev',
  2546. LEFT: 'left',
  2547. RIGHT: 'right'
  2548. };
  2549. var Event$2 = {
  2550. SLIDE: "slide" + EVENT_KEY$2,
  2551. SLID: "slid" + EVENT_KEY$2,
  2552. KEYDOWN: "keydown" + EVENT_KEY$2,
  2553. MOUSEENTER: "mouseenter" + EVENT_KEY$2,
  2554. MOUSELEAVE: "mouseleave" + EVENT_KEY$2,
  2555. TOUCHSTART: "touchstart" + EVENT_KEY$2,
  2556. TOUCHMOVE: "touchmove" + EVENT_KEY$2,
  2557. TOUCHEND: "touchend" + EVENT_KEY$2,
  2558. POINTERDOWN: "pointerdown" + EVENT_KEY$2,
  2559. POINTERUP: "pointerup" + EVENT_KEY$2,
  2560. DRAG_START: "dragstart" + EVENT_KEY$2,
  2561. LOAD_DATA_API: "load" + EVENT_KEY$2 + DATA_API_KEY$2,
  2562. CLICK_DATA_API: "click" + EVENT_KEY$2 + DATA_API_KEY$2
  2563. };
  2564. var ClassName$2 = {
  2565. CAROUSEL: 'carousel',
  2566. ACTIVE: 'active',
  2567. SLIDE: 'slide',
  2568. RIGHT: 'carousel-item-right',
  2569. LEFT: 'carousel-item-left',
  2570. NEXT: 'carousel-item-next',
  2571. PREV: 'carousel-item-prev',
  2572. ITEM: 'carousel-item',
  2573. POINTER_EVENT: 'pointer-event'
  2574. };
  2575. var Selector$2 = {
  2576. ACTIVE: '.active',
  2577. ACTIVE_ITEM: '.active.carousel-item',
  2578. ITEM: '.carousel-item',
  2579. ITEM_IMG: '.carousel-item img',
  2580. NEXT_PREV: '.carousel-item-next, .carousel-item-prev',
  2581. INDICATORS: '.carousel-indicators',
  2582. DATA_SLIDE: '[data-slide], [data-slide-to]',
  2583. DATA_RIDE: '[data-ride="carousel"]'
  2584. };
  2585. var PointerType = {
  2586. TOUCH: 'touch',
  2587. PEN: 'pen'
  2588. };
  2589. /**
  2590. * ------------------------------------------------------------------------
  2591. * Class Definition
  2592. * ------------------------------------------------------------------------
  2593. */
  2594. var Carousel =
  2595. /*#__PURE__*/
  2596. function () {
  2597. function Carousel(element, config) {
  2598. this._items = null;
  2599. this._interval = null;
  2600. this._activeElement = null;
  2601. this._isPaused = false;
  2602. this._isSliding = false;
  2603. this.touchTimeout = null;
  2604. this.touchStartX = 0;
  2605. this.touchDeltaX = 0;
  2606. this._config = this._getConfig(config);
  2607. this._element = element;
  2608. this._indicatorsElement = this._element.querySelector(Selector$2.INDICATORS);
  2609. this._touchSupported = 'ontouchstart' in document.documentElement || navigator.maxTouchPoints > 0;
  2610. this._pointerEvent = Boolean(window.PointerEvent || window.MSPointerEvent);
  2611. this._addEventListeners();
  2612. } // Getters
  2613. var _proto = Carousel.prototype;
  2614. // Public
  2615. _proto.next = function next() {
  2616. if (!this._isSliding) {
  2617. this._slide(Direction.NEXT);
  2618. }
  2619. };
  2620. _proto.nextWhenVisible = function nextWhenVisible() {
  2621. // Don't call next when the page isn't visible
  2622. // or the carousel or its parent isn't visible
  2623. if (!document.hidden && $(this._element).is(':visible') && $(this._element).css('visibility') !== 'hidden') {
  2624. this.next();
  2625. }
  2626. };
  2627. _proto.prev = function prev() {
  2628. if (!this._isSliding) {
  2629. this._slide(Direction.PREV);
  2630. }
  2631. };
  2632. _proto.pause = function pause(event) {
  2633. if (!event) {
  2634. this._isPaused = true;
  2635. }
  2636. if (this._element.querySelector(Selector$2.NEXT_PREV)) {
  2637. Util.triggerTransitionEnd(this._element);
  2638. this.cycle(true);
  2639. }
  2640. clearInterval(this._interval);
  2641. this._interval = null;
  2642. };
  2643. _proto.cycle = function cycle(event) {
  2644. if (!event) {
  2645. this._isPaused = false;
  2646. }
  2647. if (this._interval) {
  2648. clearInterval(this._interval);
  2649. this._interval = null;
  2650. }
  2651. if (this._config.interval && !this._isPaused) {
  2652. this._interval = setInterval((document.visibilityState ? this.nextWhenVisible : this.next).bind(this), this._config.interval);
  2653. }
  2654. };
  2655. _proto.to = function to(index) {
  2656. var _this = this;
  2657. this._activeElement = this._element.querySelector(Selector$2.ACTIVE_ITEM);
  2658. var activeIndex = this._getItemIndex(this._activeElement);
  2659. if (index > this._items.length - 1 || index < 0) {
  2660. return;
  2661. }
  2662. if (this._isSliding) {
  2663. $(this._element).one(Event$2.SLID, function () {
  2664. return _this.to(index);
  2665. });
  2666. return;
  2667. }
  2668. if (activeIndex === index) {
  2669. this.pause();
  2670. this.cycle();
  2671. return;
  2672. }
  2673. var direction = index > activeIndex ? Direction.NEXT : Direction.PREV;
  2674. this._slide(direction, this._items[index]);
  2675. };
  2676. _proto.dispose = function dispose() {
  2677. $(this._element).off(EVENT_KEY$2);
  2678. $.removeData(this._element, DATA_KEY$2);
  2679. this._items = null;
  2680. this._config = null;
  2681. this._element = null;
  2682. this._interval = null;
  2683. this._isPaused = null;
  2684. this._isSliding = null;
  2685. this._activeElement = null;
  2686. this._indicatorsElement = null;
  2687. } // Private
  2688. ;
  2689. _proto._getConfig = function _getConfig(config) {
  2690. config = _objectSpread2({}, Default, {}, config);
  2691. Util.typeCheckConfig(NAME$2, config, DefaultType);
  2692. return config;
  2693. };
  2694. _proto._handleSwipe = function _handleSwipe() {
  2695. var absDeltax = Math.abs(this.touchDeltaX);
  2696. if (absDeltax <= SWIPE_THRESHOLD) {
  2697. return;
  2698. }
  2699. var direction = absDeltax / this.touchDeltaX;
  2700. this.touchDeltaX = 0; // swipe left
  2701. if (direction > 0) {
  2702. this.prev();
  2703. } // swipe right
  2704. if (direction < 0) {
  2705. this.next();
  2706. }
  2707. };
  2708. _proto._addEventListeners = function _addEventListeners() {
  2709. var _this2 = this;
  2710. if (this._config.keyboard) {
  2711. $(this._element).on(Event$2.KEYDOWN, function (event) {
  2712. return _this2._keydown(event);
  2713. });
  2714. }
  2715. if (this._config.pause === 'hover') {
  2716. $(this._element).on(Event$2.MOUSEENTER, function (event) {
  2717. return _this2.pause(event);
  2718. }).on(Event$2.MOUSELEAVE, function (event) {
  2719. return _this2.cycle(event);
  2720. });
  2721. }
  2722. if (this._config.touch) {
  2723. this._addTouchEventListeners();
  2724. }
  2725. };
  2726. _proto._addTouchEventListeners = function _addTouchEventListeners() {
  2727. var _this3 = this;
  2728. if (!this._touchSupported) {
  2729. return;
  2730. }
  2731. var start = function start(event) {
  2732. if (_this3._pointerEvent && PointerType[event.originalEvent.pointerType.toUpperCase()]) {
  2733. _this3.touchStartX = event.originalEvent.clientX;
  2734. } else if (!_this3._pointerEvent) {
  2735. _this3.touchStartX = event.originalEvent.touches[0].clientX;
  2736. }
  2737. };
  2738. var move = function move(event) {
  2739. // ensure swiping with one touch and not pinching
  2740. if (event.originalEvent.touches && event.originalEvent.touches.length > 1) {
  2741. _this3.touchDeltaX = 0;
  2742. } else {
  2743. _this3.touchDeltaX = event.originalEvent.touches[0].clientX - _this3.touchStartX;
  2744. }
  2745. };
  2746. var end = function end(event) {
  2747. if (_this3._pointerEvent && PointerType[event.originalEvent.pointerType.toUpperCase()]) {
  2748. _this3.touchDeltaX = event.originalEvent.clientX - _this3.touchStartX;
  2749. }
  2750. _this3._handleSwipe();
  2751. if (_this3._config.pause === 'hover') {
  2752. // If it's a touch-enabled device, mouseenter/leave are fired as
  2753. // part of the mouse compatibility events on first tap - the carousel
  2754. // would stop cycling until user tapped out of it;
  2755. // here, we listen for touchend, explicitly pause the carousel
  2756. // (as if it's the second time we tap on it, mouseenter compat event
  2757. // is NOT fired) and after a timeout (to allow for mouse compatibility
  2758. // events to fire) we explicitly restart cycling
  2759. _this3.pause();
  2760. if (_this3.touchTimeout) {
  2761. clearTimeout(_this3.touchTimeout);
  2762. }
  2763. _this3.touchTimeout = setTimeout(function (event) {
  2764. return _this3.cycle(event);
  2765. }, TOUCHEVENT_COMPAT_WAIT + _this3._config.interval);
  2766. }
  2767. };
  2768. $(this._element.querySelectorAll(Selector$2.ITEM_IMG)).on(Event$2.DRAG_START, function (e) {
  2769. return e.preventDefault();
  2770. });
  2771. if (this._pointerEvent) {
  2772. $(this._element).on(Event$2.POINTERDOWN, function (event) {
  2773. return start(event);
  2774. });
  2775. $(this._element).on(Event$2.POINTERUP, function (event) {
  2776. return end(event);
  2777. });
  2778. this._element.classList.add(ClassName$2.POINTER_EVENT);
  2779. } else {
  2780. $(this._element).on(Event$2.TOUCHSTART, function (event) {
  2781. return start(event);
  2782. });
  2783. $(this._element).on(Event$2.TOUCHMOVE, function (event) {
  2784. return move(event);
  2785. });
  2786. $(this._element).on(Event$2.TOUCHEND, function (event) {
  2787. return end(event);
  2788. });
  2789. }
  2790. };
  2791. _proto._keydown = function _keydown(event) {
  2792. if (/input|textarea/i.test(event.target.tagName)) {
  2793. return;
  2794. }
  2795. switch (event.which) {
  2796. case ARROW_LEFT_KEYCODE:
  2797. event.preventDefault();
  2798. this.prev();
  2799. break;
  2800. case ARROW_RIGHT_KEYCODE:
  2801. event.preventDefault();
  2802. this.next();
  2803. break;
  2804. }
  2805. };
  2806. _proto._getItemIndex = function _getItemIndex(element) {
  2807. this._items = element && element.parentNode ? [].slice.call(element.parentNode.querySelectorAll(Selector$2.ITEM)) : [];
  2808. return this._items.indexOf(element);
  2809. };
  2810. _proto._getItemByDirection = function _getItemByDirection(direction, activeElement) {
  2811. var isNextDirection = direction === Direction.NEXT;
  2812. var isPrevDirection = direction === Direction.PREV;
  2813. var activeIndex = this._getItemIndex(activeElement);
  2814. var lastItemIndex = this._items.length - 1;
  2815. var isGoingToWrap = isPrevDirection && activeIndex === 0 || isNextDirection && activeIndex === lastItemIndex;
  2816. if (isGoingToWrap && !this._config.wrap) {
  2817. return activeElement;
  2818. }
  2819. var delta = direction === Direction.PREV ? -1 : 1;
  2820. var itemIndex = (activeIndex + delta) % this._items.length;
  2821. return itemIndex === -1 ? this._items[this._items.length - 1] : this._items[itemIndex];
  2822. };
  2823. _proto._triggerSlideEvent = function _triggerSlideEvent(relatedTarget, eventDirectionName) {
  2824. var targetIndex = this._getItemIndex(relatedTarget);
  2825. var fromIndex = this._getItemIndex(this._element.querySelector(Selector$2.ACTIVE_ITEM));
  2826. var slideEvent = $.Event(Event$2.SLIDE, {
  2827. relatedTarget: relatedTarget,
  2828. direction: eventDirectionName,
  2829. from: fromIndex,
  2830. to: targetIndex
  2831. });
  2832. $(this._element).trigger(slideEvent);
  2833. return slideEvent;
  2834. };
  2835. _proto._setActiveIndicatorElement = function _setActiveIndicatorElement(element) {
  2836. if (this._indicatorsElement) {
  2837. var indicators = [].slice.call(this._indicatorsElement.querySelectorAll(Selector$2.ACTIVE));
  2838. $(indicators).removeClass(ClassName$2.ACTIVE);
  2839. var nextIndicator = this._indicatorsElement.children[this._getItemIndex(element)];
  2840. if (nextIndicator) {
  2841. $(nextIndicator).addClass(ClassName$2.ACTIVE);
  2842. }
  2843. }
  2844. };
  2845. _proto._slide = function _slide(direction, element) {
  2846. var _this4 = this;
  2847. var activeElement = this._element.querySelector(Selector$2.ACTIVE_ITEM);
  2848. var activeElementIndex = this._getItemIndex(activeElement);
  2849. var nextElement = element || activeElement && this._getItemByDirection(direction, activeElement);
  2850. var nextElementIndex = this._getItemIndex(nextElement);
  2851. var isCycling = Boolean(this._interval);
  2852. var directionalClassName;
  2853. var orderClassName;
  2854. var eventDirectionName;
  2855. if (direction === Direction.NEXT) {
  2856. directionalClassName = ClassName$2.LEFT;
  2857. orderClassName = ClassName$2.NEXT;
  2858. eventDirectionName = Direction.LEFT;
  2859. } else {
  2860. directionalClassName = ClassName$2.RIGHT;
  2861. orderClassName = ClassName$2.PREV;
  2862. eventDirectionName = Direction.RIGHT;
  2863. }
  2864. if (nextElement && $(nextElement).hasClass(ClassName$2.ACTIVE)) {
  2865. this._isSliding = false;
  2866. return;
  2867. }
  2868. var slideEvent = this._triggerSlideEvent(nextElement, eventDirectionName);
  2869. if (slideEvent.isDefaultPrevented()) {
  2870. return;
  2871. }
  2872. if (!activeElement || !nextElement) {
  2873. // Some weirdness is happening, so we bail
  2874. return;
  2875. }
  2876. this._isSliding = true;
  2877. if (isCycling) {
  2878. this.pause();
  2879. }
  2880. this._setActiveIndicatorElement(nextElement);
  2881. var slidEvent = $.Event(Event$2.SLID, {
  2882. relatedTarget: nextElement,
  2883. direction: eventDirectionName,
  2884. from: activeElementIndex,
  2885. to: nextElementIndex
  2886. });
  2887. if ($(this._element).hasClass(ClassName$2.SLIDE)) {
  2888. $(nextElement).addClass(orderClassName);
  2889. Util.reflow(nextElement);
  2890. $(activeElement).addClass(directionalClassName);
  2891. $(nextElement).addClass(directionalClassName);
  2892. var nextElementInterval = parseInt(nextElement.getAttribute('data-interval'), 10);
  2893. if (nextElementInterval) {
  2894. this._config.defaultInterval = this._config.defaultInterval || this._config.interval;
  2895. this._config.interval = nextElementInterval;
  2896. } else {
  2897. this._config.interval = this._config.defaultInterval || this._config.interval;
  2898. }
  2899. var transitionDuration = Util.getTransitionDurationFromElement(activeElement);
  2900. $(activeElement).one(Util.TRANSITION_END, function () {
  2901. $(nextElement).removeClass(directionalClassName + " " + orderClassName).addClass(ClassName$2.ACTIVE);
  2902. $(activeElement).removeClass(ClassName$2.ACTIVE + " " + orderClassName + " " + directionalClassName);
  2903. _this4._isSliding = false;
  2904. setTimeout(function () {
  2905. return $(_this4._element).trigger(slidEvent);
  2906. }, 0);
  2907. }).emulateTransitionEnd(transitionDuration);
  2908. } else {
  2909. $(activeElement).removeClass(ClassName$2.ACTIVE);
  2910. $(nextElement).addClass(ClassName$2.ACTIVE);
  2911. this._isSliding = false;
  2912. $(this._element).trigger(slidEvent);
  2913. }
  2914. if (isCycling) {
  2915. this.cycle();
  2916. }
  2917. } // Static
  2918. ;
  2919. Carousel._jQueryInterface = function _jQueryInterface(config) {
  2920. return this.each(function () {
  2921. var data = $(this).data(DATA_KEY$2);
  2922. var _config = _objectSpread2({}, Default, {}, $(this).data());
  2923. if (typeof config === 'object') {
  2924. _config = _objectSpread2({}, _config, {}, config);
  2925. }
  2926. var action = typeof config === 'string' ? config : _config.slide;
  2927. if (!data) {
  2928. data = new Carousel(this, _config);
  2929. $(this).data(DATA_KEY$2, data);
  2930. }
  2931. if (typeof config === 'number') {
  2932. data.to(config);
  2933. } else if (typeof action === 'string') {
  2934. if (typeof data[action] === 'undefined') {
  2935. throw new TypeError("No method named \"" + action + "\"");
  2936. }
  2937. data[action]();
  2938. } else if (_config.interval && _config.ride) {
  2939. data.pause();
  2940. data.cycle();
  2941. }
  2942. });
  2943. };
  2944. Carousel._dataApiClickHandler = function _dataApiClickHandler(event) {
  2945. var selector = Util.getSelectorFromElement(this);
  2946. if (!selector) {
  2947. return;
  2948. }
  2949. var target = $(selector)[0];
  2950. if (!target || !$(target).hasClass(ClassName$2.CAROUSEL)) {
  2951. return;
  2952. }
  2953. var config = _objectSpread2({}, $(target).data(), {}, $(this).data());
  2954. var slideIndex = this.getAttribute('data-slide-to');
  2955. if (slideIndex) {
  2956. config.interval = false;
  2957. }
  2958. Carousel._jQueryInterface.call($(target), config);
  2959. if (slideIndex) {
  2960. $(target).data(DATA_KEY$2).to(slideIndex);
  2961. }
  2962. event.preventDefault();
  2963. };
  2964. _createClass(Carousel, null, [{
  2965. key: "VERSION",
  2966. get: function get() {
  2967. return VERSION$2;
  2968. }
  2969. }, {
  2970. key: "Default",
  2971. get: function get() {
  2972. return Default;
  2973. }
  2974. }]);
  2975. return Carousel;
  2976. }();
  2977. /**
  2978. * ------------------------------------------------------------------------
  2979. * Data Api implementation
  2980. * ------------------------------------------------------------------------
  2981. */
  2982. $(document).on(Event$2.CLICK_DATA_API, Selector$2.DATA_SLIDE, Carousel._dataApiClickHandler);
  2983. $(window).on(Event$2.LOAD_DATA_API, function () {
  2984. var carousels = [].slice.call(document.querySelectorAll(Selector$2.DATA_RIDE));
  2985. for (var i = 0, len = carousels.length; i < len; i++) {
  2986. var $carousel = $(carousels[i]);
  2987. Carousel._jQueryInterface.call($carousel, $carousel.data());
  2988. }
  2989. });
  2990. /**
  2991. * ------------------------------------------------------------------------
  2992. * jQuery
  2993. * ------------------------------------------------------------------------
  2994. */
  2995. $.fn[NAME$2] = Carousel._jQueryInterface;
  2996. $.fn[NAME$2].Constructor = Carousel;
  2997. $.fn[NAME$2].noConflict = function () {
  2998. $.fn[NAME$2] = JQUERY_NO_CONFLICT$2;
  2999. return Carousel._jQueryInterface;
  3000. };
  3001. /**
  3002. * ------------------------------------------------------------------------
  3003. * Constants
  3004. * ------------------------------------------------------------------------
  3005. */
  3006. var NAME$3 = 'collapse';
  3007. var VERSION$3 = '4.4.1';
  3008. var DATA_KEY$3 = 'bs.collapse';
  3009. var EVENT_KEY$3 = "." + DATA_KEY$3;
  3010. var DATA_API_KEY$3 = '.data-api';
  3011. var JQUERY_NO_CONFLICT$3 = $.fn[NAME$3];
  3012. var Default$1 = {
  3013. toggle: true,
  3014. parent: ''
  3015. };
  3016. var DefaultType$1 = {
  3017. toggle: 'boolean',
  3018. parent: '(string|element)'
  3019. };
  3020. var Event$3 = {
  3021. SHOW: "show" + EVENT_KEY$3,
  3022. SHOWN: "shown" + EVENT_KEY$3,
  3023. HIDE: "hide" + EVENT_KEY$3,
  3024. HIDDEN: "hidden" + EVENT_KEY$3,
  3025. CLICK_DATA_API: "click" + EVENT_KEY$3 + DATA_API_KEY$3
  3026. };
  3027. var ClassName$3 = {
  3028. SHOW: 'show',
  3029. COLLAPSE: 'collapse',
  3030. COLLAPSING: 'collapsing',
  3031. COLLAPSED: 'collapsed'
  3032. };
  3033. var Dimension = {
  3034. WIDTH: 'width',
  3035. HEIGHT: 'height'
  3036. };
  3037. var Selector$3 = {
  3038. ACTIVES: '.show, .collapsing',
  3039. DATA_TOGGLE: '[data-toggle="collapse"]'
  3040. };
  3041. /**
  3042. * ------------------------------------------------------------------------
  3043. * Class Definition
  3044. * ------------------------------------------------------------------------
  3045. */
  3046. var Collapse =
  3047. /*#__PURE__*/
  3048. function () {
  3049. function Collapse(element, config) {
  3050. this._isTransitioning = false;
  3051. this._element = element;
  3052. this._config = this._getConfig(config);
  3053. this._triggerArray = [].slice.call(document.querySelectorAll("[data-toggle=\"collapse\"][href=\"#" + element.id + "\"]," + ("[data-toggle=\"collapse\"][data-target=\"#" + element.id + "\"]")));
  3054. var toggleList = [].slice.call(document.querySelectorAll(Selector$3.DATA_TOGGLE));
  3055. for (var i = 0, len = toggleList.length; i < len; i++) {
  3056. var elem = toggleList[i];
  3057. var selector = Util.getSelectorFromElement(elem);
  3058. var filterElement = [].slice.call(document.querySelectorAll(selector)).filter(function (foundElem) {
  3059. return foundElem === element;
  3060. });
  3061. if (selector !== null && filterElement.length > 0) {
  3062. this._selector = selector;
  3063. this._triggerArray.push(elem);
  3064. }
  3065. }
  3066. this._parent = this._config.parent ? this._getParent() : null;
  3067. if (!this._config.parent) {
  3068. this._addAriaAndCollapsedClass(this._element, this._triggerArray);
  3069. }
  3070. if (this._config.toggle) {
  3071. this.toggle();
  3072. }
  3073. } // Getters
  3074. var _proto = Collapse.prototype;
  3075. // Public
  3076. _proto.toggle = function toggle() {
  3077. if ($(this._element).hasClass(ClassName$3.SHOW)) {
  3078. this.hide();
  3079. } else {
  3080. this.show();
  3081. }
  3082. };
  3083. _proto.show = function show() {
  3084. var _this = this;
  3085. if (this._isTransitioning || $(this._element).hasClass(ClassName$3.SHOW)) {
  3086. return;
  3087. }
  3088. var actives;
  3089. var activesData;
  3090. if (this._parent) {
  3091. actives = [].slice.call(this._parent.querySelectorAll(Selector$3.ACTIVES)).filter(function (elem) {
  3092. if (typeof _this._config.parent === 'string') {
  3093. return elem.getAttribute('data-parent') === _this._config.parent;
  3094. }
  3095. return elem.classList.contains(ClassName$3.COLLAPSE);
  3096. });
  3097. if (actives.length === 0) {
  3098. actives = null;
  3099. }
  3100. }
  3101. if (actives) {
  3102. activesData = $(actives).not(this._selector).data(DATA_KEY$3);
  3103. if (activesData && activesData._isTransitioning) {
  3104. return;
  3105. }
  3106. }
  3107. var startEvent = $.Event(Event$3.SHOW);
  3108. $(this._element).trigger(startEvent);
  3109. if (startEvent.isDefaultPrevented()) {
  3110. return;
  3111. }
  3112. if (actives) {
  3113. Collapse._jQueryInterface.call($(actives).not(this._selector), 'hide');
  3114. if (!activesData) {
  3115. $(actives).data(DATA_KEY$3, null);
  3116. }
  3117. }
  3118. var dimension = this._getDimension();
  3119. $(this._element).removeClass(ClassName$3.COLLAPSE).addClass(ClassName$3.COLLAPSING);
  3120. this._element.style[dimension] = 0;
  3121. if (this._triggerArray.length) {
  3122. $(this._triggerArray).removeClass(ClassName$3.COLLAPSED).attr('aria-expanded', true);
  3123. }
  3124. this.setTransitioning(true);
  3125. var complete = function complete() {
  3126. $(_this._element).removeClass(ClassName$3.COLLAPSING).addClass(ClassName$3.COLLAPSE).addClass(ClassName$3.SHOW);
  3127. _this._element.style[dimension] = '';
  3128. _this.setTransitioning(false);
  3129. $(_this._element).trigger(Event$3.SHOWN);
  3130. };
  3131. var capitalizedDimension = dimension[0].toUpperCase() + dimension.slice(1);
  3132. var scrollSize = "scroll" + capitalizedDimension;
  3133. var transitionDuration = Util.getTransitionDurationFromElement(this._element);
  3134. $(this._element).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration);
  3135. this._element.style[dimension] = this._element[scrollSize] + "px";
  3136. };
  3137. _proto.hide = function hide() {
  3138. var _this2 = this;
  3139. if (this._isTransitioning || !$(this._element).hasClass(ClassName$3.SHOW)) {
  3140. return;
  3141. }
  3142. var startEvent = $.Event(Event$3.HIDE);
  3143. $(this._element).trigger(startEvent);
  3144. if (startEvent.isDefaultPrevented()) {
  3145. return;
  3146. }
  3147. var dimension = this._getDimension();
  3148. this._element.style[dimension] = this._element.getBoundingClientRect()[dimension] + "px";
  3149. Util.reflow(this._element);
  3150. $(this._element).addClass(ClassName$3.COLLAPSING).removeClass(ClassName$3.COLLAPSE).removeClass(ClassName$3.SHOW);
  3151. var triggerArrayLength = this._triggerArray.length;
  3152. if (triggerArrayLength > 0) {
  3153. for (var i = 0; i < triggerArrayLength; i++) {
  3154. var trigger = this._triggerArray[i];
  3155. var selector = Util.getSelectorFromElement(trigger);
  3156. if (selector !== null) {
  3157. var $elem = $([].slice.call(document.querySelectorAll(selector)));
  3158. if (!$elem.hasClass(ClassName$3.SHOW)) {
  3159. $(trigger).addClass(ClassName$3.COLLAPSED).attr('aria-expanded', false);
  3160. }
  3161. }
  3162. }
  3163. }
  3164. this.setTransitioning(true);
  3165. var complete = function complete() {
  3166. _this2.setTransitioning(false);
  3167. $(_this2._element).removeClass(ClassName$3.COLLAPSING).addClass(ClassName$3.COLLAPSE).trigger(Event$3.HIDDEN);
  3168. };
  3169. this._element.style[dimension] = '';
  3170. var transitionDuration = Util.getTransitionDurationFromElement(this._element);
  3171. $(this._element).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration);
  3172. };
  3173. _proto.setTransitioning = function setTransitioning(isTransitioning) {
  3174. this._isTransitioning = isTransitioning;
  3175. };
  3176. _proto.dispose = function dispose() {
  3177. $.removeData(this._element, DATA_KEY$3);
  3178. this._config = null;
  3179. this._parent = null;
  3180. this._element = null;
  3181. this._triggerArray = null;
  3182. this._isTransitioning = null;
  3183. } // Private
  3184. ;
  3185. _proto._getConfig = function _getConfig(config) {
  3186. config = _objectSpread2({}, Default$1, {}, config);
  3187. config.toggle = Boolean(config.toggle); // Coerce string values
  3188. Util.typeCheckConfig(NAME$3, config, DefaultType$1);
  3189. return config;
  3190. };
  3191. _proto._getDimension = function _getDimension() {
  3192. var hasWidth = $(this._element).hasClass(Dimension.WIDTH);
  3193. return hasWidth ? Dimension.WIDTH : Dimension.HEIGHT;
  3194. };
  3195. _proto._getParent = function _getParent() {
  3196. var _this3 = this;
  3197. var parent;
  3198. if (Util.isElement(this._config.parent)) {
  3199. parent = this._config.parent; // It's a jQuery object
  3200. if (typeof this._config.parent.jquery !== 'undefined') {
  3201. parent = this._config.parent[0];
  3202. }
  3203. } else {
  3204. parent = document.querySelector(this._config.parent);
  3205. }
  3206. var selector = "[data-toggle=\"collapse\"][data-parent=\"" + this._config.parent + "\"]";
  3207. var children = [].slice.call(parent.querySelectorAll(selector));
  3208. $(children).each(function (i, element) {
  3209. _this3._addAriaAndCollapsedClass(Collapse._getTargetFromElement(element), [element]);
  3210. });
  3211. return parent;
  3212. };
  3213. _proto._addAriaAndCollapsedClass = function _addAriaAndCollapsedClass(element, triggerArray) {
  3214. var isOpen = $(element).hasClass(ClassName$3.SHOW);
  3215. if (triggerArray.length) {
  3216. $(triggerArray).toggleClass(ClassName$3.COLLAPSED, !isOpen).attr('aria-expanded', isOpen);
  3217. }
  3218. } // Static
  3219. ;
  3220. Collapse._getTargetFromElement = function _getTargetFromElement(element) {
  3221. var selector = Util.getSelectorFromElement(element);
  3222. return selector ? document.querySelector(selector) : null;
  3223. };
  3224. Collapse._jQueryInterface = function _jQueryInterface(config) {
  3225. return this.each(function () {
  3226. var $this = $(this);
  3227. var data = $this.data(DATA_KEY$3);
  3228. var _config = _objectSpread2({}, Default$1, {}, $this.data(), {}, typeof config === 'object' && config ? config : {});
  3229. if (!data && _config.toggle && /show|hide/.test(config)) {
  3230. _config.toggle = false;
  3231. }
  3232. if (!data) {
  3233. data = new Collapse(this, _config);
  3234. $this.data(DATA_KEY$3, data);
  3235. }
  3236. if (typeof config === 'string') {
  3237. if (typeof data[config] === 'undefined') {
  3238. throw new TypeError("No method named \"" + config + "\"");
  3239. }
  3240. data[config]();
  3241. }
  3242. });
  3243. };
  3244. _createClass(Collapse, null, [{
  3245. key: "VERSION",
  3246. get: function get() {
  3247. return VERSION$3;
  3248. }
  3249. }, {
  3250. key: "Default",
  3251. get: function get() {
  3252. return Default$1;
  3253. }
  3254. }]);
  3255. return Collapse;
  3256. }();
  3257. /**
  3258. * ------------------------------------------------------------------------
  3259. * Data Api implementation
  3260. * ------------------------------------------------------------------------
  3261. */
  3262. $(document).on(Event$3.CLICK_DATA_API, Selector$3.DATA_TOGGLE, function (event) {
  3263. // preventDefault only for <a> elements (which change the URL) not inside the collapsible element
  3264. if (event.currentTarget.tagName === 'A') {
  3265. event.preventDefault();
  3266. }
  3267. var $trigger = $(this);
  3268. var selector = Util.getSelectorFromElement(this);
  3269. var selectors = [].slice.call(document.querySelectorAll(selector));
  3270. $(selectors).each(function () {
  3271. var $target = $(this);
  3272. var data = $target.data(DATA_KEY$3);
  3273. var config = data ? 'toggle' : $trigger.data();
  3274. Collapse._jQueryInterface.call($target, config);
  3275. });
  3276. });
  3277. /**
  3278. * ------------------------------------------------------------------------
  3279. * jQuery
  3280. * ------------------------------------------------------------------------
  3281. */
  3282. $.fn[NAME$3] = Collapse._jQueryInterface;
  3283. $.fn[NAME$3].Constructor = Collapse;
  3284. $.fn[NAME$3].noConflict = function () {
  3285. $.fn[NAME$3] = JQUERY_NO_CONFLICT$3;
  3286. return Collapse._jQueryInterface;
  3287. };
  3288. /**
  3289. * ------------------------------------------------------------------------
  3290. * Constants
  3291. * ------------------------------------------------------------------------
  3292. */
  3293. var NAME$4 = 'dropdown';
  3294. var VERSION$4 = '4.4.1';
  3295. var DATA_KEY$4 = 'bs.dropdown';
  3296. var EVENT_KEY$4 = "." + DATA_KEY$4;
  3297. var DATA_API_KEY$4 = '.data-api';
  3298. var JQUERY_NO_CONFLICT$4 = $.fn[NAME$4];
  3299. var ESCAPE_KEYCODE = 27; // KeyboardEvent.which value for Escape (Esc) key
  3300. var SPACE_KEYCODE = 32; // KeyboardEvent.which value for space key
  3301. var TAB_KEYCODE = 9; // KeyboardEvent.which value for tab key
  3302. var ARROW_UP_KEYCODE = 38; // KeyboardEvent.which value for up arrow key
  3303. var ARROW_DOWN_KEYCODE = 40; // KeyboardEvent.which value for down arrow key
  3304. var RIGHT_MOUSE_BUTTON_WHICH = 3; // MouseEvent.which value for the right button (assuming a right-handed mouse)
  3305. var REGEXP_KEYDOWN = new RegExp(ARROW_UP_KEYCODE + "|" + ARROW_DOWN_KEYCODE + "|" + ESCAPE_KEYCODE);
  3306. var Event$4 = {
  3307. HIDE: "hide" + EVENT_KEY$4,
  3308. HIDDEN: "hidden" + EVENT_KEY$4,
  3309. SHOW: "show" + EVENT_KEY$4,
  3310. SHOWN: "shown" + EVENT_KEY$4,
  3311. CLICK: "click" + EVENT_KEY$4,
  3312. CLICK_DATA_API: "click" + EVENT_KEY$4 + DATA_API_KEY$4,
  3313. KEYDOWN_DATA_API: "keydown" + EVENT_KEY$4 + DATA_API_KEY$4,
  3314. KEYUP_DATA_API: "keyup" + EVENT_KEY$4 + DATA_API_KEY$4
  3315. };
  3316. var ClassName$4 = {
  3317. DISABLED: 'disabled',
  3318. SHOW: 'show',
  3319. DROPUP: 'dropup',
  3320. DROPRIGHT: 'dropright',
  3321. DROPLEFT: 'dropleft',
  3322. MENURIGHT: 'dropdown-menu-right',
  3323. MENULEFT: 'dropdown-menu-left',
  3324. POSITION_STATIC: 'position-static'
  3325. };
  3326. var Selector$4 = {
  3327. DATA_TOGGLE: '[data-toggle="dropdown"]',
  3328. FORM_CHILD: '.dropdown form',
  3329. MENU: '.dropdown-menu',
  3330. NAVBAR_NAV: '.navbar-nav',
  3331. VISIBLE_ITEMS: '.dropdown-menu .dropdown-item:not(.disabled):not(:disabled)'
  3332. };
  3333. var AttachmentMap = {
  3334. TOP: 'top-start',
  3335. TOPEND: 'top-end',
  3336. BOTTOM: 'bottom-start',
  3337. BOTTOMEND: 'bottom-end',
  3338. RIGHT: 'right-start',
  3339. RIGHTEND: 'right-end',
  3340. LEFT: 'left-start',
  3341. LEFTEND: 'left-end'
  3342. };
  3343. var Default$2 = {
  3344. offset: 0,
  3345. flip: true,
  3346. boundary: 'scrollParent',
  3347. reference: 'toggle',
  3348. display: 'dynamic',
  3349. popperConfig: null
  3350. };
  3351. var DefaultType$2 = {
  3352. offset: '(number|string|function)',
  3353. flip: 'boolean',
  3354. boundary: '(string|element)',
  3355. reference: '(string|element)',
  3356. display: 'string',
  3357. popperConfig: '(null|object)'
  3358. };
  3359. /**
  3360. * ------------------------------------------------------------------------
  3361. * Class Definition
  3362. * ------------------------------------------------------------------------
  3363. */
  3364. var Dropdown =
  3365. /*#__PURE__*/
  3366. function () {
  3367. function Dropdown(element, config) {
  3368. this._element = element;
  3369. this._popper = null;
  3370. this._config = this._getConfig(config);
  3371. this._menu = this._getMenuElement();
  3372. this._inNavbar = this._detectNavbar();
  3373. this._addEventListeners();
  3374. } // Getters
  3375. var _proto = Dropdown.prototype;
  3376. // Public
  3377. _proto.toggle = function toggle() {
  3378. if (this._element.disabled || $(this._element).hasClass(ClassName$4.DISABLED)) {
  3379. return;
  3380. }
  3381. var isActive = $(this._menu).hasClass(ClassName$4.SHOW);
  3382. Dropdown._clearMenus();
  3383. if (isActive) {
  3384. return;
  3385. }
  3386. this.show(true);
  3387. };
  3388. _proto.show = function show(usePopper) {
  3389. if (usePopper === void 0) {
  3390. usePopper = false;
  3391. }
  3392. if (this._element.disabled || $(this._element).hasClass(ClassName$4.DISABLED) || $(this._menu).hasClass(ClassName$4.SHOW)) {
  3393. return;
  3394. }
  3395. var relatedTarget = {
  3396. relatedTarget: this._element
  3397. };
  3398. var showEvent = $.Event(Event$4.SHOW, relatedTarget);
  3399. var parent = Dropdown._getParentFromElement(this._element);
  3400. $(parent).trigger(showEvent);
  3401. if (showEvent.isDefaultPrevented()) {
  3402. return;
  3403. } // Disable totally Popper.js for Dropdown in Navbar
  3404. if (!this._inNavbar && usePopper) {
  3405. /**
  3406. * Check for Popper dependency
  3407. * Popper - https://popper.js.org
  3408. */
  3409. if (typeof Popper === 'undefined') {
  3410. throw new TypeError('Bootstrap\'s dropdowns require Popper.js (https://popper.js.org/)');
  3411. }
  3412. var referenceElement = this._element;
  3413. if (this._config.reference === 'parent') {
  3414. referenceElement = parent;
  3415. } else if (Util.isElement(this._config.reference)) {
  3416. referenceElement = this._config.reference; // Check if it's jQuery element
  3417. if (typeof this._config.reference.jquery !== 'undefined') {
  3418. referenceElement = this._config.reference[0];
  3419. }
  3420. } // If boundary is not `scrollParent`, then set position to `static`
  3421. // to allow the menu to "escape" the scroll parent's boundaries
  3422. // https://github.com/twbs/bootstrap/issues/24251
  3423. if (this._config.boundary !== 'scrollParent') {
  3424. $(parent).addClass(ClassName$4.POSITION_STATIC);
  3425. }
  3426. this._popper = new Popper(referenceElement, this._menu, this._getPopperConfig());
  3427. } // If this is a touch-enabled device we add extra
  3428. // empty mouseover listeners to the body's immediate children;
  3429. // only needed because of broken event delegation on iOS
  3430. // https://www.quirksmode.org/blog/archives/2014/02/mouse_event_bub.html
  3431. if ('ontouchstart' in document.documentElement && $(parent).closest(Selector$4.NAVBAR_NAV).length === 0) {
  3432. $(document.body).children().on('mouseover', null, $.noop);
  3433. }
  3434. this._element.focus();
  3435. this._element.setAttribute('aria-expanded', true);
  3436. $(this._menu).toggleClass(ClassName$4.SHOW);
  3437. $(parent).toggleClass(ClassName$4.SHOW).trigger($.Event(Event$4.SHOWN, relatedTarget));
  3438. };
  3439. _proto.hide = function hide() {
  3440. if (this._element.disabled || $(this._element).hasClass(ClassName$4.DISABLED) || !$(this._menu).hasClass(ClassName$4.SHOW)) {
  3441. return;
  3442. }
  3443. var relatedTarget = {
  3444. relatedTarget: this._element
  3445. };
  3446. var hideEvent = $.Event(Event$4.HIDE, relatedTarget);
  3447. var parent = Dropdown._getParentFromElement(this._element);
  3448. $(parent).trigger(hideEvent);
  3449. if (hideEvent.isDefaultPrevented()) {
  3450. return;
  3451. }
  3452. if (this._popper) {
  3453. this._popper.destroy();
  3454. }
  3455. $(this._menu).toggleClass(ClassName$4.SHOW);
  3456. $(parent).toggleClass(ClassName$4.SHOW).trigger($.Event(Event$4.HIDDEN, relatedTarget));
  3457. };
  3458. _proto.dispose = function dispose() {
  3459. $.removeData(this._element, DATA_KEY$4);
  3460. $(this._element).off(EVENT_KEY$4);
  3461. this._element = null;
  3462. this._menu = null;
  3463. if (this._popper !== null) {
  3464. this._popper.destroy();
  3465. this._popper = null;
  3466. }
  3467. };
  3468. _proto.update = function update() {
  3469. this._inNavbar = this._detectNavbar();
  3470. if (this._popper !== null) {
  3471. this._popper.scheduleUpdate();
  3472. }
  3473. } // Private
  3474. ;
  3475. _proto._addEventListeners = function _addEventListeners() {
  3476. var _this = this;
  3477. $(this._element).on(Event$4.CLICK, function (event) {
  3478. event.preventDefault();
  3479. event.stopPropagation();
  3480. _this.toggle();
  3481. });
  3482. };
  3483. _proto._getConfig = function _getConfig(config) {
  3484. config = _objectSpread2({}, this.constructor.Default, {}, $(this._element).data(), {}, config);
  3485. Util.typeCheckConfig(NAME$4, config, this.constructor.DefaultType);
  3486. return config;
  3487. };
  3488. _proto._getMenuElement = function _getMenuElement() {
  3489. if (!this._menu) {
  3490. var parent = Dropdown._getParentFromElement(this._element);
  3491. if (parent) {
  3492. this._menu = parent.querySelector(Selector$4.MENU);
  3493. }
  3494. }
  3495. return this._menu;
  3496. };
  3497. _proto._getPlacement = function _getPlacement() {
  3498. var $parentDropdown = $(this._element.parentNode);
  3499. var placement = AttachmentMap.BOTTOM; // Handle dropup
  3500. if ($parentDropdown.hasClass(ClassName$4.DROPUP)) {
  3501. placement = AttachmentMap.TOP;
  3502. if ($(this._menu).hasClass(ClassName$4.MENURIGHT)) {
  3503. placement = AttachmentMap.TOPEND;
  3504. }
  3505. } else if ($parentDropdown.hasClass(ClassName$4.DROPRIGHT)) {
  3506. placement = AttachmentMap.RIGHT;
  3507. } else if ($parentDropdown.hasClass(ClassName$4.DROPLEFT)) {
  3508. placement = AttachmentMap.LEFT;
  3509. } else if ($(this._menu).hasClass(ClassName$4.MENURIGHT)) {
  3510. placement = AttachmentMap.BOTTOMEND;
  3511. }
  3512. return placement;
  3513. };
  3514. _proto._detectNavbar = function _detectNavbar() {
  3515. return $(this._element).closest('.navbar').length > 0;
  3516. };
  3517. _proto._getOffset = function _getOffset() {
  3518. var _this2 = this;
  3519. var offset = {};
  3520. if (typeof this._config.offset === 'function') {
  3521. offset.fn = function (data) {
  3522. data.offsets = _objectSpread2({}, data.offsets, {}, _this2._config.offset(data.offsets, _this2._element) || {});
  3523. return data;
  3524. };
  3525. } else {
  3526. offset.offset = this._config.offset;
  3527. }
  3528. return offset;
  3529. };
  3530. _proto._getPopperConfig = function _getPopperConfig() {
  3531. var popperConfig = {
  3532. placement: this._getPlacement(),
  3533. modifiers: {
  3534. offset: this._getOffset(),
  3535. flip: {
  3536. enabled: this._config.flip
  3537. },
  3538. preventOverflow: {
  3539. boundariesElement: this._config.boundary
  3540. }
  3541. }
  3542. }; // Disable Popper.js if we have a static display
  3543. if (this._config.display === 'static') {
  3544. popperConfig.modifiers.applyStyle = {
  3545. enabled: false
  3546. };
  3547. }
  3548. return _objectSpread2({}, popperConfig, {}, this._config.popperConfig);
  3549. } // Static
  3550. ;
  3551. Dropdown._jQueryInterface = function _jQueryInterface(config) {
  3552. return this.each(function () {
  3553. var data = $(this).data(DATA_KEY$4);
  3554. var _config = typeof config === 'object' ? config : null;
  3555. if (!data) {
  3556. data = new Dropdown(this, _config);
  3557. $(this).data(DATA_KEY$4, data);
  3558. }
  3559. if (typeof config === 'string') {
  3560. if (typeof data[config] === 'undefined') {
  3561. throw new TypeError("No method named \"" + config + "\"");
  3562. }
  3563. data[config]();
  3564. }
  3565. });
  3566. };
  3567. Dropdown._clearMenus = function _clearMenus(event) {
  3568. if (event && (event.which === RIGHT_MOUSE_BUTTON_WHICH || event.type === 'keyup' && event.which !== TAB_KEYCODE)) {
  3569. return;
  3570. }
  3571. var toggles = [].slice.call(document.querySelectorAll(Selector$4.DATA_TOGGLE));
  3572. for (var i = 0, len = toggles.length; i < len; i++) {
  3573. var parent = Dropdown._getParentFromElement(toggles[i]);
  3574. var context = $(toggles[i]).data(DATA_KEY$4);
  3575. var relatedTarget = {
  3576. relatedTarget: toggles[i]
  3577. };
  3578. if (event && event.type === 'click') {
  3579. relatedTarget.clickEvent = event;
  3580. }
  3581. if (!context) {
  3582. continue;
  3583. }
  3584. var dropdownMenu = context._menu;
  3585. if (!$(parent).hasClass(ClassName$4.SHOW)) {
  3586. continue;
  3587. }
  3588. if (event && (event.type === 'click' && /input|textarea/i.test(event.target.tagName) || event.type === 'keyup' && event.which === TAB_KEYCODE) && $.contains(parent, event.target)) {
  3589. continue;
  3590. }
  3591. var hideEvent = $.Event(Event$4.HIDE, relatedTarget);
  3592. $(parent).trigger(hideEvent);
  3593. if (hideEvent.isDefaultPrevented()) {
  3594. continue;
  3595. } // If this is a touch-enabled device we remove the extra
  3596. // empty mouseover listeners we added for iOS support
  3597. if ('ontouchstart' in document.documentElement) {
  3598. $(document.body).children().off('mouseover', null, $.noop);
  3599. }
  3600. toggles[i].setAttribute('aria-expanded', 'false');
  3601. if (context._popper) {
  3602. context._popper.destroy();
  3603. }
  3604. $(dropdownMenu).removeClass(ClassName$4.SHOW);
  3605. $(parent).removeClass(ClassName$4.SHOW).trigger($.Event(Event$4.HIDDEN, relatedTarget));
  3606. }
  3607. };
  3608. Dropdown._getParentFromElement = function _getParentFromElement(element) {
  3609. var parent;
  3610. var selector = Util.getSelectorFromElement(element);
  3611. if (selector) {
  3612. parent = document.querySelector(selector);
  3613. }
  3614. return parent || element.parentNode;
  3615. } // eslint-disable-next-line complexity
  3616. ;
  3617. Dropdown._dataApiKeydownHandler = function _dataApiKeydownHandler(event) {
  3618. // If not input/textarea:
  3619. // - And not a key in REGEXP_KEYDOWN => not a dropdown command
  3620. // If input/textarea:
  3621. // - If space key => not a dropdown command
  3622. // - If key is other than escape
  3623. // - If key is not up or down => not a dropdown command
  3624. // - If trigger inside the menu => not a dropdown command
  3625. 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)) {
  3626. return;
  3627. }
  3628. event.preventDefault();
  3629. event.stopPropagation();
  3630. if (this.disabled || $(this).hasClass(ClassName$4.DISABLED)) {
  3631. return;
  3632. }
  3633. var parent = Dropdown._getParentFromElement(this);
  3634. var isActive = $(parent).hasClass(ClassName$4.SHOW);
  3635. if (!isActive && event.which === ESCAPE_KEYCODE) {
  3636. return;
  3637. }
  3638. if (!isActive || isActive && (event.which === ESCAPE_KEYCODE || event.which === SPACE_KEYCODE)) {
  3639. if (event.which === ESCAPE_KEYCODE) {
  3640. var toggle = parent.querySelector(Selector$4.DATA_TOGGLE);
  3641. $(toggle).trigger('focus');
  3642. }
  3643. $(this).trigger('click');
  3644. return;
  3645. }
  3646. var items = [].slice.call(parent.querySelectorAll(Selector$4.VISIBLE_ITEMS)).filter(function (item) {
  3647. return $(item).is(':visible');
  3648. });
  3649. if (items.length === 0) {
  3650. return;
  3651. }
  3652. var index = items.indexOf(event.target);
  3653. if (event.which === ARROW_UP_KEYCODE && index > 0) {
  3654. // Up
  3655. index--;
  3656. }
  3657. if (event.which === ARROW_DOWN_KEYCODE && index < items.length - 1) {
  3658. // Down
  3659. index++;
  3660. }
  3661. if (index < 0) {
  3662. index = 0;
  3663. }
  3664. items[index].focus();
  3665. };
  3666. _createClass(Dropdown, null, [{
  3667. key: "VERSION",
  3668. get: function get() {
  3669. return VERSION$4;
  3670. }
  3671. }, {
  3672. key: "Default",
  3673. get: function get() {
  3674. return Default$2;
  3675. }
  3676. }, {
  3677. key: "DefaultType",
  3678. get: function get() {
  3679. return DefaultType$2;
  3680. }
  3681. }]);
  3682. return Dropdown;
  3683. }();
  3684. /**
  3685. * ------------------------------------------------------------------------
  3686. * Data Api implementation
  3687. * ------------------------------------------------------------------------
  3688. */
  3689. $(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) {
  3690. event.preventDefault();
  3691. event.stopPropagation();
  3692. Dropdown._jQueryInterface.call($(this), 'toggle');
  3693. }).on(Event$4.CLICK_DATA_API, Selector$4.FORM_CHILD, function (e) {
  3694. e.stopPropagation();
  3695. });
  3696. /**
  3697. * ------------------------------------------------------------------------
  3698. * jQuery
  3699. * ------------------------------------------------------------------------
  3700. */
  3701. $.fn[NAME$4] = Dropdown._jQueryInterface;
  3702. $.fn[NAME$4].Constructor = Dropdown;
  3703. $.fn[NAME$4].noConflict = function () {
  3704. $.fn[NAME$4] = JQUERY_NO_CONFLICT$4;
  3705. return Dropdown._jQueryInterface;
  3706. };
  3707. /**
  3708. * ------------------------------------------------------------------------
  3709. * Constants
  3710. * ------------------------------------------------------------------------
  3711. */
  3712. var NAME$5 = 'modal';
  3713. var VERSION$5 = '4.4.1';
  3714. var DATA_KEY$5 = 'bs.modal';
  3715. var EVENT_KEY$5 = "." + DATA_KEY$5;
  3716. var DATA_API_KEY$5 = '.data-api';
  3717. var JQUERY_NO_CONFLICT$5 = $.fn[NAME$5];
  3718. var ESCAPE_KEYCODE$1 = 27; // KeyboardEvent.which value for Escape (Esc) key
  3719. var Default$3 = {
  3720. backdrop: true,
  3721. keyboard: true,
  3722. focus: true,
  3723. show: true
  3724. };
  3725. var DefaultType$3 = {
  3726. backdrop: '(boolean|string)',
  3727. keyboard: 'boolean',
  3728. focus: 'boolean',
  3729. show: 'boolean'
  3730. };
  3731. var Event$5 = {
  3732. HIDE: "hide" + EVENT_KEY$5,
  3733. HIDE_PREVENTED: "hidePrevented" + EVENT_KEY$5,
  3734. HIDDEN: "hidden" + EVENT_KEY$5,
  3735. SHOW: "show" + EVENT_KEY$5,
  3736. SHOWN: "shown" + EVENT_KEY$5,
  3737. FOCUSIN: "focusin" + EVENT_KEY$5,
  3738. RESIZE: "resize" + EVENT_KEY$5,
  3739. CLICK_DISMISS: "click.dismiss" + EVENT_KEY$5,
  3740. KEYDOWN_DISMISS: "keydown.dismiss" + EVENT_KEY$5,
  3741. MOUSEUP_DISMISS: "mouseup.dismiss" + EVENT_KEY$5,
  3742. MOUSEDOWN_DISMISS: "mousedown.dismiss" + EVENT_KEY$5,
  3743. CLICK_DATA_API: "click" + EVENT_KEY$5 + DATA_API_KEY$5
  3744. };
  3745. var ClassName$5 = {
  3746. SCROLLABLE: 'modal-dialog-scrollable',
  3747. SCROLLBAR_MEASURER: 'modal-scrollbar-measure',
  3748. BACKDROP: 'modal-backdrop',
  3749. OPEN: 'modal-open',
  3750. FADE: 'fade',
  3751. SHOW: 'show',
  3752. STATIC: 'modal-static'
  3753. };
  3754. var Selector$5 = {
  3755. DIALOG: '.modal-dialog',
  3756. MODAL_BODY: '.modal-body',
  3757. DATA_TOGGLE: '[data-toggle="modal"]',
  3758. DATA_DISMISS: '[data-dismiss="modal"]',
  3759. FIXED_CONTENT: '.fixed-top, .fixed-bottom, .is-fixed, .sticky-top',
  3760. STICKY_CONTENT: '.sticky-top'
  3761. };
  3762. /**
  3763. * ------------------------------------------------------------------------
  3764. * Class Definition
  3765. * ------------------------------------------------------------------------
  3766. */
  3767. var Modal =
  3768. /*#__PURE__*/
  3769. function () {
  3770. function Modal(element, config) {
  3771. this._config = this._getConfig(config);
  3772. this._element = element;
  3773. this._dialog = element.querySelector(Selector$5.DIALOG);
  3774. this._backdrop = null;
  3775. this._isShown = false;
  3776. this._isBodyOverflowing = false;
  3777. this._ignoreBackdropClick = false;
  3778. this._isTransitioning = false;
  3779. this._scrollbarWidth = 0;
  3780. } // Getters
  3781. var _proto = Modal.prototype;
  3782. // Public
  3783. _proto.toggle = function toggle(relatedTarget) {
  3784. return this._isShown ? this.hide() : this.show(relatedTarget);
  3785. };
  3786. _proto.show = function show(relatedTarget) {
  3787. var _this = this;
  3788. if (this._isShown || this._isTransitioning) {
  3789. return;
  3790. }
  3791. if ($(this._element).hasClass(ClassName$5.FADE)) {
  3792. this._isTransitioning = true;
  3793. }
  3794. var showEvent = $.Event(Event$5.SHOW, {
  3795. relatedTarget: relatedTarget
  3796. });
  3797. $(this._element).trigger(showEvent);
  3798. if (this._isShown || showEvent.isDefaultPrevented()) {
  3799. return;
  3800. }
  3801. this._isShown = true;
  3802. this._checkScrollbar();
  3803. this._setScrollbar();
  3804. this._adjustDialog();
  3805. this._setEscapeEvent();
  3806. this._setResizeEvent();
  3807. $(this._element).on(Event$5.CLICK_DISMISS, Selector$5.DATA_DISMISS, function (event) {
  3808. return _this.hide(event);
  3809. });
  3810. $(this._dialog).on(Event$5.MOUSEDOWN_DISMISS, function () {
  3811. $(_this._element).one(Event$5.MOUSEUP_DISMISS, function (event) {
  3812. if ($(event.target).is(_this._element)) {
  3813. _this._ignoreBackdropClick = true;
  3814. }
  3815. });
  3816. });
  3817. this._showBackdrop(function () {
  3818. return _this._showElement(relatedTarget);
  3819. });
  3820. };
  3821. _proto.hide = function hide(event) {
  3822. var _this2 = this;
  3823. if (event) {
  3824. event.preventDefault();
  3825. }
  3826. if (!this._isShown || this._isTransitioning) {
  3827. return;
  3828. }
  3829. var hideEvent = $.Event(Event$5.HIDE);
  3830. $(this._element).trigger(hideEvent);
  3831. if (!this._isShown || hideEvent.isDefaultPrevented()) {
  3832. return;
  3833. }
  3834. this._isShown = false;
  3835. var transition = $(this._element).hasClass(ClassName$5.FADE);
  3836. if (transition) {
  3837. this._isTransitioning = true;
  3838. }
  3839. this._setEscapeEvent();
  3840. this._setResizeEvent();
  3841. $(document).off(Event$5.FOCUSIN);
  3842. $(this._element).removeClass(ClassName$5.SHOW);
  3843. $(this._element).off(Event$5.CLICK_DISMISS);
  3844. $(this._dialog).off(Event$5.MOUSEDOWN_DISMISS);
  3845. if (transition) {
  3846. var transitionDuration = Util.getTransitionDurationFromElement(this._element);
  3847. $(this._element).one(Util.TRANSITION_END, function (event) {
  3848. return _this2._hideModal(event);
  3849. }).emulateTransitionEnd(transitionDuration);
  3850. } else {
  3851. this._hideModal();
  3852. }
  3853. };
  3854. _proto.dispose = function dispose() {
  3855. [window, this._element, this._dialog].forEach(function (htmlElement) {
  3856. return $(htmlElement).off(EVENT_KEY$5);
  3857. });
  3858. /**
  3859. * `document` has 2 events `Event.FOCUSIN` and `Event.CLICK_DATA_API`
  3860. * Do not move `document` in `htmlElements` array
  3861. * It will remove `Event.CLICK_DATA_API` event that should remain
  3862. */
  3863. $(document).off(Event$5.FOCUSIN);
  3864. $.removeData(this._element, DATA_KEY$5);
  3865. this._config = null;
  3866. this._element = null;
  3867. this._dialog = null;
  3868. this._backdrop = null;
  3869. this._isShown = null;
  3870. this._isBodyOverflowing = null;
  3871. this._ignoreBackdropClick = null;
  3872. this._isTransitioning = null;
  3873. this._scrollbarWidth = null;
  3874. };
  3875. _proto.handleUpdate = function handleUpdate() {
  3876. this._adjustDialog();
  3877. } // Private
  3878. ;
  3879. _proto._getConfig = function _getConfig(config) {
  3880. config = _objectSpread2({}, Default$3, {}, config);
  3881. Util.typeCheckConfig(NAME$5, config, DefaultType$3);
  3882. return config;
  3883. };
  3884. _proto._triggerBackdropTransition = function _triggerBackdropTransition() {
  3885. var _this3 = this;
  3886. if (this._config.backdrop === 'static') {
  3887. var hideEventPrevented = $.Event(Event$5.HIDE_PREVENTED);
  3888. $(this._element).trigger(hideEventPrevented);
  3889. if (hideEventPrevented.defaultPrevented) {
  3890. return;
  3891. }
  3892. this._element.classList.add(ClassName$5.STATIC);
  3893. var modalTransitionDuration = Util.getTransitionDurationFromElement(this._element);
  3894. $(this._element).one(Util.TRANSITION_END, function () {
  3895. _this3._element.classList.remove(ClassName$5.STATIC);
  3896. }).emulateTransitionEnd(modalTransitionDuration);
  3897. this._element.focus();
  3898. } else {
  3899. this.hide();
  3900. }
  3901. };
  3902. _proto._showElement = function _showElement(relatedTarget) {
  3903. var _this4 = this;
  3904. var transition = $(this._element).hasClass(ClassName$5.FADE);
  3905. var modalBody = this._dialog ? this._dialog.querySelector(Selector$5.MODAL_BODY) : null;
  3906. if (!this._element.parentNode || this._element.parentNode.nodeType !== Node.ELEMENT_NODE) {
  3907. // Don't move modal's DOM position
  3908. document.body.appendChild(this._element);
  3909. }
  3910. this._element.style.display = 'block';
  3911. this._element.removeAttribute('aria-hidden');
  3912. this._element.setAttribute('aria-modal', true);
  3913. if ($(this._dialog).hasClass(ClassName$5.SCROLLABLE) && modalBody) {
  3914. modalBody.scrollTop = 0;
  3915. } else {
  3916. this._element.scrollTop = 0;
  3917. }
  3918. if (transition) {
  3919. Util.reflow(this._element);
  3920. }
  3921. $(this._element).addClass(ClassName$5.SHOW);
  3922. if (this._config.focus) {
  3923. this._enforceFocus();
  3924. }
  3925. var shownEvent = $.Event(Event$5.SHOWN, {
  3926. relatedTarget: relatedTarget
  3927. });
  3928. var transitionComplete = function transitionComplete() {
  3929. if (_this4._config.focus) {
  3930. _this4._element.focus();
  3931. }
  3932. _this4._isTransitioning = false;
  3933. $(_this4._element).trigger(shownEvent);
  3934. };
  3935. if (transition) {
  3936. var transitionDuration = Util.getTransitionDurationFromElement(this._dialog);
  3937. $(this._dialog).one(Util.TRANSITION_END, transitionComplete).emulateTransitionEnd(transitionDuration);
  3938. } else {
  3939. transitionComplete();
  3940. }
  3941. };
  3942. _proto._enforceFocus = function _enforceFocus() {
  3943. var _this5 = this;
  3944. $(document).off(Event$5.FOCUSIN) // Guard against infinite focus loop
  3945. .on(Event$5.FOCUSIN, function (event) {
  3946. if (document !== event.target && _this5._element !== event.target && $(_this5._element).has(event.target).length === 0) {
  3947. _this5._element.focus();
  3948. }
  3949. });
  3950. };
  3951. _proto._setEscapeEvent = function _setEscapeEvent() {
  3952. var _this6 = this;
  3953. if (this._isShown && this._config.keyboard) {
  3954. $(this._element).on(Event$5.KEYDOWN_DISMISS, function (event) {
  3955. if (event.which === ESCAPE_KEYCODE$1) {
  3956. _this6._triggerBackdropTransition();
  3957. }
  3958. });
  3959. } else if (!this._isShown) {
  3960. $(this._element).off(Event$5.KEYDOWN_DISMISS);
  3961. }
  3962. };
  3963. _proto._setResizeEvent = function _setResizeEvent() {
  3964. var _this7 = this;
  3965. if (this._isShown) {
  3966. $(window).on(Event$5.RESIZE, function (event) {
  3967. return _this7.handleUpdate(event);
  3968. });
  3969. } else {
  3970. $(window).off(Event$5.RESIZE);
  3971. }
  3972. };
  3973. _proto._hideModal = function _hideModal() {
  3974. var _this8 = this;
  3975. this._element.style.display = 'none';
  3976. this._element.setAttribute('aria-hidden', true);
  3977. this._element.removeAttribute('aria-modal');
  3978. this._isTransitioning = false;
  3979. this._showBackdrop(function () {
  3980. $(document.body).removeClass(ClassName$5.OPEN);
  3981. _this8._resetAdjustments();
  3982. _this8._resetScrollbar();
  3983. $(_this8._element).trigger(Event$5.HIDDEN);
  3984. });
  3985. };
  3986. _proto._removeBackdrop = function _removeBackdrop() {
  3987. if (this._backdrop) {
  3988. $(this._backdrop).remove();
  3989. this._backdrop = null;
  3990. }
  3991. };
  3992. _proto._showBackdrop = function _showBackdrop(callback) {
  3993. var _this9 = this;
  3994. var animate = $(this._element).hasClass(ClassName$5.FADE) ? ClassName$5.FADE : '';
  3995. if (this._isShown && this._config.backdrop) {
  3996. this._backdrop = document.createElement('div');
  3997. this._backdrop.className = ClassName$5.BACKDROP;
  3998. if (animate) {
  3999. this._backdrop.classList.add(animate);
  4000. }
  4001. $(this._backdrop).appendTo(document.body);
  4002. $(this._element).on(Event$5.CLICK_DISMISS, function (event) {
  4003. if (_this9._ignoreBackdropClick) {
  4004. _this9._ignoreBackdropClick = false;
  4005. return;
  4006. }
  4007. if (event.target !== event.currentTarget) {
  4008. return;
  4009. }
  4010. _this9._triggerBackdropTransition();
  4011. });
  4012. if (animate) {
  4013. Util.reflow(this._backdrop);
  4014. }
  4015. $(this._backdrop).addClass(ClassName$5.SHOW);
  4016. if (!callback) {
  4017. return;
  4018. }
  4019. if (!animate) {
  4020. callback();
  4021. return;
  4022. }
  4023. var backdropTransitionDuration = Util.getTransitionDurationFromElement(this._backdrop);
  4024. $(this._backdrop).one(Util.TRANSITION_END, callback).emulateTransitionEnd(backdropTransitionDuration);
  4025. } else if (!this._isShown && this._backdrop) {
  4026. $(this._backdrop).removeClass(ClassName$5.SHOW);
  4027. var callbackRemove = function callbackRemove() {
  4028. _this9._removeBackdrop();
  4029. if (callback) {
  4030. callback();
  4031. }
  4032. };
  4033. if ($(this._element).hasClass(ClassName$5.FADE)) {
  4034. var _backdropTransitionDuration = Util.getTransitionDurationFromElement(this._backdrop);
  4035. $(this._backdrop).one(Util.TRANSITION_END, callbackRemove).emulateTransitionEnd(_backdropTransitionDuration);
  4036. } else {
  4037. callbackRemove();
  4038. }
  4039. } else if (callback) {
  4040. callback();
  4041. }
  4042. } // ----------------------------------------------------------------------
  4043. // the following methods are used to handle overflowing modals
  4044. // todo (fat): these should probably be refactored out of modal.js
  4045. // ----------------------------------------------------------------------
  4046. ;
  4047. _proto._adjustDialog = function _adjustDialog() {
  4048. var isModalOverflowing = this._element.scrollHeight > document.documentElement.clientHeight;
  4049. if (!this._isBodyOverflowing && isModalOverflowing) {
  4050. this._element.style.paddingLeft = this._scrollbarWidth + "px";
  4051. }
  4052. if (this._isBodyOverflowing && !isModalOverflowing) {
  4053. this._element.style.paddingRight = this._scrollbarWidth + "px";
  4054. }
  4055. };
  4056. _proto._resetAdjustments = function _resetAdjustments() {
  4057. this._element.style.paddingLeft = '';
  4058. this._element.style.paddingRight = '';
  4059. };
  4060. _proto._checkScrollbar = function _checkScrollbar() {
  4061. var rect = document.body.getBoundingClientRect();
  4062. this._isBodyOverflowing = rect.left + rect.right < window.innerWidth;
  4063. this._scrollbarWidth = this._getScrollbarWidth();
  4064. };
  4065. _proto._setScrollbar = function _setScrollbar() {
  4066. var _this10 = this;
  4067. if (this._isBodyOverflowing) {
  4068. // Note: DOMNode.style.paddingRight returns the actual value or '' if not set
  4069. // while $(DOMNode).css('padding-right') returns the calculated value or 0 if not set
  4070. var fixedContent = [].slice.call(document.querySelectorAll(Selector$5.FIXED_CONTENT));
  4071. var stickyContent = [].slice.call(document.querySelectorAll(Selector$5.STICKY_CONTENT)); // Adjust fixed content padding
  4072. $(fixedContent).each(function (index, element) {
  4073. var actualPadding = element.style.paddingRight;
  4074. var calculatedPadding = $(element).css('padding-right');
  4075. $(element).data('padding-right', actualPadding).css('padding-right', parseFloat(calculatedPadding) + _this10._scrollbarWidth + "px");
  4076. }); // Adjust sticky content margin
  4077. $(stickyContent).each(function (index, element) {
  4078. var actualMargin = element.style.marginRight;
  4079. var calculatedMargin = $(element).css('margin-right');
  4080. $(element).data('margin-right', actualMargin).css('margin-right', parseFloat(calculatedMargin) - _this10._scrollbarWidth + "px");
  4081. }); // Adjust body padding
  4082. var actualPadding = document.body.style.paddingRight;
  4083. var calculatedPadding = $(document.body).css('padding-right');
  4084. $(document.body).data('padding-right', actualPadding).css('padding-right', parseFloat(calculatedPadding) + this._scrollbarWidth + "px");
  4085. }
  4086. $(document.body).addClass(ClassName$5.OPEN);
  4087. };
  4088. _proto._resetScrollbar = function _resetScrollbar() {
  4089. // Restore fixed content padding
  4090. var fixedContent = [].slice.call(document.querySelectorAll(Selector$5.FIXED_CONTENT));
  4091. $(fixedContent).each(function (index, element) {
  4092. var padding = $(element).data('padding-right');
  4093. $(element).removeData('padding-right');
  4094. element.style.paddingRight = padding ? padding : '';
  4095. }); // Restore sticky content
  4096. var elements = [].slice.call(document.querySelectorAll("" + Selector$5.STICKY_CONTENT));
  4097. $(elements).each(function (index, element) {
  4098. var margin = $(element).data('margin-right');
  4099. if (typeof margin !== 'undefined') {
  4100. $(element).css('margin-right', margin).removeData('margin-right');
  4101. }
  4102. }); // Restore body padding
  4103. var padding = $(document.body).data('padding-right');
  4104. $(document.body).removeData('padding-right');
  4105. document.body.style.paddingRight = padding ? padding : '';
  4106. };
  4107. _proto._getScrollbarWidth = function _getScrollbarWidth() {
  4108. // thx d.walsh
  4109. var scrollDiv = document.createElement('div');
  4110. scrollDiv.className = ClassName$5.SCROLLBAR_MEASURER;
  4111. document.body.appendChild(scrollDiv);
  4112. var scrollbarWidth = scrollDiv.getBoundingClientRect().width - scrollDiv.clientWidth;
  4113. document.body.removeChild(scrollDiv);
  4114. return scrollbarWidth;
  4115. } // Static
  4116. ;
  4117. Modal._jQueryInterface = function _jQueryInterface(config, relatedTarget) {
  4118. return this.each(function () {
  4119. var data = $(this).data(DATA_KEY$5);
  4120. var _config = _objectSpread2({}, Default$3, {}, $(this).data(), {}, typeof config === 'object' && config ? config : {});
  4121. if (!data) {
  4122. data = new Modal(this, _config);
  4123. $(this).data(DATA_KEY$5, data);
  4124. }
  4125. if (typeof config === 'string') {
  4126. if (typeof data[config] === 'undefined') {
  4127. throw new TypeError("No method named \"" + config + "\"");
  4128. }
  4129. data[config](relatedTarget);
  4130. } else if (_config.show) {
  4131. data.show(relatedTarget);
  4132. }
  4133. });
  4134. };
  4135. _createClass(Modal, null, [{
  4136. key: "VERSION",
  4137. get: function get() {
  4138. return VERSION$5;
  4139. }
  4140. }, {
  4141. key: "Default",
  4142. get: function get() {
  4143. return Default$3;
  4144. }
  4145. }]);
  4146. return Modal;
  4147. }();
  4148. /**
  4149. * ------------------------------------------------------------------------
  4150. * Data Api implementation
  4151. * ------------------------------------------------------------------------
  4152. */
  4153. $(document).on(Event$5.CLICK_DATA_API, Selector$5.DATA_TOGGLE, function (event) {
  4154. var _this11 = this;
  4155. var target;
  4156. var selector = Util.getSelectorFromElement(this);
  4157. if (selector) {
  4158. target = document.querySelector(selector);
  4159. }
  4160. var config = $(target).data(DATA_KEY$5) ? 'toggle' : _objectSpread2({}, $(target).data(), {}, $(this).data());
  4161. if (this.tagName === 'A' || this.tagName === 'AREA') {
  4162. event.preventDefault();
  4163. }
  4164. var $target = $(target).one(Event$5.SHOW, function (showEvent) {
  4165. if (showEvent.isDefaultPrevented()) {
  4166. // Only register focus restorer if modal will actually get shown
  4167. return;
  4168. }
  4169. $target.one(Event$5.HIDDEN, function () {
  4170. if ($(_this11).is(':visible')) {
  4171. _this11.focus();
  4172. }
  4173. });
  4174. });
  4175. Modal._jQueryInterface.call($(target), config, this);
  4176. });
  4177. /**
  4178. * ------------------------------------------------------------------------
  4179. * jQuery
  4180. * ------------------------------------------------------------------------
  4181. */
  4182. $.fn[NAME$5] = Modal._jQueryInterface;
  4183. $.fn[NAME$5].Constructor = Modal;
  4184. $.fn[NAME$5].noConflict = function () {
  4185. $.fn[NAME$5] = JQUERY_NO_CONFLICT$5;
  4186. return Modal._jQueryInterface;
  4187. };
  4188. /**
  4189. * --------------------------------------------------------------------------
  4190. * Bootstrap (v4.4.1): tools/sanitizer.js
  4191. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
  4192. * --------------------------------------------------------------------------
  4193. */
  4194. var uriAttrs = ['background', 'cite', 'href', 'itemtype', 'longdesc', 'poster', 'src', 'xlink:href'];
  4195. var ARIA_ATTRIBUTE_PATTERN = /^aria-[\w-]*$/i;
  4196. var DefaultWhitelist = {
  4197. // Global attributes allowed on any supplied element below.
  4198. '*': ['class', 'dir', 'id', 'lang', 'role', ARIA_ATTRIBUTE_PATTERN],
  4199. a: ['target', 'href', 'title', 'rel'],
  4200. area: [],
  4201. b: [],
  4202. br: [],
  4203. col: [],
  4204. code: [],
  4205. div: [],
  4206. em: [],
  4207. hr: [],
  4208. h1: [],
  4209. h2: [],
  4210. h3: [],
  4211. h4: [],
  4212. h5: [],
  4213. h6: [],
  4214. i: [],
  4215. img: ['src', 'alt', 'title', 'width', 'height'],
  4216. li: [],
  4217. ol: [],
  4218. p: [],
  4219. pre: [],
  4220. s: [],
  4221. small: [],
  4222. span: [],
  4223. sub: [],
  4224. sup: [],
  4225. strong: [],
  4226. u: [],
  4227. ul: []
  4228. };
  4229. /**
  4230. * A pattern that recognizes a commonly useful subset of URLs that are safe.
  4231. *
  4232. * Shoutout to Angular 7 https://github.com/angular/angular/blob/7.2.4/packages/core/src/sanitization/url_sanitizer.ts
  4233. */
  4234. var SAFE_URL_PATTERN = /^(?:(?:https?|mailto|ftp|tel|file):|[^&:/?#]*(?:[/?#]|$))/gi;
  4235. /**
  4236. * A pattern that matches safe data URLs. Only matches image, video and audio types.
  4237. *
  4238. * Shoutout to Angular 7 https://github.com/angular/angular/blob/7.2.4/packages/core/src/sanitization/url_sanitizer.ts
  4239. */
  4240. 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;
  4241. function allowedAttribute(attr, allowedAttributeList) {
  4242. var attrName = attr.nodeName.toLowerCase();
  4243. if (allowedAttributeList.indexOf(attrName) !== -1) {
  4244. if (uriAttrs.indexOf(attrName) !== -1) {
  4245. return Boolean(attr.nodeValue.match(SAFE_URL_PATTERN) || attr.nodeValue.match(DATA_URL_PATTERN));
  4246. }
  4247. return true;
  4248. }
  4249. var regExp = allowedAttributeList.filter(function (attrRegex) {
  4250. return attrRegex instanceof RegExp;
  4251. }); // Check if a regular expression validates the attribute.
  4252. for (var i = 0, l = regExp.length; i < l; i++) {
  4253. if (attrName.match(regExp[i])) {
  4254. return true;
  4255. }
  4256. }
  4257. return false;
  4258. }
  4259. function sanitizeHtml(unsafeHtml, whiteList, sanitizeFn) {
  4260. if (unsafeHtml.length === 0) {
  4261. return unsafeHtml;
  4262. }
  4263. if (sanitizeFn && typeof sanitizeFn === 'function') {
  4264. return sanitizeFn(unsafeHtml);
  4265. }
  4266. var domParser = new window.DOMParser();
  4267. var createdDocument = domParser.parseFromString(unsafeHtml, 'text/html');
  4268. var whitelistKeys = Object.keys(whiteList);
  4269. var elements = [].slice.call(createdDocument.body.querySelectorAll('*'));
  4270. var _loop = function _loop(i, len) {
  4271. var el = elements[i];
  4272. var elName = el.nodeName.toLowerCase();
  4273. if (whitelistKeys.indexOf(el.nodeName.toLowerCase()) === -1) {
  4274. el.parentNode.removeChild(el);
  4275. return "continue";
  4276. }
  4277. var attributeList = [].slice.call(el.attributes);
  4278. var whitelistedAttributes = [].concat(whiteList['*'] || [], whiteList[elName] || []);
  4279. attributeList.forEach(function (attr) {
  4280. if (!allowedAttribute(attr, whitelistedAttributes)) {
  4281. el.removeAttribute(attr.nodeName);
  4282. }
  4283. });
  4284. };
  4285. for (var i = 0, len = elements.length; i < len; i++) {
  4286. var _ret = _loop(i);
  4287. if (_ret === "continue") continue;
  4288. }
  4289. return createdDocument.body.innerHTML;
  4290. }
  4291. /**
  4292. * ------------------------------------------------------------------------
  4293. * Constants
  4294. * ------------------------------------------------------------------------
  4295. */
  4296. var NAME$6 = 'tooltip';
  4297. var VERSION$6 = '4.4.1';
  4298. var DATA_KEY$6 = 'bs.tooltip';
  4299. var EVENT_KEY$6 = "." + DATA_KEY$6;
  4300. var JQUERY_NO_CONFLICT$6 = $.fn[NAME$6];
  4301. var CLASS_PREFIX = 'bs-tooltip';
  4302. var BSCLS_PREFIX_REGEX = new RegExp("(^|\\s)" + CLASS_PREFIX + "\\S+", 'g');
  4303. var DISALLOWED_ATTRIBUTES = ['sanitize', 'whiteList', 'sanitizeFn'];
  4304. var DefaultType$4 = {
  4305. animation: 'boolean',
  4306. template: 'string',
  4307. title: '(string|element|function)',
  4308. trigger: 'string',
  4309. delay: '(number|object)',
  4310. html: 'boolean',
  4311. selector: '(string|boolean)',
  4312. placement: '(string|function)',
  4313. offset: '(number|string|function)',
  4314. container: '(string|element|boolean)',
  4315. fallbackPlacement: '(string|array)',
  4316. boundary: '(string|element)',
  4317. sanitize: 'boolean',
  4318. sanitizeFn: '(null|function)',
  4319. whiteList: 'object',
  4320. popperConfig: '(null|object)'
  4321. };
  4322. var AttachmentMap$1 = {
  4323. AUTO: 'auto',
  4324. TOP: 'top',
  4325. RIGHT: 'right',
  4326. BOTTOM: 'bottom',
  4327. LEFT: 'left'
  4328. };
  4329. var Default$4 = {
  4330. animation: true,
  4331. template: '<div class="tooltip" role="tooltip">' + '<div class="arrow"></div>' + '<div class="tooltip-inner"></div></div>',
  4332. trigger: 'hover focus',
  4333. title: '',
  4334. delay: 0,
  4335. html: false,
  4336. selector: false,
  4337. placement: 'top',
  4338. offset: 0,
  4339. container: false,
  4340. fallbackPlacement: 'flip',
  4341. boundary: 'scrollParent',
  4342. sanitize: true,
  4343. sanitizeFn: null,
  4344. whiteList: DefaultWhitelist,
  4345. popperConfig: null
  4346. };
  4347. var HoverState = {
  4348. SHOW: 'show',
  4349. OUT: 'out'
  4350. };
  4351. var Event$6 = {
  4352. HIDE: "hide" + EVENT_KEY$6,
  4353. HIDDEN: "hidden" + EVENT_KEY$6,
  4354. SHOW: "show" + EVENT_KEY$6,
  4355. SHOWN: "shown" + EVENT_KEY$6,
  4356. INSERTED: "inserted" + EVENT_KEY$6,
  4357. CLICK: "click" + EVENT_KEY$6,
  4358. FOCUSIN: "focusin" + EVENT_KEY$6,
  4359. FOCUSOUT: "focusout" + EVENT_KEY$6,
  4360. MOUSEENTER: "mouseenter" + EVENT_KEY$6,
  4361. MOUSELEAVE: "mouseleave" + EVENT_KEY$6
  4362. };
  4363. var ClassName$6 = {
  4364. FADE: 'fade',
  4365. SHOW: 'show'
  4366. };
  4367. var Selector$6 = {
  4368. TOOLTIP: '.tooltip',
  4369. TOOLTIP_INNER: '.tooltip-inner',
  4370. ARROW: '.arrow'
  4371. };
  4372. var Trigger = {
  4373. HOVER: 'hover',
  4374. FOCUS: 'focus',
  4375. CLICK: 'click',
  4376. MANUAL: 'manual'
  4377. };
  4378. /**
  4379. * ------------------------------------------------------------------------
  4380. * Class Definition
  4381. * ------------------------------------------------------------------------
  4382. */
  4383. var Tooltip =
  4384. /*#__PURE__*/
  4385. function () {
  4386. function Tooltip(element, config) {
  4387. if (typeof Popper === 'undefined') {
  4388. throw new TypeError('Bootstrap\'s tooltips require Popper.js (https://popper.js.org/)');
  4389. } // private
  4390. this._isEnabled = true;
  4391. this._timeout = 0;
  4392. this._hoverState = '';
  4393. this._activeTrigger = {};
  4394. this._popper = null; // Protected
  4395. this.element = element;
  4396. this.config = this._getConfig(config);
  4397. this.tip = null;
  4398. this._setListeners();
  4399. } // Getters
  4400. var _proto = Tooltip.prototype;
  4401. // Public
  4402. _proto.enable = function enable() {
  4403. this._isEnabled = true;
  4404. };
  4405. _proto.disable = function disable() {
  4406. this._isEnabled = false;
  4407. };
  4408. _proto.toggleEnabled = function toggleEnabled() {
  4409. this._isEnabled = !this._isEnabled;
  4410. };
  4411. _proto.toggle = function toggle(event) {
  4412. if (!this._isEnabled) {
  4413. return;
  4414. }
  4415. if (event) {
  4416. var dataKey = this.constructor.DATA_KEY;
  4417. var context = $(event.currentTarget).data(dataKey);
  4418. if (!context) {
  4419. context = new this.constructor(event.currentTarget, this._getDelegateConfig());
  4420. $(event.currentTarget).data(dataKey, context);
  4421. }
  4422. context._activeTrigger.click = !context._activeTrigger.click;
  4423. if (context._isWithActiveTrigger()) {
  4424. context._enter(null, context);
  4425. } else {
  4426. context._leave(null, context);
  4427. }
  4428. } else {
  4429. if ($(this.getTipElement()).hasClass(ClassName$6.SHOW)) {
  4430. this._leave(null, this);
  4431. return;
  4432. }
  4433. this._enter(null, this);
  4434. }
  4435. };
  4436. _proto.dispose = function dispose() {
  4437. clearTimeout(this._timeout);
  4438. $.removeData(this.element, this.constructor.DATA_KEY);
  4439. $(this.element).off(this.constructor.EVENT_KEY);
  4440. $(this.element).closest('.modal').off('hide.bs.modal', this._hideModalHandler);
  4441. if (this.tip) {
  4442. $(this.tip).remove();
  4443. }
  4444. this._isEnabled = null;
  4445. this._timeout = null;
  4446. this._hoverState = null;
  4447. this._activeTrigger = null;
  4448. if (this._popper) {
  4449. this._popper.destroy();
  4450. }
  4451. this._popper = null;
  4452. this.element = null;
  4453. this.config = null;
  4454. this.tip = null;
  4455. };
  4456. _proto.show = function show() {
  4457. var _this = this;
  4458. if ($(this.element).css('display') === 'none') {
  4459. throw new Error('Please use show on visible elements');
  4460. }
  4461. var showEvent = $.Event(this.constructor.Event.SHOW);
  4462. if (this.isWithContent() && this._isEnabled) {
  4463. $(this.element).trigger(showEvent);
  4464. var shadowRoot = Util.findShadowRoot(this.element);
  4465. var isInTheDom = $.contains(shadowRoot !== null ? shadowRoot : this.element.ownerDocument.documentElement, this.element);
  4466. if (showEvent.isDefaultPrevented() || !isInTheDom) {
  4467. return;
  4468. }
  4469. var tip = this.getTipElement();
  4470. var tipId = Util.getUID(this.constructor.NAME);
  4471. tip.setAttribute('id', tipId);
  4472. this.element.setAttribute('aria-describedby', tipId);
  4473. this.setContent();
  4474. if (this.config.animation) {
  4475. $(tip).addClass(ClassName$6.FADE);
  4476. }
  4477. var placement = typeof this.config.placement === 'function' ? this.config.placement.call(this, tip, this.element) : this.config.placement;
  4478. var attachment = this._getAttachment(placement);
  4479. this.addAttachmentClass(attachment);
  4480. var container = this._getContainer();
  4481. $(tip).data(this.constructor.DATA_KEY, this);
  4482. if (!$.contains(this.element.ownerDocument.documentElement, this.tip)) {
  4483. $(tip).appendTo(container);
  4484. }
  4485. $(this.element).trigger(this.constructor.Event.INSERTED);
  4486. this._popper = new Popper(this.element, tip, this._getPopperConfig(attachment));
  4487. $(tip).addClass(ClassName$6.SHOW); // If this is a touch-enabled device we add extra
  4488. // empty mouseover listeners to the body's immediate children;
  4489. // only needed because of broken event delegation on iOS
  4490. // https://www.quirksmode.org/blog/archives/2014/02/mouse_event_bub.html
  4491. if ('ontouchstart' in document.documentElement) {
  4492. $(document.body).children().on('mouseover', null, $.noop);
  4493. }
  4494. var complete = function complete() {
  4495. if (_this.config.animation) {
  4496. _this._fixTransition();
  4497. }
  4498. var prevHoverState = _this._hoverState;
  4499. _this._hoverState = null;
  4500. $(_this.element).trigger(_this.constructor.Event.SHOWN);
  4501. if (prevHoverState === HoverState.OUT) {
  4502. _this._leave(null, _this);
  4503. }
  4504. };
  4505. if ($(this.tip).hasClass(ClassName$6.FADE)) {
  4506. var transitionDuration = Util.getTransitionDurationFromElement(this.tip);
  4507. $(this.tip).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration);
  4508. } else {
  4509. complete();
  4510. }
  4511. }
  4512. };
  4513. _proto.hide = function hide(callback) {
  4514. var _this2 = this;
  4515. var tip = this.getTipElement();
  4516. var hideEvent = $.Event(this.constructor.Event.HIDE);
  4517. var complete = function complete() {
  4518. if (_this2._hoverState !== HoverState.SHOW && tip.parentNode) {
  4519. tip.parentNode.removeChild(tip);
  4520. }
  4521. _this2._cleanTipClass();
  4522. _this2.element.removeAttribute('aria-describedby');
  4523. $(_this2.element).trigger(_this2.constructor.Event.HIDDEN);
  4524. if (_this2._popper !== null) {
  4525. _this2._popper.destroy();
  4526. }
  4527. if (callback) {
  4528. callback();
  4529. }
  4530. };
  4531. $(this.element).trigger(hideEvent);
  4532. if (hideEvent.isDefaultPrevented()) {
  4533. return;
  4534. }
  4535. $(tip).removeClass(ClassName$6.SHOW); // If this is a touch-enabled device we remove the extra
  4536. // empty mouseover listeners we added for iOS support
  4537. if ('ontouchstart' in document.documentElement) {
  4538. $(document.body).children().off('mouseover', null, $.noop);
  4539. }
  4540. this._activeTrigger[Trigger.CLICK] = false;
  4541. this._activeTrigger[Trigger.FOCUS] = false;
  4542. this._activeTrigger[Trigger.HOVER] = false;
  4543. if ($(this.tip).hasClass(ClassName$6.FADE)) {
  4544. var transitionDuration = Util.getTransitionDurationFromElement(tip);
  4545. $(tip).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration);
  4546. } else {
  4547. complete();
  4548. }
  4549. this._hoverState = '';
  4550. };
  4551. _proto.update = function update() {
  4552. if (this._popper !== null) {
  4553. this._popper.scheduleUpdate();
  4554. }
  4555. } // Protected
  4556. ;
  4557. _proto.isWithContent = function isWithContent() {
  4558. return Boolean(this.getTitle());
  4559. };
  4560. _proto.addAttachmentClass = function addAttachmentClass(attachment) {
  4561. $(this.getTipElement()).addClass(CLASS_PREFIX + "-" + attachment);
  4562. };
  4563. _proto.getTipElement = function getTipElement() {
  4564. this.tip = this.tip || $(this.config.template)[0];
  4565. return this.tip;
  4566. };
  4567. _proto.setContent = function setContent() {
  4568. var tip = this.getTipElement();
  4569. this.setElementContent($(tip.querySelectorAll(Selector$6.TOOLTIP_INNER)), this.getTitle());
  4570. $(tip).removeClass(ClassName$6.FADE + " " + ClassName$6.SHOW);
  4571. };
  4572. _proto.setElementContent = function setElementContent($element, content) {
  4573. if (typeof content === 'object' && (content.nodeType || content.jquery)) {
  4574. // Content is a DOM node or a jQuery
  4575. if (this.config.html) {
  4576. if (!$(content).parent().is($element)) {
  4577. $element.empty().append(content);
  4578. }
  4579. } else {
  4580. $element.text($(content).text());
  4581. }
  4582. return;
  4583. }
  4584. if (this.config.html) {
  4585. if (this.config.sanitize) {
  4586. content = sanitizeHtml(content, this.config.whiteList, this.config.sanitizeFn);
  4587. }
  4588. $element.html(content);
  4589. } else {
  4590. $element.text(content);
  4591. }
  4592. };
  4593. _proto.getTitle = function getTitle() {
  4594. var title = this.element.getAttribute('data-original-title');
  4595. if (!title) {
  4596. title = typeof this.config.title === 'function' ? this.config.title.call(this.element) : this.config.title;
  4597. }
  4598. return title;
  4599. } // Private
  4600. ;
  4601. _proto._getPopperConfig = function _getPopperConfig(attachment) {
  4602. var _this3 = this;
  4603. var defaultBsConfig = {
  4604. placement: attachment,
  4605. modifiers: {
  4606. offset: this._getOffset(),
  4607. flip: {
  4608. behavior: this.config.fallbackPlacement
  4609. },
  4610. arrow: {
  4611. element: Selector$6.ARROW
  4612. },
  4613. preventOverflow: {
  4614. boundariesElement: this.config.boundary
  4615. }
  4616. },
  4617. onCreate: function onCreate(data) {
  4618. if (data.originalPlacement !== data.placement) {
  4619. _this3._handlePopperPlacementChange(data);
  4620. }
  4621. },
  4622. onUpdate: function onUpdate(data) {
  4623. return _this3._handlePopperPlacementChange(data);
  4624. }
  4625. };
  4626. return _objectSpread2({}, defaultBsConfig, {}, this.config.popperConfig);
  4627. };
  4628. _proto._getOffset = function _getOffset() {
  4629. var _this4 = this;
  4630. var offset = {};
  4631. if (typeof this.config.offset === 'function') {
  4632. offset.fn = function (data) {
  4633. data.offsets = _objectSpread2({}, data.offsets, {}, _this4.config.offset(data.offsets, _this4.element) || {});
  4634. return data;
  4635. };
  4636. } else {
  4637. offset.offset = this.config.offset;
  4638. }
  4639. return offset;
  4640. };
  4641. _proto._getContainer = function _getContainer() {
  4642. if (this.config.container === false) {
  4643. return document.body;
  4644. }
  4645. if (Util.isElement(this.config.container)) {
  4646. return $(this.config.container);
  4647. }
  4648. return $(document).find(this.config.container);
  4649. };
  4650. _proto._getAttachment = function _getAttachment(placement) {
  4651. return AttachmentMap$1[placement.toUpperCase()];
  4652. };
  4653. _proto._setListeners = function _setListeners() {
  4654. var _this5 = this;
  4655. var triggers = this.config.trigger.split(' ');
  4656. triggers.forEach(function (trigger) {
  4657. if (trigger === 'click') {
  4658. $(_this5.element).on(_this5.constructor.Event.CLICK, _this5.config.selector, function (event) {
  4659. return _this5.toggle(event);
  4660. });
  4661. } else if (trigger !== Trigger.MANUAL) {
  4662. var eventIn = trigger === Trigger.HOVER ? _this5.constructor.Event.MOUSEENTER : _this5.constructor.Event.FOCUSIN;
  4663. var eventOut = trigger === Trigger.HOVER ? _this5.constructor.Event.MOUSELEAVE : _this5.constructor.Event.FOCUSOUT;
  4664. $(_this5.element).on(eventIn, _this5.config.selector, function (event) {
  4665. return _this5._enter(event);
  4666. }).on(eventOut, _this5.config.selector, function (event) {
  4667. return _this5._leave(event);
  4668. });
  4669. }
  4670. });
  4671. this._hideModalHandler = function () {
  4672. if (_this5.element) {
  4673. _this5.hide();
  4674. }
  4675. };
  4676. $(this.element).closest('.modal').on('hide.bs.modal', this._hideModalHandler);
  4677. if (this.config.selector) {
  4678. this.config = _objectSpread2({}, this.config, {
  4679. trigger: 'manual',
  4680. selector: ''
  4681. });
  4682. } else {
  4683. this._fixTitle();
  4684. }
  4685. };
  4686. _proto._fixTitle = function _fixTitle() {
  4687. var titleType = typeof this.element.getAttribute('data-original-title');
  4688. if (this.element.getAttribute('title') || titleType !== 'string') {
  4689. this.element.setAttribute('data-original-title', this.element.getAttribute('title') || '');
  4690. this.element.setAttribute('title', '');
  4691. }
  4692. };
  4693. _proto._enter = function _enter(event, context) {
  4694. var dataKey = this.constructor.DATA_KEY;
  4695. context = context || $(event.currentTarget).data(dataKey);
  4696. if (!context) {
  4697. context = new this.constructor(event.currentTarget, this._getDelegateConfig());
  4698. $(event.currentTarget).data(dataKey, context);
  4699. }
  4700. if (event) {
  4701. context._activeTrigger[event.type === 'focusin' ? Trigger.FOCUS : Trigger.HOVER] = true;
  4702. }
  4703. if ($(context.getTipElement()).hasClass(ClassName$6.SHOW) || context._hoverState === HoverState.SHOW) {
  4704. context._hoverState = HoverState.SHOW;
  4705. return;
  4706. }
  4707. clearTimeout(context._timeout);
  4708. context._hoverState = HoverState.SHOW;
  4709. if (!context.config.delay || !context.config.delay.show) {
  4710. context.show();
  4711. return;
  4712. }
  4713. context._timeout = setTimeout(function () {
  4714. if (context._hoverState === HoverState.SHOW) {
  4715. context.show();
  4716. }
  4717. }, context.config.delay.show);
  4718. };
  4719. _proto._leave = function _leave(event, context) {
  4720. var dataKey = this.constructor.DATA_KEY;
  4721. context = context || $(event.currentTarget).data(dataKey);
  4722. if (!context) {
  4723. context = new this.constructor(event.currentTarget, this._getDelegateConfig());
  4724. $(event.currentTarget).data(dataKey, context);
  4725. }
  4726. if (event) {
  4727. context._activeTrigger[event.type === 'focusout' ? Trigger.FOCUS : Trigger.HOVER] = false;
  4728. }
  4729. if (context._isWithActiveTrigger()) {
  4730. return;
  4731. }
  4732. clearTimeout(context._timeout);
  4733. context._hoverState = HoverState.OUT;
  4734. if (!context.config.delay || !context.config.delay.hide) {
  4735. context.hide();
  4736. return;
  4737. }
  4738. context._timeout = setTimeout(function () {
  4739. if (context._hoverState === HoverState.OUT) {
  4740. context.hide();
  4741. }
  4742. }, context.config.delay.hide);
  4743. };
  4744. _proto._isWithActiveTrigger = function _isWithActiveTrigger() {
  4745. for (var trigger in this._activeTrigger) {
  4746. if (this._activeTrigger[trigger]) {
  4747. return true;
  4748. }
  4749. }
  4750. return false;
  4751. };
  4752. _proto._getConfig = function _getConfig(config) {
  4753. var dataAttributes = $(this.element).data();
  4754. Object.keys(dataAttributes).forEach(function (dataAttr) {
  4755. if (DISALLOWED_ATTRIBUTES.indexOf(dataAttr) !== -1) {
  4756. delete dataAttributes[dataAttr];
  4757. }
  4758. });
  4759. config = _objectSpread2({}, this.constructor.Default, {}, dataAttributes, {}, typeof config === 'object' && config ? config : {});
  4760. if (typeof config.delay === 'number') {
  4761. config.delay = {
  4762. show: config.delay,
  4763. hide: config.delay
  4764. };
  4765. }
  4766. if (typeof config.title === 'number') {
  4767. config.title = config.title.toString();
  4768. }
  4769. if (typeof config.content === 'number') {
  4770. config.content = config.content.toString();
  4771. }
  4772. Util.typeCheckConfig(NAME$6, config, this.constructor.DefaultType);
  4773. if (config.sanitize) {
  4774. config.template = sanitizeHtml(config.template, config.whiteList, config.sanitizeFn);
  4775. }
  4776. return config;
  4777. };
  4778. _proto._getDelegateConfig = function _getDelegateConfig() {
  4779. var config = {};
  4780. if (this.config) {
  4781. for (var key in this.config) {
  4782. if (this.constructor.Default[key] !== this.config[key]) {
  4783. config[key] = this.config[key];
  4784. }
  4785. }
  4786. }
  4787. return config;
  4788. };
  4789. _proto._cleanTipClass = function _cleanTipClass() {
  4790. var $tip = $(this.getTipElement());
  4791. var tabClass = $tip.attr('class').match(BSCLS_PREFIX_REGEX);
  4792. if (tabClass !== null && tabClass.length) {
  4793. $tip.removeClass(tabClass.join(''));
  4794. }
  4795. };
  4796. _proto._handlePopperPlacementChange = function _handlePopperPlacementChange(popperData) {
  4797. var popperInstance = popperData.instance;
  4798. this.tip = popperInstance.popper;
  4799. this._cleanTipClass();
  4800. this.addAttachmentClass(this._getAttachment(popperData.placement));
  4801. };
  4802. _proto._fixTransition = function _fixTransition() {
  4803. var tip = this.getTipElement();
  4804. var initConfigAnimation = this.config.animation;
  4805. if (tip.getAttribute('x-placement') !== null) {
  4806. return;
  4807. }
  4808. $(tip).removeClass(ClassName$6.FADE);
  4809. this.config.animation = false;
  4810. this.hide();
  4811. this.show();
  4812. this.config.animation = initConfigAnimation;
  4813. } // Static
  4814. ;
  4815. Tooltip._jQueryInterface = function _jQueryInterface(config) {
  4816. return this.each(function () {
  4817. var data = $(this).data(DATA_KEY$6);
  4818. var _config = typeof config === 'object' && config;
  4819. if (!data && /dispose|hide/.test(config)) {
  4820. return;
  4821. }
  4822. if (!data) {
  4823. data = new Tooltip(this, _config);
  4824. $(this).data(DATA_KEY$6, data);
  4825. }
  4826. if (typeof config === 'string') {
  4827. if (typeof data[config] === 'undefined') {
  4828. throw new TypeError("No method named \"" + config + "\"");
  4829. }
  4830. data[config]();
  4831. }
  4832. });
  4833. };
  4834. _createClass(Tooltip, null, [{
  4835. key: "VERSION",
  4836. get: function get() {
  4837. return VERSION$6;
  4838. }
  4839. }, {
  4840. key: "Default",
  4841. get: function get() {
  4842. return Default$4;
  4843. }
  4844. }, {
  4845. key: "NAME",
  4846. get: function get() {
  4847. return NAME$6;
  4848. }
  4849. }, {
  4850. key: "DATA_KEY",
  4851. get: function get() {
  4852. return DATA_KEY$6;
  4853. }
  4854. }, {
  4855. key: "Event",
  4856. get: function get() {
  4857. return Event$6;
  4858. }
  4859. }, {
  4860. key: "EVENT_KEY",
  4861. get: function get() {
  4862. return EVENT_KEY$6;
  4863. }
  4864. }, {
  4865. key: "DefaultType",
  4866. get: function get() {
  4867. return DefaultType$4;
  4868. }
  4869. }]);
  4870. return Tooltip;
  4871. }();
  4872. /**
  4873. * ------------------------------------------------------------------------
  4874. * jQuery
  4875. * ------------------------------------------------------------------------
  4876. */
  4877. $.fn[NAME$6] = Tooltip._jQueryInterface;
  4878. $.fn[NAME$6].Constructor = Tooltip;
  4879. $.fn[NAME$6].noConflict = function () {
  4880. $.fn[NAME$6] = JQUERY_NO_CONFLICT$6;
  4881. return Tooltip._jQueryInterface;
  4882. };
  4883. /**
  4884. * ------------------------------------------------------------------------
  4885. * Constants
  4886. * ------------------------------------------------------------------------
  4887. */
  4888. var NAME$7 = 'popover';
  4889. var VERSION$7 = '4.4.1';
  4890. var DATA_KEY$7 = 'bs.popover';
  4891. var EVENT_KEY$7 = "." + DATA_KEY$7;
  4892. var JQUERY_NO_CONFLICT$7 = $.fn[NAME$7];
  4893. var CLASS_PREFIX$1 = 'bs-popover';
  4894. var BSCLS_PREFIX_REGEX$1 = new RegExp("(^|\\s)" + CLASS_PREFIX$1 + "\\S+", 'g');
  4895. var Default$5 = _objectSpread2({}, Tooltip.Default, {
  4896. placement: 'right',
  4897. trigger: 'click',
  4898. content: '',
  4899. template: '<div class="popover" role="tooltip">' + '<div class="arrow"></div>' + '<h3 class="popover-header"></h3>' + '<div class="popover-body"></div></div>'
  4900. });
  4901. var DefaultType$5 = _objectSpread2({}, Tooltip.DefaultType, {
  4902. content: '(string|element|function)'
  4903. });
  4904. var ClassName$7 = {
  4905. FADE: 'fade',
  4906. SHOW: 'show'
  4907. };
  4908. var Selector$7 = {
  4909. TITLE: '.popover-header',
  4910. CONTENT: '.popover-body'
  4911. };
  4912. var Event$7 = {
  4913. HIDE: "hide" + EVENT_KEY$7,
  4914. HIDDEN: "hidden" + EVENT_KEY$7,
  4915. SHOW: "show" + EVENT_KEY$7,
  4916. SHOWN: "shown" + EVENT_KEY$7,
  4917. INSERTED: "inserted" + EVENT_KEY$7,
  4918. CLICK: "click" + EVENT_KEY$7,
  4919. FOCUSIN: "focusin" + EVENT_KEY$7,
  4920. FOCUSOUT: "focusout" + EVENT_KEY$7,
  4921. MOUSEENTER: "mouseenter" + EVENT_KEY$7,
  4922. MOUSELEAVE: "mouseleave" + EVENT_KEY$7
  4923. };
  4924. /**
  4925. * ------------------------------------------------------------------------
  4926. * Class Definition
  4927. * ------------------------------------------------------------------------
  4928. */
  4929. var Popover =
  4930. /*#__PURE__*/
  4931. function (_Tooltip) {
  4932. _inheritsLoose(Popover, _Tooltip);
  4933. function Popover() {
  4934. return _Tooltip.apply(this, arguments) || this;
  4935. }
  4936. var _proto = Popover.prototype;
  4937. // Overrides
  4938. _proto.isWithContent = function isWithContent() {
  4939. return this.getTitle() || this._getContent();
  4940. };
  4941. _proto.addAttachmentClass = function addAttachmentClass(attachment) {
  4942. $(this.getTipElement()).addClass(CLASS_PREFIX$1 + "-" + attachment);
  4943. };
  4944. _proto.getTipElement = function getTipElement() {
  4945. this.tip = this.tip || $(this.config.template)[0];
  4946. return this.tip;
  4947. };
  4948. _proto.setContent = function setContent() {
  4949. var $tip = $(this.getTipElement()); // We use append for html objects to maintain js events
  4950. this.setElementContent($tip.find(Selector$7.TITLE), this.getTitle());
  4951. var content = this._getContent();
  4952. if (typeof content === 'function') {
  4953. content = content.call(this.element);
  4954. }
  4955. this.setElementContent($tip.find(Selector$7.CONTENT), content);
  4956. $tip.removeClass(ClassName$7.FADE + " " + ClassName$7.SHOW);
  4957. } // Private
  4958. ;
  4959. _proto._getContent = function _getContent() {
  4960. return this.element.getAttribute('data-content') || this.config.content;
  4961. };
  4962. _proto._cleanTipClass = function _cleanTipClass() {
  4963. var $tip = $(this.getTipElement());
  4964. var tabClass = $tip.attr('class').match(BSCLS_PREFIX_REGEX$1);
  4965. if (tabClass !== null && tabClass.length > 0) {
  4966. $tip.removeClass(tabClass.join(''));
  4967. }
  4968. } // Static
  4969. ;
  4970. Popover._jQueryInterface = function _jQueryInterface(config) {
  4971. return this.each(function () {
  4972. var data = $(this).data(DATA_KEY$7);
  4973. var _config = typeof config === 'object' ? config : null;
  4974. if (!data && /dispose|hide/.test(config)) {
  4975. return;
  4976. }
  4977. if (!data) {
  4978. data = new Popover(this, _config);
  4979. $(this).data(DATA_KEY$7, data);
  4980. }
  4981. if (typeof config === 'string') {
  4982. if (typeof data[config] === 'undefined') {
  4983. throw new TypeError("No method named \"" + config + "\"");
  4984. }
  4985. data[config]();
  4986. }
  4987. });
  4988. };
  4989. _createClass(Popover, null, [{
  4990. key: "VERSION",
  4991. // Getters
  4992. get: function get() {
  4993. return VERSION$7;
  4994. }
  4995. }, {
  4996. key: "Default",
  4997. get: function get() {
  4998. return Default$5;
  4999. }
  5000. }, {
  5001. key: "NAME",
  5002. get: function get() {
  5003. return NAME$7;
  5004. }
  5005. }, {
  5006. key: "DATA_KEY",
  5007. get: function get() {
  5008. return DATA_KEY$7;
  5009. }
  5010. }, {
  5011. key: "Event",
  5012. get: function get() {
  5013. return Event$7;
  5014. }
  5015. }, {
  5016. key: "EVENT_KEY",
  5017. get: function get() {
  5018. return EVENT_KEY$7;
  5019. }
  5020. }, {
  5021. key: "DefaultType",
  5022. get: function get() {
  5023. return DefaultType$5;
  5024. }
  5025. }]);
  5026. return Popover;
  5027. }(Tooltip);
  5028. /**
  5029. * ------------------------------------------------------------------------
  5030. * jQuery
  5031. * ------------------------------------------------------------------------
  5032. */
  5033. $.fn[NAME$7] = Popover._jQueryInterface;
  5034. $.fn[NAME$7].Constructor = Popover;
  5035. $.fn[NAME$7].noConflict = function () {
  5036. $.fn[NAME$7] = JQUERY_NO_CONFLICT$7;
  5037. return Popover._jQueryInterface;
  5038. };
  5039. /**
  5040. * ------------------------------------------------------------------------
  5041. * Constants
  5042. * ------------------------------------------------------------------------
  5043. */
  5044. var NAME$8 = 'scrollspy';
  5045. var VERSION$8 = '4.4.1';
  5046. var DATA_KEY$8 = 'bs.scrollspy';
  5047. var EVENT_KEY$8 = "." + DATA_KEY$8;
  5048. var DATA_API_KEY$6 = '.data-api';
  5049. var JQUERY_NO_CONFLICT$8 = $.fn[NAME$8];
  5050. var Default$6 = {
  5051. offset: 10,
  5052. method: 'auto',
  5053. target: ''
  5054. };
  5055. var DefaultType$6 = {
  5056. offset: 'number',
  5057. method: 'string',
  5058. target: '(string|element)'
  5059. };
  5060. var Event$8 = {
  5061. ACTIVATE: "activate" + EVENT_KEY$8,
  5062. SCROLL: "scroll" + EVENT_KEY$8,
  5063. LOAD_DATA_API: "load" + EVENT_KEY$8 + DATA_API_KEY$6
  5064. };
  5065. var ClassName$8 = {
  5066. DROPDOWN_ITEM: 'dropdown-item',
  5067. DROPDOWN_MENU: 'dropdown-menu',
  5068. ACTIVE: 'active'
  5069. };
  5070. var Selector$8 = {
  5071. DATA_SPY: '[data-spy="scroll"]',
  5072. ACTIVE: '.active',
  5073. NAV_LIST_GROUP: '.nav, .list-group',
  5074. NAV_LINKS: '.nav-link',
  5075. NAV_ITEMS: '.nav-item',
  5076. LIST_ITEMS: '.list-group-item',
  5077. DROPDOWN: '.dropdown',
  5078. DROPDOWN_ITEMS: '.dropdown-item',
  5079. DROPDOWN_TOGGLE: '.dropdown-toggle'
  5080. };
  5081. var OffsetMethod = {
  5082. OFFSET: 'offset',
  5083. POSITION: 'position'
  5084. };
  5085. /**
  5086. * ------------------------------------------------------------------------
  5087. * Class Definition
  5088. * ------------------------------------------------------------------------
  5089. */
  5090. var ScrollSpy =
  5091. /*#__PURE__*/
  5092. function () {
  5093. function ScrollSpy(element, config) {
  5094. var _this = this;
  5095. this._element = element;
  5096. this._scrollElement = element.tagName === 'BODY' ? window : element;
  5097. this._config = this._getConfig(config);
  5098. this._selector = this._config.target + " " + Selector$8.NAV_LINKS + "," + (this._config.target + " " + Selector$8.LIST_ITEMS + ",") + (this._config.target + " " + Selector$8.DROPDOWN_ITEMS);
  5099. this._offsets = [];
  5100. this._targets = [];
  5101. this._activeTarget = null;
  5102. this._scrollHeight = 0;
  5103. $(this._scrollElement).on(Event$8.SCROLL, function (event) {
  5104. return _this._process(event);
  5105. });
  5106. this.refresh();
  5107. this._process();
  5108. } // Getters
  5109. var _proto = ScrollSpy.prototype;
  5110. // Public
  5111. _proto.refresh = function refresh() {
  5112. var _this2 = this;
  5113. var autoMethod = this._scrollElement === this._scrollElement.window ? OffsetMethod.OFFSET : OffsetMethod.POSITION;
  5114. var offsetMethod = this._config.method === 'auto' ? autoMethod : this._config.method;
  5115. var offsetBase = offsetMethod === OffsetMethod.POSITION ? this._getScrollTop() : 0;
  5116. this._offsets = [];
  5117. this._targets = [];
  5118. this._scrollHeight = this._getScrollHeight();
  5119. var targets = [].slice.call(document.querySelectorAll(this._selector));
  5120. targets.map(function (element) {
  5121. var target;
  5122. var targetSelector = Util.getSelectorFromElement(element);
  5123. if (targetSelector) {
  5124. target = document.querySelector(targetSelector);
  5125. }
  5126. if (target) {
  5127. var targetBCR = target.getBoundingClientRect();
  5128. if (targetBCR.width || targetBCR.height) {
  5129. // TODO (fat): remove sketch reliance on jQuery position/offset
  5130. return [$(target)[offsetMethod]().top + offsetBase, targetSelector];
  5131. }
  5132. }
  5133. return null;
  5134. }).filter(function (item) {
  5135. return item;
  5136. }).sort(function (a, b) {
  5137. return a[0] - b[0];
  5138. }).forEach(function (item) {
  5139. _this2._offsets.push(item[0]);
  5140. _this2._targets.push(item[1]);
  5141. });
  5142. };
  5143. _proto.dispose = function dispose() {
  5144. $.removeData(this._element, DATA_KEY$8);
  5145. $(this._scrollElement).off(EVENT_KEY$8);
  5146. this._element = null;
  5147. this._scrollElement = null;
  5148. this._config = null;
  5149. this._selector = null;
  5150. this._offsets = null;
  5151. this._targets = null;
  5152. this._activeTarget = null;
  5153. this._scrollHeight = null;
  5154. } // Private
  5155. ;
  5156. _proto._getConfig = function _getConfig(config) {
  5157. config = _objectSpread2({}, Default$6, {}, typeof config === 'object' && config ? config : {});
  5158. if (typeof config.target !== 'string') {
  5159. var id = $(config.target).attr('id');
  5160. if (!id) {
  5161. id = Util.getUID(NAME$8);
  5162. $(config.target).attr('id', id);
  5163. }
  5164. config.target = "#" + id;
  5165. }
  5166. Util.typeCheckConfig(NAME$8, config, DefaultType$6);
  5167. return config;
  5168. };
  5169. _proto._getScrollTop = function _getScrollTop() {
  5170. return this._scrollElement === window ? this._scrollElement.pageYOffset : this._scrollElement.scrollTop;
  5171. };
  5172. _proto._getScrollHeight = function _getScrollHeight() {
  5173. return this._scrollElement.scrollHeight || Math.max(document.body.scrollHeight, document.documentElement.scrollHeight);
  5174. };
  5175. _proto._getOffsetHeight = function _getOffsetHeight() {
  5176. return this._scrollElement === window ? window.innerHeight : this._scrollElement.getBoundingClientRect().height;
  5177. };
  5178. _proto._process = function _process() {
  5179. var scrollTop = this._getScrollTop() + this._config.offset;
  5180. var scrollHeight = this._getScrollHeight();
  5181. var maxScroll = this._config.offset + scrollHeight - this._getOffsetHeight();
  5182. if (this._scrollHeight !== scrollHeight) {
  5183. this.refresh();
  5184. }
  5185. if (scrollTop >= maxScroll) {
  5186. var target = this._targets[this._targets.length - 1];
  5187. if (this._activeTarget !== target) {
  5188. this._activate(target);
  5189. }
  5190. return;
  5191. }
  5192. if (this._activeTarget && scrollTop < this._offsets[0] && this._offsets[0] > 0) {
  5193. this._activeTarget = null;
  5194. this._clear();
  5195. return;
  5196. }
  5197. var offsetLength = this._offsets.length;
  5198. for (var i = offsetLength; i--;) {
  5199. var isActiveTarget = this._activeTarget !== this._targets[i] && scrollTop >= this._offsets[i] && (typeof this._offsets[i + 1] === 'undefined' || scrollTop < this._offsets[i + 1]);
  5200. if (isActiveTarget) {
  5201. this._activate(this._targets[i]);
  5202. }
  5203. }
  5204. };
  5205. _proto._activate = function _activate(target) {
  5206. this._activeTarget = target;
  5207. this._clear();
  5208. var queries = this._selector.split(',').map(function (selector) {
  5209. return selector + "[data-target=\"" + target + "\"]," + selector + "[href=\"" + target + "\"]";
  5210. });
  5211. var $link = $([].slice.call(document.querySelectorAll(queries.join(','))));
  5212. if ($link.hasClass(ClassName$8.DROPDOWN_ITEM)) {
  5213. $link.closest(Selector$8.DROPDOWN).find(Selector$8.DROPDOWN_TOGGLE).addClass(ClassName$8.ACTIVE);
  5214. $link.addClass(ClassName$8.ACTIVE);
  5215. } else {
  5216. // Set triggered link as active
  5217. $link.addClass(ClassName$8.ACTIVE); // Set triggered links parents as active
  5218. // With both <ul> and <nav> markup a parent is the previous sibling of any nav ancestor
  5219. $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
  5220. $link.parents(Selector$8.NAV_LIST_GROUP).prev(Selector$8.NAV_ITEMS).children(Selector$8.NAV_LINKS).addClass(ClassName$8.ACTIVE);
  5221. }
  5222. $(this._scrollElement).trigger(Event$8.ACTIVATE, {
  5223. relatedTarget: target
  5224. });
  5225. };
  5226. _proto._clear = function _clear() {
  5227. [].slice.call(document.querySelectorAll(this._selector)).filter(function (node) {
  5228. return node.classList.contains(ClassName$8.ACTIVE);
  5229. }).forEach(function (node) {
  5230. return node.classList.remove(ClassName$8.ACTIVE);
  5231. });
  5232. } // Static
  5233. ;
  5234. ScrollSpy._jQueryInterface = function _jQueryInterface(config) {
  5235. return this.each(function () {
  5236. var data = $(this).data(DATA_KEY$8);
  5237. var _config = typeof config === 'object' && config;
  5238. if (!data) {
  5239. data = new ScrollSpy(this, _config);
  5240. $(this).data(DATA_KEY$8, data);
  5241. }
  5242. if (typeof config === 'string') {
  5243. if (typeof data[config] === 'undefined') {
  5244. throw new TypeError("No method named \"" + config + "\"");
  5245. }
  5246. data[config]();
  5247. }
  5248. });
  5249. };
  5250. _createClass(ScrollSpy, null, [{
  5251. key: "VERSION",
  5252. get: function get() {
  5253. return VERSION$8;
  5254. }
  5255. }, {
  5256. key: "Default",
  5257. get: function get() {
  5258. return Default$6;
  5259. }
  5260. }]);
  5261. return ScrollSpy;
  5262. }();
  5263. /**
  5264. * ------------------------------------------------------------------------
  5265. * Data Api implementation
  5266. * ------------------------------------------------------------------------
  5267. */
  5268. $(window).on(Event$8.LOAD_DATA_API, function () {
  5269. var scrollSpys = [].slice.call(document.querySelectorAll(Selector$8.DATA_SPY));
  5270. var scrollSpysLength = scrollSpys.length;
  5271. for (var i = scrollSpysLength; i--;) {
  5272. var $spy = $(scrollSpys[i]);
  5273. ScrollSpy._jQueryInterface.call($spy, $spy.data());
  5274. }
  5275. });
  5276. /**
  5277. * ------------------------------------------------------------------------
  5278. * jQuery
  5279. * ------------------------------------------------------------------------
  5280. */
  5281. $.fn[NAME$8] = ScrollSpy._jQueryInterface;
  5282. $.fn[NAME$8].Constructor = ScrollSpy;
  5283. $.fn[NAME$8].noConflict = function () {
  5284. $.fn[NAME$8] = JQUERY_NO_CONFLICT$8;
  5285. return ScrollSpy._jQueryInterface;
  5286. };
  5287. /**
  5288. * ------------------------------------------------------------------------
  5289. * Constants
  5290. * ------------------------------------------------------------------------
  5291. */
  5292. var NAME$9 = 'tab';
  5293. var VERSION$9 = '4.4.1';
  5294. var DATA_KEY$9 = 'bs.tab';
  5295. var EVENT_KEY$9 = "." + DATA_KEY$9;
  5296. var DATA_API_KEY$7 = '.data-api';
  5297. var JQUERY_NO_CONFLICT$9 = $.fn[NAME$9];
  5298. var Event$9 = {
  5299. HIDE: "hide" + EVENT_KEY$9,
  5300. HIDDEN: "hidden" + EVENT_KEY$9,
  5301. SHOW: "show" + EVENT_KEY$9,
  5302. SHOWN: "shown" + EVENT_KEY$9,
  5303. CLICK_DATA_API: "click" + EVENT_KEY$9 + DATA_API_KEY$7
  5304. };
  5305. var ClassName$9 = {
  5306. DROPDOWN_MENU: 'dropdown-menu',
  5307. ACTIVE: 'active',
  5308. DISABLED: 'disabled',
  5309. FADE: 'fade',
  5310. SHOW: 'show'
  5311. };
  5312. var Selector$9 = {
  5313. DROPDOWN: '.dropdown',
  5314. NAV_LIST_GROUP: '.nav, .list-group',
  5315. ACTIVE: '.active',
  5316. ACTIVE_UL: '> li > .active',
  5317. DATA_TOGGLE: '[data-toggle="tab"], [data-toggle="pill"], [data-toggle="list"]',
  5318. DROPDOWN_TOGGLE: '.dropdown-toggle',
  5319. DROPDOWN_ACTIVE_CHILD: '> .dropdown-menu .active'
  5320. };
  5321. /**
  5322. * ------------------------------------------------------------------------
  5323. * Class Definition
  5324. * ------------------------------------------------------------------------
  5325. */
  5326. var Tab =
  5327. /*#__PURE__*/
  5328. function () {
  5329. function Tab(element) {
  5330. this._element = element;
  5331. } // Getters
  5332. var _proto = Tab.prototype;
  5333. // Public
  5334. _proto.show = function show() {
  5335. var _this = this;
  5336. if (this._element.parentNode && this._element.parentNode.nodeType === Node.ELEMENT_NODE && $(this._element).hasClass(ClassName$9.ACTIVE) || $(this._element).hasClass(ClassName$9.DISABLED)) {
  5337. return;
  5338. }
  5339. var target;
  5340. var previous;
  5341. var listElement = $(this._element).closest(Selector$9.NAV_LIST_GROUP)[0];
  5342. var selector = Util.getSelectorFromElement(this._element);
  5343. if (listElement) {
  5344. var itemSelector = listElement.nodeName === 'UL' || listElement.nodeName === 'OL' ? Selector$9.ACTIVE_UL : Selector$9.ACTIVE;
  5345. previous = $.makeArray($(listElement).find(itemSelector));
  5346. previous = previous[previous.length - 1];
  5347. }
  5348. var hideEvent = $.Event(Event$9.HIDE, {
  5349. relatedTarget: this._element
  5350. });
  5351. var showEvent = $.Event(Event$9.SHOW, {
  5352. relatedTarget: previous
  5353. });
  5354. if (previous) {
  5355. $(previous).trigger(hideEvent);
  5356. }
  5357. $(this._element).trigger(showEvent);
  5358. if (showEvent.isDefaultPrevented() || hideEvent.isDefaultPrevented()) {
  5359. return;
  5360. }
  5361. if (selector) {
  5362. target = document.querySelector(selector);
  5363. }
  5364. this._activate(this._element, listElement);
  5365. var complete = function complete() {
  5366. var hiddenEvent = $.Event(Event$9.HIDDEN, {
  5367. relatedTarget: _this._element
  5368. });
  5369. var shownEvent = $.Event(Event$9.SHOWN, {
  5370. relatedTarget: previous
  5371. });
  5372. $(previous).trigger(hiddenEvent);
  5373. $(_this._element).trigger(shownEvent);
  5374. };
  5375. if (target) {
  5376. this._activate(target, target.parentNode, complete);
  5377. } else {
  5378. complete();
  5379. }
  5380. };
  5381. _proto.dispose = function dispose() {
  5382. $.removeData(this._element, DATA_KEY$9);
  5383. this._element = null;
  5384. } // Private
  5385. ;
  5386. _proto._activate = function _activate(element, container, callback) {
  5387. var _this2 = this;
  5388. var activeElements = container && (container.nodeName === 'UL' || container.nodeName === 'OL') ? $(container).find(Selector$9.ACTIVE_UL) : $(container).children(Selector$9.ACTIVE);
  5389. var active = activeElements[0];
  5390. var isTransitioning = callback && active && $(active).hasClass(ClassName$9.FADE);
  5391. var complete = function complete() {
  5392. return _this2._transitionComplete(element, active, callback);
  5393. };
  5394. if (active && isTransitioning) {
  5395. var transitionDuration = Util.getTransitionDurationFromElement(active);
  5396. $(active).removeClass(ClassName$9.SHOW).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration);
  5397. } else {
  5398. complete();
  5399. }
  5400. };
  5401. _proto._transitionComplete = function _transitionComplete(element, active, callback) {
  5402. if (active) {
  5403. $(active).removeClass(ClassName$9.ACTIVE);
  5404. var dropdownChild = $(active.parentNode).find(Selector$9.DROPDOWN_ACTIVE_CHILD)[0];
  5405. if (dropdownChild) {
  5406. $(dropdownChild).removeClass(ClassName$9.ACTIVE);
  5407. }
  5408. if (active.getAttribute('role') === 'tab') {
  5409. active.setAttribute('aria-selected', false);
  5410. }
  5411. }
  5412. $(element).addClass(ClassName$9.ACTIVE);
  5413. if (element.getAttribute('role') === 'tab') {
  5414. element.setAttribute('aria-selected', true);
  5415. }
  5416. Util.reflow(element);
  5417. if (element.classList.contains(ClassName$9.FADE)) {
  5418. element.classList.add(ClassName$9.SHOW);
  5419. }
  5420. if (element.parentNode && $(element.parentNode).hasClass(ClassName$9.DROPDOWN_MENU)) {
  5421. var dropdownElement = $(element).closest(Selector$9.DROPDOWN)[0];
  5422. if (dropdownElement) {
  5423. var dropdownToggleList = [].slice.call(dropdownElement.querySelectorAll(Selector$9.DROPDOWN_TOGGLE));
  5424. $(dropdownToggleList).addClass(ClassName$9.ACTIVE);
  5425. }
  5426. element.setAttribute('aria-expanded', true);
  5427. }
  5428. if (callback) {
  5429. callback();
  5430. }
  5431. } // Static
  5432. ;
  5433. Tab._jQueryInterface = function _jQueryInterface(config) {
  5434. return this.each(function () {
  5435. var $this = $(this);
  5436. var data = $this.data(DATA_KEY$9);
  5437. if (!data) {
  5438. data = new Tab(this);
  5439. $this.data(DATA_KEY$9, data);
  5440. }
  5441. if (typeof config === 'string') {
  5442. if (typeof data[config] === 'undefined') {
  5443. throw new TypeError("No method named \"" + config + "\"");
  5444. }
  5445. data[config]();
  5446. }
  5447. });
  5448. };
  5449. _createClass(Tab, null, [{
  5450. key: "VERSION",
  5451. get: function get() {
  5452. return VERSION$9;
  5453. }
  5454. }]);
  5455. return Tab;
  5456. }();
  5457. /**
  5458. * ------------------------------------------------------------------------
  5459. * Data Api implementation
  5460. * ------------------------------------------------------------------------
  5461. */
  5462. $(document).on(Event$9.CLICK_DATA_API, Selector$9.DATA_TOGGLE, function (event) {
  5463. event.preventDefault();
  5464. Tab._jQueryInterface.call($(this), 'show');
  5465. });
  5466. /**
  5467. * ------------------------------------------------------------------------
  5468. * jQuery
  5469. * ------------------------------------------------------------------------
  5470. */
  5471. $.fn[NAME$9] = Tab._jQueryInterface;
  5472. $.fn[NAME$9].Constructor = Tab;
  5473. $.fn[NAME$9].noConflict = function () {
  5474. $.fn[NAME$9] = JQUERY_NO_CONFLICT$9;
  5475. return Tab._jQueryInterface;
  5476. };
  5477. /**
  5478. * ------------------------------------------------------------------------
  5479. * Constants
  5480. * ------------------------------------------------------------------------
  5481. */
  5482. var NAME$a = 'toast';
  5483. var VERSION$a = '4.4.1';
  5484. var DATA_KEY$a = 'bs.toast';
  5485. var EVENT_KEY$a = "." + DATA_KEY$a;
  5486. var JQUERY_NO_CONFLICT$a = $.fn[NAME$a];
  5487. var Event$a = {
  5488. CLICK_DISMISS: "click.dismiss" + EVENT_KEY$a,
  5489. HIDE: "hide" + EVENT_KEY$a,
  5490. HIDDEN: "hidden" + EVENT_KEY$a,
  5491. SHOW: "show" + EVENT_KEY$a,
  5492. SHOWN: "shown" + EVENT_KEY$a
  5493. };
  5494. var ClassName$a = {
  5495. FADE: 'fade',
  5496. HIDE: 'hide',
  5497. SHOW: 'show',
  5498. SHOWING: 'showing'
  5499. };
  5500. var DefaultType$7 = {
  5501. animation: 'boolean',
  5502. autohide: 'boolean',
  5503. delay: 'number'
  5504. };
  5505. var Default$7 = {
  5506. animation: true,
  5507. autohide: true,
  5508. delay: 500
  5509. };
  5510. var Selector$a = {
  5511. DATA_DISMISS: '[data-dismiss="toast"]'
  5512. };
  5513. /**
  5514. * ------------------------------------------------------------------------
  5515. * Class Definition
  5516. * ------------------------------------------------------------------------
  5517. */
  5518. var Toast =
  5519. /*#__PURE__*/
  5520. function () {
  5521. function Toast(element, config) {
  5522. this._element = element;
  5523. this._config = this._getConfig(config);
  5524. this._timeout = null;
  5525. this._setListeners();
  5526. } // Getters
  5527. var _proto = Toast.prototype;
  5528. // Public
  5529. _proto.show = function show() {
  5530. var _this = this;
  5531. var showEvent = $.Event(Event$a.SHOW);
  5532. $(this._element).trigger(showEvent);
  5533. if (showEvent.isDefaultPrevented()) {
  5534. return;
  5535. }
  5536. if (this._config.animation) {
  5537. this._element.classList.add(ClassName$a.FADE);
  5538. }
  5539. var complete = function complete() {
  5540. _this._element.classList.remove(ClassName$a.SHOWING);
  5541. _this._element.classList.add(ClassName$a.SHOW);
  5542. $(_this._element).trigger(Event$a.SHOWN);
  5543. if (_this._config.autohide) {
  5544. _this._timeout = setTimeout(function () {
  5545. _this.hide();
  5546. }, _this._config.delay);
  5547. }
  5548. };
  5549. this._element.classList.remove(ClassName$a.HIDE);
  5550. Util.reflow(this._element);
  5551. this._element.classList.add(ClassName$a.SHOWING);
  5552. if (this._config.animation) {
  5553. var transitionDuration = Util.getTransitionDurationFromElement(this._element);
  5554. $(this._element).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration);
  5555. } else {
  5556. complete();
  5557. }
  5558. };
  5559. _proto.hide = function hide() {
  5560. if (!this._element.classList.contains(ClassName$a.SHOW)) {
  5561. return;
  5562. }
  5563. var hideEvent = $.Event(Event$a.HIDE);
  5564. $(this._element).trigger(hideEvent);
  5565. if (hideEvent.isDefaultPrevented()) {
  5566. return;
  5567. }
  5568. this._close();
  5569. };
  5570. _proto.dispose = function dispose() {
  5571. clearTimeout(this._timeout);
  5572. this._timeout = null;
  5573. if (this._element.classList.contains(ClassName$a.SHOW)) {
  5574. this._element.classList.remove(ClassName$a.SHOW);
  5575. }
  5576. $(this._element).off(Event$a.CLICK_DISMISS);
  5577. $.removeData(this._element, DATA_KEY$a);
  5578. this._element = null;
  5579. this._config = null;
  5580. } // Private
  5581. ;
  5582. _proto._getConfig = function _getConfig(config) {
  5583. config = _objectSpread2({}, Default$7, {}, $(this._element).data(), {}, typeof config === 'object' && config ? config : {});
  5584. Util.typeCheckConfig(NAME$a, config, this.constructor.DefaultType);
  5585. return config;
  5586. };
  5587. _proto._setListeners = function _setListeners() {
  5588. var _this2 = this;
  5589. $(this._element).on(Event$a.CLICK_DISMISS, Selector$a.DATA_DISMISS, function () {
  5590. return _this2.hide();
  5591. });
  5592. };
  5593. _proto._close = function _close() {
  5594. var _this3 = this;
  5595. var complete = function complete() {
  5596. _this3._element.classList.add(ClassName$a.HIDE);
  5597. $(_this3._element).trigger(Event$a.HIDDEN);
  5598. };
  5599. this._element.classList.remove(ClassName$a.SHOW);
  5600. if (this._config.animation) {
  5601. var transitionDuration = Util.getTransitionDurationFromElement(this._element);
  5602. $(this._element).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration);
  5603. } else {
  5604. complete();
  5605. }
  5606. } // Static
  5607. ;
  5608. Toast._jQueryInterface = function _jQueryInterface(config) {
  5609. return this.each(function () {
  5610. var $element = $(this);
  5611. var data = $element.data(DATA_KEY$a);
  5612. var _config = typeof config === 'object' && config;
  5613. if (!data) {
  5614. data = new Toast(this, _config);
  5615. $element.data(DATA_KEY$a, data);
  5616. }
  5617. if (typeof config === 'string') {
  5618. if (typeof data[config] === 'undefined') {
  5619. throw new TypeError("No method named \"" + config + "\"");
  5620. }
  5621. data[config](this);
  5622. }
  5623. });
  5624. };
  5625. _createClass(Toast, null, [{
  5626. key: "VERSION",
  5627. get: function get() {
  5628. return VERSION$a;
  5629. }
  5630. }, {
  5631. key: "DefaultType",
  5632. get: function get() {
  5633. return DefaultType$7;
  5634. }
  5635. }, {
  5636. key: "Default",
  5637. get: function get() {
  5638. return Default$7;
  5639. }
  5640. }]);
  5641. return Toast;
  5642. }();
  5643. /**
  5644. * ------------------------------------------------------------------------
  5645. * jQuery
  5646. * ------------------------------------------------------------------------
  5647. */
  5648. $.fn[NAME$a] = Toast._jQueryInterface;
  5649. $.fn[NAME$a].Constructor = Toast;
  5650. $.fn[NAME$a].noConflict = function () {
  5651. $.fn[NAME$a] = JQUERY_NO_CONFLICT$a;
  5652. return Toast._jQueryInterface;
  5653. };
  5654. exports.Alert = Alert;
  5655. exports.Button = Button;
  5656. exports.Carousel = Carousel;
  5657. exports.Collapse = Collapse;
  5658. exports.Dropdown = Dropdown;
  5659. exports.Modal = Modal;
  5660. exports.Popover = Popover;
  5661. exports.Scrollspy = ScrollSpy;
  5662. exports.Tab = Tab;
  5663. exports.Toast = Toast;
  5664. exports.Tooltip = Tooltip;
  5665. exports.Util = Util;
  5666. Object.defineProperty(exports, '__esModule', { value: true });
  5667. })));
  5668. //# sourceMappingURL=bootstrap.js.map
  5669. /***/ }),
  5670. /***/ "./node_modules/buffer/index.js":
  5671. /*!**************************************!*\
  5672. !*** ./node_modules/buffer/index.js ***!
  5673. \**************************************/
  5674. /*! no static exports found */
  5675. /***/ (function(module, exports, __webpack_require__) {
  5676. "use strict";
  5677. /* WEBPACK VAR INJECTION */(function(global) {/*!
  5678. * The buffer module from node.js, for the browser.
  5679. *
  5680. * @author Feross Aboukhadijeh <http://feross.org>
  5681. * @license MIT
  5682. */
  5683. /* eslint-disable no-proto */
  5684. var base64 = __webpack_require__(/*! base64-js */ "./node_modules/base64-js/index.js")
  5685. var ieee754 = __webpack_require__(/*! ieee754 */ "./node_modules/ieee754/index.js")
  5686. var isArray = __webpack_require__(/*! isarray */ "./node_modules/isarray/index.js")
  5687. exports.Buffer = Buffer
  5688. exports.SlowBuffer = SlowBuffer
  5689. exports.INSPECT_MAX_BYTES = 50
  5690. /**
  5691. * If `Buffer.TYPED_ARRAY_SUPPORT`:
  5692. * === true Use Uint8Array implementation (fastest)
  5693. * === false Use Object implementation (most compatible, even IE6)
  5694. *
  5695. * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,
  5696. * Opera 11.6+, iOS 4.2+.
  5697. *
  5698. * Due to various browser bugs, sometimes the Object implementation will be used even
  5699. * when the browser supports typed arrays.
  5700. *
  5701. * Note:
  5702. *
  5703. * - Firefox 4-29 lacks support for adding new properties to `Uint8Array` instances,
  5704. * See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438.
  5705. *
  5706. * - Chrome 9-10 is missing the `TypedArray.prototype.subarray` function.
  5707. *
  5708. * - IE10 has a broken `TypedArray.prototype.subarray` function which returns arrays of
  5709. * incorrect length in some situations.
  5710. * We detect these buggy browsers and set `Buffer.TYPED_ARRAY_SUPPORT` to `false` so they
  5711. * get the Object implementation, which is slower but behaves correctly.
  5712. */
  5713. Buffer.TYPED_ARRAY_SUPPORT = global.TYPED_ARRAY_SUPPORT !== undefined
  5714. ? global.TYPED_ARRAY_SUPPORT
  5715. : typedArraySupport()
  5716. /*
  5717. * Export kMaxLength after typed array support is determined.
  5718. */
  5719. exports.kMaxLength = kMaxLength()
  5720. function typedArraySupport () {
  5721. try {
  5722. var arr = new Uint8Array(1)
  5723. arr.__proto__ = {__proto__: Uint8Array.prototype, foo: function () { return 42 }}
  5724. return arr.foo() === 42 && // typed array instances can be augmented
  5725. typeof arr.subarray === 'function' && // chrome 9-10 lack `subarray`
  5726. arr.subarray(1, 1).byteLength === 0 // ie10 has broken `subarray`
  5727. } catch (e) {
  5728. return false
  5729. }
  5730. }
  5731. function kMaxLength () {
  5732. return Buffer.TYPED_ARRAY_SUPPORT
  5733. ? 0x7fffffff
  5734. : 0x3fffffff
  5735. }
  5736. function createBuffer (that, length) {
  5737. if (kMaxLength() < length) {
  5738. throw new RangeError('Invalid typed array length')
  5739. }
  5740. if (Buffer.TYPED_ARRAY_SUPPORT) {
  5741. // Return an augmented `Uint8Array` instance, for best performance
  5742. that = new Uint8Array(length)
  5743. that.__proto__ = Buffer.prototype
  5744. } else {
  5745. // Fallback: Return an object instance of the Buffer class
  5746. if (that === null) {
  5747. that = new Buffer(length)
  5748. }
  5749. that.length = length
  5750. }
  5751. return that
  5752. }
  5753. /**
  5754. * The Buffer constructor returns instances of `Uint8Array` that have their
  5755. * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of
  5756. * `Uint8Array`, so the returned instances will have all the node `Buffer` methods
  5757. * and the `Uint8Array` methods. Square bracket notation works as expected -- it
  5758. * returns a single octet.
  5759. *
  5760. * The `Uint8Array` prototype remains unmodified.
  5761. */
  5762. function Buffer (arg, encodingOrOffset, length) {
  5763. if (!Buffer.TYPED_ARRAY_SUPPORT && !(this instanceof Buffer)) {
  5764. return new Buffer(arg, encodingOrOffset, length)
  5765. }
  5766. // Common case.
  5767. if (typeof arg === 'number') {
  5768. if (typeof encodingOrOffset === 'string') {
  5769. throw new Error(
  5770. 'If encoding is specified then the first argument must be a string'
  5771. )
  5772. }
  5773. return allocUnsafe(this, arg)
  5774. }
  5775. return from(this, arg, encodingOrOffset, length)
  5776. }
  5777. Buffer.poolSize = 8192 // not used by this implementation
  5778. // TODO: Legacy, not needed anymore. Remove in next major version.
  5779. Buffer._augment = function (arr) {
  5780. arr.__proto__ = Buffer.prototype
  5781. return arr
  5782. }
  5783. function from (that, value, encodingOrOffset, length) {
  5784. if (typeof value === 'number') {
  5785. throw new TypeError('"value" argument must not be a number')
  5786. }
  5787. if (typeof ArrayBuffer !== 'undefined' && value instanceof ArrayBuffer) {
  5788. return fromArrayBuffer(that, value, encodingOrOffset, length)
  5789. }
  5790. if (typeof value === 'string') {
  5791. return fromString(that, value, encodingOrOffset)
  5792. }
  5793. return fromObject(that, value)
  5794. }
  5795. /**
  5796. * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError
  5797. * if value is a number.
  5798. * Buffer.from(str[, encoding])
  5799. * Buffer.from(array)
  5800. * Buffer.from(buffer)
  5801. * Buffer.from(arrayBuffer[, byteOffset[, length]])
  5802. **/
  5803. Buffer.from = function (value, encodingOrOffset, length) {
  5804. return from(null, value, encodingOrOffset, length)
  5805. }
  5806. if (Buffer.TYPED_ARRAY_SUPPORT) {
  5807. Buffer.prototype.__proto__ = Uint8Array.prototype
  5808. Buffer.__proto__ = Uint8Array
  5809. if (typeof Symbol !== 'undefined' && Symbol.species &&
  5810. Buffer[Symbol.species] === Buffer) {
  5811. // Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97
  5812. Object.defineProperty(Buffer, Symbol.species, {
  5813. value: null,
  5814. configurable: true
  5815. })
  5816. }
  5817. }
  5818. function assertSize (size) {
  5819. if (typeof size !== 'number') {
  5820. throw new TypeError('"size" argument must be a number')
  5821. } else if (size < 0) {
  5822. throw new RangeError('"size" argument must not be negative')
  5823. }
  5824. }
  5825. function alloc (that, size, fill, encoding) {
  5826. assertSize(size)
  5827. if (size <= 0) {
  5828. return createBuffer(that, size)
  5829. }
  5830. if (fill !== undefined) {
  5831. // Only pay attention to encoding if it's a string. This
  5832. // prevents accidentally sending in a number that would
  5833. // be interpretted as a start offset.
  5834. return typeof encoding === 'string'
  5835. ? createBuffer(that, size).fill(fill, encoding)
  5836. : createBuffer(that, size).fill(fill)
  5837. }
  5838. return createBuffer(that, size)
  5839. }
  5840. /**
  5841. * Creates a new filled Buffer instance.
  5842. * alloc(size[, fill[, encoding]])
  5843. **/
  5844. Buffer.alloc = function (size, fill, encoding) {
  5845. return alloc(null, size, fill, encoding)
  5846. }
  5847. function allocUnsafe (that, size) {
  5848. assertSize(size)
  5849. that = createBuffer(that, size < 0 ? 0 : checked(size) | 0)
  5850. if (!Buffer.TYPED_ARRAY_SUPPORT) {
  5851. for (var i = 0; i < size; ++i) {
  5852. that[i] = 0
  5853. }
  5854. }
  5855. return that
  5856. }
  5857. /**
  5858. * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance.
  5859. * */
  5860. Buffer.allocUnsafe = function (size) {
  5861. return allocUnsafe(null, size)
  5862. }
  5863. /**
  5864. * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
  5865. */
  5866. Buffer.allocUnsafeSlow = function (size) {
  5867. return allocUnsafe(null, size)
  5868. }
  5869. function fromString (that, string, encoding) {
  5870. if (typeof encoding !== 'string' || encoding === '') {
  5871. encoding = 'utf8'
  5872. }
  5873. if (!Buffer.isEncoding(encoding)) {
  5874. throw new TypeError('"encoding" must be a valid string encoding')
  5875. }
  5876. var length = byteLength(string, encoding) | 0
  5877. that = createBuffer(that, length)
  5878. var actual = that.write(string, encoding)
  5879. if (actual !== length) {
  5880. // Writing a hex string, for example, that contains invalid characters will
  5881. // cause everything after the first invalid character to be ignored. (e.g.
  5882. // 'abxxcd' will be treated as 'ab')
  5883. that = that.slice(0, actual)
  5884. }
  5885. return that
  5886. }
  5887. function fromArrayLike (that, array) {
  5888. var length = array.length < 0 ? 0 : checked(array.length) | 0
  5889. that = createBuffer(that, length)
  5890. for (var i = 0; i < length; i += 1) {
  5891. that[i] = array[i] & 255
  5892. }
  5893. return that
  5894. }
  5895. function fromArrayBuffer (that, array, byteOffset, length) {
  5896. array.byteLength // this throws if `array` is not a valid ArrayBuffer
  5897. if (byteOffset < 0 || array.byteLength < byteOffset) {
  5898. throw new RangeError('\'offset\' is out of bounds')
  5899. }
  5900. if (array.byteLength < byteOffset + (length || 0)) {
  5901. throw new RangeError('\'length\' is out of bounds')
  5902. }
  5903. if (byteOffset === undefined && length === undefined) {
  5904. array = new Uint8Array(array)
  5905. } else if (length === undefined) {
  5906. array = new Uint8Array(array, byteOffset)
  5907. } else {
  5908. array = new Uint8Array(array, byteOffset, length)
  5909. }
  5910. if (Buffer.TYPED_ARRAY_SUPPORT) {
  5911. // Return an augmented `Uint8Array` instance, for best performance
  5912. that = array
  5913. that.__proto__ = Buffer.prototype
  5914. } else {
  5915. // Fallback: Return an object instance of the Buffer class
  5916. that = fromArrayLike(that, array)
  5917. }
  5918. return that
  5919. }
  5920. function fromObject (that, obj) {
  5921. if (Buffer.isBuffer(obj)) {
  5922. var len = checked(obj.length) | 0
  5923. that = createBuffer(that, len)
  5924. if (that.length === 0) {
  5925. return that
  5926. }
  5927. obj.copy(that, 0, 0, len)
  5928. return that
  5929. }
  5930. if (obj) {
  5931. if ((typeof ArrayBuffer !== 'undefined' &&
  5932. obj.buffer instanceof ArrayBuffer) || 'length' in obj) {
  5933. if (typeof obj.length !== 'number' || isnan(obj.length)) {
  5934. return createBuffer(that, 0)
  5935. }
  5936. return fromArrayLike(that, obj)
  5937. }
  5938. if (obj.type === 'Buffer' && isArray(obj.data)) {
  5939. return fromArrayLike(that, obj.data)
  5940. }
  5941. }
  5942. throw new TypeError('First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.')
  5943. }
  5944. function checked (length) {
  5945. // Note: cannot use `length < kMaxLength()` here because that fails when
  5946. // length is NaN (which is otherwise coerced to zero.)
  5947. if (length >= kMaxLength()) {
  5948. throw new RangeError('Attempt to allocate Buffer larger than maximum ' +
  5949. 'size: 0x' + kMaxLength().toString(16) + ' bytes')
  5950. }
  5951. return length | 0
  5952. }
  5953. function SlowBuffer (length) {
  5954. if (+length != length) { // eslint-disable-line eqeqeq
  5955. length = 0
  5956. }
  5957. return Buffer.alloc(+length)
  5958. }
  5959. Buffer.isBuffer = function isBuffer (b) {
  5960. return !!(b != null && b._isBuffer)
  5961. }
  5962. Buffer.compare = function compare (a, b) {
  5963. if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {
  5964. throw new TypeError('Arguments must be Buffers')
  5965. }
  5966. if (a === b) return 0
  5967. var x = a.length
  5968. var y = b.length
  5969. for (var i = 0, len = Math.min(x, y); i < len; ++i) {
  5970. if (a[i] !== b[i]) {
  5971. x = a[i]
  5972. y = b[i]
  5973. break
  5974. }
  5975. }
  5976. if (x < y) return -1
  5977. if (y < x) return 1
  5978. return 0
  5979. }
  5980. Buffer.isEncoding = function isEncoding (encoding) {
  5981. switch (String(encoding).toLowerCase()) {
  5982. case 'hex':
  5983. case 'utf8':
  5984. case 'utf-8':
  5985. case 'ascii':
  5986. case 'latin1':
  5987. case 'binary':
  5988. case 'base64':
  5989. case 'ucs2':
  5990. case 'ucs-2':
  5991. case 'utf16le':
  5992. case 'utf-16le':
  5993. return true
  5994. default:
  5995. return false
  5996. }
  5997. }
  5998. Buffer.concat = function concat (list, length) {
  5999. if (!isArray(list)) {
  6000. throw new TypeError('"list" argument must be an Array of Buffers')
  6001. }
  6002. if (list.length === 0) {
  6003. return Buffer.alloc(0)
  6004. }
  6005. var i
  6006. if (length === undefined) {
  6007. length = 0
  6008. for (i = 0; i < list.length; ++i) {
  6009. length += list[i].length
  6010. }
  6011. }
  6012. var buffer = Buffer.allocUnsafe(length)
  6013. var pos = 0
  6014. for (i = 0; i < list.length; ++i) {
  6015. var buf = list[i]
  6016. if (!Buffer.isBuffer(buf)) {
  6017. throw new TypeError('"list" argument must be an Array of Buffers')
  6018. }
  6019. buf.copy(buffer, pos)
  6020. pos += buf.length
  6021. }
  6022. return buffer
  6023. }
  6024. function byteLength (string, encoding) {
  6025. if (Buffer.isBuffer(string)) {
  6026. return string.length
  6027. }
  6028. if (typeof ArrayBuffer !== 'undefined' && typeof ArrayBuffer.isView === 'function' &&
  6029. (ArrayBuffer.isView(string) || string instanceof ArrayBuffer)) {
  6030. return string.byteLength
  6031. }
  6032. if (typeof string !== 'string') {
  6033. string = '' + string
  6034. }
  6035. var len = string.length
  6036. if (len === 0) return 0
  6037. // Use a for loop to avoid recursion
  6038. var loweredCase = false
  6039. for (;;) {
  6040. switch (encoding) {
  6041. case 'ascii':
  6042. case 'latin1':
  6043. case 'binary':
  6044. return len
  6045. case 'utf8':
  6046. case 'utf-8':
  6047. case undefined:
  6048. return utf8ToBytes(string).length
  6049. case 'ucs2':
  6050. case 'ucs-2':
  6051. case 'utf16le':
  6052. case 'utf-16le':
  6053. return len * 2
  6054. case 'hex':
  6055. return len >>> 1
  6056. case 'base64':
  6057. return base64ToBytes(string).length
  6058. default:
  6059. if (loweredCase) return utf8ToBytes(string).length // assume utf8
  6060. encoding = ('' + encoding).toLowerCase()
  6061. loweredCase = true
  6062. }
  6063. }
  6064. }
  6065. Buffer.byteLength = byteLength
  6066. function slowToString (encoding, start, end) {
  6067. var loweredCase = false
  6068. // No need to verify that "this.length <= MAX_UINT32" since it's a read-only
  6069. // property of a typed array.
  6070. // This behaves neither like String nor Uint8Array in that we set start/end
  6071. // to their upper/lower bounds if the value passed is out of range.
  6072. // undefined is handled specially as per ECMA-262 6th Edition,
  6073. // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization.
  6074. if (start === undefined || start < 0) {
  6075. start = 0
  6076. }
  6077. // Return early if start > this.length. Done here to prevent potential uint32
  6078. // coercion fail below.
  6079. if (start > this.length) {
  6080. return ''
  6081. }
  6082. if (end === undefined || end > this.length) {
  6083. end = this.length
  6084. }
  6085. if (end <= 0) {
  6086. return ''
  6087. }
  6088. // Force coersion to uint32. This will also coerce falsey/NaN values to 0.
  6089. end >>>= 0
  6090. start >>>= 0
  6091. if (end <= start) {
  6092. return ''
  6093. }
  6094. if (!encoding) encoding = 'utf8'
  6095. while (true) {
  6096. switch (encoding) {
  6097. case 'hex':
  6098. return hexSlice(this, start, end)
  6099. case 'utf8':
  6100. case 'utf-8':
  6101. return utf8Slice(this, start, end)
  6102. case 'ascii':
  6103. return asciiSlice(this, start, end)
  6104. case 'latin1':
  6105. case 'binary':
  6106. return latin1Slice(this, start, end)
  6107. case 'base64':
  6108. return base64Slice(this, start, end)
  6109. case 'ucs2':
  6110. case 'ucs-2':
  6111. case 'utf16le':
  6112. case 'utf-16le':
  6113. return utf16leSlice(this, start, end)
  6114. default:
  6115. if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
  6116. encoding = (encoding + '').toLowerCase()
  6117. loweredCase = true
  6118. }
  6119. }
  6120. }
  6121. // The property is used by `Buffer.isBuffer` and `is-buffer` (in Safari 5-7) to detect
  6122. // Buffer instances.
  6123. Buffer.prototype._isBuffer = true
  6124. function swap (b, n, m) {
  6125. var i = b[n]
  6126. b[n] = b[m]
  6127. b[m] = i
  6128. }
  6129. Buffer.prototype.swap16 = function swap16 () {
  6130. var len = this.length
  6131. if (len % 2 !== 0) {
  6132. throw new RangeError('Buffer size must be a multiple of 16-bits')
  6133. }
  6134. for (var i = 0; i < len; i += 2) {
  6135. swap(this, i, i + 1)
  6136. }
  6137. return this
  6138. }
  6139. Buffer.prototype.swap32 = function swap32 () {
  6140. var len = this.length
  6141. if (len % 4 !== 0) {
  6142. throw new RangeError('Buffer size must be a multiple of 32-bits')
  6143. }
  6144. for (var i = 0; i < len; i += 4) {
  6145. swap(this, i, i + 3)
  6146. swap(this, i + 1, i + 2)
  6147. }
  6148. return this
  6149. }
  6150. Buffer.prototype.swap64 = function swap64 () {
  6151. var len = this.length
  6152. if (len % 8 !== 0) {
  6153. throw new RangeError('Buffer size must be a multiple of 64-bits')
  6154. }
  6155. for (var i = 0; i < len; i += 8) {
  6156. swap(this, i, i + 7)
  6157. swap(this, i + 1, i + 6)
  6158. swap(this, i + 2, i + 5)
  6159. swap(this, i + 3, i + 4)
  6160. }
  6161. return this
  6162. }
  6163. Buffer.prototype.toString = function toString () {
  6164. var length = this.length | 0
  6165. if (length === 0) return ''
  6166. if (arguments.length === 0) return utf8Slice(this, 0, length)
  6167. return slowToString.apply(this, arguments)
  6168. }
  6169. Buffer.prototype.equals = function equals (b) {
  6170. if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')
  6171. if (this === b) return true
  6172. return Buffer.compare(this, b) === 0
  6173. }
  6174. Buffer.prototype.inspect = function inspect () {
  6175. var str = ''
  6176. var max = exports.INSPECT_MAX_BYTES
  6177. if (this.length > 0) {
  6178. str = this.toString('hex', 0, max).match(/.{2}/g).join(' ')
  6179. if (this.length > max) str += ' ... '
  6180. }
  6181. return '<Buffer ' + str + '>'
  6182. }
  6183. Buffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) {
  6184. if (!Buffer.isBuffer(target)) {
  6185. throw new TypeError('Argument must be a Buffer')
  6186. }
  6187. if (start === undefined) {
  6188. start = 0
  6189. }
  6190. if (end === undefined) {
  6191. end = target ? target.length : 0
  6192. }
  6193. if (thisStart === undefined) {
  6194. thisStart = 0
  6195. }
  6196. if (thisEnd === undefined) {
  6197. thisEnd = this.length
  6198. }
  6199. if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {
  6200. throw new RangeError('out of range index')
  6201. }
  6202. if (thisStart >= thisEnd && start >= end) {
  6203. return 0
  6204. }
  6205. if (thisStart >= thisEnd) {
  6206. return -1
  6207. }
  6208. if (start >= end) {
  6209. return 1
  6210. }
  6211. start >>>= 0
  6212. end >>>= 0
  6213. thisStart >>>= 0
  6214. thisEnd >>>= 0
  6215. if (this === target) return 0
  6216. var x = thisEnd - thisStart
  6217. var y = end - start
  6218. var len = Math.min(x, y)
  6219. var thisCopy = this.slice(thisStart, thisEnd)
  6220. var targetCopy = target.slice(start, end)
  6221. for (var i = 0; i < len; ++i) {
  6222. if (thisCopy[i] !== targetCopy[i]) {
  6223. x = thisCopy[i]
  6224. y = targetCopy[i]
  6225. break
  6226. }
  6227. }
  6228. if (x < y) return -1
  6229. if (y < x) return 1
  6230. return 0
  6231. }
  6232. // Finds either the first index of `val` in `buffer` at offset >= `byteOffset`,
  6233. // OR the last index of `val` in `buffer` at offset <= `byteOffset`.
  6234. //
  6235. // Arguments:
  6236. // - buffer - a Buffer to search
  6237. // - val - a string, Buffer, or number
  6238. // - byteOffset - an index into `buffer`; will be clamped to an int32
  6239. // - encoding - an optional encoding, relevant is val is a string
  6240. // - dir - true for indexOf, false for lastIndexOf
  6241. function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) {
  6242. // Empty buffer means no match
  6243. if (buffer.length === 0) return -1
  6244. // Normalize byteOffset
  6245. if (typeof byteOffset === 'string') {
  6246. encoding = byteOffset
  6247. byteOffset = 0
  6248. } else if (byteOffset > 0x7fffffff) {
  6249. byteOffset = 0x7fffffff
  6250. } else if (byteOffset < -0x80000000) {
  6251. byteOffset = -0x80000000
  6252. }
  6253. byteOffset = +byteOffset // Coerce to Number.
  6254. if (isNaN(byteOffset)) {
  6255. // byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer
  6256. byteOffset = dir ? 0 : (buffer.length - 1)
  6257. }
  6258. // Normalize byteOffset: negative offsets start from the end of the buffer
  6259. if (byteOffset < 0) byteOffset = buffer.length + byteOffset
  6260. if (byteOffset >= buffer.length) {
  6261. if (dir) return -1
  6262. else byteOffset = buffer.length - 1
  6263. } else if (byteOffset < 0) {
  6264. if (dir) byteOffset = 0
  6265. else return -1
  6266. }
  6267. // Normalize val
  6268. if (typeof val === 'string') {
  6269. val = Buffer.from(val, encoding)
  6270. }
  6271. // Finally, search either indexOf (if dir is true) or lastIndexOf
  6272. if (Buffer.isBuffer(val)) {
  6273. // Special case: looking for empty string/buffer always fails
  6274. if (val.length === 0) {
  6275. return -1
  6276. }
  6277. return arrayIndexOf(buffer, val, byteOffset, encoding, dir)
  6278. } else if (typeof val === 'number') {
  6279. val = val & 0xFF // Search for a byte value [0-255]
  6280. if (Buffer.TYPED_ARRAY_SUPPORT &&
  6281. typeof Uint8Array.prototype.indexOf === 'function') {
  6282. if (dir) {
  6283. return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset)
  6284. } else {
  6285. return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset)
  6286. }
  6287. }
  6288. return arrayIndexOf(buffer, [ val ], byteOffset, encoding, dir)
  6289. }
  6290. throw new TypeError('val must be string, number or Buffer')
  6291. }
  6292. function arrayIndexOf (arr, val, byteOffset, encoding, dir) {
  6293. var indexSize = 1
  6294. var arrLength = arr.length
  6295. var valLength = val.length
  6296. if (encoding !== undefined) {
  6297. encoding = String(encoding).toLowerCase()
  6298. if (encoding === 'ucs2' || encoding === 'ucs-2' ||
  6299. encoding === 'utf16le' || encoding === 'utf-16le') {
  6300. if (arr.length < 2 || val.length < 2) {
  6301. return -1
  6302. }
  6303. indexSize = 2
  6304. arrLength /= 2
  6305. valLength /= 2
  6306. byteOffset /= 2
  6307. }
  6308. }
  6309. function read (buf, i) {
  6310. if (indexSize === 1) {
  6311. return buf[i]
  6312. } else {
  6313. return buf.readUInt16BE(i * indexSize)
  6314. }
  6315. }
  6316. var i
  6317. if (dir) {
  6318. var foundIndex = -1
  6319. for (i = byteOffset; i < arrLength; i++) {
  6320. if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {
  6321. if (foundIndex === -1) foundIndex = i
  6322. if (i - foundIndex + 1 === valLength) return foundIndex * indexSize
  6323. } else {
  6324. if (foundIndex !== -1) i -= i - foundIndex
  6325. foundIndex = -1
  6326. }
  6327. }
  6328. } else {
  6329. if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength
  6330. for (i = byteOffset; i >= 0; i--) {
  6331. var found = true
  6332. for (var j = 0; j < valLength; j++) {
  6333. if (read(arr, i + j) !== read(val, j)) {
  6334. found = false
  6335. break
  6336. }
  6337. }
  6338. if (found) return i
  6339. }
  6340. }
  6341. return -1
  6342. }
  6343. Buffer.prototype.includes = function includes (val, byteOffset, encoding) {
  6344. return this.indexOf(val, byteOffset, encoding) !== -1
  6345. }
  6346. Buffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) {
  6347. return bidirectionalIndexOf(this, val, byteOffset, encoding, true)
  6348. }
  6349. Buffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) {
  6350. return bidirectionalIndexOf(this, val, byteOffset, encoding, false)
  6351. }
  6352. function hexWrite (buf, string, offset, length) {
  6353. offset = Number(offset) || 0
  6354. var remaining = buf.length - offset
  6355. if (!length) {
  6356. length = remaining
  6357. } else {
  6358. length = Number(length)
  6359. if (length > remaining) {
  6360. length = remaining
  6361. }
  6362. }
  6363. // must be an even number of digits
  6364. var strLen = string.length
  6365. if (strLen % 2 !== 0) throw new TypeError('Invalid hex string')
  6366. if (length > strLen / 2) {
  6367. length = strLen / 2
  6368. }
  6369. for (var i = 0; i < length; ++i) {
  6370. var parsed = parseInt(string.substr(i * 2, 2), 16)
  6371. if (isNaN(parsed)) return i
  6372. buf[offset + i] = parsed
  6373. }
  6374. return i
  6375. }
  6376. function utf8Write (buf, string, offset, length) {
  6377. return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length)
  6378. }
  6379. function asciiWrite (buf, string, offset, length) {
  6380. return blitBuffer(asciiToBytes(string), buf, offset, length)
  6381. }
  6382. function latin1Write (buf, string, offset, length) {
  6383. return asciiWrite(buf, string, offset, length)
  6384. }
  6385. function base64Write (buf, string, offset, length) {
  6386. return blitBuffer(base64ToBytes(string), buf, offset, length)
  6387. }
  6388. function ucs2Write (buf, string, offset, length) {
  6389. return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length)
  6390. }
  6391. Buffer.prototype.write = function write (string, offset, length, encoding) {
  6392. // Buffer#write(string)
  6393. if (offset === undefined) {
  6394. encoding = 'utf8'
  6395. length = this.length
  6396. offset = 0
  6397. // Buffer#write(string, encoding)
  6398. } else if (length === undefined && typeof offset === 'string') {
  6399. encoding = offset
  6400. length = this.length
  6401. offset = 0
  6402. // Buffer#write(string, offset[, length][, encoding])
  6403. } else if (isFinite(offset)) {
  6404. offset = offset | 0
  6405. if (isFinite(length)) {
  6406. length = length | 0
  6407. if (encoding === undefined) encoding = 'utf8'
  6408. } else {
  6409. encoding = length
  6410. length = undefined
  6411. }
  6412. // legacy write(string, encoding, offset, length) - remove in v0.13
  6413. } else {
  6414. throw new Error(
  6415. 'Buffer.write(string, encoding, offset[, length]) is no longer supported'
  6416. )
  6417. }
  6418. var remaining = this.length - offset
  6419. if (length === undefined || length > remaining) length = remaining
  6420. if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) {
  6421. throw new RangeError('Attempt to write outside buffer bounds')
  6422. }
  6423. if (!encoding) encoding = 'utf8'
  6424. var loweredCase = false
  6425. for (;;) {
  6426. switch (encoding) {
  6427. case 'hex':
  6428. return hexWrite(this, string, offset, length)
  6429. case 'utf8':
  6430. case 'utf-8':
  6431. return utf8Write(this, string, offset, length)
  6432. case 'ascii':
  6433. return asciiWrite(this, string, offset, length)
  6434. case 'latin1':
  6435. case 'binary':
  6436. return latin1Write(this, string, offset, length)
  6437. case 'base64':
  6438. // Warning: maxLength not taken into account in base64Write
  6439. return base64Write(this, string, offset, length)
  6440. case 'ucs2':
  6441. case 'ucs-2':
  6442. case 'utf16le':
  6443. case 'utf-16le':
  6444. return ucs2Write(this, string, offset, length)
  6445. default:
  6446. if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
  6447. encoding = ('' + encoding).toLowerCase()
  6448. loweredCase = true
  6449. }
  6450. }
  6451. }
  6452. Buffer.prototype.toJSON = function toJSON () {
  6453. return {
  6454. type: 'Buffer',
  6455. data: Array.prototype.slice.call(this._arr || this, 0)
  6456. }
  6457. }
  6458. function base64Slice (buf, start, end) {
  6459. if (start === 0 && end === buf.length) {
  6460. return base64.fromByteArray(buf)
  6461. } else {
  6462. return base64.fromByteArray(buf.slice(start, end))
  6463. }
  6464. }
  6465. function utf8Slice (buf, start, end) {
  6466. end = Math.min(buf.length, end)
  6467. var res = []
  6468. var i = start
  6469. while (i < end) {
  6470. var firstByte = buf[i]
  6471. var codePoint = null
  6472. var bytesPerSequence = (firstByte > 0xEF) ? 4
  6473. : (firstByte > 0xDF) ? 3
  6474. : (firstByte > 0xBF) ? 2
  6475. : 1
  6476. if (i + bytesPerSequence <= end) {
  6477. var secondByte, thirdByte, fourthByte, tempCodePoint
  6478. switch (bytesPerSequence) {
  6479. case 1:
  6480. if (firstByte < 0x80) {
  6481. codePoint = firstByte
  6482. }
  6483. break
  6484. case 2:
  6485. secondByte = buf[i + 1]
  6486. if ((secondByte & 0xC0) === 0x80) {
  6487. tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F)
  6488. if (tempCodePoint > 0x7F) {
  6489. codePoint = tempCodePoint
  6490. }
  6491. }
  6492. break
  6493. case 3:
  6494. secondByte = buf[i + 1]
  6495. thirdByte = buf[i + 2]
  6496. if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {
  6497. tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F)
  6498. if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) {
  6499. codePoint = tempCodePoint
  6500. }
  6501. }
  6502. break
  6503. case 4:
  6504. secondByte = buf[i + 1]
  6505. thirdByte = buf[i + 2]
  6506. fourthByte = buf[i + 3]
  6507. if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {
  6508. tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F)
  6509. if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) {
  6510. codePoint = tempCodePoint
  6511. }
  6512. }
  6513. }
  6514. }
  6515. if (codePoint === null) {
  6516. // we did not generate a valid codePoint so insert a
  6517. // replacement char (U+FFFD) and advance only 1 byte
  6518. codePoint = 0xFFFD
  6519. bytesPerSequence = 1
  6520. } else if (codePoint > 0xFFFF) {
  6521. // encode to utf16 (surrogate pair dance)
  6522. codePoint -= 0x10000
  6523. res.push(codePoint >>> 10 & 0x3FF | 0xD800)
  6524. codePoint = 0xDC00 | codePoint & 0x3FF
  6525. }
  6526. res.push(codePoint)
  6527. i += bytesPerSequence
  6528. }
  6529. return decodeCodePointsArray(res)
  6530. }
  6531. // Based on http://stackoverflow.com/a/22747272/680742, the browser with
  6532. // the lowest limit is Chrome, with 0x10000 args.
  6533. // We go 1 magnitude less, for safety
  6534. var MAX_ARGUMENTS_LENGTH = 0x1000
  6535. function decodeCodePointsArray (codePoints) {
  6536. var len = codePoints.length
  6537. if (len <= MAX_ARGUMENTS_LENGTH) {
  6538. return String.fromCharCode.apply(String, codePoints) // avoid extra slice()
  6539. }
  6540. // Decode in chunks to avoid "call stack size exceeded".
  6541. var res = ''
  6542. var i = 0
  6543. while (i < len) {
  6544. res += String.fromCharCode.apply(
  6545. String,
  6546. codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)
  6547. )
  6548. }
  6549. return res
  6550. }
  6551. function asciiSlice (buf, start, end) {
  6552. var ret = ''
  6553. end = Math.min(buf.length, end)
  6554. for (var i = start; i < end; ++i) {
  6555. ret += String.fromCharCode(buf[i] & 0x7F)
  6556. }
  6557. return ret
  6558. }
  6559. function latin1Slice (buf, start, end) {
  6560. var ret = ''
  6561. end = Math.min(buf.length, end)
  6562. for (var i = start; i < end; ++i) {
  6563. ret += String.fromCharCode(buf[i])
  6564. }
  6565. return ret
  6566. }
  6567. function hexSlice (buf, start, end) {
  6568. var len = buf.length
  6569. if (!start || start < 0) start = 0
  6570. if (!end || end < 0 || end > len) end = len
  6571. var out = ''
  6572. for (var i = start; i < end; ++i) {
  6573. out += toHex(buf[i])
  6574. }
  6575. return out
  6576. }
  6577. function utf16leSlice (buf, start, end) {
  6578. var bytes = buf.slice(start, end)
  6579. var res = ''
  6580. for (var i = 0; i < bytes.length; i += 2) {
  6581. res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256)
  6582. }
  6583. return res
  6584. }
  6585. Buffer.prototype.slice = function slice (start, end) {
  6586. var len = this.length
  6587. start = ~~start
  6588. end = end === undefined ? len : ~~end
  6589. if (start < 0) {
  6590. start += len
  6591. if (start < 0) start = 0
  6592. } else if (start > len) {
  6593. start = len
  6594. }
  6595. if (end < 0) {
  6596. end += len
  6597. if (end < 0) end = 0
  6598. } else if (end > len) {
  6599. end = len
  6600. }
  6601. if (end < start) end = start
  6602. var newBuf
  6603. if (Buffer.TYPED_ARRAY_SUPPORT) {
  6604. newBuf = this.subarray(start, end)
  6605. newBuf.__proto__ = Buffer.prototype
  6606. } else {
  6607. var sliceLen = end - start
  6608. newBuf = new Buffer(sliceLen, undefined)
  6609. for (var i = 0; i < sliceLen; ++i) {
  6610. newBuf[i] = this[i + start]
  6611. }
  6612. }
  6613. return newBuf
  6614. }
  6615. /*
  6616. * Need to make sure that buffer isn't trying to write out of bounds.
  6617. */
  6618. function checkOffset (offset, ext, length) {
  6619. if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint')
  6620. if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length')
  6621. }
  6622. Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) {
  6623. offset = offset | 0
  6624. byteLength = byteLength | 0
  6625. if (!noAssert) checkOffset(offset, byteLength, this.length)
  6626. var val = this[offset]
  6627. var mul = 1
  6628. var i = 0
  6629. while (++i < byteLength && (mul *= 0x100)) {
  6630. val += this[offset + i] * mul
  6631. }
  6632. return val
  6633. }
  6634. Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) {
  6635. offset = offset | 0
  6636. byteLength = byteLength | 0
  6637. if (!noAssert) {
  6638. checkOffset(offset, byteLength, this.length)
  6639. }
  6640. var val = this[offset + --byteLength]
  6641. var mul = 1
  6642. while (byteLength > 0 && (mul *= 0x100)) {
  6643. val += this[offset + --byteLength] * mul
  6644. }
  6645. return val
  6646. }
  6647. Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) {
  6648. if (!noAssert) checkOffset(offset, 1, this.length)
  6649. return this[offset]
  6650. }
  6651. Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) {
  6652. if (!noAssert) checkOffset(offset, 2, this.length)
  6653. return this[offset] | (this[offset + 1] << 8)
  6654. }
  6655. Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) {
  6656. if (!noAssert) checkOffset(offset, 2, this.length)
  6657. return (this[offset] << 8) | this[offset + 1]
  6658. }
  6659. Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) {
  6660. if (!noAssert) checkOffset(offset, 4, this.length)
  6661. return ((this[offset]) |
  6662. (this[offset + 1] << 8) |
  6663. (this[offset + 2] << 16)) +
  6664. (this[offset + 3] * 0x1000000)
  6665. }
  6666. Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) {
  6667. if (!noAssert) checkOffset(offset, 4, this.length)
  6668. return (this[offset] * 0x1000000) +
  6669. ((this[offset + 1] << 16) |
  6670. (this[offset + 2] << 8) |
  6671. this[offset + 3])
  6672. }
  6673. Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) {
  6674. offset = offset | 0
  6675. byteLength = byteLength | 0
  6676. if (!noAssert) checkOffset(offset, byteLength, this.length)
  6677. var val = this[offset]
  6678. var mul = 1
  6679. var i = 0
  6680. while (++i < byteLength && (mul *= 0x100)) {
  6681. val += this[offset + i] * mul
  6682. }
  6683. mul *= 0x80
  6684. if (val >= mul) val -= Math.pow(2, 8 * byteLength)
  6685. return val
  6686. }
  6687. Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) {
  6688. offset = offset | 0
  6689. byteLength = byteLength | 0
  6690. if (!noAssert) checkOffset(offset, byteLength, this.length)
  6691. var i = byteLength
  6692. var mul = 1
  6693. var val = this[offset + --i]
  6694. while (i > 0 && (mul *= 0x100)) {
  6695. val += this[offset + --i] * mul
  6696. }
  6697. mul *= 0x80
  6698. if (val >= mul) val -= Math.pow(2, 8 * byteLength)
  6699. return val
  6700. }
  6701. Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) {
  6702. if (!noAssert) checkOffset(offset, 1, this.length)
  6703. if (!(this[offset] & 0x80)) return (this[offset])
  6704. return ((0xff - this[offset] + 1) * -1)
  6705. }
  6706. Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) {
  6707. if (!noAssert) checkOffset(offset, 2, this.length)
  6708. var val = this[offset] | (this[offset + 1] << 8)
  6709. return (val & 0x8000) ? val | 0xFFFF0000 : val
  6710. }
  6711. Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) {
  6712. if (!noAssert) checkOffset(offset, 2, this.length)
  6713. var val = this[offset + 1] | (this[offset] << 8)
  6714. return (val & 0x8000) ? val | 0xFFFF0000 : val
  6715. }
  6716. Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) {
  6717. if (!noAssert) checkOffset(offset, 4, this.length)
  6718. return (this[offset]) |
  6719. (this[offset + 1] << 8) |
  6720. (this[offset + 2] << 16) |
  6721. (this[offset + 3] << 24)
  6722. }
  6723. Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) {
  6724. if (!noAssert) checkOffset(offset, 4, this.length)
  6725. return (this[offset] << 24) |
  6726. (this[offset + 1] << 16) |
  6727. (this[offset + 2] << 8) |
  6728. (this[offset + 3])
  6729. }
  6730. Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) {
  6731. if (!noAssert) checkOffset(offset, 4, this.length)
  6732. return ieee754.read(this, offset, true, 23, 4)
  6733. }
  6734. Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) {
  6735. if (!noAssert) checkOffset(offset, 4, this.length)
  6736. return ieee754.read(this, offset, false, 23, 4)
  6737. }
  6738. Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) {
  6739. if (!noAssert) checkOffset(offset, 8, this.length)
  6740. return ieee754.read(this, offset, true, 52, 8)
  6741. }
  6742. Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) {
  6743. if (!noAssert) checkOffset(offset, 8, this.length)
  6744. return ieee754.read(this, offset, false, 52, 8)
  6745. }
  6746. function checkInt (buf, value, offset, ext, max, min) {
  6747. if (!Buffer.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance')
  6748. if (value > max || value < min) throw new RangeError('"value" argument is out of bounds')
  6749. if (offset + ext > buf.length) throw new RangeError('Index out of range')
  6750. }
  6751. Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) {
  6752. value = +value
  6753. offset = offset | 0
  6754. byteLength = byteLength | 0
  6755. if (!noAssert) {
  6756. var maxBytes = Math.pow(2, 8 * byteLength) - 1
  6757. checkInt(this, value, offset, byteLength, maxBytes, 0)
  6758. }
  6759. var mul = 1
  6760. var i = 0
  6761. this[offset] = value & 0xFF
  6762. while (++i < byteLength && (mul *= 0x100)) {
  6763. this[offset + i] = (value / mul) & 0xFF
  6764. }
  6765. return offset + byteLength
  6766. }
  6767. Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) {
  6768. value = +value
  6769. offset = offset | 0
  6770. byteLength = byteLength | 0
  6771. if (!noAssert) {
  6772. var maxBytes = Math.pow(2, 8 * byteLength) - 1
  6773. checkInt(this, value, offset, byteLength, maxBytes, 0)
  6774. }
  6775. var i = byteLength - 1
  6776. var mul = 1
  6777. this[offset + i] = value & 0xFF
  6778. while (--i >= 0 && (mul *= 0x100)) {
  6779. this[offset + i] = (value / mul) & 0xFF
  6780. }
  6781. return offset + byteLength
  6782. }
  6783. Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) {
  6784. value = +value
  6785. offset = offset | 0
  6786. if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0)
  6787. if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)
  6788. this[offset] = (value & 0xff)
  6789. return offset + 1
  6790. }
  6791. function objectWriteUInt16 (buf, value, offset, littleEndian) {
  6792. if (value < 0) value = 0xffff + value + 1
  6793. for (var i = 0, j = Math.min(buf.length - offset, 2); i < j; ++i) {
  6794. buf[offset + i] = (value & (0xff << (8 * (littleEndian ? i : 1 - i)))) >>>
  6795. (littleEndian ? i : 1 - i) * 8
  6796. }
  6797. }
  6798. Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) {
  6799. value = +value
  6800. offset = offset | 0
  6801. if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
  6802. if (Buffer.TYPED_ARRAY_SUPPORT) {
  6803. this[offset] = (value & 0xff)
  6804. this[offset + 1] = (value >>> 8)
  6805. } else {
  6806. objectWriteUInt16(this, value, offset, true)
  6807. }
  6808. return offset + 2
  6809. }
  6810. Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) {
  6811. value = +value
  6812. offset = offset | 0
  6813. if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
  6814. if (Buffer.TYPED_ARRAY_SUPPORT) {
  6815. this[offset] = (value >>> 8)
  6816. this[offset + 1] = (value & 0xff)
  6817. } else {
  6818. objectWriteUInt16(this, value, offset, false)
  6819. }
  6820. return offset + 2
  6821. }
  6822. function objectWriteUInt32 (buf, value, offset, littleEndian) {
  6823. if (value < 0) value = 0xffffffff + value + 1
  6824. for (var i = 0, j = Math.min(buf.length - offset, 4); i < j; ++i) {
  6825. buf[offset + i] = (value >>> (littleEndian ? i : 3 - i) * 8) & 0xff
  6826. }
  6827. }
  6828. Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) {
  6829. value = +value
  6830. offset = offset | 0
  6831. if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
  6832. if (Buffer.TYPED_ARRAY_SUPPORT) {
  6833. this[offset + 3] = (value >>> 24)
  6834. this[offset + 2] = (value >>> 16)
  6835. this[offset + 1] = (value >>> 8)
  6836. this[offset] = (value & 0xff)
  6837. } else {
  6838. objectWriteUInt32(this, value, offset, true)
  6839. }
  6840. return offset + 4
  6841. }
  6842. Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) {
  6843. value = +value
  6844. offset = offset | 0
  6845. if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
  6846. if (Buffer.TYPED_ARRAY_SUPPORT) {
  6847. this[offset] = (value >>> 24)
  6848. this[offset + 1] = (value >>> 16)
  6849. this[offset + 2] = (value >>> 8)
  6850. this[offset + 3] = (value & 0xff)
  6851. } else {
  6852. objectWriteUInt32(this, value, offset, false)
  6853. }
  6854. return offset + 4
  6855. }
  6856. Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) {
  6857. value = +value
  6858. offset = offset | 0
  6859. if (!noAssert) {
  6860. var limit = Math.pow(2, 8 * byteLength - 1)
  6861. checkInt(this, value, offset, byteLength, limit - 1, -limit)
  6862. }
  6863. var i = 0
  6864. var mul = 1
  6865. var sub = 0
  6866. this[offset] = value & 0xFF
  6867. while (++i < byteLength && (mul *= 0x100)) {
  6868. if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {
  6869. sub = 1
  6870. }
  6871. this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
  6872. }
  6873. return offset + byteLength
  6874. }
  6875. Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) {
  6876. value = +value
  6877. offset = offset | 0
  6878. if (!noAssert) {
  6879. var limit = Math.pow(2, 8 * byteLength - 1)
  6880. checkInt(this, value, offset, byteLength, limit - 1, -limit)
  6881. }
  6882. var i = byteLength - 1
  6883. var mul = 1
  6884. var sub = 0
  6885. this[offset + i] = value & 0xFF
  6886. while (--i >= 0 && (mul *= 0x100)) {
  6887. if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {
  6888. sub = 1
  6889. }
  6890. this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
  6891. }
  6892. return offset + byteLength
  6893. }
  6894. Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) {
  6895. value = +value
  6896. offset = offset | 0
  6897. if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80)
  6898. if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)
  6899. if (value < 0) value = 0xff + value + 1
  6900. this[offset] = (value & 0xff)
  6901. return offset + 1
  6902. }
  6903. Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) {
  6904. value = +value
  6905. offset = offset | 0
  6906. if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
  6907. if (Buffer.TYPED_ARRAY_SUPPORT) {
  6908. this[offset] = (value & 0xff)
  6909. this[offset + 1] = (value >>> 8)
  6910. } else {
  6911. objectWriteUInt16(this, value, offset, true)
  6912. }
  6913. return offset + 2
  6914. }
  6915. Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) {
  6916. value = +value
  6917. offset = offset | 0
  6918. if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
  6919. if (Buffer.TYPED_ARRAY_SUPPORT) {
  6920. this[offset] = (value >>> 8)
  6921. this[offset + 1] = (value & 0xff)
  6922. } else {
  6923. objectWriteUInt16(this, value, offset, false)
  6924. }
  6925. return offset + 2
  6926. }
  6927. Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) {
  6928. value = +value
  6929. offset = offset | 0
  6930. if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
  6931. if (Buffer.TYPED_ARRAY_SUPPORT) {
  6932. this[offset] = (value & 0xff)
  6933. this[offset + 1] = (value >>> 8)
  6934. this[offset + 2] = (value >>> 16)
  6935. this[offset + 3] = (value >>> 24)
  6936. } else {
  6937. objectWriteUInt32(this, value, offset, true)
  6938. }
  6939. return offset + 4
  6940. }
  6941. Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) {
  6942. value = +value
  6943. offset = offset | 0
  6944. if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
  6945. if (value < 0) value = 0xffffffff + value + 1
  6946. if (Buffer.TYPED_ARRAY_SUPPORT) {
  6947. this[offset] = (value >>> 24)
  6948. this[offset + 1] = (value >>> 16)
  6949. this[offset + 2] = (value >>> 8)
  6950. this[offset + 3] = (value & 0xff)
  6951. } else {
  6952. objectWriteUInt32(this, value, offset, false)
  6953. }
  6954. return offset + 4
  6955. }
  6956. function checkIEEE754 (buf, value, offset, ext, max, min) {
  6957. if (offset + ext > buf.length) throw new RangeError('Index out of range')
  6958. if (offset < 0) throw new RangeError('Index out of range')
  6959. }
  6960. function writeFloat (buf, value, offset, littleEndian, noAssert) {
  6961. if (!noAssert) {
  6962. checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38)
  6963. }
  6964. ieee754.write(buf, value, offset, littleEndian, 23, 4)
  6965. return offset + 4
  6966. }
  6967. Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) {
  6968. return writeFloat(this, value, offset, true, noAssert)
  6969. }
  6970. Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) {
  6971. return writeFloat(this, value, offset, false, noAssert)
  6972. }
  6973. function writeDouble (buf, value, offset, littleEndian, noAssert) {
  6974. if (!noAssert) {
  6975. checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308)
  6976. }
  6977. ieee754.write(buf, value, offset, littleEndian, 52, 8)
  6978. return offset + 8
  6979. }
  6980. Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) {
  6981. return writeDouble(this, value, offset, true, noAssert)
  6982. }
  6983. Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) {
  6984. return writeDouble(this, value, offset, false, noAssert)
  6985. }
  6986. // copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)
  6987. Buffer.prototype.copy = function copy (target, targetStart, start, end) {
  6988. if (!start) start = 0
  6989. if (!end && end !== 0) end = this.length
  6990. if (targetStart >= target.length) targetStart = target.length
  6991. if (!targetStart) targetStart = 0
  6992. if (end > 0 && end < start) end = start
  6993. // Copy 0 bytes; we're done
  6994. if (end === start) return 0
  6995. if (target.length === 0 || this.length === 0) return 0
  6996. // Fatal error conditions
  6997. if (targetStart < 0) {
  6998. throw new RangeError('targetStart out of bounds')
  6999. }
  7000. if (start < 0 || start >= this.length) throw new RangeError('sourceStart out of bounds')
  7001. if (end < 0) throw new RangeError('sourceEnd out of bounds')
  7002. // Are we oob?
  7003. if (end > this.length) end = this.length
  7004. if (target.length - targetStart < end - start) {
  7005. end = target.length - targetStart + start
  7006. }
  7007. var len = end - start
  7008. var i
  7009. if (this === target && start < targetStart && targetStart < end) {
  7010. // descending copy from end
  7011. for (i = len - 1; i >= 0; --i) {
  7012. target[i + targetStart] = this[i + start]
  7013. }
  7014. } else if (len < 1000 || !Buffer.TYPED_ARRAY_SUPPORT) {
  7015. // ascending copy from start
  7016. for (i = 0; i < len; ++i) {
  7017. target[i + targetStart] = this[i + start]
  7018. }
  7019. } else {
  7020. Uint8Array.prototype.set.call(
  7021. target,
  7022. this.subarray(start, start + len),
  7023. targetStart
  7024. )
  7025. }
  7026. return len
  7027. }
  7028. // Usage:
  7029. // buffer.fill(number[, offset[, end]])
  7030. // buffer.fill(buffer[, offset[, end]])
  7031. // buffer.fill(string[, offset[, end]][, encoding])
  7032. Buffer.prototype.fill = function fill (val, start, end, encoding) {
  7033. // Handle string cases:
  7034. if (typeof val === 'string') {
  7035. if (typeof start === 'string') {
  7036. encoding = start
  7037. start = 0
  7038. end = this.length
  7039. } else if (typeof end === 'string') {
  7040. encoding = end
  7041. end = this.length
  7042. }
  7043. if (val.length === 1) {
  7044. var code = val.charCodeAt(0)
  7045. if (code < 256) {
  7046. val = code
  7047. }
  7048. }
  7049. if (encoding !== undefined && typeof encoding !== 'string') {
  7050. throw new TypeError('encoding must be a string')
  7051. }
  7052. if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) {
  7053. throw new TypeError('Unknown encoding: ' + encoding)
  7054. }
  7055. } else if (typeof val === 'number') {
  7056. val = val & 255
  7057. }
  7058. // Invalid ranges are not set to a default, so can range check early.
  7059. if (start < 0 || this.length < start || this.length < end) {
  7060. throw new RangeError('Out of range index')
  7061. }
  7062. if (end <= start) {
  7063. return this
  7064. }
  7065. start = start >>> 0
  7066. end = end === undefined ? this.length : end >>> 0
  7067. if (!val) val = 0
  7068. var i
  7069. if (typeof val === 'number') {
  7070. for (i = start; i < end; ++i) {
  7071. this[i] = val
  7072. }
  7073. } else {
  7074. var bytes = Buffer.isBuffer(val)
  7075. ? val
  7076. : utf8ToBytes(new Buffer(val, encoding).toString())
  7077. var len = bytes.length
  7078. for (i = 0; i < end - start; ++i) {
  7079. this[i + start] = bytes[i % len]
  7080. }
  7081. }
  7082. return this
  7083. }
  7084. // HELPER FUNCTIONS
  7085. // ================
  7086. var INVALID_BASE64_RE = /[^+\/0-9A-Za-z-_]/g
  7087. function base64clean (str) {
  7088. // Node strips out invalid characters like \n and \t from the string, base64-js does not
  7089. str = stringtrim(str).replace(INVALID_BASE64_RE, '')
  7090. // Node converts strings with length < 2 to ''
  7091. if (str.length < 2) return ''
  7092. // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not
  7093. while (str.length % 4 !== 0) {
  7094. str = str + '='
  7095. }
  7096. return str
  7097. }
  7098. function stringtrim (str) {
  7099. if (str.trim) return str.trim()
  7100. return str.replace(/^\s+|\s+$/g, '')
  7101. }
  7102. function toHex (n) {
  7103. if (n < 16) return '0' + n.toString(16)
  7104. return n.toString(16)
  7105. }
  7106. function utf8ToBytes (string, units) {
  7107. units = units || Infinity
  7108. var codePoint
  7109. var length = string.length
  7110. var leadSurrogate = null
  7111. var bytes = []
  7112. for (var i = 0; i < length; ++i) {
  7113. codePoint = string.charCodeAt(i)
  7114. // is surrogate component
  7115. if (codePoint > 0xD7FF && codePoint < 0xE000) {
  7116. // last char was a lead
  7117. if (!leadSurrogate) {
  7118. // no lead yet
  7119. if (codePoint > 0xDBFF) {
  7120. // unexpected trail
  7121. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  7122. continue
  7123. } else if (i + 1 === length) {
  7124. // unpaired lead
  7125. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  7126. continue
  7127. }
  7128. // valid lead
  7129. leadSurrogate = codePoint
  7130. continue
  7131. }
  7132. // 2 leads in a row
  7133. if (codePoint < 0xDC00) {
  7134. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  7135. leadSurrogate = codePoint
  7136. continue
  7137. }
  7138. // valid surrogate pair
  7139. codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000
  7140. } else if (leadSurrogate) {
  7141. // valid bmp char, but last char was a lead
  7142. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  7143. }
  7144. leadSurrogate = null
  7145. // encode utf8
  7146. if (codePoint < 0x80) {
  7147. if ((units -= 1) < 0) break
  7148. bytes.push(codePoint)
  7149. } else if (codePoint < 0x800) {
  7150. if ((units -= 2) < 0) break
  7151. bytes.push(
  7152. codePoint >> 0x6 | 0xC0,
  7153. codePoint & 0x3F | 0x80
  7154. )
  7155. } else if (codePoint < 0x10000) {
  7156. if ((units -= 3) < 0) break
  7157. bytes.push(
  7158. codePoint >> 0xC | 0xE0,
  7159. codePoint >> 0x6 & 0x3F | 0x80,
  7160. codePoint & 0x3F | 0x80
  7161. )
  7162. } else if (codePoint < 0x110000) {
  7163. if ((units -= 4) < 0) break
  7164. bytes.push(
  7165. codePoint >> 0x12 | 0xF0,
  7166. codePoint >> 0xC & 0x3F | 0x80,
  7167. codePoint >> 0x6 & 0x3F | 0x80,
  7168. codePoint & 0x3F | 0x80
  7169. )
  7170. } else {
  7171. throw new Error('Invalid code point')
  7172. }
  7173. }
  7174. return bytes
  7175. }
  7176. function asciiToBytes (str) {
  7177. var byteArray = []
  7178. for (var i = 0; i < str.length; ++i) {
  7179. // Node's code seems to be doing this and not & 0x7F..
  7180. byteArray.push(str.charCodeAt(i) & 0xFF)
  7181. }
  7182. return byteArray
  7183. }
  7184. function utf16leToBytes (str, units) {
  7185. var c, hi, lo
  7186. var byteArray = []
  7187. for (var i = 0; i < str.length; ++i) {
  7188. if ((units -= 2) < 0) break
  7189. c = str.charCodeAt(i)
  7190. hi = c >> 8
  7191. lo = c % 256
  7192. byteArray.push(lo)
  7193. byteArray.push(hi)
  7194. }
  7195. return byteArray
  7196. }
  7197. function base64ToBytes (str) {
  7198. return base64.toByteArray(base64clean(str))
  7199. }
  7200. function blitBuffer (src, dst, offset, length) {
  7201. for (var i = 0; i < length; ++i) {
  7202. if ((i + offset >= dst.length) || (i >= src.length)) break
  7203. dst[i + offset] = src[i]
  7204. }
  7205. return i
  7206. }
  7207. function isnan (val) {
  7208. return val !== val // eslint-disable-line no-self-compare
  7209. }
  7210. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../webpack/buildin/global.js */ "./node_modules/webpack/buildin/global.js")))
  7211. /***/ }),
  7212. /***/ "./node_modules/clipboard/dist/clipboard.js":
  7213. /*!**************************************************!*\
  7214. !*** ./node_modules/clipboard/dist/clipboard.js ***!
  7215. \**************************************************/
  7216. /*! no static exports found */
  7217. /***/ (function(module, exports, __webpack_require__) {
  7218. /*!
  7219. * clipboard.js v2.0.4
  7220. * https://zenorocha.github.io/clipboard.js
  7221. *
  7222. * Licensed MIT © Zeno Rocha
  7223. */
  7224. (function webpackUniversalModuleDefinition(root, factory) {
  7225. if(true)
  7226. module.exports = factory();
  7227. else {}
  7228. })(this, function() {
  7229. return /******/ (function(modules) { // webpackBootstrap
  7230. /******/ // The module cache
  7231. /******/ var installedModules = {};
  7232. /******/
  7233. /******/ // The require function
  7234. /******/ function __webpack_require__(moduleId) {
  7235. /******/
  7236. /******/ // Check if module is in cache
  7237. /******/ if(installedModules[moduleId]) {
  7238. /******/ return installedModules[moduleId].exports;
  7239. /******/ }
  7240. /******/ // Create a new module (and put it into the cache)
  7241. /******/ var module = installedModules[moduleId] = {
  7242. /******/ i: moduleId,
  7243. /******/ l: false,
  7244. /******/ exports: {}
  7245. /******/ };
  7246. /******/
  7247. /******/ // Execute the module function
  7248. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  7249. /******/
  7250. /******/ // Flag the module as loaded
  7251. /******/ module.l = true;
  7252. /******/
  7253. /******/ // Return the exports of the module
  7254. /******/ return module.exports;
  7255. /******/ }
  7256. /******/
  7257. /******/
  7258. /******/ // expose the modules object (__webpack_modules__)
  7259. /******/ __webpack_require__.m = modules;
  7260. /******/
  7261. /******/ // expose the module cache
  7262. /******/ __webpack_require__.c = installedModules;
  7263. /******/
  7264. /******/ // define getter function for harmony exports
  7265. /******/ __webpack_require__.d = function(exports, name, getter) {
  7266. /******/ if(!__webpack_require__.o(exports, name)) {
  7267. /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
  7268. /******/ }
  7269. /******/ };
  7270. /******/
  7271. /******/ // define __esModule on exports
  7272. /******/ __webpack_require__.r = function(exports) {
  7273. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  7274. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  7275. /******/ }
  7276. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  7277. /******/ };
  7278. /******/
  7279. /******/ // create a fake namespace object
  7280. /******/ // mode & 1: value is a module id, require it
  7281. /******/ // mode & 2: merge all properties of value into the ns
  7282. /******/ // mode & 4: return value when already ns object
  7283. /******/ // mode & 8|1: behave like require
  7284. /******/ __webpack_require__.t = function(value, mode) {
  7285. /******/ if(mode & 1) value = __webpack_require__(value);
  7286. /******/ if(mode & 8) return value;
  7287. /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
  7288. /******/ var ns = Object.create(null);
  7289. /******/ __webpack_require__.r(ns);
  7290. /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
  7291. /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
  7292. /******/ return ns;
  7293. /******/ };
  7294. /******/
  7295. /******/ // getDefaultExport function for compatibility with non-harmony modules
  7296. /******/ __webpack_require__.n = function(module) {
  7297. /******/ var getter = module && module.__esModule ?
  7298. /******/ function getDefault() { return module['default']; } :
  7299. /******/ function getModuleExports() { return module; };
  7300. /******/ __webpack_require__.d(getter, 'a', getter);
  7301. /******/ return getter;
  7302. /******/ };
  7303. /******/
  7304. /******/ // Object.prototype.hasOwnProperty.call
  7305. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  7306. /******/
  7307. /******/ // __webpack_public_path__
  7308. /******/ __webpack_require__.p = "";
  7309. /******/
  7310. /******/
  7311. /******/ // Load entry module and return exports
  7312. /******/ return __webpack_require__(__webpack_require__.s = 0);
  7313. /******/ })
  7314. /************************************************************************/
  7315. /******/ ([
  7316. /* 0 */
  7317. /***/ (function(module, exports, __webpack_require__) {
  7318. "use strict";
  7319. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
  7320. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  7321. var _clipboardAction = __webpack_require__(1);
  7322. var _clipboardAction2 = _interopRequireDefault(_clipboardAction);
  7323. var _tinyEmitter = __webpack_require__(3);
  7324. var _tinyEmitter2 = _interopRequireDefault(_tinyEmitter);
  7325. var _goodListener = __webpack_require__(4);
  7326. var _goodListener2 = _interopRequireDefault(_goodListener);
  7327. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  7328. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  7329. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  7330. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  7331. /**
  7332. * Base class which takes one or more elements, adds event listeners to them,
  7333. * and instantiates a new `ClipboardAction` on each click.
  7334. */
  7335. var Clipboard = function (_Emitter) {
  7336. _inherits(Clipboard, _Emitter);
  7337. /**
  7338. * @param {String|HTMLElement|HTMLCollection|NodeList} trigger
  7339. * @param {Object} options
  7340. */
  7341. function Clipboard(trigger, options) {
  7342. _classCallCheck(this, Clipboard);
  7343. var _this = _possibleConstructorReturn(this, (Clipboard.__proto__ || Object.getPrototypeOf(Clipboard)).call(this));
  7344. _this.resolveOptions(options);
  7345. _this.listenClick(trigger);
  7346. return _this;
  7347. }
  7348. /**
  7349. * Defines if attributes would be resolved using internal setter functions
  7350. * or custom functions that were passed in the constructor.
  7351. * @param {Object} options
  7352. */
  7353. _createClass(Clipboard, [{
  7354. key: 'resolveOptions',
  7355. value: function resolveOptions() {
  7356. var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  7357. this.action = typeof options.action === 'function' ? options.action : this.defaultAction;
  7358. this.target = typeof options.target === 'function' ? options.target : this.defaultTarget;
  7359. this.text = typeof options.text === 'function' ? options.text : this.defaultText;
  7360. this.container = _typeof(options.container) === 'object' ? options.container : document.body;
  7361. }
  7362. /**
  7363. * Adds a click event listener to the passed trigger.
  7364. * @param {String|HTMLElement|HTMLCollection|NodeList} trigger
  7365. */
  7366. }, {
  7367. key: 'listenClick',
  7368. value: function listenClick(trigger) {
  7369. var _this2 = this;
  7370. this.listener = (0, _goodListener2.default)(trigger, 'click', function (e) {
  7371. return _this2.onClick(e);
  7372. });
  7373. }
  7374. /**
  7375. * Defines a new `ClipboardAction` on each click event.
  7376. * @param {Event} e
  7377. */
  7378. }, {
  7379. key: 'onClick',
  7380. value: function onClick(e) {
  7381. var trigger = e.delegateTarget || e.currentTarget;
  7382. if (this.clipboardAction) {
  7383. this.clipboardAction = null;
  7384. }
  7385. this.clipboardAction = new _clipboardAction2.default({
  7386. action: this.action(trigger),
  7387. target: this.target(trigger),
  7388. text: this.text(trigger),
  7389. container: this.container,
  7390. trigger: trigger,
  7391. emitter: this
  7392. });
  7393. }
  7394. /**
  7395. * Default `action` lookup function.
  7396. * @param {Element} trigger
  7397. */
  7398. }, {
  7399. key: 'defaultAction',
  7400. value: function defaultAction(trigger) {
  7401. return getAttributeValue('action', trigger);
  7402. }
  7403. /**
  7404. * Default `target` lookup function.
  7405. * @param {Element} trigger
  7406. */
  7407. }, {
  7408. key: 'defaultTarget',
  7409. value: function defaultTarget(trigger) {
  7410. var selector = getAttributeValue('target', trigger);
  7411. if (selector) {
  7412. return document.querySelector(selector);
  7413. }
  7414. }
  7415. /**
  7416. * Returns the support of the given action, or all actions if no action is
  7417. * given.
  7418. * @param {String} [action]
  7419. */
  7420. }, {
  7421. key: 'defaultText',
  7422. /**
  7423. * Default `text` lookup function.
  7424. * @param {Element} trigger
  7425. */
  7426. value: function defaultText(trigger) {
  7427. return getAttributeValue('text', trigger);
  7428. }
  7429. /**
  7430. * Destroy lifecycle.
  7431. */
  7432. }, {
  7433. key: 'destroy',
  7434. value: function destroy() {
  7435. this.listener.destroy();
  7436. if (this.clipboardAction) {
  7437. this.clipboardAction.destroy();
  7438. this.clipboardAction = null;
  7439. }
  7440. }
  7441. }], [{
  7442. key: 'isSupported',
  7443. value: function isSupported() {
  7444. var action = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ['copy', 'cut'];
  7445. var actions = typeof action === 'string' ? [action] : action;
  7446. var support = !!document.queryCommandSupported;
  7447. actions.forEach(function (action) {
  7448. support = support && !!document.queryCommandSupported(action);
  7449. });
  7450. return support;
  7451. }
  7452. }]);
  7453. return Clipboard;
  7454. }(_tinyEmitter2.default);
  7455. /**
  7456. * Helper function to retrieve attribute value.
  7457. * @param {String} suffix
  7458. * @param {Element} element
  7459. */
  7460. function getAttributeValue(suffix, element) {
  7461. var attribute = 'data-clipboard-' + suffix;
  7462. if (!element.hasAttribute(attribute)) {
  7463. return;
  7464. }
  7465. return element.getAttribute(attribute);
  7466. }
  7467. module.exports = Clipboard;
  7468. /***/ }),
  7469. /* 1 */
  7470. /***/ (function(module, exports, __webpack_require__) {
  7471. "use strict";
  7472. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
  7473. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  7474. var _select = __webpack_require__(2);
  7475. var _select2 = _interopRequireDefault(_select);
  7476. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  7477. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  7478. /**
  7479. * Inner class which performs selection from either `text` or `target`
  7480. * properties and then executes copy or cut operations.
  7481. */
  7482. var ClipboardAction = function () {
  7483. /**
  7484. * @param {Object} options
  7485. */
  7486. function ClipboardAction(options) {
  7487. _classCallCheck(this, ClipboardAction);
  7488. this.resolveOptions(options);
  7489. this.initSelection();
  7490. }
  7491. /**
  7492. * Defines base properties passed from constructor.
  7493. * @param {Object} options
  7494. */
  7495. _createClass(ClipboardAction, [{
  7496. key: 'resolveOptions',
  7497. value: function resolveOptions() {
  7498. var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  7499. this.action = options.action;
  7500. this.container = options.container;
  7501. this.emitter = options.emitter;
  7502. this.target = options.target;
  7503. this.text = options.text;
  7504. this.trigger = options.trigger;
  7505. this.selectedText = '';
  7506. }
  7507. /**
  7508. * Decides which selection strategy is going to be applied based
  7509. * on the existence of `text` and `target` properties.
  7510. */
  7511. }, {
  7512. key: 'initSelection',
  7513. value: function initSelection() {
  7514. if (this.text) {
  7515. this.selectFake();
  7516. } else if (this.target) {
  7517. this.selectTarget();
  7518. }
  7519. }
  7520. /**
  7521. * Creates a fake textarea element, sets its value from `text` property,
  7522. * and makes a selection on it.
  7523. */
  7524. }, {
  7525. key: 'selectFake',
  7526. value: function selectFake() {
  7527. var _this = this;
  7528. var isRTL = document.documentElement.getAttribute('dir') == 'rtl';
  7529. this.removeFake();
  7530. this.fakeHandlerCallback = function () {
  7531. return _this.removeFake();
  7532. };
  7533. this.fakeHandler = this.container.addEventListener('click', this.fakeHandlerCallback) || true;
  7534. this.fakeElem = document.createElement('textarea');
  7535. // Prevent zooming on iOS
  7536. this.fakeElem.style.fontSize = '12pt';
  7537. // Reset box model
  7538. this.fakeElem.style.border = '0';
  7539. this.fakeElem.style.padding = '0';
  7540. this.fakeElem.style.margin = '0';
  7541. // Move element out of screen horizontally
  7542. this.fakeElem.style.position = 'absolute';
  7543. this.fakeElem.style[isRTL ? 'right' : 'left'] = '-9999px';
  7544. // Move element to the same position vertically
  7545. var yPosition = window.pageYOffset || document.documentElement.scrollTop;
  7546. this.fakeElem.style.top = yPosition + 'px';
  7547. this.fakeElem.setAttribute('readonly', '');
  7548. this.fakeElem.value = this.text;
  7549. this.container.appendChild(this.fakeElem);
  7550. this.selectedText = (0, _select2.default)(this.fakeElem);
  7551. this.copyText();
  7552. }
  7553. /**
  7554. * Only removes the fake element after another click event, that way
  7555. * a user can hit `Ctrl+C` to copy because selection still exists.
  7556. */
  7557. }, {
  7558. key: 'removeFake',
  7559. value: function removeFake() {
  7560. if (this.fakeHandler) {
  7561. this.container.removeEventListener('click', this.fakeHandlerCallback);
  7562. this.fakeHandler = null;
  7563. this.fakeHandlerCallback = null;
  7564. }
  7565. if (this.fakeElem) {
  7566. this.container.removeChild(this.fakeElem);
  7567. this.fakeElem = null;
  7568. }
  7569. }
  7570. /**
  7571. * Selects the content from element passed on `target` property.
  7572. */
  7573. }, {
  7574. key: 'selectTarget',
  7575. value: function selectTarget() {
  7576. this.selectedText = (0, _select2.default)(this.target);
  7577. this.copyText();
  7578. }
  7579. /**
  7580. * Executes the copy operation based on the current selection.
  7581. */
  7582. }, {
  7583. key: 'copyText',
  7584. value: function copyText() {
  7585. var succeeded = void 0;
  7586. try {
  7587. succeeded = document.execCommand(this.action);
  7588. } catch (err) {
  7589. succeeded = false;
  7590. }
  7591. this.handleResult(succeeded);
  7592. }
  7593. /**
  7594. * Fires an event based on the copy operation result.
  7595. * @param {Boolean} succeeded
  7596. */
  7597. }, {
  7598. key: 'handleResult',
  7599. value: function handleResult(succeeded) {
  7600. this.emitter.emit(succeeded ? 'success' : 'error', {
  7601. action: this.action,
  7602. text: this.selectedText,
  7603. trigger: this.trigger,
  7604. clearSelection: this.clearSelection.bind(this)
  7605. });
  7606. }
  7607. /**
  7608. * Moves focus away from `target` and back to the trigger, removes current selection.
  7609. */
  7610. }, {
  7611. key: 'clearSelection',
  7612. value: function clearSelection() {
  7613. if (this.trigger) {
  7614. this.trigger.focus();
  7615. }
  7616. window.getSelection().removeAllRanges();
  7617. }
  7618. /**
  7619. * Sets the `action` to be performed which can be either 'copy' or 'cut'.
  7620. * @param {String} action
  7621. */
  7622. }, {
  7623. key: 'destroy',
  7624. /**
  7625. * Destroy lifecycle.
  7626. */
  7627. value: function destroy() {
  7628. this.removeFake();
  7629. }
  7630. }, {
  7631. key: 'action',
  7632. set: function set() {
  7633. var action = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'copy';
  7634. this._action = action;
  7635. if (this._action !== 'copy' && this._action !== 'cut') {
  7636. throw new Error('Invalid "action" value, use either "copy" or "cut"');
  7637. }
  7638. }
  7639. /**
  7640. * Gets the `action` property.
  7641. * @return {String}
  7642. */
  7643. ,
  7644. get: function get() {
  7645. return this._action;
  7646. }
  7647. /**
  7648. * Sets the `target` property using an element
  7649. * that will be have its content copied.
  7650. * @param {Element} target
  7651. */
  7652. }, {
  7653. key: 'target',
  7654. set: function set(target) {
  7655. if (target !== undefined) {
  7656. if (target && (typeof target === 'undefined' ? 'undefined' : _typeof(target)) === 'object' && target.nodeType === 1) {
  7657. if (this.action === 'copy' && target.hasAttribute('disabled')) {
  7658. throw new Error('Invalid "target" attribute. Please use "readonly" instead of "disabled" attribute');
  7659. }
  7660. if (this.action === 'cut' && (target.hasAttribute('readonly') || target.hasAttribute('disabled'))) {
  7661. throw new Error('Invalid "target" attribute. You can\'t cut text from elements with "readonly" or "disabled" attributes');
  7662. }
  7663. this._target = target;
  7664. } else {
  7665. throw new Error('Invalid "target" value, use a valid Element');
  7666. }
  7667. }
  7668. }
  7669. /**
  7670. * Gets the `target` property.
  7671. * @return {String|HTMLElement}
  7672. */
  7673. ,
  7674. get: function get() {
  7675. return this._target;
  7676. }
  7677. }]);
  7678. return ClipboardAction;
  7679. }();
  7680. module.exports = ClipboardAction;
  7681. /***/ }),
  7682. /* 2 */
  7683. /***/ (function(module, exports) {
  7684. function select(element) {
  7685. var selectedText;
  7686. if (element.nodeName === 'SELECT') {
  7687. element.focus();
  7688. selectedText = element.value;
  7689. }
  7690. else if (element.nodeName === 'INPUT' || element.nodeName === 'TEXTAREA') {
  7691. var isReadOnly = element.hasAttribute('readonly');
  7692. if (!isReadOnly) {
  7693. element.setAttribute('readonly', '');
  7694. }
  7695. element.select();
  7696. element.setSelectionRange(0, element.value.length);
  7697. if (!isReadOnly) {
  7698. element.removeAttribute('readonly');
  7699. }
  7700. selectedText = element.value;
  7701. }
  7702. else {
  7703. if (element.hasAttribute('contenteditable')) {
  7704. element.focus();
  7705. }
  7706. var selection = window.getSelection();
  7707. var range = document.createRange();
  7708. range.selectNodeContents(element);
  7709. selection.removeAllRanges();
  7710. selection.addRange(range);
  7711. selectedText = selection.toString();
  7712. }
  7713. return selectedText;
  7714. }
  7715. module.exports = select;
  7716. /***/ }),
  7717. /* 3 */
  7718. /***/ (function(module, exports) {
  7719. function E () {
  7720. // Keep this empty so it's easier to inherit from
  7721. // (via https://github.com/lipsmack from https://github.com/scottcorgan/tiny-emitter/issues/3)
  7722. }
  7723. E.prototype = {
  7724. on: function (name, callback, ctx) {
  7725. var e = this.e || (this.e = {});
  7726. (e[name] || (e[name] = [])).push({
  7727. fn: callback,
  7728. ctx: ctx
  7729. });
  7730. return this;
  7731. },
  7732. once: function (name, callback, ctx) {
  7733. var self = this;
  7734. function listener () {
  7735. self.off(name, listener);
  7736. callback.apply(ctx, arguments);
  7737. };
  7738. listener._ = callback
  7739. return this.on(name, listener, ctx);
  7740. },
  7741. emit: function (name) {
  7742. var data = [].slice.call(arguments, 1);
  7743. var evtArr = ((this.e || (this.e = {}))[name] || []).slice();
  7744. var i = 0;
  7745. var len = evtArr.length;
  7746. for (i; i < len; i++) {
  7747. evtArr[i].fn.apply(evtArr[i].ctx, data);
  7748. }
  7749. return this;
  7750. },
  7751. off: function (name, callback) {
  7752. var e = this.e || (this.e = {});
  7753. var evts = e[name];
  7754. var liveEvents = [];
  7755. if (evts && callback) {
  7756. for (var i = 0, len = evts.length; i < len; i++) {
  7757. if (evts[i].fn !== callback && evts[i].fn._ !== callback)
  7758. liveEvents.push(evts[i]);
  7759. }
  7760. }
  7761. // Remove event from queue to prevent memory leak
  7762. // Suggested by https://github.com/lazd
  7763. // Ref: https://github.com/scottcorgan/tiny-emitter/commit/c6ebfaa9bc973b33d110a84a307742b7cf94c953#commitcomment-5024910
  7764. (liveEvents.length)
  7765. ? e[name] = liveEvents
  7766. : delete e[name];
  7767. return this;
  7768. }
  7769. };
  7770. module.exports = E;
  7771. /***/ }),
  7772. /* 4 */
  7773. /***/ (function(module, exports, __webpack_require__) {
  7774. var is = __webpack_require__(5);
  7775. var delegate = __webpack_require__(6);
  7776. /**
  7777. * Validates all params and calls the right
  7778. * listener function based on its target type.
  7779. *
  7780. * @param {String|HTMLElement|HTMLCollection|NodeList} target
  7781. * @param {String} type
  7782. * @param {Function} callback
  7783. * @return {Object}
  7784. */
  7785. function listen(target, type, callback) {
  7786. if (!target && !type && !callback) {
  7787. throw new Error('Missing required arguments');
  7788. }
  7789. if (!is.string(type)) {
  7790. throw new TypeError('Second argument must be a String');
  7791. }
  7792. if (!is.fn(callback)) {
  7793. throw new TypeError('Third argument must be a Function');
  7794. }
  7795. if (is.node(target)) {
  7796. return listenNode(target, type, callback);
  7797. }
  7798. else if (is.nodeList(target)) {
  7799. return listenNodeList(target, type, callback);
  7800. }
  7801. else if (is.string(target)) {
  7802. return listenSelector(target, type, callback);
  7803. }
  7804. else {
  7805. throw new TypeError('First argument must be a String, HTMLElement, HTMLCollection, or NodeList');
  7806. }
  7807. }
  7808. /**
  7809. * Adds an event listener to a HTML element
  7810. * and returns a remove listener function.
  7811. *
  7812. * @param {HTMLElement} node
  7813. * @param {String} type
  7814. * @param {Function} callback
  7815. * @return {Object}
  7816. */
  7817. function listenNode(node, type, callback) {
  7818. node.addEventListener(type, callback);
  7819. return {
  7820. destroy: function() {
  7821. node.removeEventListener(type, callback);
  7822. }
  7823. }
  7824. }
  7825. /**
  7826. * Add an event listener to a list of HTML elements
  7827. * and returns a remove listener function.
  7828. *
  7829. * @param {NodeList|HTMLCollection} nodeList
  7830. * @param {String} type
  7831. * @param {Function} callback
  7832. * @return {Object}
  7833. */
  7834. function listenNodeList(nodeList, type, callback) {
  7835. Array.prototype.forEach.call(nodeList, function(node) {
  7836. node.addEventListener(type, callback);
  7837. });
  7838. return {
  7839. destroy: function() {
  7840. Array.prototype.forEach.call(nodeList, function(node) {
  7841. node.removeEventListener(type, callback);
  7842. });
  7843. }
  7844. }
  7845. }
  7846. /**
  7847. * Add an event listener to a selector
  7848. * and returns a remove listener function.
  7849. *
  7850. * @param {String} selector
  7851. * @param {String} type
  7852. * @param {Function} callback
  7853. * @return {Object}
  7854. */
  7855. function listenSelector(selector, type, callback) {
  7856. return delegate(document.body, selector, type, callback);
  7857. }
  7858. module.exports = listen;
  7859. /***/ }),
  7860. /* 5 */
  7861. /***/ (function(module, exports) {
  7862. /**
  7863. * Check if argument is a HTML element.
  7864. *
  7865. * @param {Object} value
  7866. * @return {Boolean}
  7867. */
  7868. exports.node = function(value) {
  7869. return value !== undefined
  7870. && value instanceof HTMLElement
  7871. && value.nodeType === 1;
  7872. };
  7873. /**
  7874. * Check if argument is a list of HTML elements.
  7875. *
  7876. * @param {Object} value
  7877. * @return {Boolean}
  7878. */
  7879. exports.nodeList = function(value) {
  7880. var type = Object.prototype.toString.call(value);
  7881. return value !== undefined
  7882. && (type === '[object NodeList]' || type === '[object HTMLCollection]')
  7883. && ('length' in value)
  7884. && (value.length === 0 || exports.node(value[0]));
  7885. };
  7886. /**
  7887. * Check if argument is a string.
  7888. *
  7889. * @param {Object} value
  7890. * @return {Boolean}
  7891. */
  7892. exports.string = function(value) {
  7893. return typeof value === 'string'
  7894. || value instanceof String;
  7895. };
  7896. /**
  7897. * Check if argument is a function.
  7898. *
  7899. * @param {Object} value
  7900. * @return {Boolean}
  7901. */
  7902. exports.fn = function(value) {
  7903. var type = Object.prototype.toString.call(value);
  7904. return type === '[object Function]';
  7905. };
  7906. /***/ }),
  7907. /* 6 */
  7908. /***/ (function(module, exports, __webpack_require__) {
  7909. var closest = __webpack_require__(7);
  7910. /**
  7911. * Delegates event to a selector.
  7912. *
  7913. * @param {Element} element
  7914. * @param {String} selector
  7915. * @param {String} type
  7916. * @param {Function} callback
  7917. * @param {Boolean} useCapture
  7918. * @return {Object}
  7919. */
  7920. function _delegate(element, selector, type, callback, useCapture) {
  7921. var listenerFn = listener.apply(this, arguments);
  7922. element.addEventListener(type, listenerFn, useCapture);
  7923. return {
  7924. destroy: function() {
  7925. element.removeEventListener(type, listenerFn, useCapture);
  7926. }
  7927. }
  7928. }
  7929. /**
  7930. * Delegates event to a selector.
  7931. *
  7932. * @param {Element|String|Array} [elements]
  7933. * @param {String} selector
  7934. * @param {String} type
  7935. * @param {Function} callback
  7936. * @param {Boolean} useCapture
  7937. * @return {Object}
  7938. */
  7939. function delegate(elements, selector, type, callback, useCapture) {
  7940. // Handle the regular Element usage
  7941. if (typeof elements.addEventListener === 'function') {
  7942. return _delegate.apply(null, arguments);
  7943. }
  7944. // Handle Element-less usage, it defaults to global delegation
  7945. if (typeof type === 'function') {
  7946. // Use `document` as the first parameter, then apply arguments
  7947. // This is a short way to .unshift `arguments` without running into deoptimizations
  7948. return _delegate.bind(null, document).apply(null, arguments);
  7949. }
  7950. // Handle Selector-based usage
  7951. if (typeof elements === 'string') {
  7952. elements = document.querySelectorAll(elements);
  7953. }
  7954. // Handle Array-like based usage
  7955. return Array.prototype.map.call(elements, function (element) {
  7956. return _delegate(element, selector, type, callback, useCapture);
  7957. });
  7958. }
  7959. /**
  7960. * Finds closest match and invokes callback.
  7961. *
  7962. * @param {Element} element
  7963. * @param {String} selector
  7964. * @param {String} type
  7965. * @param {Function} callback
  7966. * @return {Function}
  7967. */
  7968. function listener(element, selector, type, callback) {
  7969. return function(e) {
  7970. e.delegateTarget = closest(e.target, selector);
  7971. if (e.delegateTarget) {
  7972. callback.call(element, e);
  7973. }
  7974. }
  7975. }
  7976. module.exports = delegate;
  7977. /***/ }),
  7978. /* 7 */
  7979. /***/ (function(module, exports) {
  7980. var DOCUMENT_NODE_TYPE = 9;
  7981. /**
  7982. * A polyfill for Element.matches()
  7983. */
  7984. if (typeof Element !== 'undefined' && !Element.prototype.matches) {
  7985. var proto = Element.prototype;
  7986. proto.matches = proto.matchesSelector ||
  7987. proto.mozMatchesSelector ||
  7988. proto.msMatchesSelector ||
  7989. proto.oMatchesSelector ||
  7990. proto.webkitMatchesSelector;
  7991. }
  7992. /**
  7993. * Finds the closest parent that matches a selector.
  7994. *
  7995. * @param {Element} element
  7996. * @param {String} selector
  7997. * @return {Function}
  7998. */
  7999. function closest (element, selector) {
  8000. while (element && element.nodeType !== DOCUMENT_NODE_TYPE) {
  8001. if (typeof element.matches === 'function' &&
  8002. element.matches(selector)) {
  8003. return element;
  8004. }
  8005. element = element.parentNode;
  8006. }
  8007. }
  8008. module.exports = closest;
  8009. /***/ })
  8010. /******/ ]);
  8011. });
  8012. /***/ }),
  8013. /***/ "./node_modules/ieee754/index.js":
  8014. /*!***************************************!*\
  8015. !*** ./node_modules/ieee754/index.js ***!
  8016. \***************************************/
  8017. /*! no static exports found */
  8018. /***/ (function(module, exports) {
  8019. exports.read = function (buffer, offset, isLE, mLen, nBytes) {
  8020. var e, m
  8021. var eLen = (nBytes * 8) - mLen - 1
  8022. var eMax = (1 << eLen) - 1
  8023. var eBias = eMax >> 1
  8024. var nBits = -7
  8025. var i = isLE ? (nBytes - 1) : 0
  8026. var d = isLE ? -1 : 1
  8027. var s = buffer[offset + i]
  8028. i += d
  8029. e = s & ((1 << (-nBits)) - 1)
  8030. s >>= (-nBits)
  8031. nBits += eLen
  8032. for (; nBits > 0; e = (e * 256) + buffer[offset + i], i += d, nBits -= 8) {}
  8033. m = e & ((1 << (-nBits)) - 1)
  8034. e >>= (-nBits)
  8035. nBits += mLen
  8036. for (; nBits > 0; m = (m * 256) + buffer[offset + i], i += d, nBits -= 8) {}
  8037. if (e === 0) {
  8038. e = 1 - eBias
  8039. } else if (e === eMax) {
  8040. return m ? NaN : ((s ? -1 : 1) * Infinity)
  8041. } else {
  8042. m = m + Math.pow(2, mLen)
  8043. e = e - eBias
  8044. }
  8045. return (s ? -1 : 1) * m * Math.pow(2, e - mLen)
  8046. }
  8047. exports.write = function (buffer, value, offset, isLE, mLen, nBytes) {
  8048. var e, m, c
  8049. var eLen = (nBytes * 8) - mLen - 1
  8050. var eMax = (1 << eLen) - 1
  8051. var eBias = eMax >> 1
  8052. var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0)
  8053. var i = isLE ? 0 : (nBytes - 1)
  8054. var d = isLE ? 1 : -1
  8055. var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0
  8056. value = Math.abs(value)
  8057. if (isNaN(value) || value === Infinity) {
  8058. m = isNaN(value) ? 1 : 0
  8059. e = eMax
  8060. } else {
  8061. e = Math.floor(Math.log(value) / Math.LN2)
  8062. if (value * (c = Math.pow(2, -e)) < 1) {
  8063. e--
  8064. c *= 2
  8065. }
  8066. if (e + eBias >= 1) {
  8067. value += rt / c
  8068. } else {
  8069. value += rt * Math.pow(2, 1 - eBias)
  8070. }
  8071. if (value * c >= 2) {
  8072. e++
  8073. c /= 2
  8074. }
  8075. if (e + eBias >= eMax) {
  8076. m = 0
  8077. e = eMax
  8078. } else if (e + eBias >= 1) {
  8079. m = ((value * c) - 1) * Math.pow(2, mLen)
  8080. e = e + eBias
  8081. } else {
  8082. m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen)
  8083. e = 0
  8084. }
  8085. }
  8086. for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}
  8087. e = (e << mLen) | m
  8088. eLen += mLen
  8089. for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}
  8090. buffer[offset + i - d] |= s * 128
  8091. }
  8092. /***/ }),
  8093. /***/ "./node_modules/isarray/index.js":
  8094. /*!***************************************!*\
  8095. !*** ./node_modules/isarray/index.js ***!
  8096. \***************************************/
  8097. /*! no static exports found */
  8098. /***/ (function(module, exports) {
  8099. var toString = {}.toString;
  8100. module.exports = Array.isArray || function (arr) {
  8101. return toString.call(arr) == '[object Array]';
  8102. };
  8103. /***/ }),
  8104. /***/ "./node_modules/jquery/dist/jquery.js":
  8105. /*!********************************************!*\
  8106. !*** ./node_modules/jquery/dist/jquery.js ***!
  8107. \********************************************/
  8108. /*! no static exports found */
  8109. /***/ (function(module, exports, __webpack_require__) {
  8110. var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/*!
  8111. * jQuery JavaScript Library v3.4.1
  8112. * https://jquery.com/
  8113. *
  8114. * Includes Sizzle.js
  8115. * https://sizzlejs.com/
  8116. *
  8117. * Copyright JS Foundation and other contributors
  8118. * Released under the MIT license
  8119. * https://jquery.org/license
  8120. *
  8121. * Date: 2019-05-01T21:04Z
  8122. */
  8123. ( function( global, factory ) {
  8124. "use strict";
  8125. if ( true && typeof module.exports === "object" ) {
  8126. // For CommonJS and CommonJS-like environments where a proper `window`
  8127. // is present, execute the factory and get jQuery.
  8128. // For environments that do not have a `window` with a `document`
  8129. // (such as Node.js), expose a factory as module.exports.
  8130. // This accentuates the need for the creation of a real `window`.
  8131. // e.g. var jQuery = require("jquery")(window);
  8132. // See ticket #14549 for more info.
  8133. module.exports = global.document ?
  8134. factory( global, true ) :
  8135. function( w ) {
  8136. if ( !w.document ) {
  8137. throw new Error( "jQuery requires a window with a document" );
  8138. }
  8139. return factory( w );
  8140. };
  8141. } else {
  8142. factory( global );
  8143. }
  8144. // Pass this if window is not defined yet
  8145. } )( typeof window !== "undefined" ? window : this, function( window, noGlobal ) {
  8146. // Edge <= 12 - 13+, Firefox <=18 - 45+, IE 10 - 11, Safari 5.1 - 9+, iOS 6 - 9.1
  8147. // throw exceptions when non-strict code (e.g., ASP.NET 4.5) accesses strict mode
  8148. // arguments.callee.caller (trac-13335). But as of jQuery 3.0 (2016), strict mode should be common
  8149. // enough that all such attempts are guarded in a try block.
  8150. "use strict";
  8151. var arr = [];
  8152. var document = window.document;
  8153. var getProto = Object.getPrototypeOf;
  8154. var slice = arr.slice;
  8155. var concat = arr.concat;
  8156. var push = arr.push;
  8157. var indexOf = arr.indexOf;
  8158. var class2type = {};
  8159. var toString = class2type.toString;
  8160. var hasOwn = class2type.hasOwnProperty;
  8161. var fnToString = hasOwn.toString;
  8162. var ObjectFunctionString = fnToString.call( Object );
  8163. var support = {};
  8164. var isFunction = function isFunction( obj ) {
  8165. // Support: Chrome <=57, Firefox <=52
  8166. // In some browsers, typeof returns "function" for HTML <object> elements
  8167. // (i.e., `typeof document.createElement( "object" ) === "function"`).
  8168. // We don't want to classify *any* DOM node as a function.
  8169. return typeof obj === "function" && typeof obj.nodeType !== "number";
  8170. };
  8171. var isWindow = function isWindow( obj ) {
  8172. return obj != null && obj === obj.window;
  8173. };
  8174. var preservedScriptAttributes = {
  8175. type: true,
  8176. src: true,
  8177. nonce: true,
  8178. noModule: true
  8179. };
  8180. function DOMEval( code, node, doc ) {
  8181. doc = doc || document;
  8182. var i, val,
  8183. script = doc.createElement( "script" );
  8184. script.text = code;
  8185. if ( node ) {
  8186. for ( i in preservedScriptAttributes ) {
  8187. // Support: Firefox 64+, Edge 18+
  8188. // Some browsers don't support the "nonce" property on scripts.
  8189. // On the other hand, just using `getAttribute` is not enough as
  8190. // the `nonce` attribute is reset to an empty string whenever it
  8191. // becomes browsing-context connected.
  8192. // See https://github.com/whatwg/html/issues/2369
  8193. // See https://html.spec.whatwg.org/#nonce-attributes
  8194. // The `node.getAttribute` check was added for the sake of
  8195. // `jQuery.globalEval` so that it can fake a nonce-containing node
  8196. // via an object.
  8197. val = node[ i ] || node.getAttribute && node.getAttribute( i );
  8198. if ( val ) {
  8199. script.setAttribute( i, val );
  8200. }
  8201. }
  8202. }
  8203. doc.head.appendChild( script ).parentNode.removeChild( script );
  8204. }
  8205. function toType( obj ) {
  8206. if ( obj == null ) {
  8207. return obj + "";
  8208. }
  8209. // Support: Android <=2.3 only (functionish RegExp)
  8210. return typeof obj === "object" || typeof obj === "function" ?
  8211. class2type[ toString.call( obj ) ] || "object" :
  8212. typeof obj;
  8213. }
  8214. /* global Symbol */
  8215. // Defining this global in .eslintrc.json would create a danger of using the global
  8216. // unguarded in another place, it seems safer to define global only for this module
  8217. var
  8218. version = "3.4.1",
  8219. // Define a local copy of jQuery
  8220. jQuery = function( selector, context ) {
  8221. // The jQuery object is actually just the init constructor 'enhanced'
  8222. // Need init if jQuery is called (just allow error to be thrown if not included)
  8223. return new jQuery.fn.init( selector, context );
  8224. },
  8225. // Support: Android <=4.0 only
  8226. // Make sure we trim BOM and NBSP
  8227. rtrim = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g;
  8228. jQuery.fn = jQuery.prototype = {
  8229. // The current version of jQuery being used
  8230. jquery: version,
  8231. constructor: jQuery,
  8232. // The default length of a jQuery object is 0
  8233. length: 0,
  8234. toArray: function() {
  8235. return slice.call( this );
  8236. },
  8237. // Get the Nth element in the matched element set OR
  8238. // Get the whole matched element set as a clean array
  8239. get: function( num ) {
  8240. // Return all the elements in a clean array
  8241. if ( num == null ) {
  8242. return slice.call( this );
  8243. }
  8244. // Return just the one element from the set
  8245. return num < 0 ? this[ num + this.length ] : this[ num ];
  8246. },
  8247. // Take an array of elements and push it onto the stack
  8248. // (returning the new matched element set)
  8249. pushStack: function( elems ) {
  8250. // Build a new jQuery matched element set
  8251. var ret = jQuery.merge( this.constructor(), elems );
  8252. // Add the old object onto the stack (as a reference)
  8253. ret.prevObject = this;
  8254. // Return the newly-formed element set
  8255. return ret;
  8256. },
  8257. // Execute a callback for every element in the matched set.
  8258. each: function( callback ) {
  8259. return jQuery.each( this, callback );
  8260. },
  8261. map: function( callback ) {
  8262. return this.pushStack( jQuery.map( this, function( elem, i ) {
  8263. return callback.call( elem, i, elem );
  8264. } ) );
  8265. },
  8266. slice: function() {
  8267. return this.pushStack( slice.apply( this, arguments ) );
  8268. },
  8269. first: function() {
  8270. return this.eq( 0 );
  8271. },
  8272. last: function() {
  8273. return this.eq( -1 );
  8274. },
  8275. eq: function( i ) {
  8276. var len = this.length,
  8277. j = +i + ( i < 0 ? len : 0 );
  8278. return this.pushStack( j >= 0 && j < len ? [ this[ j ] ] : [] );
  8279. },
  8280. end: function() {
  8281. return this.prevObject || this.constructor();
  8282. },
  8283. // For internal use only.
  8284. // Behaves like an Array's method, not like a jQuery method.
  8285. push: push,
  8286. sort: arr.sort,
  8287. splice: arr.splice
  8288. };
  8289. jQuery.extend = jQuery.fn.extend = function() {
  8290. var options, name, src, copy, copyIsArray, clone,
  8291. target = arguments[ 0 ] || {},
  8292. i = 1,
  8293. length = arguments.length,
  8294. deep = false;
  8295. // Handle a deep copy situation
  8296. if ( typeof target === "boolean" ) {
  8297. deep = target;
  8298. // Skip the boolean and the target
  8299. target = arguments[ i ] || {};
  8300. i++;
  8301. }
  8302. // Handle case when target is a string or something (possible in deep copy)
  8303. if ( typeof target !== "object" && !isFunction( target ) ) {
  8304. target = {};
  8305. }
  8306. // Extend jQuery itself if only one argument is passed
  8307. if ( i === length ) {
  8308. target = this;
  8309. i--;
  8310. }
  8311. for ( ; i < length; i++ ) {
  8312. // Only deal with non-null/undefined values
  8313. if ( ( options = arguments[ i ] ) != null ) {
  8314. // Extend the base object
  8315. for ( name in options ) {
  8316. copy = options[ name ];
  8317. // Prevent Object.prototype pollution
  8318. // Prevent never-ending loop
  8319. if ( name === "__proto__" || target === copy ) {
  8320. continue;
  8321. }
  8322. // Recurse if we're merging plain objects or arrays
  8323. if ( deep && copy && ( jQuery.isPlainObject( copy ) ||
  8324. ( copyIsArray = Array.isArray( copy ) ) ) ) {
  8325. src = target[ name ];
  8326. // Ensure proper type for the source value
  8327. if ( copyIsArray && !Array.isArray( src ) ) {
  8328. clone = [];
  8329. } else if ( !copyIsArray && !jQuery.isPlainObject( src ) ) {
  8330. clone = {};
  8331. } else {
  8332. clone = src;
  8333. }
  8334. copyIsArray = false;
  8335. // Never move original objects, clone them
  8336. target[ name ] = jQuery.extend( deep, clone, copy );
  8337. // Don't bring in undefined values
  8338. } else if ( copy !== undefined ) {
  8339. target[ name ] = copy;
  8340. }
  8341. }
  8342. }
  8343. }
  8344. // Return the modified object
  8345. return target;
  8346. };
  8347. jQuery.extend( {
  8348. // Unique for each copy of jQuery on the page
  8349. expando: "jQuery" + ( version + Math.random() ).replace( /\D/g, "" ),
  8350. // Assume jQuery is ready without the ready module
  8351. isReady: true,
  8352. error: function( msg ) {
  8353. throw new Error( msg );
  8354. },
  8355. noop: function() {},
  8356. isPlainObject: function( obj ) {
  8357. var proto, Ctor;
  8358. // Detect obvious negatives
  8359. // Use toString instead of jQuery.type to catch host objects
  8360. if ( !obj || toString.call( obj ) !== "[object Object]" ) {
  8361. return false;
  8362. }
  8363. proto = getProto( obj );
  8364. // Objects with no prototype (e.g., `Object.create( null )`) are plain
  8365. if ( !proto ) {
  8366. return true;
  8367. }
  8368. // Objects with prototype are plain iff they were constructed by a global Object function
  8369. Ctor = hasOwn.call( proto, "constructor" ) && proto.constructor;
  8370. return typeof Ctor === "function" && fnToString.call( Ctor ) === ObjectFunctionString;
  8371. },
  8372. isEmptyObject: function( obj ) {
  8373. var name;
  8374. for ( name in obj ) {
  8375. return false;
  8376. }
  8377. return true;
  8378. },
  8379. // Evaluates a script in a global context
  8380. globalEval: function( code, options ) {
  8381. DOMEval( code, { nonce: options && options.nonce } );
  8382. },
  8383. each: function( obj, callback ) {
  8384. var length, i = 0;
  8385. if ( isArrayLike( obj ) ) {
  8386. length = obj.length;
  8387. for ( ; i < length; i++ ) {
  8388. if ( callback.call( obj[ i ], i, obj[ i ] ) === false ) {
  8389. break;
  8390. }
  8391. }
  8392. } else {
  8393. for ( i in obj ) {
  8394. if ( callback.call( obj[ i ], i, obj[ i ] ) === false ) {
  8395. break;
  8396. }
  8397. }
  8398. }
  8399. return obj;
  8400. },
  8401. // Support: Android <=4.0 only
  8402. trim: function( text ) {
  8403. return text == null ?
  8404. "" :
  8405. ( text + "" ).replace( rtrim, "" );
  8406. },
  8407. // results is for internal usage only
  8408. makeArray: function( arr, results ) {
  8409. var ret = results || [];
  8410. if ( arr != null ) {
  8411. if ( isArrayLike( Object( arr ) ) ) {
  8412. jQuery.merge( ret,
  8413. typeof arr === "string" ?
  8414. [ arr ] : arr
  8415. );
  8416. } else {
  8417. push.call( ret, arr );
  8418. }
  8419. }
  8420. return ret;
  8421. },
  8422. inArray: function( elem, arr, i ) {
  8423. return arr == null ? -1 : indexOf.call( arr, elem, i );
  8424. },
  8425. // Support: Android <=4.0 only, PhantomJS 1 only
  8426. // push.apply(_, arraylike) throws on ancient WebKit
  8427. merge: function( first, second ) {
  8428. var len = +second.length,
  8429. j = 0,
  8430. i = first.length;
  8431. for ( ; j < len; j++ ) {
  8432. first[ i++ ] = second[ j ];
  8433. }
  8434. first.length = i;
  8435. return first;
  8436. },
  8437. grep: function( elems, callback, invert ) {
  8438. var callbackInverse,
  8439. matches = [],
  8440. i = 0,
  8441. length = elems.length,
  8442. callbackExpect = !invert;
  8443. // Go through the array, only saving the items
  8444. // that pass the validator function
  8445. for ( ; i < length; i++ ) {
  8446. callbackInverse = !callback( elems[ i ], i );
  8447. if ( callbackInverse !== callbackExpect ) {
  8448. matches.push( elems[ i ] );
  8449. }
  8450. }
  8451. return matches;
  8452. },
  8453. // arg is for internal usage only
  8454. map: function( elems, callback, arg ) {
  8455. var length, value,
  8456. i = 0,
  8457. ret = [];
  8458. // Go through the array, translating each of the items to their new values
  8459. if ( isArrayLike( elems ) ) {
  8460. length = elems.length;
  8461. for ( ; i < length; i++ ) {
  8462. value = callback( elems[ i ], i, arg );
  8463. if ( value != null ) {
  8464. ret.push( value );
  8465. }
  8466. }
  8467. // Go through every key on the object,
  8468. } else {
  8469. for ( i in elems ) {
  8470. value = callback( elems[ i ], i, arg );
  8471. if ( value != null ) {
  8472. ret.push( value );
  8473. }
  8474. }
  8475. }
  8476. // Flatten any nested arrays
  8477. return concat.apply( [], ret );
  8478. },
  8479. // A global GUID counter for objects
  8480. guid: 1,
  8481. // jQuery.support is not used in Core but other projects attach their
  8482. // properties to it so it needs to exist.
  8483. support: support
  8484. } );
  8485. if ( typeof Symbol === "function" ) {
  8486. jQuery.fn[ Symbol.iterator ] = arr[ Symbol.iterator ];
  8487. }
  8488. // Populate the class2type map
  8489. jQuery.each( "Boolean Number String Function Array Date RegExp Object Error Symbol".split( " " ),
  8490. function( i, name ) {
  8491. class2type[ "[object " + name + "]" ] = name.toLowerCase();
  8492. } );
  8493. function isArrayLike( obj ) {
  8494. // Support: real iOS 8.2 only (not reproducible in simulator)
  8495. // `in` check used to prevent JIT error (gh-2145)
  8496. // hasOwn isn't used here due to false negatives
  8497. // regarding Nodelist length in IE
  8498. var length = !!obj && "length" in obj && obj.length,
  8499. type = toType( obj );
  8500. if ( isFunction( obj ) || isWindow( obj ) ) {
  8501. return false;
  8502. }
  8503. return type === "array" || length === 0 ||
  8504. typeof length === "number" && length > 0 && ( length - 1 ) in obj;
  8505. }
  8506. var Sizzle =
  8507. /*!
  8508. * Sizzle CSS Selector Engine v2.3.4
  8509. * https://sizzlejs.com/
  8510. *
  8511. * Copyright JS Foundation and other contributors
  8512. * Released under the MIT license
  8513. * https://js.foundation/
  8514. *
  8515. * Date: 2019-04-08
  8516. */
  8517. (function( window ) {
  8518. var i,
  8519. support,
  8520. Expr,
  8521. getText,
  8522. isXML,
  8523. tokenize,
  8524. compile,
  8525. select,
  8526. outermostContext,
  8527. sortInput,
  8528. hasDuplicate,
  8529. // Local document vars
  8530. setDocument,
  8531. document,
  8532. docElem,
  8533. documentIsHTML,
  8534. rbuggyQSA,
  8535. rbuggyMatches,
  8536. matches,
  8537. contains,
  8538. // Instance-specific data
  8539. expando = "sizzle" + 1 * new Date(),
  8540. preferredDoc = window.document,
  8541. dirruns = 0,
  8542. done = 0,
  8543. classCache = createCache(),
  8544. tokenCache = createCache(),
  8545. compilerCache = createCache(),
  8546. nonnativeSelectorCache = createCache(),
  8547. sortOrder = function( a, b ) {
  8548. if ( a === b ) {
  8549. hasDuplicate = true;
  8550. }
  8551. return 0;
  8552. },
  8553. // Instance methods
  8554. hasOwn = ({}).hasOwnProperty,
  8555. arr = [],
  8556. pop = arr.pop,
  8557. push_native = arr.push,
  8558. push = arr.push,
  8559. slice = arr.slice,
  8560. // Use a stripped-down indexOf as it's faster than native
  8561. // https://jsperf.com/thor-indexof-vs-for/5
  8562. indexOf = function( list, elem ) {
  8563. var i = 0,
  8564. len = list.length;
  8565. for ( ; i < len; i++ ) {
  8566. if ( list[i] === elem ) {
  8567. return i;
  8568. }
  8569. }
  8570. return -1;
  8571. },
  8572. booleans = "checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",
  8573. // Regular expressions
  8574. // http://www.w3.org/TR/css3-selectors/#whitespace
  8575. whitespace = "[\\x20\\t\\r\\n\\f]",
  8576. // http://www.w3.org/TR/CSS21/syndata.html#value-def-identifier
  8577. identifier = "(?:\\\\.|[\\w-]|[^\0-\\xa0])+",
  8578. // Attribute selectors: http://www.w3.org/TR/selectors/#attribute-selectors
  8579. attributes = "\\[" + whitespace + "*(" + identifier + ")(?:" + whitespace +
  8580. // Operator (capture 2)
  8581. "*([*^$|!~]?=)" + whitespace +
  8582. // "Attribute values must be CSS identifiers [capture 5] or strings [capture 3 or capture 4]"
  8583. "*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|(" + identifier + "))|)" + whitespace +
  8584. "*\\]",
  8585. pseudos = ":(" + identifier + ")(?:\\((" +
  8586. // To reduce the number of selectors needing tokenize in the preFilter, prefer arguments:
  8587. // 1. quoted (capture 3; capture 4 or capture 5)
  8588. "('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|" +
  8589. // 2. simple (capture 6)
  8590. "((?:\\\\.|[^\\\\()[\\]]|" + attributes + ")*)|" +
  8591. // 3. anything else (capture 2)
  8592. ".*" +
  8593. ")\\)|)",
  8594. // Leading and non-escaped trailing whitespace, capturing some non-whitespace characters preceding the latter
  8595. rwhitespace = new RegExp( whitespace + "+", "g" ),
  8596. rtrim = new RegExp( "^" + whitespace + "+|((?:^|[^\\\\])(?:\\\\.)*)" + whitespace + "+$", "g" ),
  8597. rcomma = new RegExp( "^" + whitespace + "*," + whitespace + "*" ),
  8598. rcombinators = new RegExp( "^" + whitespace + "*([>+~]|" + whitespace + ")" + whitespace + "*" ),
  8599. rdescend = new RegExp( whitespace + "|>" ),
  8600. rpseudo = new RegExp( pseudos ),
  8601. ridentifier = new RegExp( "^" + identifier + "$" ),
  8602. matchExpr = {
  8603. "ID": new RegExp( "^#(" + identifier + ")" ),
  8604. "CLASS": new RegExp( "^\\.(" + identifier + ")" ),
  8605. "TAG": new RegExp( "^(" + identifier + "|[*])" ),
  8606. "ATTR": new RegExp( "^" + attributes ),
  8607. "PSEUDO": new RegExp( "^" + pseudos ),
  8608. "CHILD": new RegExp( "^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\(" + whitespace +
  8609. "*(even|odd|(([+-]|)(\\d*)n|)" + whitespace + "*(?:([+-]|)" + whitespace +
  8610. "*(\\d+)|))" + whitespace + "*\\)|)", "i" ),
  8611. "bool": new RegExp( "^(?:" + booleans + ")$", "i" ),
  8612. // For use in libraries implementing .is()
  8613. // We use this for POS matching in `select`
  8614. "needsContext": new RegExp( "^" + whitespace + "*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\(" +
  8615. whitespace + "*((?:-\\d)?\\d*)" + whitespace + "*\\)|)(?=[^-]|$)", "i" )
  8616. },
  8617. rhtml = /HTML$/i,
  8618. rinputs = /^(?:input|select|textarea|button)$/i,
  8619. rheader = /^h\d$/i,
  8620. rnative = /^[^{]+\{\s*\[native \w/,
  8621. // Easily-parseable/retrievable ID or TAG or CLASS selectors
  8622. rquickExpr = /^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,
  8623. rsibling = /[+~]/,
  8624. // CSS escapes
  8625. // http://www.w3.org/TR/CSS21/syndata.html#escaped-characters
  8626. runescape = new RegExp( "\\\\([\\da-f]{1,6}" + whitespace + "?|(" + whitespace + ")|.)", "ig" ),
  8627. funescape = function( _, escaped, escapedWhitespace ) {
  8628. var high = "0x" + escaped - 0x10000;
  8629. // NaN means non-codepoint
  8630. // Support: Firefox<24
  8631. // Workaround erroneous numeric interpretation of +"0x"
  8632. return high !== high || escapedWhitespace ?
  8633. escaped :
  8634. high < 0 ?
  8635. // BMP codepoint
  8636. String.fromCharCode( high + 0x10000 ) :
  8637. // Supplemental Plane codepoint (surrogate pair)
  8638. String.fromCharCode( high >> 10 | 0xD800, high & 0x3FF | 0xDC00 );
  8639. },
  8640. // CSS string/identifier serialization
  8641. // https://drafts.csswg.org/cssom/#common-serializing-idioms
  8642. rcssescape = /([\0-\x1f\x7f]|^-?\d)|^-$|[^\0-\x1f\x7f-\uFFFF\w-]/g,
  8643. fcssescape = function( ch, asCodePoint ) {
  8644. if ( asCodePoint ) {
  8645. // U+0000 NULL becomes U+FFFD REPLACEMENT CHARACTER
  8646. if ( ch === "\0" ) {
  8647. return "\uFFFD";
  8648. }
  8649. // Control characters and (dependent upon position) numbers get escaped as code points
  8650. return ch.slice( 0, -1 ) + "\\" + ch.charCodeAt( ch.length - 1 ).toString( 16 ) + " ";
  8651. }
  8652. // Other potentially-special ASCII characters get backslash-escaped
  8653. return "\\" + ch;
  8654. },
  8655. // Used for iframes
  8656. // See setDocument()
  8657. // Removing the function wrapper causes a "Permission Denied"
  8658. // error in IE
  8659. unloadHandler = function() {
  8660. setDocument();
  8661. },
  8662. inDisabledFieldset = addCombinator(
  8663. function( elem ) {
  8664. return elem.disabled === true && elem.nodeName.toLowerCase() === "fieldset";
  8665. },
  8666. { dir: "parentNode", next: "legend" }
  8667. );
  8668. // Optimize for push.apply( _, NodeList )
  8669. try {
  8670. push.apply(
  8671. (arr = slice.call( preferredDoc.childNodes )),
  8672. preferredDoc.childNodes
  8673. );
  8674. // Support: Android<4.0
  8675. // Detect silently failing push.apply
  8676. arr[ preferredDoc.childNodes.length ].nodeType;
  8677. } catch ( e ) {
  8678. push = { apply: arr.length ?
  8679. // Leverage slice if possible
  8680. function( target, els ) {
  8681. push_native.apply( target, slice.call(els) );
  8682. } :
  8683. // Support: IE<9
  8684. // Otherwise append directly
  8685. function( target, els ) {
  8686. var j = target.length,
  8687. i = 0;
  8688. // Can't trust NodeList.length
  8689. while ( (target[j++] = els[i++]) ) {}
  8690. target.length = j - 1;
  8691. }
  8692. };
  8693. }
  8694. function Sizzle( selector, context, results, seed ) {
  8695. var m, i, elem, nid, match, groups, newSelector,
  8696. newContext = context && context.ownerDocument,
  8697. // nodeType defaults to 9, since context defaults to document
  8698. nodeType = context ? context.nodeType : 9;
  8699. results = results || [];
  8700. // Return early from calls with invalid selector or context
  8701. if ( typeof selector !== "string" || !selector ||
  8702. nodeType !== 1 && nodeType !== 9 && nodeType !== 11 ) {
  8703. return results;
  8704. }
  8705. // Try to shortcut find operations (as opposed to filters) in HTML documents
  8706. if ( !seed ) {
  8707. if ( ( context ? context.ownerDocument || context : preferredDoc ) !== document ) {
  8708. setDocument( context );
  8709. }
  8710. context = context || document;
  8711. if ( documentIsHTML ) {
  8712. // If the selector is sufficiently simple, try using a "get*By*" DOM method
  8713. // (excepting DocumentFragment context, where the methods don't exist)
  8714. if ( nodeType !== 11 && (match = rquickExpr.exec( selector )) ) {
  8715. // ID selector
  8716. if ( (m = match[1]) ) {
  8717. // Document context
  8718. if ( nodeType === 9 ) {
  8719. if ( (elem = context.getElementById( m )) ) {
  8720. // Support: IE, Opera, Webkit
  8721. // TODO: identify versions
  8722. // getElementById can match elements by name instead of ID
  8723. if ( elem.id === m ) {
  8724. results.push( elem );
  8725. return results;
  8726. }
  8727. } else {
  8728. return results;
  8729. }
  8730. // Element context
  8731. } else {
  8732. // Support: IE, Opera, Webkit
  8733. // TODO: identify versions
  8734. // getElementById can match elements by name instead of ID
  8735. if ( newContext && (elem = newContext.getElementById( m )) &&
  8736. contains( context, elem ) &&
  8737. elem.id === m ) {
  8738. results.push( elem );
  8739. return results;
  8740. }
  8741. }
  8742. // Type selector
  8743. } else if ( match[2] ) {
  8744. push.apply( results, context.getElementsByTagName( selector ) );
  8745. return results;
  8746. // Class selector
  8747. } else if ( (m = match[3]) && support.getElementsByClassName &&
  8748. context.getElementsByClassName ) {
  8749. push.apply( results, context.getElementsByClassName( m ) );
  8750. return results;
  8751. }
  8752. }
  8753. // Take advantage of querySelectorAll
  8754. if ( support.qsa &&
  8755. !nonnativeSelectorCache[ selector + " " ] &&
  8756. (!rbuggyQSA || !rbuggyQSA.test( selector )) &&
  8757. // Support: IE 8 only
  8758. // Exclude object elements
  8759. (nodeType !== 1 || context.nodeName.toLowerCase() !== "object") ) {
  8760. newSelector = selector;
  8761. newContext = context;
  8762. // qSA considers elements outside a scoping root when evaluating child or
  8763. // descendant combinators, which is not what we want.
  8764. // In such cases, we work around the behavior by prefixing every selector in the
  8765. // list with an ID selector referencing the scope context.
  8766. // Thanks to Andrew Dupont for this technique.
  8767. if ( nodeType === 1 && rdescend.test( selector ) ) {
  8768. // Capture the context ID, setting it first if necessary
  8769. if ( (nid = context.getAttribute( "id" )) ) {
  8770. nid = nid.replace( rcssescape, fcssescape );
  8771. } else {
  8772. context.setAttribute( "id", (nid = expando) );
  8773. }
  8774. // Prefix every selector in the list
  8775. groups = tokenize( selector );
  8776. i = groups.length;
  8777. while ( i-- ) {
  8778. groups[i] = "#" + nid + " " + toSelector( groups[i] );
  8779. }
  8780. newSelector = groups.join( "," );
  8781. // Expand context for sibling selectors
  8782. newContext = rsibling.test( selector ) && testContext( context.parentNode ) ||
  8783. context;
  8784. }
  8785. try {
  8786. push.apply( results,
  8787. newContext.querySelectorAll( newSelector )
  8788. );
  8789. return results;
  8790. } catch ( qsaError ) {
  8791. nonnativeSelectorCache( selector, true );
  8792. } finally {
  8793. if ( nid === expando ) {
  8794. context.removeAttribute( "id" );
  8795. }
  8796. }
  8797. }
  8798. }
  8799. }
  8800. // All others
  8801. return select( selector.replace( rtrim, "$1" ), context, results, seed );
  8802. }
  8803. /**
  8804. * Create key-value caches of limited size
  8805. * @returns {function(string, object)} Returns the Object data after storing it on itself with
  8806. * property name the (space-suffixed) string and (if the cache is larger than Expr.cacheLength)
  8807. * deleting the oldest entry
  8808. */
  8809. function createCache() {
  8810. var keys = [];
  8811. function cache( key, value ) {
  8812. // Use (key + " ") to avoid collision with native prototype properties (see Issue #157)
  8813. if ( keys.push( key + " " ) > Expr.cacheLength ) {
  8814. // Only keep the most recent entries
  8815. delete cache[ keys.shift() ];
  8816. }
  8817. return (cache[ key + " " ] = value);
  8818. }
  8819. return cache;
  8820. }
  8821. /**
  8822. * Mark a function for special use by Sizzle
  8823. * @param {Function} fn The function to mark
  8824. */
  8825. function markFunction( fn ) {
  8826. fn[ expando ] = true;
  8827. return fn;
  8828. }
  8829. /**
  8830. * Support testing using an element
  8831. * @param {Function} fn Passed the created element and returns a boolean result
  8832. */
  8833. function assert( fn ) {
  8834. var el = document.createElement("fieldset");
  8835. try {
  8836. return !!fn( el );
  8837. } catch (e) {
  8838. return false;
  8839. } finally {
  8840. // Remove from its parent by default
  8841. if ( el.parentNode ) {
  8842. el.parentNode.removeChild( el );
  8843. }
  8844. // release memory in IE
  8845. el = null;
  8846. }
  8847. }
  8848. /**
  8849. * Adds the same handler for all of the specified attrs
  8850. * @param {String} attrs Pipe-separated list of attributes
  8851. * @param {Function} handler The method that will be applied
  8852. */
  8853. function addHandle( attrs, handler ) {
  8854. var arr = attrs.split("|"),
  8855. i = arr.length;
  8856. while ( i-- ) {
  8857. Expr.attrHandle[ arr[i] ] = handler;
  8858. }
  8859. }
  8860. /**
  8861. * Checks document order of two siblings
  8862. * @param {Element} a
  8863. * @param {Element} b
  8864. * @returns {Number} Returns less than 0 if a precedes b, greater than 0 if a follows b
  8865. */
  8866. function siblingCheck( a, b ) {
  8867. var cur = b && a,
  8868. diff = cur && a.nodeType === 1 && b.nodeType === 1 &&
  8869. a.sourceIndex - b.sourceIndex;
  8870. // Use IE sourceIndex if available on both nodes
  8871. if ( diff ) {
  8872. return diff;
  8873. }
  8874. // Check if b follows a
  8875. if ( cur ) {
  8876. while ( (cur = cur.nextSibling) ) {
  8877. if ( cur === b ) {
  8878. return -1;
  8879. }
  8880. }
  8881. }
  8882. return a ? 1 : -1;
  8883. }
  8884. /**
  8885. * Returns a function to use in pseudos for input types
  8886. * @param {String} type
  8887. */
  8888. function createInputPseudo( type ) {
  8889. return function( elem ) {
  8890. var name = elem.nodeName.toLowerCase();
  8891. return name === "input" && elem.type === type;
  8892. };
  8893. }
  8894. /**
  8895. * Returns a function to use in pseudos for buttons
  8896. * @param {String} type
  8897. */
  8898. function createButtonPseudo( type ) {
  8899. return function( elem ) {
  8900. var name = elem.nodeName.toLowerCase();
  8901. return (name === "input" || name === "button") && elem.type === type;
  8902. };
  8903. }
  8904. /**
  8905. * Returns a function to use in pseudos for :enabled/:disabled
  8906. * @param {Boolean} disabled true for :disabled; false for :enabled
  8907. */
  8908. function createDisabledPseudo( disabled ) {
  8909. // Known :disabled false positives: fieldset[disabled] > legend:nth-of-type(n+2) :can-disable
  8910. return function( elem ) {
  8911. // Only certain elements can match :enabled or :disabled
  8912. // https://html.spec.whatwg.org/multipage/scripting.html#selector-enabled
  8913. // https://html.spec.whatwg.org/multipage/scripting.html#selector-disabled
  8914. if ( "form" in elem ) {
  8915. // Check for inherited disabledness on relevant non-disabled elements:
  8916. // * listed form-associated elements in a disabled fieldset
  8917. // https://html.spec.whatwg.org/multipage/forms.html#category-listed
  8918. // https://html.spec.whatwg.org/multipage/forms.html#concept-fe-disabled
  8919. // * option elements in a disabled optgroup
  8920. // https://html.spec.whatwg.org/multipage/forms.html#concept-option-disabled
  8921. // All such elements have a "form" property.
  8922. if ( elem.parentNode && elem.disabled === false ) {
  8923. // Option elements defer to a parent optgroup if present
  8924. if ( "label" in elem ) {
  8925. if ( "label" in elem.parentNode ) {
  8926. return elem.parentNode.disabled === disabled;
  8927. } else {
  8928. return elem.disabled === disabled;
  8929. }
  8930. }
  8931. // Support: IE 6 - 11
  8932. // Use the isDisabled shortcut property to check for disabled fieldset ancestors
  8933. return elem.isDisabled === disabled ||
  8934. // Where there is no isDisabled, check manually
  8935. /* jshint -W018 */
  8936. elem.isDisabled !== !disabled &&
  8937. inDisabledFieldset( elem ) === disabled;
  8938. }
  8939. return elem.disabled === disabled;
  8940. // Try to winnow out elements that can't be disabled before trusting the disabled property.
  8941. // Some victims get caught in our net (label, legend, menu, track), but it shouldn't
  8942. // even exist on them, let alone have a boolean value.
  8943. } else if ( "label" in elem ) {
  8944. return elem.disabled === disabled;
  8945. }
  8946. // Remaining elements are neither :enabled nor :disabled
  8947. return false;
  8948. };
  8949. }
  8950. /**
  8951. * Returns a function to use in pseudos for positionals
  8952. * @param {Function} fn
  8953. */
  8954. function createPositionalPseudo( fn ) {
  8955. return markFunction(function( argument ) {
  8956. argument = +argument;
  8957. return markFunction(function( seed, matches ) {
  8958. var j,
  8959. matchIndexes = fn( [], seed.length, argument ),
  8960. i = matchIndexes.length;
  8961. // Match elements found at the specified indexes
  8962. while ( i-- ) {
  8963. if ( seed[ (j = matchIndexes[i]) ] ) {
  8964. seed[j] = !(matches[j] = seed[j]);
  8965. }
  8966. }
  8967. });
  8968. });
  8969. }
  8970. /**
  8971. * Checks a node for validity as a Sizzle context
  8972. * @param {Element|Object=} context
  8973. * @returns {Element|Object|Boolean} The input node if acceptable, otherwise a falsy value
  8974. */
  8975. function testContext( context ) {
  8976. return context && typeof context.getElementsByTagName !== "undefined" && context;
  8977. }
  8978. // Expose support vars for convenience
  8979. support = Sizzle.support = {};
  8980. /**
  8981. * Detects XML nodes
  8982. * @param {Element|Object} elem An element or a document
  8983. * @returns {Boolean} True iff elem is a non-HTML XML node
  8984. */
  8985. isXML = Sizzle.isXML = function( elem ) {
  8986. var namespace = elem.namespaceURI,
  8987. docElem = (elem.ownerDocument || elem).documentElement;
  8988. // Support: IE <=8
  8989. // Assume HTML when documentElement doesn't yet exist, such as inside loading iframes
  8990. // https://bugs.jquery.com/ticket/4833
  8991. return !rhtml.test( namespace || docElem && docElem.nodeName || "HTML" );
  8992. };
  8993. /**
  8994. * Sets document-related variables once based on the current document
  8995. * @param {Element|Object} [doc] An element or document object to use to set the document
  8996. * @returns {Object} Returns the current document
  8997. */
  8998. setDocument = Sizzle.setDocument = function( node ) {
  8999. var hasCompare, subWindow,
  9000. doc = node ? node.ownerDocument || node : preferredDoc;
  9001. // Return early if doc is invalid or already selected
  9002. if ( doc === document || doc.nodeType !== 9 || !doc.documentElement ) {
  9003. return document;
  9004. }
  9005. // Update global variables
  9006. document = doc;
  9007. docElem = document.documentElement;
  9008. documentIsHTML = !isXML( document );
  9009. // Support: IE 9-11, Edge
  9010. // Accessing iframe documents after unload throws "permission denied" errors (jQuery #13936)
  9011. if ( preferredDoc !== document &&
  9012. (subWindow = document.defaultView) && subWindow.top !== subWindow ) {
  9013. // Support: IE 11, Edge
  9014. if ( subWindow.addEventListener ) {
  9015. subWindow.addEventListener( "unload", unloadHandler, false );
  9016. // Support: IE 9 - 10 only
  9017. } else if ( subWindow.attachEvent ) {
  9018. subWindow.attachEvent( "onunload", unloadHandler );
  9019. }
  9020. }
  9021. /* Attributes
  9022. ---------------------------------------------------------------------- */
  9023. // Support: IE<8
  9024. // Verify that getAttribute really returns attributes and not properties
  9025. // (excepting IE8 booleans)
  9026. support.attributes = assert(function( el ) {
  9027. el.className = "i";
  9028. return !el.getAttribute("className");
  9029. });
  9030. /* getElement(s)By*
  9031. ---------------------------------------------------------------------- */
  9032. // Check if getElementsByTagName("*") returns only elements
  9033. support.getElementsByTagName = assert(function( el ) {
  9034. el.appendChild( document.createComment("") );
  9035. return !el.getElementsByTagName("*").length;
  9036. });
  9037. // Support: IE<9
  9038. support.getElementsByClassName = rnative.test( document.getElementsByClassName );
  9039. // Support: IE<10
  9040. // Check if getElementById returns elements by name
  9041. // The broken getElementById methods don't pick up programmatically-set names,
  9042. // so use a roundabout getElementsByName test
  9043. support.getById = assert(function( el ) {
  9044. docElem.appendChild( el ).id = expando;
  9045. return !document.getElementsByName || !document.getElementsByName( expando ).length;
  9046. });
  9047. // ID filter and find
  9048. if ( support.getById ) {
  9049. Expr.filter["ID"] = function( id ) {
  9050. var attrId = id.replace( runescape, funescape );
  9051. return function( elem ) {
  9052. return elem.getAttribute("id") === attrId;
  9053. };
  9054. };
  9055. Expr.find["ID"] = function( id, context ) {
  9056. if ( typeof context.getElementById !== "undefined" && documentIsHTML ) {
  9057. var elem = context.getElementById( id );
  9058. return elem ? [ elem ] : [];
  9059. }
  9060. };
  9061. } else {
  9062. Expr.filter["ID"] = function( id ) {
  9063. var attrId = id.replace( runescape, funescape );
  9064. return function( elem ) {
  9065. var node = typeof elem.getAttributeNode !== "undefined" &&
  9066. elem.getAttributeNode("id");
  9067. return node && node.value === attrId;
  9068. };
  9069. };
  9070. // Support: IE 6 - 7 only
  9071. // getElementById is not reliable as a find shortcut
  9072. Expr.find["ID"] = function( id, context ) {
  9073. if ( typeof context.getElementById !== "undefined" && documentIsHTML ) {
  9074. var node, i, elems,
  9075. elem = context.getElementById( id );
  9076. if ( elem ) {
  9077. // Verify the id attribute
  9078. node = elem.getAttributeNode("id");
  9079. if ( node && node.value === id ) {
  9080. return [ elem ];
  9081. }
  9082. // Fall back on getElementsByName
  9083. elems = context.getElementsByName( id );
  9084. i = 0;
  9085. while ( (elem = elems[i++]) ) {
  9086. node = elem.getAttributeNode("id");
  9087. if ( node && node.value === id ) {
  9088. return [ elem ];
  9089. }
  9090. }
  9091. }
  9092. return [];
  9093. }
  9094. };
  9095. }
  9096. // Tag
  9097. Expr.find["TAG"] = support.getElementsByTagName ?
  9098. function( tag, context ) {
  9099. if ( typeof context.getElementsByTagName !== "undefined" ) {
  9100. return context.getElementsByTagName( tag );
  9101. // DocumentFragment nodes don't have gEBTN
  9102. } else if ( support.qsa ) {
  9103. return context.querySelectorAll( tag );
  9104. }
  9105. } :
  9106. function( tag, context ) {
  9107. var elem,
  9108. tmp = [],
  9109. i = 0,
  9110. // By happy coincidence, a (broken) gEBTN appears on DocumentFragment nodes too
  9111. results = context.getElementsByTagName( tag );
  9112. // Filter out possible comments
  9113. if ( tag === "*" ) {
  9114. while ( (elem = results[i++]) ) {
  9115. if ( elem.nodeType === 1 ) {
  9116. tmp.push( elem );
  9117. }
  9118. }
  9119. return tmp;
  9120. }
  9121. return results;
  9122. };
  9123. // Class
  9124. Expr.find["CLASS"] = support.getElementsByClassName && function( className, context ) {
  9125. if ( typeof context.getElementsByClassName !== "undefined" && documentIsHTML ) {
  9126. return context.getElementsByClassName( className );
  9127. }
  9128. };
  9129. /* QSA/matchesSelector
  9130. ---------------------------------------------------------------------- */
  9131. // QSA and matchesSelector support
  9132. // matchesSelector(:active) reports false when true (IE9/Opera 11.5)
  9133. rbuggyMatches = [];
  9134. // qSa(:focus) reports false when true (Chrome 21)
  9135. // We allow this because of a bug in IE8/9 that throws an error
  9136. // whenever `document.activeElement` is accessed on an iframe
  9137. // So, we allow :focus to pass through QSA all the time to avoid the IE error
  9138. // See https://bugs.jquery.com/ticket/13378
  9139. rbuggyQSA = [];
  9140. if ( (support.qsa = rnative.test( document.querySelectorAll )) ) {
  9141. // Build QSA regex
  9142. // Regex strategy adopted from Diego Perini
  9143. assert(function( el ) {
  9144. // Select is set to empty string on purpose
  9145. // This is to test IE's treatment of not explicitly
  9146. // setting a boolean content attribute,
  9147. // since its presence should be enough
  9148. // https://bugs.jquery.com/ticket/12359
  9149. docElem.appendChild( el ).innerHTML = "<a id='" + expando + "'></a>" +
  9150. "<select id='" + expando + "-\r\\' msallowcapture=''>" +
  9151. "<option selected=''></option></select>";
  9152. // Support: IE8, Opera 11-12.16
  9153. // Nothing should be selected when empty strings follow ^= or $= or *=
  9154. // The test attribute must be unknown in Opera but "safe" for WinRT
  9155. // https://msdn.microsoft.com/en-us/library/ie/hh465388.aspx#attribute_section
  9156. if ( el.querySelectorAll("[msallowcapture^='']").length ) {
  9157. rbuggyQSA.push( "[*^$]=" + whitespace + "*(?:''|\"\")" );
  9158. }
  9159. // Support: IE8
  9160. // Boolean attributes and "value" are not treated correctly
  9161. if ( !el.querySelectorAll("[selected]").length ) {
  9162. rbuggyQSA.push( "\\[" + whitespace + "*(?:value|" + booleans + ")" );
  9163. }
  9164. // Support: Chrome<29, Android<4.4, Safari<7.0+, iOS<7.0+, PhantomJS<1.9.8+
  9165. if ( !el.querySelectorAll( "[id~=" + expando + "-]" ).length ) {
  9166. rbuggyQSA.push("~=");
  9167. }
  9168. // Webkit/Opera - :checked should return selected option elements
  9169. // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
  9170. // IE8 throws error here and will not see later tests
  9171. if ( !el.querySelectorAll(":checked").length ) {
  9172. rbuggyQSA.push(":checked");
  9173. }
  9174. // Support: Safari 8+, iOS 8+
  9175. // https://bugs.webkit.org/show_bug.cgi?id=136851
  9176. // In-page `selector#id sibling-combinator selector` fails
  9177. if ( !el.querySelectorAll( "a#" + expando + "+*" ).length ) {
  9178. rbuggyQSA.push(".#.+[+~]");
  9179. }
  9180. });
  9181. assert(function( el ) {
  9182. el.innerHTML = "<a href='' disabled='disabled'></a>" +
  9183. "<select disabled='disabled'><option/></select>";
  9184. // Support: Windows 8 Native Apps
  9185. // The type and name attributes are restricted during .innerHTML assignment
  9186. var input = document.createElement("input");
  9187. input.setAttribute( "type", "hidden" );
  9188. el.appendChild( input ).setAttribute( "name", "D" );
  9189. // Support: IE8
  9190. // Enforce case-sensitivity of name attribute
  9191. if ( el.querySelectorAll("[name=d]").length ) {
  9192. rbuggyQSA.push( "name" + whitespace + "*[*^$|!~]?=" );
  9193. }
  9194. // FF 3.5 - :enabled/:disabled and hidden elements (hidden elements are still enabled)
  9195. // IE8 throws error here and will not see later tests
  9196. if ( el.querySelectorAll(":enabled").length !== 2 ) {
  9197. rbuggyQSA.push( ":enabled", ":disabled" );
  9198. }
  9199. // Support: IE9-11+
  9200. // IE's :disabled selector does not pick up the children of disabled fieldsets
  9201. docElem.appendChild( el ).disabled = true;
  9202. if ( el.querySelectorAll(":disabled").length !== 2 ) {
  9203. rbuggyQSA.push( ":enabled", ":disabled" );
  9204. }
  9205. // Opera 10-11 does not throw on post-comma invalid pseudos
  9206. el.querySelectorAll("*,:x");
  9207. rbuggyQSA.push(",.*:");
  9208. });
  9209. }
  9210. if ( (support.matchesSelector = rnative.test( (matches = docElem.matches ||
  9211. docElem.webkitMatchesSelector ||
  9212. docElem.mozMatchesSelector ||
  9213. docElem.oMatchesSelector ||
  9214. docElem.msMatchesSelector) )) ) {
  9215. assert(function( el ) {
  9216. // Check to see if it's possible to do matchesSelector
  9217. // on a disconnected node (IE 9)
  9218. support.disconnectedMatch = matches.call( el, "*" );
  9219. // This should fail with an exception
  9220. // Gecko does not error, returns false instead
  9221. matches.call( el, "[s!='']:x" );
  9222. rbuggyMatches.push( "!=", pseudos );
  9223. });
  9224. }
  9225. rbuggyQSA = rbuggyQSA.length && new RegExp( rbuggyQSA.join("|") );
  9226. rbuggyMatches = rbuggyMatches.length && new RegExp( rbuggyMatches.join("|") );
  9227. /* Contains
  9228. ---------------------------------------------------------------------- */
  9229. hasCompare = rnative.test( docElem.compareDocumentPosition );
  9230. // Element contains another
  9231. // Purposefully self-exclusive
  9232. // As in, an element does not contain itself
  9233. contains = hasCompare || rnative.test( docElem.contains ) ?
  9234. function( a, b ) {
  9235. var adown = a.nodeType === 9 ? a.documentElement : a,
  9236. bup = b && b.parentNode;
  9237. return a === bup || !!( bup && bup.nodeType === 1 && (
  9238. adown.contains ?
  9239. adown.contains( bup ) :
  9240. a.compareDocumentPosition && a.compareDocumentPosition( bup ) & 16
  9241. ));
  9242. } :
  9243. function( a, b ) {
  9244. if ( b ) {
  9245. while ( (b = b.parentNode) ) {
  9246. if ( b === a ) {
  9247. return true;
  9248. }
  9249. }
  9250. }
  9251. return false;
  9252. };
  9253. /* Sorting
  9254. ---------------------------------------------------------------------- */
  9255. // Document order sorting
  9256. sortOrder = hasCompare ?
  9257. function( a, b ) {
  9258. // Flag for duplicate removal
  9259. if ( a === b ) {
  9260. hasDuplicate = true;
  9261. return 0;
  9262. }
  9263. // Sort on method existence if only one input has compareDocumentPosition
  9264. var compare = !a.compareDocumentPosition - !b.compareDocumentPosition;
  9265. if ( compare ) {
  9266. return compare;
  9267. }
  9268. // Calculate position if both inputs belong to the same document
  9269. compare = ( a.ownerDocument || a ) === ( b.ownerDocument || b ) ?
  9270. a.compareDocumentPosition( b ) :
  9271. // Otherwise we know they are disconnected
  9272. 1;
  9273. // Disconnected nodes
  9274. if ( compare & 1 ||
  9275. (!support.sortDetached && b.compareDocumentPosition( a ) === compare) ) {
  9276. // Choose the first element that is related to our preferred document
  9277. if ( a === document || a.ownerDocument === preferredDoc && contains(preferredDoc, a) ) {
  9278. return -1;
  9279. }
  9280. if ( b === document || b.ownerDocument === preferredDoc && contains(preferredDoc, b) ) {
  9281. return 1;
  9282. }
  9283. // Maintain original order
  9284. return sortInput ?
  9285. ( indexOf( sortInput, a ) - indexOf( sortInput, b ) ) :
  9286. 0;
  9287. }
  9288. return compare & 4 ? -1 : 1;
  9289. } :
  9290. function( a, b ) {
  9291. // Exit early if the nodes are identical
  9292. if ( a === b ) {
  9293. hasDuplicate = true;
  9294. return 0;
  9295. }
  9296. var cur,
  9297. i = 0,
  9298. aup = a.parentNode,
  9299. bup = b.parentNode,
  9300. ap = [ a ],
  9301. bp = [ b ];
  9302. // Parentless nodes are either documents or disconnected
  9303. if ( !aup || !bup ) {
  9304. return a === document ? -1 :
  9305. b === document ? 1 :
  9306. aup ? -1 :
  9307. bup ? 1 :
  9308. sortInput ?
  9309. ( indexOf( sortInput, a ) - indexOf( sortInput, b ) ) :
  9310. 0;
  9311. // If the nodes are siblings, we can do a quick check
  9312. } else if ( aup === bup ) {
  9313. return siblingCheck( a, b );
  9314. }
  9315. // Otherwise we need full lists of their ancestors for comparison
  9316. cur = a;
  9317. while ( (cur = cur.parentNode) ) {
  9318. ap.unshift( cur );
  9319. }
  9320. cur = b;
  9321. while ( (cur = cur.parentNode) ) {
  9322. bp.unshift( cur );
  9323. }
  9324. // Walk down the tree looking for a discrepancy
  9325. while ( ap[i] === bp[i] ) {
  9326. i++;
  9327. }
  9328. return i ?
  9329. // Do a sibling check if the nodes have a common ancestor
  9330. siblingCheck( ap[i], bp[i] ) :
  9331. // Otherwise nodes in our document sort first
  9332. ap[i] === preferredDoc ? -1 :
  9333. bp[i] === preferredDoc ? 1 :
  9334. 0;
  9335. };
  9336. return document;
  9337. };
  9338. Sizzle.matches = function( expr, elements ) {
  9339. return Sizzle( expr, null, null, elements );
  9340. };
  9341. Sizzle.matchesSelector = function( elem, expr ) {
  9342. // Set document vars if needed
  9343. if ( ( elem.ownerDocument || elem ) !== document ) {
  9344. setDocument( elem );
  9345. }
  9346. if ( support.matchesSelector && documentIsHTML &&
  9347. !nonnativeSelectorCache[ expr + " " ] &&
  9348. ( !rbuggyMatches || !rbuggyMatches.test( expr ) ) &&
  9349. ( !rbuggyQSA || !rbuggyQSA.test( expr ) ) ) {
  9350. try {
  9351. var ret = matches.call( elem, expr );
  9352. // IE 9's matchesSelector returns false on disconnected nodes
  9353. if ( ret || support.disconnectedMatch ||
  9354. // As well, disconnected nodes are said to be in a document
  9355. // fragment in IE 9
  9356. elem.document && elem.document.nodeType !== 11 ) {
  9357. return ret;
  9358. }
  9359. } catch (e) {
  9360. nonnativeSelectorCache( expr, true );
  9361. }
  9362. }
  9363. return Sizzle( expr, document, null, [ elem ] ).length > 0;
  9364. };
  9365. Sizzle.contains = function( context, elem ) {
  9366. // Set document vars if needed
  9367. if ( ( context.ownerDocument || context ) !== document ) {
  9368. setDocument( context );
  9369. }
  9370. return contains( context, elem );
  9371. };
  9372. Sizzle.attr = function( elem, name ) {
  9373. // Set document vars if needed
  9374. if ( ( elem.ownerDocument || elem ) !== document ) {
  9375. setDocument( elem );
  9376. }
  9377. var fn = Expr.attrHandle[ name.toLowerCase() ],
  9378. // Don't get fooled by Object.prototype properties (jQuery #13807)
  9379. val = fn && hasOwn.call( Expr.attrHandle, name.toLowerCase() ) ?
  9380. fn( elem, name, !documentIsHTML ) :
  9381. undefined;
  9382. return val !== undefined ?
  9383. val :
  9384. support.attributes || !documentIsHTML ?
  9385. elem.getAttribute( name ) :
  9386. (val = elem.getAttributeNode(name)) && val.specified ?
  9387. val.value :
  9388. null;
  9389. };
  9390. Sizzle.escape = function( sel ) {
  9391. return (sel + "").replace( rcssescape, fcssescape );
  9392. };
  9393. Sizzle.error = function( msg ) {
  9394. throw new Error( "Syntax error, unrecognized expression: " + msg );
  9395. };
  9396. /**
  9397. * Document sorting and removing duplicates
  9398. * @param {ArrayLike} results
  9399. */
  9400. Sizzle.uniqueSort = function( results ) {
  9401. var elem,
  9402. duplicates = [],
  9403. j = 0,
  9404. i = 0;
  9405. // Unless we *know* we can detect duplicates, assume their presence
  9406. hasDuplicate = !support.detectDuplicates;
  9407. sortInput = !support.sortStable && results.slice( 0 );
  9408. results.sort( sortOrder );
  9409. if ( hasDuplicate ) {
  9410. while ( (elem = results[i++]) ) {
  9411. if ( elem === results[ i ] ) {
  9412. j = duplicates.push( i );
  9413. }
  9414. }
  9415. while ( j-- ) {
  9416. results.splice( duplicates[ j ], 1 );
  9417. }
  9418. }
  9419. // Clear input after sorting to release objects
  9420. // See https://github.com/jquery/sizzle/pull/225
  9421. sortInput = null;
  9422. return results;
  9423. };
  9424. /**
  9425. * Utility function for retrieving the text value of an array of DOM nodes
  9426. * @param {Array|Element} elem
  9427. */
  9428. getText = Sizzle.getText = function( elem ) {
  9429. var node,
  9430. ret = "",
  9431. i = 0,
  9432. nodeType = elem.nodeType;
  9433. if ( !nodeType ) {
  9434. // If no nodeType, this is expected to be an array
  9435. while ( (node = elem[i++]) ) {
  9436. // Do not traverse comment nodes
  9437. ret += getText( node );
  9438. }
  9439. } else if ( nodeType === 1 || nodeType === 9 || nodeType === 11 ) {
  9440. // Use textContent for elements
  9441. // innerText usage removed for consistency of new lines (jQuery #11153)
  9442. if ( typeof elem.textContent === "string" ) {
  9443. return elem.textContent;
  9444. } else {
  9445. // Traverse its children
  9446. for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
  9447. ret += getText( elem );
  9448. }
  9449. }
  9450. } else if ( nodeType === 3 || nodeType === 4 ) {
  9451. return elem.nodeValue;
  9452. }
  9453. // Do not include comment or processing instruction nodes
  9454. return ret;
  9455. };
  9456. Expr = Sizzle.selectors = {
  9457. // Can be adjusted by the user
  9458. cacheLength: 50,
  9459. createPseudo: markFunction,
  9460. match: matchExpr,
  9461. attrHandle: {},
  9462. find: {},
  9463. relative: {
  9464. ">": { dir: "parentNode", first: true },
  9465. " ": { dir: "parentNode" },
  9466. "+": { dir: "previousSibling", first: true },
  9467. "~": { dir: "previousSibling" }
  9468. },
  9469. preFilter: {
  9470. "ATTR": function( match ) {
  9471. match[1] = match[1].replace( runescape, funescape );
  9472. // Move the given value to match[3] whether quoted or unquoted
  9473. match[3] = ( match[3] || match[4] || match[5] || "" ).replace( runescape, funescape );
  9474. if ( match[2] === "~=" ) {
  9475. match[3] = " " + match[3] + " ";
  9476. }
  9477. return match.slice( 0, 4 );
  9478. },
  9479. "CHILD": function( match ) {
  9480. /* matches from matchExpr["CHILD"]
  9481. 1 type (only|nth|...)
  9482. 2 what (child|of-type)
  9483. 3 argument (even|odd|\d*|\d*n([+-]\d+)?|...)
  9484. 4 xn-component of xn+y argument ([+-]?\d*n|)
  9485. 5 sign of xn-component
  9486. 6 x of xn-component
  9487. 7 sign of y-component
  9488. 8 y of y-component
  9489. */
  9490. match[1] = match[1].toLowerCase();
  9491. if ( match[1].slice( 0, 3 ) === "nth" ) {
  9492. // nth-* requires argument
  9493. if ( !match[3] ) {
  9494. Sizzle.error( match[0] );
  9495. }
  9496. // numeric x and y parameters for Expr.filter.CHILD
  9497. // remember that false/true cast respectively to 0/1
  9498. match[4] = +( match[4] ? match[5] + (match[6] || 1) : 2 * ( match[3] === "even" || match[3] === "odd" ) );
  9499. match[5] = +( ( match[7] + match[8] ) || match[3] === "odd" );
  9500. // other types prohibit arguments
  9501. } else if ( match[3] ) {
  9502. Sizzle.error( match[0] );
  9503. }
  9504. return match;
  9505. },
  9506. "PSEUDO": function( match ) {
  9507. var excess,
  9508. unquoted = !match[6] && match[2];
  9509. if ( matchExpr["CHILD"].test( match[0] ) ) {
  9510. return null;
  9511. }
  9512. // Accept quoted arguments as-is
  9513. if ( match[3] ) {
  9514. match[2] = match[4] || match[5] || "";
  9515. // Strip excess characters from unquoted arguments
  9516. } else if ( unquoted && rpseudo.test( unquoted ) &&
  9517. // Get excess from tokenize (recursively)
  9518. (excess = tokenize( unquoted, true )) &&
  9519. // advance to the next closing parenthesis
  9520. (excess = unquoted.indexOf( ")", unquoted.length - excess ) - unquoted.length) ) {
  9521. // excess is a negative index
  9522. match[0] = match[0].slice( 0, excess );
  9523. match[2] = unquoted.slice( 0, excess );
  9524. }
  9525. // Return only captures needed by the pseudo filter method (type and argument)
  9526. return match.slice( 0, 3 );
  9527. }
  9528. },
  9529. filter: {
  9530. "TAG": function( nodeNameSelector ) {
  9531. var nodeName = nodeNameSelector.replace( runescape, funescape ).toLowerCase();
  9532. return nodeNameSelector === "*" ?
  9533. function() { return true; } :
  9534. function( elem ) {
  9535. return elem.nodeName && elem.nodeName.toLowerCase() === nodeName;
  9536. };
  9537. },
  9538. "CLASS": function( className ) {
  9539. var pattern = classCache[ className + " " ];
  9540. return pattern ||
  9541. (pattern = new RegExp( "(^|" + whitespace + ")" + className + "(" + whitespace + "|$)" )) &&
  9542. classCache( className, function( elem ) {
  9543. return pattern.test( typeof elem.className === "string" && elem.className || typeof elem.getAttribute !== "undefined" && elem.getAttribute("class") || "" );
  9544. });
  9545. },
  9546. "ATTR": function( name, operator, check ) {
  9547. return function( elem ) {
  9548. var result = Sizzle.attr( elem, name );
  9549. if ( result == null ) {
  9550. return operator === "!=";
  9551. }
  9552. if ( !operator ) {
  9553. return true;
  9554. }
  9555. result += "";
  9556. return operator === "=" ? result === check :
  9557. operator === "!=" ? result !== check :
  9558. operator === "^=" ? check && result.indexOf( check ) === 0 :
  9559. operator === "*=" ? check && result.indexOf( check ) > -1 :
  9560. operator === "$=" ? check && result.slice( -check.length ) === check :
  9561. operator === "~=" ? ( " " + result.replace( rwhitespace, " " ) + " " ).indexOf( check ) > -1 :
  9562. operator === "|=" ? result === check || result.slice( 0, check.length + 1 ) === check + "-" :
  9563. false;
  9564. };
  9565. },
  9566. "CHILD": function( type, what, argument, first, last ) {
  9567. var simple = type.slice( 0, 3 ) !== "nth",
  9568. forward = type.slice( -4 ) !== "last",
  9569. ofType = what === "of-type";
  9570. return first === 1 && last === 0 ?
  9571. // Shortcut for :nth-*(n)
  9572. function( elem ) {
  9573. return !!elem.parentNode;
  9574. } :
  9575. function( elem, context, xml ) {
  9576. var cache, uniqueCache, outerCache, node, nodeIndex, start,
  9577. dir = simple !== forward ? "nextSibling" : "previousSibling",
  9578. parent = elem.parentNode,
  9579. name = ofType && elem.nodeName.toLowerCase(),
  9580. useCache = !xml && !ofType,
  9581. diff = false;
  9582. if ( parent ) {
  9583. // :(first|last|only)-(child|of-type)
  9584. if ( simple ) {
  9585. while ( dir ) {
  9586. node = elem;
  9587. while ( (node = node[ dir ]) ) {
  9588. if ( ofType ?
  9589. node.nodeName.toLowerCase() === name :
  9590. node.nodeType === 1 ) {
  9591. return false;
  9592. }
  9593. }
  9594. // Reverse direction for :only-* (if we haven't yet done so)
  9595. start = dir = type === "only" && !start && "nextSibling";
  9596. }
  9597. return true;
  9598. }
  9599. start = [ forward ? parent.firstChild : parent.lastChild ];
  9600. // non-xml :nth-child(...) stores cache data on `parent`
  9601. if ( forward && useCache ) {
  9602. // Seek `elem` from a previously-cached index
  9603. // ...in a gzip-friendly way
  9604. node = parent;
  9605. outerCache = node[ expando ] || (node[ expando ] = {});
  9606. // Support: IE <9 only
  9607. // Defend against cloned attroperties (jQuery gh-1709)
  9608. uniqueCache = outerCache[ node.uniqueID ] ||
  9609. (outerCache[ node.uniqueID ] = {});
  9610. cache = uniqueCache[ type ] || [];
  9611. nodeIndex = cache[ 0 ] === dirruns && cache[ 1 ];
  9612. diff = nodeIndex && cache[ 2 ];
  9613. node = nodeIndex && parent.childNodes[ nodeIndex ];
  9614. while ( (node = ++nodeIndex && node && node[ dir ] ||
  9615. // Fallback to seeking `elem` from the start
  9616. (diff = nodeIndex = 0) || start.pop()) ) {
  9617. // When found, cache indexes on `parent` and break
  9618. if ( node.nodeType === 1 && ++diff && node === elem ) {
  9619. uniqueCache[ type ] = [ dirruns, nodeIndex, diff ];
  9620. break;
  9621. }
  9622. }
  9623. } else {
  9624. // Use previously-cached element index if available
  9625. if ( useCache ) {
  9626. // ...in a gzip-friendly way
  9627. node = elem;
  9628. outerCache = node[ expando ] || (node[ expando ] = {});
  9629. // Support: IE <9 only
  9630. // Defend against cloned attroperties (jQuery gh-1709)
  9631. uniqueCache = outerCache[ node.uniqueID ] ||
  9632. (outerCache[ node.uniqueID ] = {});
  9633. cache = uniqueCache[ type ] || [];
  9634. nodeIndex = cache[ 0 ] === dirruns && cache[ 1 ];
  9635. diff = nodeIndex;
  9636. }
  9637. // xml :nth-child(...)
  9638. // or :nth-last-child(...) or :nth(-last)?-of-type(...)
  9639. if ( diff === false ) {
  9640. // Use the same loop as above to seek `elem` from the start
  9641. while ( (node = ++nodeIndex && node && node[ dir ] ||
  9642. (diff = nodeIndex = 0) || start.pop()) ) {
  9643. if ( ( ofType ?
  9644. node.nodeName.toLowerCase() === name :
  9645. node.nodeType === 1 ) &&
  9646. ++diff ) {
  9647. // Cache the index of each encountered element
  9648. if ( useCache ) {
  9649. outerCache = node[ expando ] || (node[ expando ] = {});
  9650. // Support: IE <9 only
  9651. // Defend against cloned attroperties (jQuery gh-1709)
  9652. uniqueCache = outerCache[ node.uniqueID ] ||
  9653. (outerCache[ node.uniqueID ] = {});
  9654. uniqueCache[ type ] = [ dirruns, diff ];
  9655. }
  9656. if ( node === elem ) {
  9657. break;
  9658. }
  9659. }
  9660. }
  9661. }
  9662. }
  9663. // Incorporate the offset, then check against cycle size
  9664. diff -= last;
  9665. return diff === first || ( diff % first === 0 && diff / first >= 0 );
  9666. }
  9667. };
  9668. },
  9669. "PSEUDO": function( pseudo, argument ) {
  9670. // pseudo-class names are case-insensitive
  9671. // http://www.w3.org/TR/selectors/#pseudo-classes
  9672. // Prioritize by case sensitivity in case custom pseudos are added with uppercase letters
  9673. // Remember that setFilters inherits from pseudos
  9674. var args,
  9675. fn = Expr.pseudos[ pseudo ] || Expr.setFilters[ pseudo.toLowerCase() ] ||
  9676. Sizzle.error( "unsupported pseudo: " + pseudo );
  9677. // The user may use createPseudo to indicate that
  9678. // arguments are needed to create the filter function
  9679. // just as Sizzle does
  9680. if ( fn[ expando ] ) {
  9681. return fn( argument );
  9682. }
  9683. // But maintain support for old signatures
  9684. if ( fn.length > 1 ) {
  9685. args = [ pseudo, pseudo, "", argument ];
  9686. return Expr.setFilters.hasOwnProperty( pseudo.toLowerCase() ) ?
  9687. markFunction(function( seed, matches ) {
  9688. var idx,
  9689. matched = fn( seed, argument ),
  9690. i = matched.length;
  9691. while ( i-- ) {
  9692. idx = indexOf( seed, matched[i] );
  9693. seed[ idx ] = !( matches[ idx ] = matched[i] );
  9694. }
  9695. }) :
  9696. function( elem ) {
  9697. return fn( elem, 0, args );
  9698. };
  9699. }
  9700. return fn;
  9701. }
  9702. },
  9703. pseudos: {
  9704. // Potentially complex pseudos
  9705. "not": markFunction(function( selector ) {
  9706. // Trim the selector passed to compile
  9707. // to avoid treating leading and trailing
  9708. // spaces as combinators
  9709. var input = [],
  9710. results = [],
  9711. matcher = compile( selector.replace( rtrim, "$1" ) );
  9712. return matcher[ expando ] ?
  9713. markFunction(function( seed, matches, context, xml ) {
  9714. var elem,
  9715. unmatched = matcher( seed, null, xml, [] ),
  9716. i = seed.length;
  9717. // Match elements unmatched by `matcher`
  9718. while ( i-- ) {
  9719. if ( (elem = unmatched[i]) ) {
  9720. seed[i] = !(matches[i] = elem);
  9721. }
  9722. }
  9723. }) :
  9724. function( elem, context, xml ) {
  9725. input[0] = elem;
  9726. matcher( input, null, xml, results );
  9727. // Don't keep the element (issue #299)
  9728. input[0] = null;
  9729. return !results.pop();
  9730. };
  9731. }),
  9732. "has": markFunction(function( selector ) {
  9733. return function( elem ) {
  9734. return Sizzle( selector, elem ).length > 0;
  9735. };
  9736. }),
  9737. "contains": markFunction(function( text ) {
  9738. text = text.replace( runescape, funescape );
  9739. return function( elem ) {
  9740. return ( elem.textContent || getText( elem ) ).indexOf( text ) > -1;
  9741. };
  9742. }),
  9743. // "Whether an element is represented by a :lang() selector
  9744. // is based solely on the element's language value
  9745. // being equal to the identifier C,
  9746. // or beginning with the identifier C immediately followed by "-".
  9747. // The matching of C against the element's language value is performed case-insensitively.
  9748. // The identifier C does not have to be a valid language name."
  9749. // http://www.w3.org/TR/selectors/#lang-pseudo
  9750. "lang": markFunction( function( lang ) {
  9751. // lang value must be a valid identifier
  9752. if ( !ridentifier.test(lang || "") ) {
  9753. Sizzle.error( "unsupported lang: " + lang );
  9754. }
  9755. lang = lang.replace( runescape, funescape ).toLowerCase();
  9756. return function( elem ) {
  9757. var elemLang;
  9758. do {
  9759. if ( (elemLang = documentIsHTML ?
  9760. elem.lang :
  9761. elem.getAttribute("xml:lang") || elem.getAttribute("lang")) ) {
  9762. elemLang = elemLang.toLowerCase();
  9763. return elemLang === lang || elemLang.indexOf( lang + "-" ) === 0;
  9764. }
  9765. } while ( (elem = elem.parentNode) && elem.nodeType === 1 );
  9766. return false;
  9767. };
  9768. }),
  9769. // Miscellaneous
  9770. "target": function( elem ) {
  9771. var hash = window.location && window.location.hash;
  9772. return hash && hash.slice( 1 ) === elem.id;
  9773. },
  9774. "root": function( elem ) {
  9775. return elem === docElem;
  9776. },
  9777. "focus": function( elem ) {
  9778. return elem === document.activeElement && (!document.hasFocus || document.hasFocus()) && !!(elem.type || elem.href || ~elem.tabIndex);
  9779. },
  9780. // Boolean properties
  9781. "enabled": createDisabledPseudo( false ),
  9782. "disabled": createDisabledPseudo( true ),
  9783. "checked": function( elem ) {
  9784. // In CSS3, :checked should return both checked and selected elements
  9785. // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
  9786. var nodeName = elem.nodeName.toLowerCase();
  9787. return (nodeName === "input" && !!elem.checked) || (nodeName === "option" && !!elem.selected);
  9788. },
  9789. "selected": function( elem ) {
  9790. // Accessing this property makes selected-by-default
  9791. // options in Safari work properly
  9792. if ( elem.parentNode ) {
  9793. elem.parentNode.selectedIndex;
  9794. }
  9795. return elem.selected === true;
  9796. },
  9797. // Contents
  9798. "empty": function( elem ) {
  9799. // http://www.w3.org/TR/selectors/#empty-pseudo
  9800. // :empty is negated by element (1) or content nodes (text: 3; cdata: 4; entity ref: 5),
  9801. // but not by others (comment: 8; processing instruction: 7; etc.)
  9802. // nodeType < 6 works because attributes (2) do not appear as children
  9803. for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
  9804. if ( elem.nodeType < 6 ) {
  9805. return false;
  9806. }
  9807. }
  9808. return true;
  9809. },
  9810. "parent": function( elem ) {
  9811. return !Expr.pseudos["empty"]( elem );
  9812. },
  9813. // Element/input types
  9814. "header": function( elem ) {
  9815. return rheader.test( elem.nodeName );
  9816. },
  9817. "input": function( elem ) {
  9818. return rinputs.test( elem.nodeName );
  9819. },
  9820. "button": function( elem ) {
  9821. var name = elem.nodeName.toLowerCase();
  9822. return name === "input" && elem.type === "button" || name === "button";
  9823. },
  9824. "text": function( elem ) {
  9825. var attr;
  9826. return elem.nodeName.toLowerCase() === "input" &&
  9827. elem.type === "text" &&
  9828. // Support: IE<8
  9829. // New HTML5 attribute values (e.g., "search") appear with elem.type === "text"
  9830. ( (attr = elem.getAttribute("type")) == null || attr.toLowerCase() === "text" );
  9831. },
  9832. // Position-in-collection
  9833. "first": createPositionalPseudo(function() {
  9834. return [ 0 ];
  9835. }),
  9836. "last": createPositionalPseudo(function( matchIndexes, length ) {
  9837. return [ length - 1 ];
  9838. }),
  9839. "eq": createPositionalPseudo(function( matchIndexes, length, argument ) {
  9840. return [ argument < 0 ? argument + length : argument ];
  9841. }),
  9842. "even": createPositionalPseudo(function( matchIndexes, length ) {
  9843. var i = 0;
  9844. for ( ; i < length; i += 2 ) {
  9845. matchIndexes.push( i );
  9846. }
  9847. return matchIndexes;
  9848. }),
  9849. "odd": createPositionalPseudo(function( matchIndexes, length ) {
  9850. var i = 1;
  9851. for ( ; i < length; i += 2 ) {
  9852. matchIndexes.push( i );
  9853. }
  9854. return matchIndexes;
  9855. }),
  9856. "lt": createPositionalPseudo(function( matchIndexes, length, argument ) {
  9857. var i = argument < 0 ?
  9858. argument + length :
  9859. argument > length ?
  9860. length :
  9861. argument;
  9862. for ( ; --i >= 0; ) {
  9863. matchIndexes.push( i );
  9864. }
  9865. return matchIndexes;
  9866. }),
  9867. "gt": createPositionalPseudo(function( matchIndexes, length, argument ) {
  9868. var i = argument < 0 ? argument + length : argument;
  9869. for ( ; ++i < length; ) {
  9870. matchIndexes.push( i );
  9871. }
  9872. return matchIndexes;
  9873. })
  9874. }
  9875. };
  9876. Expr.pseudos["nth"] = Expr.pseudos["eq"];
  9877. // Add button/input type pseudos
  9878. for ( i in { radio: true, checkbox: true, file: true, password: true, image: true } ) {
  9879. Expr.pseudos[ i ] = createInputPseudo( i );
  9880. }
  9881. for ( i in { submit: true, reset: true } ) {
  9882. Expr.pseudos[ i ] = createButtonPseudo( i );
  9883. }
  9884. // Easy API for creating new setFilters
  9885. function setFilters() {}
  9886. setFilters.prototype = Expr.filters = Expr.pseudos;
  9887. Expr.setFilters = new setFilters();
  9888. tokenize = Sizzle.tokenize = function( selector, parseOnly ) {
  9889. var matched, match, tokens, type,
  9890. soFar, groups, preFilters,
  9891. cached = tokenCache[ selector + " " ];
  9892. if ( cached ) {
  9893. return parseOnly ? 0 : cached.slice( 0 );
  9894. }
  9895. soFar = selector;
  9896. groups = [];
  9897. preFilters = Expr.preFilter;
  9898. while ( soFar ) {
  9899. // Comma and first run
  9900. if ( !matched || (match = rcomma.exec( soFar )) ) {
  9901. if ( match ) {
  9902. // Don't consume trailing commas as valid
  9903. soFar = soFar.slice( match[0].length ) || soFar;
  9904. }
  9905. groups.push( (tokens = []) );
  9906. }
  9907. matched = false;
  9908. // Combinators
  9909. if ( (match = rcombinators.exec( soFar )) ) {
  9910. matched = match.shift();
  9911. tokens.push({
  9912. value: matched,
  9913. // Cast descendant combinators to space
  9914. type: match[0].replace( rtrim, " " )
  9915. });
  9916. soFar = soFar.slice( matched.length );
  9917. }
  9918. // Filters
  9919. for ( type in Expr.filter ) {
  9920. if ( (match = matchExpr[ type ].exec( soFar )) && (!preFilters[ type ] ||
  9921. (match = preFilters[ type ]( match ))) ) {
  9922. matched = match.shift();
  9923. tokens.push({
  9924. value: matched,
  9925. type: type,
  9926. matches: match
  9927. });
  9928. soFar = soFar.slice( matched.length );
  9929. }
  9930. }
  9931. if ( !matched ) {
  9932. break;
  9933. }
  9934. }
  9935. // Return the length of the invalid excess
  9936. // if we're just parsing
  9937. // Otherwise, throw an error or return tokens
  9938. return parseOnly ?
  9939. soFar.length :
  9940. soFar ?
  9941. Sizzle.error( selector ) :
  9942. // Cache the tokens
  9943. tokenCache( selector, groups ).slice( 0 );
  9944. };
  9945. function toSelector( tokens ) {
  9946. var i = 0,
  9947. len = tokens.length,
  9948. selector = "";
  9949. for ( ; i < len; i++ ) {
  9950. selector += tokens[i].value;
  9951. }
  9952. return selector;
  9953. }
  9954. function addCombinator( matcher, combinator, base ) {
  9955. var dir = combinator.dir,
  9956. skip = combinator.next,
  9957. key = skip || dir,
  9958. checkNonElements = base && key === "parentNode",
  9959. doneName = done++;
  9960. return combinator.first ?
  9961. // Check against closest ancestor/preceding element
  9962. function( elem, context, xml ) {
  9963. while ( (elem = elem[ dir ]) ) {
  9964. if ( elem.nodeType === 1 || checkNonElements ) {
  9965. return matcher( elem, context, xml );
  9966. }
  9967. }
  9968. return false;
  9969. } :
  9970. // Check against all ancestor/preceding elements
  9971. function( elem, context, xml ) {
  9972. var oldCache, uniqueCache, outerCache,
  9973. newCache = [ dirruns, doneName ];
  9974. // We can't set arbitrary data on XML nodes, so they don't benefit from combinator caching
  9975. if ( xml ) {
  9976. while ( (elem = elem[ dir ]) ) {
  9977. if ( elem.nodeType === 1 || checkNonElements ) {
  9978. if ( matcher( elem, context, xml ) ) {
  9979. return true;
  9980. }
  9981. }
  9982. }
  9983. } else {
  9984. while ( (elem = elem[ dir ]) ) {
  9985. if ( elem.nodeType === 1 || checkNonElements ) {
  9986. outerCache = elem[ expando ] || (elem[ expando ] = {});
  9987. // Support: IE <9 only
  9988. // Defend against cloned attroperties (jQuery gh-1709)
  9989. uniqueCache = outerCache[ elem.uniqueID ] || (outerCache[ elem.uniqueID ] = {});
  9990. if ( skip && skip === elem.nodeName.toLowerCase() ) {
  9991. elem = elem[ dir ] || elem;
  9992. } else if ( (oldCache = uniqueCache[ key ]) &&
  9993. oldCache[ 0 ] === dirruns && oldCache[ 1 ] === doneName ) {
  9994. // Assign to newCache so results back-propagate to previous elements
  9995. return (newCache[ 2 ] = oldCache[ 2 ]);
  9996. } else {
  9997. // Reuse newcache so results back-propagate to previous elements
  9998. uniqueCache[ key ] = newCache;
  9999. // A match means we're done; a fail means we have to keep checking
  10000. if ( (newCache[ 2 ] = matcher( elem, context, xml )) ) {
  10001. return true;
  10002. }
  10003. }
  10004. }
  10005. }
  10006. }
  10007. return false;
  10008. };
  10009. }
  10010. function elementMatcher( matchers ) {
  10011. return matchers.length > 1 ?
  10012. function( elem, context, xml ) {
  10013. var i = matchers.length;
  10014. while ( i-- ) {
  10015. if ( !matchers[i]( elem, context, xml ) ) {
  10016. return false;
  10017. }
  10018. }
  10019. return true;
  10020. } :
  10021. matchers[0];
  10022. }
  10023. function multipleContexts( selector, contexts, results ) {
  10024. var i = 0,
  10025. len = contexts.length;
  10026. for ( ; i < len; i++ ) {
  10027. Sizzle( selector, contexts[i], results );
  10028. }
  10029. return results;
  10030. }
  10031. function condense( unmatched, map, filter, context, xml ) {
  10032. var elem,
  10033. newUnmatched = [],
  10034. i = 0,
  10035. len = unmatched.length,
  10036. mapped = map != null;
  10037. for ( ; i < len; i++ ) {
  10038. if ( (elem = unmatched[i]) ) {
  10039. if ( !filter || filter( elem, context, xml ) ) {
  10040. newUnmatched.push( elem );
  10041. if ( mapped ) {
  10042. map.push( i );
  10043. }
  10044. }
  10045. }
  10046. }
  10047. return newUnmatched;
  10048. }
  10049. function setMatcher( preFilter, selector, matcher, postFilter, postFinder, postSelector ) {
  10050. if ( postFilter && !postFilter[ expando ] ) {
  10051. postFilter = setMatcher( postFilter );
  10052. }
  10053. if ( postFinder && !postFinder[ expando ] ) {
  10054. postFinder = setMatcher( postFinder, postSelector );
  10055. }
  10056. return markFunction(function( seed, results, context, xml ) {
  10057. var temp, i, elem,
  10058. preMap = [],
  10059. postMap = [],
  10060. preexisting = results.length,
  10061. // Get initial elements from seed or context
  10062. elems = seed || multipleContexts( selector || "*", context.nodeType ? [ context ] : context, [] ),
  10063. // Prefilter to get matcher input, preserving a map for seed-results synchronization
  10064. matcherIn = preFilter && ( seed || !selector ) ?
  10065. condense( elems, preMap, preFilter, context, xml ) :
  10066. elems,
  10067. matcherOut = matcher ?
  10068. // If we have a postFinder, or filtered seed, or non-seed postFilter or preexisting results,
  10069. postFinder || ( seed ? preFilter : preexisting || postFilter ) ?
  10070. // ...intermediate processing is necessary
  10071. [] :
  10072. // ...otherwise use results directly
  10073. results :
  10074. matcherIn;
  10075. // Find primary matches
  10076. if ( matcher ) {
  10077. matcher( matcherIn, matcherOut, context, xml );
  10078. }
  10079. // Apply postFilter
  10080. if ( postFilter ) {
  10081. temp = condense( matcherOut, postMap );
  10082. postFilter( temp, [], context, xml );
  10083. // Un-match failing elements by moving them back to matcherIn
  10084. i = temp.length;
  10085. while ( i-- ) {
  10086. if ( (elem = temp[i]) ) {
  10087. matcherOut[ postMap[i] ] = !(matcherIn[ postMap[i] ] = elem);
  10088. }
  10089. }
  10090. }
  10091. if ( seed ) {
  10092. if ( postFinder || preFilter ) {
  10093. if ( postFinder ) {
  10094. // Get the final matcherOut by condensing this intermediate into postFinder contexts
  10095. temp = [];
  10096. i = matcherOut.length;
  10097. while ( i-- ) {
  10098. if ( (elem = matcherOut[i]) ) {
  10099. // Restore matcherIn since elem is not yet a final match
  10100. temp.push( (matcherIn[i] = elem) );
  10101. }
  10102. }
  10103. postFinder( null, (matcherOut = []), temp, xml );
  10104. }
  10105. // Move matched elements from seed to results to keep them synchronized
  10106. i = matcherOut.length;
  10107. while ( i-- ) {
  10108. if ( (elem = matcherOut[i]) &&
  10109. (temp = postFinder ? indexOf( seed, elem ) : preMap[i]) > -1 ) {
  10110. seed[temp] = !(results[temp] = elem);
  10111. }
  10112. }
  10113. }
  10114. // Add elements to results, through postFinder if defined
  10115. } else {
  10116. matcherOut = condense(
  10117. matcherOut === results ?
  10118. matcherOut.splice( preexisting, matcherOut.length ) :
  10119. matcherOut
  10120. );
  10121. if ( postFinder ) {
  10122. postFinder( null, results, matcherOut, xml );
  10123. } else {
  10124. push.apply( results, matcherOut );
  10125. }
  10126. }
  10127. });
  10128. }
  10129. function matcherFromTokens( tokens ) {
  10130. var checkContext, matcher, j,
  10131. len = tokens.length,
  10132. leadingRelative = Expr.relative[ tokens[0].type ],
  10133. implicitRelative = leadingRelative || Expr.relative[" "],
  10134. i = leadingRelative ? 1 : 0,
  10135. // The foundational matcher ensures that elements are reachable from top-level context(s)
  10136. matchContext = addCombinator( function( elem ) {
  10137. return elem === checkContext;
  10138. }, implicitRelative, true ),
  10139. matchAnyContext = addCombinator( function( elem ) {
  10140. return indexOf( checkContext, elem ) > -1;
  10141. }, implicitRelative, true ),
  10142. matchers = [ function( elem, context, xml ) {
  10143. var ret = ( !leadingRelative && ( xml || context !== outermostContext ) ) || (
  10144. (checkContext = context).nodeType ?
  10145. matchContext( elem, context, xml ) :
  10146. matchAnyContext( elem, context, xml ) );
  10147. // Avoid hanging onto element (issue #299)
  10148. checkContext = null;
  10149. return ret;
  10150. } ];
  10151. for ( ; i < len; i++ ) {
  10152. if ( (matcher = Expr.relative[ tokens[i].type ]) ) {
  10153. matchers = [ addCombinator(elementMatcher( matchers ), matcher) ];
  10154. } else {
  10155. matcher = Expr.filter[ tokens[i].type ].apply( null, tokens[i].matches );
  10156. // Return special upon seeing a positional matcher
  10157. if ( matcher[ expando ] ) {
  10158. // Find the next relative operator (if any) for proper handling
  10159. j = ++i;
  10160. for ( ; j < len; j++ ) {
  10161. if ( Expr.relative[ tokens[j].type ] ) {
  10162. break;
  10163. }
  10164. }
  10165. return setMatcher(
  10166. i > 1 && elementMatcher( matchers ),
  10167. i > 1 && toSelector(
  10168. // If the preceding token was a descendant combinator, insert an implicit any-element `*`
  10169. tokens.slice( 0, i - 1 ).concat({ value: tokens[ i - 2 ].type === " " ? "*" : "" })
  10170. ).replace( rtrim, "$1" ),
  10171. matcher,
  10172. i < j && matcherFromTokens( tokens.slice( i, j ) ),
  10173. j < len && matcherFromTokens( (tokens = tokens.slice( j )) ),
  10174. j < len && toSelector( tokens )
  10175. );
  10176. }
  10177. matchers.push( matcher );
  10178. }
  10179. }
  10180. return elementMatcher( matchers );
  10181. }
  10182. function matcherFromGroupMatchers( elementMatchers, setMatchers ) {
  10183. var bySet = setMatchers.length > 0,
  10184. byElement = elementMatchers.length > 0,
  10185. superMatcher = function( seed, context, xml, results, outermost ) {
  10186. var elem, j, matcher,
  10187. matchedCount = 0,
  10188. i = "0",
  10189. unmatched = seed && [],
  10190. setMatched = [],
  10191. contextBackup = outermostContext,
  10192. // We must always have either seed elements or outermost context
  10193. elems = seed || byElement && Expr.find["TAG"]( "*", outermost ),
  10194. // Use integer dirruns iff this is the outermost matcher
  10195. dirrunsUnique = (dirruns += contextBackup == null ? 1 : Math.random() || 0.1),
  10196. len = elems.length;
  10197. if ( outermost ) {
  10198. outermostContext = context === document || context || outermost;
  10199. }
  10200. // Add elements passing elementMatchers directly to results
  10201. // Support: IE<9, Safari
  10202. // Tolerate NodeList properties (IE: "length"; Safari: <number>) matching elements by id
  10203. for ( ; i !== len && (elem = elems[i]) != null; i++ ) {
  10204. if ( byElement && elem ) {
  10205. j = 0;
  10206. if ( !context && elem.ownerDocument !== document ) {
  10207. setDocument( elem );
  10208. xml = !documentIsHTML;
  10209. }
  10210. while ( (matcher = elementMatchers[j++]) ) {
  10211. if ( matcher( elem, context || document, xml) ) {
  10212. results.push( elem );
  10213. break;
  10214. }
  10215. }
  10216. if ( outermost ) {
  10217. dirruns = dirrunsUnique;
  10218. }
  10219. }
  10220. // Track unmatched elements for set filters
  10221. if ( bySet ) {
  10222. // They will have gone through all possible matchers
  10223. if ( (elem = !matcher && elem) ) {
  10224. matchedCount--;
  10225. }
  10226. // Lengthen the array for every element, matched or not
  10227. if ( seed ) {
  10228. unmatched.push( elem );
  10229. }
  10230. }
  10231. }
  10232. // `i` is now the count of elements visited above, and adding it to `matchedCount`
  10233. // makes the latter nonnegative.
  10234. matchedCount += i;
  10235. // Apply set filters to unmatched elements
  10236. // NOTE: This can be skipped if there are no unmatched elements (i.e., `matchedCount`
  10237. // equals `i`), unless we didn't visit _any_ elements in the above loop because we have
  10238. // no element matchers and no seed.
  10239. // Incrementing an initially-string "0" `i` allows `i` to remain a string only in that
  10240. // case, which will result in a "00" `matchedCount` that differs from `i` but is also
  10241. // numerically zero.
  10242. if ( bySet && i !== matchedCount ) {
  10243. j = 0;
  10244. while ( (matcher = setMatchers[j++]) ) {
  10245. matcher( unmatched, setMatched, context, xml );
  10246. }
  10247. if ( seed ) {
  10248. // Reintegrate element matches to eliminate the need for sorting
  10249. if ( matchedCount > 0 ) {
  10250. while ( i-- ) {
  10251. if ( !(unmatched[i] || setMatched[i]) ) {
  10252. setMatched[i] = pop.call( results );
  10253. }
  10254. }
  10255. }
  10256. // Discard index placeholder values to get only actual matches
  10257. setMatched = condense( setMatched );
  10258. }
  10259. // Add matches to results
  10260. push.apply( results, setMatched );
  10261. // Seedless set matches succeeding multiple successful matchers stipulate sorting
  10262. if ( outermost && !seed && setMatched.length > 0 &&
  10263. ( matchedCount + setMatchers.length ) > 1 ) {
  10264. Sizzle.uniqueSort( results );
  10265. }
  10266. }
  10267. // Override manipulation of globals by nested matchers
  10268. if ( outermost ) {
  10269. dirruns = dirrunsUnique;
  10270. outermostContext = contextBackup;
  10271. }
  10272. return unmatched;
  10273. };
  10274. return bySet ?
  10275. markFunction( superMatcher ) :
  10276. superMatcher;
  10277. }
  10278. compile = Sizzle.compile = function( selector, match /* Internal Use Only */ ) {
  10279. var i,
  10280. setMatchers = [],
  10281. elementMatchers = [],
  10282. cached = compilerCache[ selector + " " ];
  10283. if ( !cached ) {
  10284. // Generate a function of recursive functions that can be used to check each element
  10285. if ( !match ) {
  10286. match = tokenize( selector );
  10287. }
  10288. i = match.length;
  10289. while ( i-- ) {
  10290. cached = matcherFromTokens( match[i] );
  10291. if ( cached[ expando ] ) {
  10292. setMatchers.push( cached );
  10293. } else {
  10294. elementMatchers.push( cached );
  10295. }
  10296. }
  10297. // Cache the compiled function
  10298. cached = compilerCache( selector, matcherFromGroupMatchers( elementMatchers, setMatchers ) );
  10299. // Save selector and tokenization
  10300. cached.selector = selector;
  10301. }
  10302. return cached;
  10303. };
  10304. /**
  10305. * A low-level selection function that works with Sizzle's compiled
  10306. * selector functions
  10307. * @param {String|Function} selector A selector or a pre-compiled
  10308. * selector function built with Sizzle.compile
  10309. * @param {Element} context
  10310. * @param {Array} [results]
  10311. * @param {Array} [seed] A set of elements to match against
  10312. */
  10313. select = Sizzle.select = function( selector, context, results, seed ) {
  10314. var i, tokens, token, type, find,
  10315. compiled = typeof selector === "function" && selector,
  10316. match = !seed && tokenize( (selector = compiled.selector || selector) );
  10317. results = results || [];
  10318. // Try to minimize operations if there is only one selector in the list and no seed
  10319. // (the latter of which guarantees us context)
  10320. if ( match.length === 1 ) {
  10321. // Reduce context if the leading compound selector is an ID
  10322. tokens = match[0] = match[0].slice( 0 );
  10323. if ( tokens.length > 2 && (token = tokens[0]).type === "ID" &&
  10324. context.nodeType === 9 && documentIsHTML && Expr.relative[ tokens[1].type ] ) {
  10325. context = ( Expr.find["ID"]( token.matches[0].replace(runescape, funescape), context ) || [] )[0];
  10326. if ( !context ) {
  10327. return results;
  10328. // Precompiled matchers will still verify ancestry, so step up a level
  10329. } else if ( compiled ) {
  10330. context = context.parentNode;
  10331. }
  10332. selector = selector.slice( tokens.shift().value.length );
  10333. }
  10334. // Fetch a seed set for right-to-left matching
  10335. i = matchExpr["needsContext"].test( selector ) ? 0 : tokens.length;
  10336. while ( i-- ) {
  10337. token = tokens[i];
  10338. // Abort if we hit a combinator
  10339. if ( Expr.relative[ (type = token.type) ] ) {
  10340. break;
  10341. }
  10342. if ( (find = Expr.find[ type ]) ) {
  10343. // Search, expanding context for leading sibling combinators
  10344. if ( (seed = find(
  10345. token.matches[0].replace( runescape, funescape ),
  10346. rsibling.test( tokens[0].type ) && testContext( context.parentNode ) || context
  10347. )) ) {
  10348. // If seed is empty or no tokens remain, we can return early
  10349. tokens.splice( i, 1 );
  10350. selector = seed.length && toSelector( tokens );
  10351. if ( !selector ) {
  10352. push.apply( results, seed );
  10353. return results;
  10354. }
  10355. break;
  10356. }
  10357. }
  10358. }
  10359. }
  10360. // Compile and execute a filtering function if one is not provided
  10361. // Provide `match` to avoid retokenization if we modified the selector above
  10362. ( compiled || compile( selector, match ) )(
  10363. seed,
  10364. context,
  10365. !documentIsHTML,
  10366. results,
  10367. !context || rsibling.test( selector ) && testContext( context.parentNode ) || context
  10368. );
  10369. return results;
  10370. };
  10371. // One-time assignments
  10372. // Sort stability
  10373. support.sortStable = expando.split("").sort( sortOrder ).join("") === expando;
  10374. // Support: Chrome 14-35+
  10375. // Always assume duplicates if they aren't passed to the comparison function
  10376. support.detectDuplicates = !!hasDuplicate;
  10377. // Initialize against the default document
  10378. setDocument();
  10379. // Support: Webkit<537.32 - Safari 6.0.3/Chrome 25 (fixed in Chrome 27)
  10380. // Detached nodes confoundingly follow *each other*
  10381. support.sortDetached = assert(function( el ) {
  10382. // Should return 1, but returns 4 (following)
  10383. return el.compareDocumentPosition( document.createElement("fieldset") ) & 1;
  10384. });
  10385. // Support: IE<8
  10386. // Prevent attribute/property "interpolation"
  10387. // https://msdn.microsoft.com/en-us/library/ms536429%28VS.85%29.aspx
  10388. if ( !assert(function( el ) {
  10389. el.innerHTML = "<a href='#'></a>";
  10390. return el.firstChild.getAttribute("href") === "#" ;
  10391. }) ) {
  10392. addHandle( "type|href|height|width", function( elem, name, isXML ) {
  10393. if ( !isXML ) {
  10394. return elem.getAttribute( name, name.toLowerCase() === "type" ? 1 : 2 );
  10395. }
  10396. });
  10397. }
  10398. // Support: IE<9
  10399. // Use defaultValue in place of getAttribute("value")
  10400. if ( !support.attributes || !assert(function( el ) {
  10401. el.innerHTML = "<input/>";
  10402. el.firstChild.setAttribute( "value", "" );
  10403. return el.firstChild.getAttribute( "value" ) === "";
  10404. }) ) {
  10405. addHandle( "value", function( elem, name, isXML ) {
  10406. if ( !isXML && elem.nodeName.toLowerCase() === "input" ) {
  10407. return elem.defaultValue;
  10408. }
  10409. });
  10410. }
  10411. // Support: IE<9
  10412. // Use getAttributeNode to fetch booleans when getAttribute lies
  10413. if ( !assert(function( el ) {
  10414. return el.getAttribute("disabled") == null;
  10415. }) ) {
  10416. addHandle( booleans, function( elem, name, isXML ) {
  10417. var val;
  10418. if ( !isXML ) {
  10419. return elem[ name ] === true ? name.toLowerCase() :
  10420. (val = elem.getAttributeNode( name )) && val.specified ?
  10421. val.value :
  10422. null;
  10423. }
  10424. });
  10425. }
  10426. return Sizzle;
  10427. })( window );
  10428. jQuery.find = Sizzle;
  10429. jQuery.expr = Sizzle.selectors;
  10430. // Deprecated
  10431. jQuery.expr[ ":" ] = jQuery.expr.pseudos;
  10432. jQuery.uniqueSort = jQuery.unique = Sizzle.uniqueSort;
  10433. jQuery.text = Sizzle.getText;
  10434. jQuery.isXMLDoc = Sizzle.isXML;
  10435. jQuery.contains = Sizzle.contains;
  10436. jQuery.escapeSelector = Sizzle.escape;
  10437. var dir = function( elem, dir, until ) {
  10438. var matched = [],
  10439. truncate = until !== undefined;
  10440. while ( ( elem = elem[ dir ] ) && elem.nodeType !== 9 ) {
  10441. if ( elem.nodeType === 1 ) {
  10442. if ( truncate && jQuery( elem ).is( until ) ) {
  10443. break;
  10444. }
  10445. matched.push( elem );
  10446. }
  10447. }
  10448. return matched;
  10449. };
  10450. var siblings = function( n, elem ) {
  10451. var matched = [];
  10452. for ( ; n; n = n.nextSibling ) {
  10453. if ( n.nodeType === 1 && n !== elem ) {
  10454. matched.push( n );
  10455. }
  10456. }
  10457. return matched;
  10458. };
  10459. var rneedsContext = jQuery.expr.match.needsContext;
  10460. function nodeName( elem, name ) {
  10461. return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase();
  10462. };
  10463. var rsingleTag = ( /^<([a-z][^\/\0>:\x20\t\r\n\f]*)[\x20\t\r\n\f]*\/?>(?:<\/\1>|)$/i );
  10464. // Implement the identical functionality for filter and not
  10465. function winnow( elements, qualifier, not ) {
  10466. if ( isFunction( qualifier ) ) {
  10467. return jQuery.grep( elements, function( elem, i ) {
  10468. return !!qualifier.call( elem, i, elem ) !== not;
  10469. } );
  10470. }
  10471. // Single element
  10472. if ( qualifier.nodeType ) {
  10473. return jQuery.grep( elements, function( elem ) {
  10474. return ( elem === qualifier ) !== not;
  10475. } );
  10476. }
  10477. // Arraylike of elements (jQuery, arguments, Array)
  10478. if ( typeof qualifier !== "string" ) {
  10479. return jQuery.grep( elements, function( elem ) {
  10480. return ( indexOf.call( qualifier, elem ) > -1 ) !== not;
  10481. } );
  10482. }
  10483. // Filtered directly for both simple and complex selectors
  10484. return jQuery.filter( qualifier, elements, not );
  10485. }
  10486. jQuery.filter = function( expr, elems, not ) {
  10487. var elem = elems[ 0 ];
  10488. if ( not ) {
  10489. expr = ":not(" + expr + ")";
  10490. }
  10491. if ( elems.length === 1 && elem.nodeType === 1 ) {
  10492. return jQuery.find.matchesSelector( elem, expr ) ? [ elem ] : [];
  10493. }
  10494. return jQuery.find.matches( expr, jQuery.grep( elems, function( elem ) {
  10495. return elem.nodeType === 1;
  10496. } ) );
  10497. };
  10498. jQuery.fn.extend( {
  10499. find: function( selector ) {
  10500. var i, ret,
  10501. len = this.length,
  10502. self = this;
  10503. if ( typeof selector !== "string" ) {
  10504. return this.pushStack( jQuery( selector ).filter( function() {
  10505. for ( i = 0; i < len; i++ ) {
  10506. if ( jQuery.contains( self[ i ], this ) ) {
  10507. return true;
  10508. }
  10509. }
  10510. } ) );
  10511. }
  10512. ret = this.pushStack( [] );
  10513. for ( i = 0; i < len; i++ ) {
  10514. jQuery.find( selector, self[ i ], ret );
  10515. }
  10516. return len > 1 ? jQuery.uniqueSort( ret ) : ret;
  10517. },
  10518. filter: function( selector ) {
  10519. return this.pushStack( winnow( this, selector || [], false ) );
  10520. },
  10521. not: function( selector ) {
  10522. return this.pushStack( winnow( this, selector || [], true ) );
  10523. },
  10524. is: function( selector ) {
  10525. return !!winnow(
  10526. this,
  10527. // If this is a positional/relative selector, check membership in the returned set
  10528. // so $("p:first").is("p:last") won't return true for a doc with two "p".
  10529. typeof selector === "string" && rneedsContext.test( selector ) ?
  10530. jQuery( selector ) :
  10531. selector || [],
  10532. false
  10533. ).length;
  10534. }
  10535. } );
  10536. // Initialize a jQuery object
  10537. // A central reference to the root jQuery(document)
  10538. var rootjQuery,
  10539. // A simple way to check for HTML strings
  10540. // Prioritize #id over <tag> to avoid XSS via location.hash (#9521)
  10541. // Strict HTML recognition (#11290: must start with <)
  10542. // Shortcut simple #id case for speed
  10543. rquickExpr = /^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]+))$/,
  10544. init = jQuery.fn.init = function( selector, context, root ) {
  10545. var match, elem;
  10546. // HANDLE: $(""), $(null), $(undefined), $(false)
  10547. if ( !selector ) {
  10548. return this;
  10549. }
  10550. // Method init() accepts an alternate rootjQuery
  10551. // so migrate can support jQuery.sub (gh-2101)
  10552. root = root || rootjQuery;
  10553. // Handle HTML strings
  10554. if ( typeof selector === "string" ) {
  10555. if ( selector[ 0 ] === "<" &&
  10556. selector[ selector.length - 1 ] === ">" &&
  10557. selector.length >= 3 ) {
  10558. // Assume that strings that start and end with <> are HTML and skip the regex check
  10559. match = [ null, selector, null ];
  10560. } else {
  10561. match = rquickExpr.exec( selector );
  10562. }
  10563. // Match html or make sure no context is specified for #id
  10564. if ( match && ( match[ 1 ] || !context ) ) {
  10565. // HANDLE: $(html) -> $(array)
  10566. if ( match[ 1 ] ) {
  10567. context = context instanceof jQuery ? context[ 0 ] : context;
  10568. // Option to run scripts is true for back-compat
  10569. // Intentionally let the error be thrown if parseHTML is not present
  10570. jQuery.merge( this, jQuery.parseHTML(
  10571. match[ 1 ],
  10572. context && context.nodeType ? context.ownerDocument || context : document,
  10573. true
  10574. ) );
  10575. // HANDLE: $(html, props)
  10576. if ( rsingleTag.test( match[ 1 ] ) && jQuery.isPlainObject( context ) ) {
  10577. for ( match in context ) {
  10578. // Properties of context are called as methods if possible
  10579. if ( isFunction( this[ match ] ) ) {
  10580. this[ match ]( context[ match ] );
  10581. // ...and otherwise set as attributes
  10582. } else {
  10583. this.attr( match, context[ match ] );
  10584. }
  10585. }
  10586. }
  10587. return this;
  10588. // HANDLE: $(#id)
  10589. } else {
  10590. elem = document.getElementById( match[ 2 ] );
  10591. if ( elem ) {
  10592. // Inject the element directly into the jQuery object
  10593. this[ 0 ] = elem;
  10594. this.length = 1;
  10595. }
  10596. return this;
  10597. }
  10598. // HANDLE: $(expr, $(...))
  10599. } else if ( !context || context.jquery ) {
  10600. return ( context || root ).find( selector );
  10601. // HANDLE: $(expr, context)
  10602. // (which is just equivalent to: $(context).find(expr)
  10603. } else {
  10604. return this.constructor( context ).find( selector );
  10605. }
  10606. // HANDLE: $(DOMElement)
  10607. } else if ( selector.nodeType ) {
  10608. this[ 0 ] = selector;
  10609. this.length = 1;
  10610. return this;
  10611. // HANDLE: $(function)
  10612. // Shortcut for document ready
  10613. } else if ( isFunction( selector ) ) {
  10614. return root.ready !== undefined ?
  10615. root.ready( selector ) :
  10616. // Execute immediately if ready is not present
  10617. selector( jQuery );
  10618. }
  10619. return jQuery.makeArray( selector, this );
  10620. };
  10621. // Give the init function the jQuery prototype for later instantiation
  10622. init.prototype = jQuery.fn;
  10623. // Initialize central reference
  10624. rootjQuery = jQuery( document );
  10625. var rparentsprev = /^(?:parents|prev(?:Until|All))/,
  10626. // Methods guaranteed to produce a unique set when starting from a unique set
  10627. guaranteedUnique = {
  10628. children: true,
  10629. contents: true,
  10630. next: true,
  10631. prev: true
  10632. };
  10633. jQuery.fn.extend( {
  10634. has: function( target ) {
  10635. var targets = jQuery( target, this ),
  10636. l = targets.length;
  10637. return this.filter( function() {
  10638. var i = 0;
  10639. for ( ; i < l; i++ ) {
  10640. if ( jQuery.contains( this, targets[ i ] ) ) {
  10641. return true;
  10642. }
  10643. }
  10644. } );
  10645. },
  10646. closest: function( selectors, context ) {
  10647. var cur,
  10648. i = 0,
  10649. l = this.length,
  10650. matched = [],
  10651. targets = typeof selectors !== "string" && jQuery( selectors );
  10652. // Positional selectors never match, since there's no _selection_ context
  10653. if ( !rneedsContext.test( selectors ) ) {
  10654. for ( ; i < l; i++ ) {
  10655. for ( cur = this[ i ]; cur && cur !== context; cur = cur.parentNode ) {
  10656. // Always skip document fragments
  10657. if ( cur.nodeType < 11 && ( targets ?
  10658. targets.index( cur ) > -1 :
  10659. // Don't pass non-elements to Sizzle
  10660. cur.nodeType === 1 &&
  10661. jQuery.find.matchesSelector( cur, selectors ) ) ) {
  10662. matched.push( cur );
  10663. break;
  10664. }
  10665. }
  10666. }
  10667. }
  10668. return this.pushStack( matched.length > 1 ? jQuery.uniqueSort( matched ) : matched );
  10669. },
  10670. // Determine the position of an element within the set
  10671. index: function( elem ) {
  10672. // No argument, return index in parent
  10673. if ( !elem ) {
  10674. return ( this[ 0 ] && this[ 0 ].parentNode ) ? this.first().prevAll().length : -1;
  10675. }
  10676. // Index in selector
  10677. if ( typeof elem === "string" ) {
  10678. return indexOf.call( jQuery( elem ), this[ 0 ] );
  10679. }
  10680. // Locate the position of the desired element
  10681. return indexOf.call( this,
  10682. // If it receives a jQuery object, the first element is used
  10683. elem.jquery ? elem[ 0 ] : elem
  10684. );
  10685. },
  10686. add: function( selector, context ) {
  10687. return this.pushStack(
  10688. jQuery.uniqueSort(
  10689. jQuery.merge( this.get(), jQuery( selector, context ) )
  10690. )
  10691. );
  10692. },
  10693. addBack: function( selector ) {
  10694. return this.add( selector == null ?
  10695. this.prevObject : this.prevObject.filter( selector )
  10696. );
  10697. }
  10698. } );
  10699. function sibling( cur, dir ) {
  10700. while ( ( cur = cur[ dir ] ) && cur.nodeType !== 1 ) {}
  10701. return cur;
  10702. }
  10703. jQuery.each( {
  10704. parent: function( elem ) {
  10705. var parent = elem.parentNode;
  10706. return parent && parent.nodeType !== 11 ? parent : null;
  10707. },
  10708. parents: function( elem ) {
  10709. return dir( elem, "parentNode" );
  10710. },
  10711. parentsUntil: function( elem, i, until ) {
  10712. return dir( elem, "parentNode", until );
  10713. },
  10714. next: function( elem ) {
  10715. return sibling( elem, "nextSibling" );
  10716. },
  10717. prev: function( elem ) {
  10718. return sibling( elem, "previousSibling" );
  10719. },
  10720. nextAll: function( elem ) {
  10721. return dir( elem, "nextSibling" );
  10722. },
  10723. prevAll: function( elem ) {
  10724. return dir( elem, "previousSibling" );
  10725. },
  10726. nextUntil: function( elem, i, until ) {
  10727. return dir( elem, "nextSibling", until );
  10728. },
  10729. prevUntil: function( elem, i, until ) {
  10730. return dir( elem, "previousSibling", until );
  10731. },
  10732. siblings: function( elem ) {
  10733. return siblings( ( elem.parentNode || {} ).firstChild, elem );
  10734. },
  10735. children: function( elem ) {
  10736. return siblings( elem.firstChild );
  10737. },
  10738. contents: function( elem ) {
  10739. if ( typeof elem.contentDocument !== "undefined" ) {
  10740. return elem.contentDocument;
  10741. }
  10742. // Support: IE 9 - 11 only, iOS 7 only, Android Browser <=4.3 only
  10743. // Treat the template element as a regular one in browsers that
  10744. // don't support it.
  10745. if ( nodeName( elem, "template" ) ) {
  10746. elem = elem.content || elem;
  10747. }
  10748. return jQuery.merge( [], elem.childNodes );
  10749. }
  10750. }, function( name, fn ) {
  10751. jQuery.fn[ name ] = function( until, selector ) {
  10752. var matched = jQuery.map( this, fn, until );
  10753. if ( name.slice( -5 ) !== "Until" ) {
  10754. selector = until;
  10755. }
  10756. if ( selector && typeof selector === "string" ) {
  10757. matched = jQuery.filter( selector, matched );
  10758. }
  10759. if ( this.length > 1 ) {
  10760. // Remove duplicates
  10761. if ( !guaranteedUnique[ name ] ) {
  10762. jQuery.uniqueSort( matched );
  10763. }
  10764. // Reverse order for parents* and prev-derivatives
  10765. if ( rparentsprev.test( name ) ) {
  10766. matched.reverse();
  10767. }
  10768. }
  10769. return this.pushStack( matched );
  10770. };
  10771. } );
  10772. var rnothtmlwhite = ( /[^\x20\t\r\n\f]+/g );
  10773. // Convert String-formatted options into Object-formatted ones
  10774. function createOptions( options ) {
  10775. var object = {};
  10776. jQuery.each( options.match( rnothtmlwhite ) || [], function( _, flag ) {
  10777. object[ flag ] = true;
  10778. } );
  10779. return object;
  10780. }
  10781. /*
  10782. * Create a callback list using the following parameters:
  10783. *
  10784. * options: an optional list of space-separated options that will change how
  10785. * the callback list behaves or a more traditional option object
  10786. *
  10787. * By default a callback list will act like an event callback list and can be
  10788. * "fired" multiple times.
  10789. *
  10790. * Possible options:
  10791. *
  10792. * once: will ensure the callback list can only be fired once (like a Deferred)
  10793. *
  10794. * memory: will keep track of previous values and will call any callback added
  10795. * after the list has been fired right away with the latest "memorized"
  10796. * values (like a Deferred)
  10797. *
  10798. * unique: will ensure a callback can only be added once (no duplicate in the list)
  10799. *
  10800. * stopOnFalse: interrupt callings when a callback returns false
  10801. *
  10802. */
  10803. jQuery.Callbacks = function( options ) {
  10804. // Convert options from String-formatted to Object-formatted if needed
  10805. // (we check in cache first)
  10806. options = typeof options === "string" ?
  10807. createOptions( options ) :
  10808. jQuery.extend( {}, options );
  10809. var // Flag to know if list is currently firing
  10810. firing,
  10811. // Last fire value for non-forgettable lists
  10812. memory,
  10813. // Flag to know if list was already fired
  10814. fired,
  10815. // Flag to prevent firing
  10816. locked,
  10817. // Actual callback list
  10818. list = [],
  10819. // Queue of execution data for repeatable lists
  10820. queue = [],
  10821. // Index of currently firing callback (modified by add/remove as needed)
  10822. firingIndex = -1,
  10823. // Fire callbacks
  10824. fire = function() {
  10825. // Enforce single-firing
  10826. locked = locked || options.once;
  10827. // Execute callbacks for all pending executions,
  10828. // respecting firingIndex overrides and runtime changes
  10829. fired = firing = true;
  10830. for ( ; queue.length; firingIndex = -1 ) {
  10831. memory = queue.shift();
  10832. while ( ++firingIndex < list.length ) {
  10833. // Run callback and check for early termination
  10834. if ( list[ firingIndex ].apply( memory[ 0 ], memory[ 1 ] ) === false &&
  10835. options.stopOnFalse ) {
  10836. // Jump to end and forget the data so .add doesn't re-fire
  10837. firingIndex = list.length;
  10838. memory = false;
  10839. }
  10840. }
  10841. }
  10842. // Forget the data if we're done with it
  10843. if ( !options.memory ) {
  10844. memory = false;
  10845. }
  10846. firing = false;
  10847. // Clean up if we're done firing for good
  10848. if ( locked ) {
  10849. // Keep an empty list if we have data for future add calls
  10850. if ( memory ) {
  10851. list = [];
  10852. // Otherwise, this object is spent
  10853. } else {
  10854. list = "";
  10855. }
  10856. }
  10857. },
  10858. // Actual Callbacks object
  10859. self = {
  10860. // Add a callback or a collection of callbacks to the list
  10861. add: function() {
  10862. if ( list ) {
  10863. // If we have memory from a past run, we should fire after adding
  10864. if ( memory && !firing ) {
  10865. firingIndex = list.length - 1;
  10866. queue.push( memory );
  10867. }
  10868. ( function add( args ) {
  10869. jQuery.each( args, function( _, arg ) {
  10870. if ( isFunction( arg ) ) {
  10871. if ( !options.unique || !self.has( arg ) ) {
  10872. list.push( arg );
  10873. }
  10874. } else if ( arg && arg.length && toType( arg ) !== "string" ) {
  10875. // Inspect recursively
  10876. add( arg );
  10877. }
  10878. } );
  10879. } )( arguments );
  10880. if ( memory && !firing ) {
  10881. fire();
  10882. }
  10883. }
  10884. return this;
  10885. },
  10886. // Remove a callback from the list
  10887. remove: function() {
  10888. jQuery.each( arguments, function( _, arg ) {
  10889. var index;
  10890. while ( ( index = jQuery.inArray( arg, list, index ) ) > -1 ) {
  10891. list.splice( index, 1 );
  10892. // Handle firing indexes
  10893. if ( index <= firingIndex ) {
  10894. firingIndex--;
  10895. }
  10896. }
  10897. } );
  10898. return this;
  10899. },
  10900. // Check if a given callback is in the list.
  10901. // If no argument is given, return whether or not list has callbacks attached.
  10902. has: function( fn ) {
  10903. return fn ?
  10904. jQuery.inArray( fn, list ) > -1 :
  10905. list.length > 0;
  10906. },
  10907. // Remove all callbacks from the list
  10908. empty: function() {
  10909. if ( list ) {
  10910. list = [];
  10911. }
  10912. return this;
  10913. },
  10914. // Disable .fire and .add
  10915. // Abort any current/pending executions
  10916. // Clear all callbacks and values
  10917. disable: function() {
  10918. locked = queue = [];
  10919. list = memory = "";
  10920. return this;
  10921. },
  10922. disabled: function() {
  10923. return !list;
  10924. },
  10925. // Disable .fire
  10926. // Also disable .add unless we have memory (since it would have no effect)
  10927. // Abort any pending executions
  10928. lock: function() {
  10929. locked = queue = [];
  10930. if ( !memory && !firing ) {
  10931. list = memory = "";
  10932. }
  10933. return this;
  10934. },
  10935. locked: function() {
  10936. return !!locked;
  10937. },
  10938. // Call all callbacks with the given context and arguments
  10939. fireWith: function( context, args ) {
  10940. if ( !locked ) {
  10941. args = args || [];
  10942. args = [ context, args.slice ? args.slice() : args ];
  10943. queue.push( args );
  10944. if ( !firing ) {
  10945. fire();
  10946. }
  10947. }
  10948. return this;
  10949. },
  10950. // Call all the callbacks with the given arguments
  10951. fire: function() {
  10952. self.fireWith( this, arguments );
  10953. return this;
  10954. },
  10955. // To know if the callbacks have already been called at least once
  10956. fired: function() {
  10957. return !!fired;
  10958. }
  10959. };
  10960. return self;
  10961. };
  10962. function Identity( v ) {
  10963. return v;
  10964. }
  10965. function Thrower( ex ) {
  10966. throw ex;
  10967. }
  10968. function adoptValue( value, resolve, reject, noValue ) {
  10969. var method;
  10970. try {
  10971. // Check for promise aspect first to privilege synchronous behavior
  10972. if ( value && isFunction( ( method = value.promise ) ) ) {
  10973. method.call( value ).done( resolve ).fail( reject );
  10974. // Other thenables
  10975. } else if ( value && isFunction( ( method = value.then ) ) ) {
  10976. method.call( value, resolve, reject );
  10977. // Other non-thenables
  10978. } else {
  10979. // Control `resolve` arguments by letting Array#slice cast boolean `noValue` to integer:
  10980. // * false: [ value ].slice( 0 ) => resolve( value )
  10981. // * true: [ value ].slice( 1 ) => resolve()
  10982. resolve.apply( undefined, [ value ].slice( noValue ) );
  10983. }
  10984. // For Promises/A+, convert exceptions into rejections
  10985. // Since jQuery.when doesn't unwrap thenables, we can skip the extra checks appearing in
  10986. // Deferred#then to conditionally suppress rejection.
  10987. } catch ( value ) {
  10988. // Support: Android 4.0 only
  10989. // Strict mode functions invoked without .call/.apply get global-object context
  10990. reject.apply( undefined, [ value ] );
  10991. }
  10992. }
  10993. jQuery.extend( {
  10994. Deferred: function( func ) {
  10995. var tuples = [
  10996. // action, add listener, callbacks,
  10997. // ... .then handlers, argument index, [final state]
  10998. [ "notify", "progress", jQuery.Callbacks( "memory" ),
  10999. jQuery.Callbacks( "memory" ), 2 ],
  11000. [ "resolve", "done", jQuery.Callbacks( "once memory" ),
  11001. jQuery.Callbacks( "once memory" ), 0, "resolved" ],
  11002. [ "reject", "fail", jQuery.Callbacks( "once memory" ),
  11003. jQuery.Callbacks( "once memory" ), 1, "rejected" ]
  11004. ],
  11005. state = "pending",
  11006. promise = {
  11007. state: function() {
  11008. return state;
  11009. },
  11010. always: function() {
  11011. deferred.done( arguments ).fail( arguments );
  11012. return this;
  11013. },
  11014. "catch": function( fn ) {
  11015. return promise.then( null, fn );
  11016. },
  11017. // Keep pipe for back-compat
  11018. pipe: function( /* fnDone, fnFail, fnProgress */ ) {
  11019. var fns = arguments;
  11020. return jQuery.Deferred( function( newDefer ) {
  11021. jQuery.each( tuples, function( i, tuple ) {
  11022. // Map tuples (progress, done, fail) to arguments (done, fail, progress)
  11023. var fn = isFunction( fns[ tuple[ 4 ] ] ) && fns[ tuple[ 4 ] ];
  11024. // deferred.progress(function() { bind to newDefer or newDefer.notify })
  11025. // deferred.done(function() { bind to newDefer or newDefer.resolve })
  11026. // deferred.fail(function() { bind to newDefer or newDefer.reject })
  11027. deferred[ tuple[ 1 ] ]( function() {
  11028. var returned = fn && fn.apply( this, arguments );
  11029. if ( returned && isFunction( returned.promise ) ) {
  11030. returned.promise()
  11031. .progress( newDefer.notify )
  11032. .done( newDefer.resolve )
  11033. .fail( newDefer.reject );
  11034. } else {
  11035. newDefer[ tuple[ 0 ] + "With" ](
  11036. this,
  11037. fn ? [ returned ] : arguments
  11038. );
  11039. }
  11040. } );
  11041. } );
  11042. fns = null;
  11043. } ).promise();
  11044. },
  11045. then: function( onFulfilled, onRejected, onProgress ) {
  11046. var maxDepth = 0;
  11047. function resolve( depth, deferred, handler, special ) {
  11048. return function() {
  11049. var that = this,
  11050. args = arguments,
  11051. mightThrow = function() {
  11052. var returned, then;
  11053. // Support: Promises/A+ section 2.3.3.3.3
  11054. // https://promisesaplus.com/#point-59
  11055. // Ignore double-resolution attempts
  11056. if ( depth < maxDepth ) {
  11057. return;
  11058. }
  11059. returned = handler.apply( that, args );
  11060. // Support: Promises/A+ section 2.3.1
  11061. // https://promisesaplus.com/#point-48
  11062. if ( returned === deferred.promise() ) {
  11063. throw new TypeError( "Thenable self-resolution" );
  11064. }
  11065. // Support: Promises/A+ sections 2.3.3.1, 3.5
  11066. // https://promisesaplus.com/#point-54
  11067. // https://promisesaplus.com/#point-75
  11068. // Retrieve `then` only once
  11069. then = returned &&
  11070. // Support: Promises/A+ section 2.3.4
  11071. // https://promisesaplus.com/#point-64
  11072. // Only check objects and functions for thenability
  11073. ( typeof returned === "object" ||
  11074. typeof returned === "function" ) &&
  11075. returned.then;
  11076. // Handle a returned thenable
  11077. if ( isFunction( then ) ) {
  11078. // Special processors (notify) just wait for resolution
  11079. if ( special ) {
  11080. then.call(
  11081. returned,
  11082. resolve( maxDepth, deferred, Identity, special ),
  11083. resolve( maxDepth, deferred, Thrower, special )
  11084. );
  11085. // Normal processors (resolve) also hook into progress
  11086. } else {
  11087. // ...and disregard older resolution values
  11088. maxDepth++;
  11089. then.call(
  11090. returned,
  11091. resolve( maxDepth, deferred, Identity, special ),
  11092. resolve( maxDepth, deferred, Thrower, special ),
  11093. resolve( maxDepth, deferred, Identity,
  11094. deferred.notifyWith )
  11095. );
  11096. }
  11097. // Handle all other returned values
  11098. } else {
  11099. // Only substitute handlers pass on context
  11100. // and multiple values (non-spec behavior)
  11101. if ( handler !== Identity ) {
  11102. that = undefined;
  11103. args = [ returned ];
  11104. }
  11105. // Process the value(s)
  11106. // Default process is resolve
  11107. ( special || deferred.resolveWith )( that, args );
  11108. }
  11109. },
  11110. // Only normal processors (resolve) catch and reject exceptions
  11111. process = special ?
  11112. mightThrow :
  11113. function() {
  11114. try {
  11115. mightThrow();
  11116. } catch ( e ) {
  11117. if ( jQuery.Deferred.exceptionHook ) {
  11118. jQuery.Deferred.exceptionHook( e,
  11119. process.stackTrace );
  11120. }
  11121. // Support: Promises/A+ section 2.3.3.3.4.1
  11122. // https://promisesaplus.com/#point-61
  11123. // Ignore post-resolution exceptions
  11124. if ( depth + 1 >= maxDepth ) {
  11125. // Only substitute handlers pass on context
  11126. // and multiple values (non-spec behavior)
  11127. if ( handler !== Thrower ) {
  11128. that = undefined;
  11129. args = [ e ];
  11130. }
  11131. deferred.rejectWith( that, args );
  11132. }
  11133. }
  11134. };
  11135. // Support: Promises/A+ section 2.3.3.3.1
  11136. // https://promisesaplus.com/#point-57
  11137. // Re-resolve promises immediately to dodge false rejection from
  11138. // subsequent errors
  11139. if ( depth ) {
  11140. process();
  11141. } else {
  11142. // Call an optional hook to record the stack, in case of exception
  11143. // since it's otherwise lost when execution goes async
  11144. if ( jQuery.Deferred.getStackHook ) {
  11145. process.stackTrace = jQuery.Deferred.getStackHook();
  11146. }
  11147. window.setTimeout( process );
  11148. }
  11149. };
  11150. }
  11151. return jQuery.Deferred( function( newDefer ) {
  11152. // progress_handlers.add( ... )
  11153. tuples[ 0 ][ 3 ].add(
  11154. resolve(
  11155. 0,
  11156. newDefer,
  11157. isFunction( onProgress ) ?
  11158. onProgress :
  11159. Identity,
  11160. newDefer.notifyWith
  11161. )
  11162. );
  11163. // fulfilled_handlers.add( ... )
  11164. tuples[ 1 ][ 3 ].add(
  11165. resolve(
  11166. 0,
  11167. newDefer,
  11168. isFunction( onFulfilled ) ?
  11169. onFulfilled :
  11170. Identity
  11171. )
  11172. );
  11173. // rejected_handlers.add( ... )
  11174. tuples[ 2 ][ 3 ].add(
  11175. resolve(
  11176. 0,
  11177. newDefer,
  11178. isFunction( onRejected ) ?
  11179. onRejected :
  11180. Thrower
  11181. )
  11182. );
  11183. } ).promise();
  11184. },
  11185. // Get a promise for this deferred
  11186. // If obj is provided, the promise aspect is added to the object
  11187. promise: function( obj ) {
  11188. return obj != null ? jQuery.extend( obj, promise ) : promise;
  11189. }
  11190. },
  11191. deferred = {};
  11192. // Add list-specific methods
  11193. jQuery.each( tuples, function( i, tuple ) {
  11194. var list = tuple[ 2 ],
  11195. stateString = tuple[ 5 ];
  11196. // promise.progress = list.add
  11197. // promise.done = list.add
  11198. // promise.fail = list.add
  11199. promise[ tuple[ 1 ] ] = list.add;
  11200. // Handle state
  11201. if ( stateString ) {
  11202. list.add(
  11203. function() {
  11204. // state = "resolved" (i.e., fulfilled)
  11205. // state = "rejected"
  11206. state = stateString;
  11207. },
  11208. // rejected_callbacks.disable
  11209. // fulfilled_callbacks.disable
  11210. tuples[ 3 - i ][ 2 ].disable,
  11211. // rejected_handlers.disable
  11212. // fulfilled_handlers.disable
  11213. tuples[ 3 - i ][ 3 ].disable,
  11214. // progress_callbacks.lock
  11215. tuples[ 0 ][ 2 ].lock,
  11216. // progress_handlers.lock
  11217. tuples[ 0 ][ 3 ].lock
  11218. );
  11219. }
  11220. // progress_handlers.fire
  11221. // fulfilled_handlers.fire
  11222. // rejected_handlers.fire
  11223. list.add( tuple[ 3 ].fire );
  11224. // deferred.notify = function() { deferred.notifyWith(...) }
  11225. // deferred.resolve = function() { deferred.resolveWith(...) }
  11226. // deferred.reject = function() { deferred.rejectWith(...) }
  11227. deferred[ tuple[ 0 ] ] = function() {
  11228. deferred[ tuple[ 0 ] + "With" ]( this === deferred ? undefined : this, arguments );
  11229. return this;
  11230. };
  11231. // deferred.notifyWith = list.fireWith
  11232. // deferred.resolveWith = list.fireWith
  11233. // deferred.rejectWith = list.fireWith
  11234. deferred[ tuple[ 0 ] + "With" ] = list.fireWith;
  11235. } );
  11236. // Make the deferred a promise
  11237. promise.promise( deferred );
  11238. // Call given func if any
  11239. if ( func ) {
  11240. func.call( deferred, deferred );
  11241. }
  11242. // All done!
  11243. return deferred;
  11244. },
  11245. // Deferred helper
  11246. when: function( singleValue ) {
  11247. var
  11248. // count of uncompleted subordinates
  11249. remaining = arguments.length,
  11250. // count of unprocessed arguments
  11251. i = remaining,
  11252. // subordinate fulfillment data
  11253. resolveContexts = Array( i ),
  11254. resolveValues = slice.call( arguments ),
  11255. // the master Deferred
  11256. master = jQuery.Deferred(),
  11257. // subordinate callback factory
  11258. updateFunc = function( i ) {
  11259. return function( value ) {
  11260. resolveContexts[ i ] = this;
  11261. resolveValues[ i ] = arguments.length > 1 ? slice.call( arguments ) : value;
  11262. if ( !( --remaining ) ) {
  11263. master.resolveWith( resolveContexts, resolveValues );
  11264. }
  11265. };
  11266. };
  11267. // Single- and empty arguments are adopted like Promise.resolve
  11268. if ( remaining <= 1 ) {
  11269. adoptValue( singleValue, master.done( updateFunc( i ) ).resolve, master.reject,
  11270. !remaining );
  11271. // Use .then() to unwrap secondary thenables (cf. gh-3000)
  11272. if ( master.state() === "pending" ||
  11273. isFunction( resolveValues[ i ] && resolveValues[ i ].then ) ) {
  11274. return master.then();
  11275. }
  11276. }
  11277. // Multiple arguments are aggregated like Promise.all array elements
  11278. while ( i-- ) {
  11279. adoptValue( resolveValues[ i ], updateFunc( i ), master.reject );
  11280. }
  11281. return master.promise();
  11282. }
  11283. } );
  11284. // These usually indicate a programmer mistake during development,
  11285. // warn about them ASAP rather than swallowing them by default.
  11286. var rerrorNames = /^(Eval|Internal|Range|Reference|Syntax|Type|URI)Error$/;
  11287. jQuery.Deferred.exceptionHook = function( error, stack ) {
  11288. // Support: IE 8 - 9 only
  11289. // Console exists when dev tools are open, which can happen at any time
  11290. if ( window.console && window.console.warn && error && rerrorNames.test( error.name ) ) {
  11291. window.console.warn( "jQuery.Deferred exception: " + error.message, error.stack, stack );
  11292. }
  11293. };
  11294. jQuery.readyException = function( error ) {
  11295. window.setTimeout( function() {
  11296. throw error;
  11297. } );
  11298. };
  11299. // The deferred used on DOM ready
  11300. var readyList = jQuery.Deferred();
  11301. jQuery.fn.ready = function( fn ) {
  11302. readyList
  11303. .then( fn )
  11304. // Wrap jQuery.readyException in a function so that the lookup
  11305. // happens at the time of error handling instead of callback
  11306. // registration.
  11307. .catch( function( error ) {
  11308. jQuery.readyException( error );
  11309. } );
  11310. return this;
  11311. };
  11312. jQuery.extend( {
  11313. // Is the DOM ready to be used? Set to true once it occurs.
  11314. isReady: false,
  11315. // A counter to track how many items to wait for before
  11316. // the ready event fires. See #6781
  11317. readyWait: 1,
  11318. // Handle when the DOM is ready
  11319. ready: function( wait ) {
  11320. // Abort if there are pending holds or we're already ready
  11321. if ( wait === true ? --jQuery.readyWait : jQuery.isReady ) {
  11322. return;
  11323. }
  11324. // Remember that the DOM is ready
  11325. jQuery.isReady = true;
  11326. // If a normal DOM Ready event fired, decrement, and wait if need be
  11327. if ( wait !== true && --jQuery.readyWait > 0 ) {
  11328. return;
  11329. }
  11330. // If there are functions bound, to execute
  11331. readyList.resolveWith( document, [ jQuery ] );
  11332. }
  11333. } );
  11334. jQuery.ready.then = readyList.then;
  11335. // The ready event handler and self cleanup method
  11336. function completed() {
  11337. document.removeEventListener( "DOMContentLoaded", completed );
  11338. window.removeEventListener( "load", completed );
  11339. jQuery.ready();
  11340. }
  11341. // Catch cases where $(document).ready() is called
  11342. // after the browser event has already occurred.
  11343. // Support: IE <=9 - 10 only
  11344. // Older IE sometimes signals "interactive" too soon
  11345. if ( document.readyState === "complete" ||
  11346. ( document.readyState !== "loading" && !document.documentElement.doScroll ) ) {
  11347. // Handle it asynchronously to allow scripts the opportunity to delay ready
  11348. window.setTimeout( jQuery.ready );
  11349. } else {
  11350. // Use the handy event callback
  11351. document.addEventListener( "DOMContentLoaded", completed );
  11352. // A fallback to window.onload, that will always work
  11353. window.addEventListener( "load", completed );
  11354. }
  11355. // Multifunctional method to get and set values of a collection
  11356. // The value/s can optionally be executed if it's a function
  11357. var access = function( elems, fn, key, value, chainable, emptyGet, raw ) {
  11358. var i = 0,
  11359. len = elems.length,
  11360. bulk = key == null;
  11361. // Sets many values
  11362. if ( toType( key ) === "object" ) {
  11363. chainable = true;
  11364. for ( i in key ) {
  11365. access( elems, fn, i, key[ i ], true, emptyGet, raw );
  11366. }
  11367. // Sets one value
  11368. } else if ( value !== undefined ) {
  11369. chainable = true;
  11370. if ( !isFunction( value ) ) {
  11371. raw = true;
  11372. }
  11373. if ( bulk ) {
  11374. // Bulk operations run against the entire set
  11375. if ( raw ) {
  11376. fn.call( elems, value );
  11377. fn = null;
  11378. // ...except when executing function values
  11379. } else {
  11380. bulk = fn;
  11381. fn = function( elem, key, value ) {
  11382. return bulk.call( jQuery( elem ), value );
  11383. };
  11384. }
  11385. }
  11386. if ( fn ) {
  11387. for ( ; i < len; i++ ) {
  11388. fn(
  11389. elems[ i ], key, raw ?
  11390. value :
  11391. value.call( elems[ i ], i, fn( elems[ i ], key ) )
  11392. );
  11393. }
  11394. }
  11395. }
  11396. if ( chainable ) {
  11397. return elems;
  11398. }
  11399. // Gets
  11400. if ( bulk ) {
  11401. return fn.call( elems );
  11402. }
  11403. return len ? fn( elems[ 0 ], key ) : emptyGet;
  11404. };
  11405. // Matches dashed string for camelizing
  11406. var rmsPrefix = /^-ms-/,
  11407. rdashAlpha = /-([a-z])/g;
  11408. // Used by camelCase as callback to replace()
  11409. function fcamelCase( all, letter ) {
  11410. return letter.toUpperCase();
  11411. }
  11412. // Convert dashed to camelCase; used by the css and data modules
  11413. // Support: IE <=9 - 11, Edge 12 - 15
  11414. // Microsoft forgot to hump their vendor prefix (#9572)
  11415. function camelCase( string ) {
  11416. return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase );
  11417. }
  11418. var acceptData = function( owner ) {
  11419. // Accepts only:
  11420. // - Node
  11421. // - Node.ELEMENT_NODE
  11422. // - Node.DOCUMENT_NODE
  11423. // - Object
  11424. // - Any
  11425. return owner.nodeType === 1 || owner.nodeType === 9 || !( +owner.nodeType );
  11426. };
  11427. function Data() {
  11428. this.expando = jQuery.expando + Data.uid++;
  11429. }
  11430. Data.uid = 1;
  11431. Data.prototype = {
  11432. cache: function( owner ) {
  11433. // Check if the owner object already has a cache
  11434. var value = owner[ this.expando ];
  11435. // If not, create one
  11436. if ( !value ) {
  11437. value = {};
  11438. // We can accept data for non-element nodes in modern browsers,
  11439. // but we should not, see #8335.
  11440. // Always return an empty object.
  11441. if ( acceptData( owner ) ) {
  11442. // If it is a node unlikely to be stringify-ed or looped over
  11443. // use plain assignment
  11444. if ( owner.nodeType ) {
  11445. owner[ this.expando ] = value;
  11446. // Otherwise secure it in a non-enumerable property
  11447. // configurable must be true to allow the property to be
  11448. // deleted when data is removed
  11449. } else {
  11450. Object.defineProperty( owner, this.expando, {
  11451. value: value,
  11452. configurable: true
  11453. } );
  11454. }
  11455. }
  11456. }
  11457. return value;
  11458. },
  11459. set: function( owner, data, value ) {
  11460. var prop,
  11461. cache = this.cache( owner );
  11462. // Handle: [ owner, key, value ] args
  11463. // Always use camelCase key (gh-2257)
  11464. if ( typeof data === "string" ) {
  11465. cache[ camelCase( data ) ] = value;
  11466. // Handle: [ owner, { properties } ] args
  11467. } else {
  11468. // Copy the properties one-by-one to the cache object
  11469. for ( prop in data ) {
  11470. cache[ camelCase( prop ) ] = data[ prop ];
  11471. }
  11472. }
  11473. return cache;
  11474. },
  11475. get: function( owner, key ) {
  11476. return key === undefined ?
  11477. this.cache( owner ) :
  11478. // Always use camelCase key (gh-2257)
  11479. owner[ this.expando ] && owner[ this.expando ][ camelCase( key ) ];
  11480. },
  11481. access: function( owner, key, value ) {
  11482. // In cases where either:
  11483. //
  11484. // 1. No key was specified
  11485. // 2. A string key was specified, but no value provided
  11486. //
  11487. // Take the "read" path and allow the get method to determine
  11488. // which value to return, respectively either:
  11489. //
  11490. // 1. The entire cache object
  11491. // 2. The data stored at the key
  11492. //
  11493. if ( key === undefined ||
  11494. ( ( key && typeof key === "string" ) && value === undefined ) ) {
  11495. return this.get( owner, key );
  11496. }
  11497. // When the key is not a string, or both a key and value
  11498. // are specified, set or extend (existing objects) with either:
  11499. //
  11500. // 1. An object of properties
  11501. // 2. A key and value
  11502. //
  11503. this.set( owner, key, value );
  11504. // Since the "set" path can have two possible entry points
  11505. // return the expected data based on which path was taken[*]
  11506. return value !== undefined ? value : key;
  11507. },
  11508. remove: function( owner, key ) {
  11509. var i,
  11510. cache = owner[ this.expando ];
  11511. if ( cache === undefined ) {
  11512. return;
  11513. }
  11514. if ( key !== undefined ) {
  11515. // Support array or space separated string of keys
  11516. if ( Array.isArray( key ) ) {
  11517. // If key is an array of keys...
  11518. // We always set camelCase keys, so remove that.
  11519. key = key.map( camelCase );
  11520. } else {
  11521. key = camelCase( key );
  11522. // If a key with the spaces exists, use it.
  11523. // Otherwise, create an array by matching non-whitespace
  11524. key = key in cache ?
  11525. [ key ] :
  11526. ( key.match( rnothtmlwhite ) || [] );
  11527. }
  11528. i = key.length;
  11529. while ( i-- ) {
  11530. delete cache[ key[ i ] ];
  11531. }
  11532. }
  11533. // Remove the expando if there's no more data
  11534. if ( key === undefined || jQuery.isEmptyObject( cache ) ) {
  11535. // Support: Chrome <=35 - 45
  11536. // Webkit & Blink performance suffers when deleting properties
  11537. // from DOM nodes, so set to undefined instead
  11538. // https://bugs.chromium.org/p/chromium/issues/detail?id=378607 (bug restricted)
  11539. if ( owner.nodeType ) {
  11540. owner[ this.expando ] = undefined;
  11541. } else {
  11542. delete owner[ this.expando ];
  11543. }
  11544. }
  11545. },
  11546. hasData: function( owner ) {
  11547. var cache = owner[ this.expando ];
  11548. return cache !== undefined && !jQuery.isEmptyObject( cache );
  11549. }
  11550. };
  11551. var dataPriv = new Data();
  11552. var dataUser = new Data();
  11553. // Implementation Summary
  11554. //
  11555. // 1. Enforce API surface and semantic compatibility with 1.9.x branch
  11556. // 2. Improve the module's maintainability by reducing the storage
  11557. // paths to a single mechanism.
  11558. // 3. Use the same single mechanism to support "private" and "user" data.
  11559. // 4. _Never_ expose "private" data to user code (TODO: Drop _data, _removeData)
  11560. // 5. Avoid exposing implementation details on user objects (eg. expando properties)
  11561. // 6. Provide a clear path for implementation upgrade to WeakMap in 2014
  11562. var rbrace = /^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,
  11563. rmultiDash = /[A-Z]/g;
  11564. function getData( data ) {
  11565. if ( data === "true" ) {
  11566. return true;
  11567. }
  11568. if ( data === "false" ) {
  11569. return false;
  11570. }
  11571. if ( data === "null" ) {
  11572. return null;
  11573. }
  11574. // Only convert to a number if it doesn't change the string
  11575. if ( data === +data + "" ) {
  11576. return +data;
  11577. }
  11578. if ( rbrace.test( data ) ) {
  11579. return JSON.parse( data );
  11580. }
  11581. return data;
  11582. }
  11583. function dataAttr( elem, key, data ) {
  11584. var name;
  11585. // If nothing was found internally, try to fetch any
  11586. // data from the HTML5 data-* attribute
  11587. if ( data === undefined && elem.nodeType === 1 ) {
  11588. name = "data-" + key.replace( rmultiDash, "-$&" ).toLowerCase();
  11589. data = elem.getAttribute( name );
  11590. if ( typeof data === "string" ) {
  11591. try {
  11592. data = getData( data );
  11593. } catch ( e ) {}
  11594. // Make sure we set the data so it isn't changed later
  11595. dataUser.set( elem, key, data );
  11596. } else {
  11597. data = undefined;
  11598. }
  11599. }
  11600. return data;
  11601. }
  11602. jQuery.extend( {
  11603. hasData: function( elem ) {
  11604. return dataUser.hasData( elem ) || dataPriv.hasData( elem );
  11605. },
  11606. data: function( elem, name, data ) {
  11607. return dataUser.access( elem, name, data );
  11608. },
  11609. removeData: function( elem, name ) {
  11610. dataUser.remove( elem, name );
  11611. },
  11612. // TODO: Now that all calls to _data and _removeData have been replaced
  11613. // with direct calls to dataPriv methods, these can be deprecated.
  11614. _data: function( elem, name, data ) {
  11615. return dataPriv.access( elem, name, data );
  11616. },
  11617. _removeData: function( elem, name ) {
  11618. dataPriv.remove( elem, name );
  11619. }
  11620. } );
  11621. jQuery.fn.extend( {
  11622. data: function( key, value ) {
  11623. var i, name, data,
  11624. elem = this[ 0 ],
  11625. attrs = elem && elem.attributes;
  11626. // Gets all values
  11627. if ( key === undefined ) {
  11628. if ( this.length ) {
  11629. data = dataUser.get( elem );
  11630. if ( elem.nodeType === 1 && !dataPriv.get( elem, "hasDataAttrs" ) ) {
  11631. i = attrs.length;
  11632. while ( i-- ) {
  11633. // Support: IE 11 only
  11634. // The attrs elements can be null (#14894)
  11635. if ( attrs[ i ] ) {
  11636. name = attrs[ i ].name;
  11637. if ( name.indexOf( "data-" ) === 0 ) {
  11638. name = camelCase( name.slice( 5 ) );
  11639. dataAttr( elem, name, data[ name ] );
  11640. }
  11641. }
  11642. }
  11643. dataPriv.set( elem, "hasDataAttrs", true );
  11644. }
  11645. }
  11646. return data;
  11647. }
  11648. // Sets multiple values
  11649. if ( typeof key === "object" ) {
  11650. return this.each( function() {
  11651. dataUser.set( this, key );
  11652. } );
  11653. }
  11654. return access( this, function( value ) {
  11655. var data;
  11656. // The calling jQuery object (element matches) is not empty
  11657. // (and therefore has an element appears at this[ 0 ]) and the
  11658. // `value` parameter was not undefined. An empty jQuery object
  11659. // will result in `undefined` for elem = this[ 0 ] which will
  11660. // throw an exception if an attempt to read a data cache is made.
  11661. if ( elem && value === undefined ) {
  11662. // Attempt to get data from the cache
  11663. // The key will always be camelCased in Data
  11664. data = dataUser.get( elem, key );
  11665. if ( data !== undefined ) {
  11666. return data;
  11667. }
  11668. // Attempt to "discover" the data in
  11669. // HTML5 custom data-* attrs
  11670. data = dataAttr( elem, key );
  11671. if ( data !== undefined ) {
  11672. return data;
  11673. }
  11674. // We tried really hard, but the data doesn't exist.
  11675. return;
  11676. }
  11677. // Set the data...
  11678. this.each( function() {
  11679. // We always store the camelCased key
  11680. dataUser.set( this, key, value );
  11681. } );
  11682. }, null, value, arguments.length > 1, null, true );
  11683. },
  11684. removeData: function( key ) {
  11685. return this.each( function() {
  11686. dataUser.remove( this, key );
  11687. } );
  11688. }
  11689. } );
  11690. jQuery.extend( {
  11691. queue: function( elem, type, data ) {
  11692. var queue;
  11693. if ( elem ) {
  11694. type = ( type || "fx" ) + "queue";
  11695. queue = dataPriv.get( elem, type );
  11696. // Speed up dequeue by getting out quickly if this is just a lookup
  11697. if ( data ) {
  11698. if ( !queue || Array.isArray( data ) ) {
  11699. queue = dataPriv.access( elem, type, jQuery.makeArray( data ) );
  11700. } else {
  11701. queue.push( data );
  11702. }
  11703. }
  11704. return queue || [];
  11705. }
  11706. },
  11707. dequeue: function( elem, type ) {
  11708. type = type || "fx";
  11709. var queue = jQuery.queue( elem, type ),
  11710. startLength = queue.length,
  11711. fn = queue.shift(),
  11712. hooks = jQuery._queueHooks( elem, type ),
  11713. next = function() {
  11714. jQuery.dequeue( elem, type );
  11715. };
  11716. // If the fx queue is dequeued, always remove the progress sentinel
  11717. if ( fn === "inprogress" ) {
  11718. fn = queue.shift();
  11719. startLength--;
  11720. }
  11721. if ( fn ) {
  11722. // Add a progress sentinel to prevent the fx queue from being
  11723. // automatically dequeued
  11724. if ( type === "fx" ) {
  11725. queue.unshift( "inprogress" );
  11726. }
  11727. // Clear up the last queue stop function
  11728. delete hooks.stop;
  11729. fn.call( elem, next, hooks );
  11730. }
  11731. if ( !startLength && hooks ) {
  11732. hooks.empty.fire();
  11733. }
  11734. },
  11735. // Not public - generate a queueHooks object, or return the current one
  11736. _queueHooks: function( elem, type ) {
  11737. var key = type + "queueHooks";
  11738. return dataPriv.get( elem, key ) || dataPriv.access( elem, key, {
  11739. empty: jQuery.Callbacks( "once memory" ).add( function() {
  11740. dataPriv.remove( elem, [ type + "queue", key ] );
  11741. } )
  11742. } );
  11743. }
  11744. } );
  11745. jQuery.fn.extend( {
  11746. queue: function( type, data ) {
  11747. var setter = 2;
  11748. if ( typeof type !== "string" ) {
  11749. data = type;
  11750. type = "fx";
  11751. setter--;
  11752. }
  11753. if ( arguments.length < setter ) {
  11754. return jQuery.queue( this[ 0 ], type );
  11755. }
  11756. return data === undefined ?
  11757. this :
  11758. this.each( function() {
  11759. var queue = jQuery.queue( this, type, data );
  11760. // Ensure a hooks for this queue
  11761. jQuery._queueHooks( this, type );
  11762. if ( type === "fx" && queue[ 0 ] !== "inprogress" ) {
  11763. jQuery.dequeue( this, type );
  11764. }
  11765. } );
  11766. },
  11767. dequeue: function( type ) {
  11768. return this.each( function() {
  11769. jQuery.dequeue( this, type );
  11770. } );
  11771. },
  11772. clearQueue: function( type ) {
  11773. return this.queue( type || "fx", [] );
  11774. },
  11775. // Get a promise resolved when queues of a certain type
  11776. // are emptied (fx is the type by default)
  11777. promise: function( type, obj ) {
  11778. var tmp,
  11779. count = 1,
  11780. defer = jQuery.Deferred(),
  11781. elements = this,
  11782. i = this.length,
  11783. resolve = function() {
  11784. if ( !( --count ) ) {
  11785. defer.resolveWith( elements, [ elements ] );
  11786. }
  11787. };
  11788. if ( typeof type !== "string" ) {
  11789. obj = type;
  11790. type = undefined;
  11791. }
  11792. type = type || "fx";
  11793. while ( i-- ) {
  11794. tmp = dataPriv.get( elements[ i ], type + "queueHooks" );
  11795. if ( tmp && tmp.empty ) {
  11796. count++;
  11797. tmp.empty.add( resolve );
  11798. }
  11799. }
  11800. resolve();
  11801. return defer.promise( obj );
  11802. }
  11803. } );
  11804. var pnum = ( /[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/ ).source;
  11805. var rcssNum = new RegExp( "^(?:([+-])=|)(" + pnum + ")([a-z%]*)$", "i" );
  11806. var cssExpand = [ "Top", "Right", "Bottom", "Left" ];
  11807. var documentElement = document.documentElement;
  11808. var isAttached = function( elem ) {
  11809. return jQuery.contains( elem.ownerDocument, elem );
  11810. },
  11811. composed = { composed: true };
  11812. // Support: IE 9 - 11+, Edge 12 - 18+, iOS 10.0 - 10.2 only
  11813. // Check attachment across shadow DOM boundaries when possible (gh-3504)
  11814. // Support: iOS 10.0-10.2 only
  11815. // Early iOS 10 versions support `attachShadow` but not `getRootNode`,
  11816. // leading to errors. We need to check for `getRootNode`.
  11817. if ( documentElement.getRootNode ) {
  11818. isAttached = function( elem ) {
  11819. return jQuery.contains( elem.ownerDocument, elem ) ||
  11820. elem.getRootNode( composed ) === elem.ownerDocument;
  11821. };
  11822. }
  11823. var isHiddenWithinTree = function( elem, el ) {
  11824. // isHiddenWithinTree might be called from jQuery#filter function;
  11825. // in that case, element will be second argument
  11826. elem = el || elem;
  11827. // Inline style trumps all
  11828. return elem.style.display === "none" ||
  11829. elem.style.display === "" &&
  11830. // Otherwise, check computed style
  11831. // Support: Firefox <=43 - 45
  11832. // Disconnected elements can have computed display: none, so first confirm that elem is
  11833. // in the document.
  11834. isAttached( elem ) &&
  11835. jQuery.css( elem, "display" ) === "none";
  11836. };
  11837. var swap = function( elem, options, callback, args ) {
  11838. var ret, name,
  11839. old = {};
  11840. // Remember the old values, and insert the new ones
  11841. for ( name in options ) {
  11842. old[ name ] = elem.style[ name ];
  11843. elem.style[ name ] = options[ name ];
  11844. }
  11845. ret = callback.apply( elem, args || [] );
  11846. // Revert the old values
  11847. for ( name in options ) {
  11848. elem.style[ name ] = old[ name ];
  11849. }
  11850. return ret;
  11851. };
  11852. function adjustCSS( elem, prop, valueParts, tween ) {
  11853. var adjusted, scale,
  11854. maxIterations = 20,
  11855. currentValue = tween ?
  11856. function() {
  11857. return tween.cur();
  11858. } :
  11859. function() {
  11860. return jQuery.css( elem, prop, "" );
  11861. },
  11862. initial = currentValue(),
  11863. unit = valueParts && valueParts[ 3 ] || ( jQuery.cssNumber[ prop ] ? "" : "px" ),
  11864. // Starting value computation is required for potential unit mismatches
  11865. initialInUnit = elem.nodeType &&
  11866. ( jQuery.cssNumber[ prop ] || unit !== "px" && +initial ) &&
  11867. rcssNum.exec( jQuery.css( elem, prop ) );
  11868. if ( initialInUnit && initialInUnit[ 3 ] !== unit ) {
  11869. // Support: Firefox <=54
  11870. // Halve the iteration target value to prevent interference from CSS upper bounds (gh-2144)
  11871. initial = initial / 2;
  11872. // Trust units reported by jQuery.css
  11873. unit = unit || initialInUnit[ 3 ];
  11874. // Iteratively approximate from a nonzero starting point
  11875. initialInUnit = +initial || 1;
  11876. while ( maxIterations-- ) {
  11877. // Evaluate and update our best guess (doubling guesses that zero out).
  11878. // Finish if the scale equals or crosses 1 (making the old*new product non-positive).
  11879. jQuery.style( elem, prop, initialInUnit + unit );
  11880. if ( ( 1 - scale ) * ( 1 - ( scale = currentValue() / initial || 0.5 ) ) <= 0 ) {
  11881. maxIterations = 0;
  11882. }
  11883. initialInUnit = initialInUnit / scale;
  11884. }
  11885. initialInUnit = initialInUnit * 2;
  11886. jQuery.style( elem, prop, initialInUnit + unit );
  11887. // Make sure we update the tween properties later on
  11888. valueParts = valueParts || [];
  11889. }
  11890. if ( valueParts ) {
  11891. initialInUnit = +initialInUnit || +initial || 0;
  11892. // Apply relative offset (+=/-=) if specified
  11893. adjusted = valueParts[ 1 ] ?
  11894. initialInUnit + ( valueParts[ 1 ] + 1 ) * valueParts[ 2 ] :
  11895. +valueParts[ 2 ];
  11896. if ( tween ) {
  11897. tween.unit = unit;
  11898. tween.start = initialInUnit;
  11899. tween.end = adjusted;
  11900. }
  11901. }
  11902. return adjusted;
  11903. }
  11904. var defaultDisplayMap = {};
  11905. function getDefaultDisplay( elem ) {
  11906. var temp,
  11907. doc = elem.ownerDocument,
  11908. nodeName = elem.nodeName,
  11909. display = defaultDisplayMap[ nodeName ];
  11910. if ( display ) {
  11911. return display;
  11912. }
  11913. temp = doc.body.appendChild( doc.createElement( nodeName ) );
  11914. display = jQuery.css( temp, "display" );
  11915. temp.parentNode.removeChild( temp );
  11916. if ( display === "none" ) {
  11917. display = "block";
  11918. }
  11919. defaultDisplayMap[ nodeName ] = display;
  11920. return display;
  11921. }
  11922. function showHide( elements, show ) {
  11923. var display, elem,
  11924. values = [],
  11925. index = 0,
  11926. length = elements.length;
  11927. // Determine new display value for elements that need to change
  11928. for ( ; index < length; index++ ) {
  11929. elem = elements[ index ];
  11930. if ( !elem.style ) {
  11931. continue;
  11932. }
  11933. display = elem.style.display;
  11934. if ( show ) {
  11935. // Since we force visibility upon cascade-hidden elements, an immediate (and slow)
  11936. // check is required in this first loop unless we have a nonempty display value (either
  11937. // inline or about-to-be-restored)
  11938. if ( display === "none" ) {
  11939. values[ index ] = dataPriv.get( elem, "display" ) || null;
  11940. if ( !values[ index ] ) {
  11941. elem.style.display = "";
  11942. }
  11943. }
  11944. if ( elem.style.display === "" && isHiddenWithinTree( elem ) ) {
  11945. values[ index ] = getDefaultDisplay( elem );
  11946. }
  11947. } else {
  11948. if ( display !== "none" ) {
  11949. values[ index ] = "none";
  11950. // Remember what we're overwriting
  11951. dataPriv.set( elem, "display", display );
  11952. }
  11953. }
  11954. }
  11955. // Set the display of the elements in a second loop to avoid constant reflow
  11956. for ( index = 0; index < length; index++ ) {
  11957. if ( values[ index ] != null ) {
  11958. elements[ index ].style.display = values[ index ];
  11959. }
  11960. }
  11961. return elements;
  11962. }
  11963. jQuery.fn.extend( {
  11964. show: function() {
  11965. return showHide( this, true );
  11966. },
  11967. hide: function() {
  11968. return showHide( this );
  11969. },
  11970. toggle: function( state ) {
  11971. if ( typeof state === "boolean" ) {
  11972. return state ? this.show() : this.hide();
  11973. }
  11974. return this.each( function() {
  11975. if ( isHiddenWithinTree( this ) ) {
  11976. jQuery( this ).show();
  11977. } else {
  11978. jQuery( this ).hide();
  11979. }
  11980. } );
  11981. }
  11982. } );
  11983. var rcheckableType = ( /^(?:checkbox|radio)$/i );
  11984. var rtagName = ( /<([a-z][^\/\0>\x20\t\r\n\f]*)/i );
  11985. var rscriptType = ( /^$|^module$|\/(?:java|ecma)script/i );
  11986. // We have to close these tags to support XHTML (#13200)
  11987. var wrapMap = {
  11988. // Support: IE <=9 only
  11989. option: [ 1, "<select multiple='multiple'>", "</select>" ],
  11990. // XHTML parsers do not magically insert elements in the
  11991. // same way that tag soup parsers do. So we cannot shorten
  11992. // this by omitting <tbody> or other required elements.
  11993. thead: [ 1, "<table>", "</table>" ],
  11994. col: [ 2, "<table><colgroup>", "</colgroup></table>" ],
  11995. tr: [ 2, "<table><tbody>", "</tbody></table>" ],
  11996. td: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ],
  11997. _default: [ 0, "", "" ]
  11998. };
  11999. // Support: IE <=9 only
  12000. wrapMap.optgroup = wrapMap.option;
  12001. wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead;
  12002. wrapMap.th = wrapMap.td;
  12003. function getAll( context, tag ) {
  12004. // Support: IE <=9 - 11 only
  12005. // Use typeof to avoid zero-argument method invocation on host objects (#15151)
  12006. var ret;
  12007. if ( typeof context.getElementsByTagName !== "undefined" ) {
  12008. ret = context.getElementsByTagName( tag || "*" );
  12009. } else if ( typeof context.querySelectorAll !== "undefined" ) {
  12010. ret = context.querySelectorAll( tag || "*" );
  12011. } else {
  12012. ret = [];
  12013. }
  12014. if ( tag === undefined || tag && nodeName( context, tag ) ) {
  12015. return jQuery.merge( [ context ], ret );
  12016. }
  12017. return ret;
  12018. }
  12019. // Mark scripts as having already been evaluated
  12020. function setGlobalEval( elems, refElements ) {
  12021. var i = 0,
  12022. l = elems.length;
  12023. for ( ; i < l; i++ ) {
  12024. dataPriv.set(
  12025. elems[ i ],
  12026. "globalEval",
  12027. !refElements || dataPriv.get( refElements[ i ], "globalEval" )
  12028. );
  12029. }
  12030. }
  12031. var rhtml = /<|&#?\w+;/;
  12032. function buildFragment( elems, context, scripts, selection, ignored ) {
  12033. var elem, tmp, tag, wrap, attached, j,
  12034. fragment = context.createDocumentFragment(),
  12035. nodes = [],
  12036. i = 0,
  12037. l = elems.length;
  12038. for ( ; i < l; i++ ) {
  12039. elem = elems[ i ];
  12040. if ( elem || elem === 0 ) {
  12041. // Add nodes directly
  12042. if ( toType( elem ) === "object" ) {
  12043. // Support: Android <=4.0 only, PhantomJS 1 only
  12044. // push.apply(_, arraylike) throws on ancient WebKit
  12045. jQuery.merge( nodes, elem.nodeType ? [ elem ] : elem );
  12046. // Convert non-html into a text node
  12047. } else if ( !rhtml.test( elem ) ) {
  12048. nodes.push( context.createTextNode( elem ) );
  12049. // Convert html into DOM nodes
  12050. } else {
  12051. tmp = tmp || fragment.appendChild( context.createElement( "div" ) );
  12052. // Deserialize a standard representation
  12053. tag = ( rtagName.exec( elem ) || [ "", "" ] )[ 1 ].toLowerCase();
  12054. wrap = wrapMap[ tag ] || wrapMap._default;
  12055. tmp.innerHTML = wrap[ 1 ] + jQuery.htmlPrefilter( elem ) + wrap[ 2 ];
  12056. // Descend through wrappers to the right content
  12057. j = wrap[ 0 ];
  12058. while ( j-- ) {
  12059. tmp = tmp.lastChild;
  12060. }
  12061. // Support: Android <=4.0 only, PhantomJS 1 only
  12062. // push.apply(_, arraylike) throws on ancient WebKit
  12063. jQuery.merge( nodes, tmp.childNodes );
  12064. // Remember the top-level container
  12065. tmp = fragment.firstChild;
  12066. // Ensure the created nodes are orphaned (#12392)
  12067. tmp.textContent = "";
  12068. }
  12069. }
  12070. }
  12071. // Remove wrapper from fragment
  12072. fragment.textContent = "";
  12073. i = 0;
  12074. while ( ( elem = nodes[ i++ ] ) ) {
  12075. // Skip elements already in the context collection (trac-4087)
  12076. if ( selection && jQuery.inArray( elem, selection ) > -1 ) {
  12077. if ( ignored ) {
  12078. ignored.push( elem );
  12079. }
  12080. continue;
  12081. }
  12082. attached = isAttached( elem );
  12083. // Append to fragment
  12084. tmp = getAll( fragment.appendChild( elem ), "script" );
  12085. // Preserve script evaluation history
  12086. if ( attached ) {
  12087. setGlobalEval( tmp );
  12088. }
  12089. // Capture executables
  12090. if ( scripts ) {
  12091. j = 0;
  12092. while ( ( elem = tmp[ j++ ] ) ) {
  12093. if ( rscriptType.test( elem.type || "" ) ) {
  12094. scripts.push( elem );
  12095. }
  12096. }
  12097. }
  12098. }
  12099. return fragment;
  12100. }
  12101. ( function() {
  12102. var fragment = document.createDocumentFragment(),
  12103. div = fragment.appendChild( document.createElement( "div" ) ),
  12104. input = document.createElement( "input" );
  12105. // Support: Android 4.0 - 4.3 only
  12106. // Check state lost if the name is set (#11217)
  12107. // Support: Windows Web Apps (WWA)
  12108. // `name` and `type` must use .setAttribute for WWA (#14901)
  12109. input.setAttribute( "type", "radio" );
  12110. input.setAttribute( "checked", "checked" );
  12111. input.setAttribute( "name", "t" );
  12112. div.appendChild( input );
  12113. // Support: Android <=4.1 only
  12114. // Older WebKit doesn't clone checked state correctly in fragments
  12115. support.checkClone = div.cloneNode( true ).cloneNode( true ).lastChild.checked;
  12116. // Support: IE <=11 only
  12117. // Make sure textarea (and checkbox) defaultValue is properly cloned
  12118. div.innerHTML = "<textarea>x</textarea>";
  12119. support.noCloneChecked = !!div.cloneNode( true ).lastChild.defaultValue;
  12120. } )();
  12121. var
  12122. rkeyEvent = /^key/,
  12123. rmouseEvent = /^(?:mouse|pointer|contextmenu|drag|drop)|click/,
  12124. rtypenamespace = /^([^.]*)(?:\.(.+)|)/;
  12125. function returnTrue() {
  12126. return true;
  12127. }
  12128. function returnFalse() {
  12129. return false;
  12130. }
  12131. // Support: IE <=9 - 11+
  12132. // focus() and blur() are asynchronous, except when they are no-op.
  12133. // So expect focus to be synchronous when the element is already active,
  12134. // and blur to be synchronous when the element is not already active.
  12135. // (focus and blur are always synchronous in other supported browsers,
  12136. // this just defines when we can count on it).
  12137. function expectSync( elem, type ) {
  12138. return ( elem === safeActiveElement() ) === ( type === "focus" );
  12139. }
  12140. // Support: IE <=9 only
  12141. // Accessing document.activeElement can throw unexpectedly
  12142. // https://bugs.jquery.com/ticket/13393
  12143. function safeActiveElement() {
  12144. try {
  12145. return document.activeElement;
  12146. } catch ( err ) { }
  12147. }
  12148. function on( elem, types, selector, data, fn, one ) {
  12149. var origFn, type;
  12150. // Types can be a map of types/handlers
  12151. if ( typeof types === "object" ) {
  12152. // ( types-Object, selector, data )
  12153. if ( typeof selector !== "string" ) {
  12154. // ( types-Object, data )
  12155. data = data || selector;
  12156. selector = undefined;
  12157. }
  12158. for ( type in types ) {
  12159. on( elem, type, selector, data, types[ type ], one );
  12160. }
  12161. return elem;
  12162. }
  12163. if ( data == null && fn == null ) {
  12164. // ( types, fn )
  12165. fn = selector;
  12166. data = selector = undefined;
  12167. } else if ( fn == null ) {
  12168. if ( typeof selector === "string" ) {
  12169. // ( types, selector, fn )
  12170. fn = data;
  12171. data = undefined;
  12172. } else {
  12173. // ( types, data, fn )
  12174. fn = data;
  12175. data = selector;
  12176. selector = undefined;
  12177. }
  12178. }
  12179. if ( fn === false ) {
  12180. fn = returnFalse;
  12181. } else if ( !fn ) {
  12182. return elem;
  12183. }
  12184. if ( one === 1 ) {
  12185. origFn = fn;
  12186. fn = function( event ) {
  12187. // Can use an empty set, since event contains the info
  12188. jQuery().off( event );
  12189. return origFn.apply( this, arguments );
  12190. };
  12191. // Use same guid so caller can remove using origFn
  12192. fn.guid = origFn.guid || ( origFn.guid = jQuery.guid++ );
  12193. }
  12194. return elem.each( function() {
  12195. jQuery.event.add( this, types, fn, data, selector );
  12196. } );
  12197. }
  12198. /*
  12199. * Helper functions for managing events -- not part of the public interface.
  12200. * Props to Dean Edwards' addEvent library for many of the ideas.
  12201. */
  12202. jQuery.event = {
  12203. global: {},
  12204. add: function( elem, types, handler, data, selector ) {
  12205. var handleObjIn, eventHandle, tmp,
  12206. events, t, handleObj,
  12207. special, handlers, type, namespaces, origType,
  12208. elemData = dataPriv.get( elem );
  12209. // Don't attach events to noData or text/comment nodes (but allow plain objects)
  12210. if ( !elemData ) {
  12211. return;
  12212. }
  12213. // Caller can pass in an object of custom data in lieu of the handler
  12214. if ( handler.handler ) {
  12215. handleObjIn = handler;
  12216. handler = handleObjIn.handler;
  12217. selector = handleObjIn.selector;
  12218. }
  12219. // Ensure that invalid selectors throw exceptions at attach time
  12220. // Evaluate against documentElement in case elem is a non-element node (e.g., document)
  12221. if ( selector ) {
  12222. jQuery.find.matchesSelector( documentElement, selector );
  12223. }
  12224. // Make sure that the handler has a unique ID, used to find/remove it later
  12225. if ( !handler.guid ) {
  12226. handler.guid = jQuery.guid++;
  12227. }
  12228. // Init the element's event structure and main handler, if this is the first
  12229. if ( !( events = elemData.events ) ) {
  12230. events = elemData.events = {};
  12231. }
  12232. if ( !( eventHandle = elemData.handle ) ) {
  12233. eventHandle = elemData.handle = function( e ) {
  12234. // Discard the second event of a jQuery.event.trigger() and
  12235. // when an event is called after a page has unloaded
  12236. return typeof jQuery !== "undefined" && jQuery.event.triggered !== e.type ?
  12237. jQuery.event.dispatch.apply( elem, arguments ) : undefined;
  12238. };
  12239. }
  12240. // Handle multiple events separated by a space
  12241. types = ( types || "" ).match( rnothtmlwhite ) || [ "" ];
  12242. t = types.length;
  12243. while ( t-- ) {
  12244. tmp = rtypenamespace.exec( types[ t ] ) || [];
  12245. type = origType = tmp[ 1 ];
  12246. namespaces = ( tmp[ 2 ] || "" ).split( "." ).sort();
  12247. // There *must* be a type, no attaching namespace-only handlers
  12248. if ( !type ) {
  12249. continue;
  12250. }
  12251. // If event changes its type, use the special event handlers for the changed type
  12252. special = jQuery.event.special[ type ] || {};
  12253. // If selector defined, determine special event api type, otherwise given type
  12254. type = ( selector ? special.delegateType : special.bindType ) || type;
  12255. // Update special based on newly reset type
  12256. special = jQuery.event.special[ type ] || {};
  12257. // handleObj is passed to all event handlers
  12258. handleObj = jQuery.extend( {
  12259. type: type,
  12260. origType: origType,
  12261. data: data,
  12262. handler: handler,
  12263. guid: handler.guid,
  12264. selector: selector,
  12265. needsContext: selector && jQuery.expr.match.needsContext.test( selector ),
  12266. namespace: namespaces.join( "." )
  12267. }, handleObjIn );
  12268. // Init the event handler queue if we're the first
  12269. if ( !( handlers = events[ type ] ) ) {
  12270. handlers = events[ type ] = [];
  12271. handlers.delegateCount = 0;
  12272. // Only use addEventListener if the special events handler returns false
  12273. if ( !special.setup ||
  12274. special.setup.call( elem, data, namespaces, eventHandle ) === false ) {
  12275. if ( elem.addEventListener ) {
  12276. elem.addEventListener( type, eventHandle );
  12277. }
  12278. }
  12279. }
  12280. if ( special.add ) {
  12281. special.add.call( elem, handleObj );
  12282. if ( !handleObj.handler.guid ) {
  12283. handleObj.handler.guid = handler.guid;
  12284. }
  12285. }
  12286. // Add to the element's handler list, delegates in front
  12287. if ( selector ) {
  12288. handlers.splice( handlers.delegateCount++, 0, handleObj );
  12289. } else {
  12290. handlers.push( handleObj );
  12291. }
  12292. // Keep track of which events have ever been used, for event optimization
  12293. jQuery.event.global[ type ] = true;
  12294. }
  12295. },
  12296. // Detach an event or set of events from an element
  12297. remove: function( elem, types, handler, selector, mappedTypes ) {
  12298. var j, origCount, tmp,
  12299. events, t, handleObj,
  12300. special, handlers, type, namespaces, origType,
  12301. elemData = dataPriv.hasData( elem ) && dataPriv.get( elem );
  12302. if ( !elemData || !( events = elemData.events ) ) {
  12303. return;
  12304. }
  12305. // Once for each type.namespace in types; type may be omitted
  12306. types = ( types || "" ).match( rnothtmlwhite ) || [ "" ];
  12307. t = types.length;
  12308. while ( t-- ) {
  12309. tmp = rtypenamespace.exec( types[ t ] ) || [];
  12310. type = origType = tmp[ 1 ];
  12311. namespaces = ( tmp[ 2 ] || "" ).split( "." ).sort();
  12312. // Unbind all events (on this namespace, if provided) for the element
  12313. if ( !type ) {
  12314. for ( type in events ) {
  12315. jQuery.event.remove( elem, type + types[ t ], handler, selector, true );
  12316. }
  12317. continue;
  12318. }
  12319. special = jQuery.event.special[ type ] || {};
  12320. type = ( selector ? special.delegateType : special.bindType ) || type;
  12321. handlers = events[ type ] || [];
  12322. tmp = tmp[ 2 ] &&
  12323. new RegExp( "(^|\\.)" + namespaces.join( "\\.(?:.*\\.|)" ) + "(\\.|$)" );
  12324. // Remove matching events
  12325. origCount = j = handlers.length;
  12326. while ( j-- ) {
  12327. handleObj = handlers[ j ];
  12328. if ( ( mappedTypes || origType === handleObj.origType ) &&
  12329. ( !handler || handler.guid === handleObj.guid ) &&
  12330. ( !tmp || tmp.test( handleObj.namespace ) ) &&
  12331. ( !selector || selector === handleObj.selector ||
  12332. selector === "**" && handleObj.selector ) ) {
  12333. handlers.splice( j, 1 );
  12334. if ( handleObj.selector ) {
  12335. handlers.delegateCount--;
  12336. }
  12337. if ( special.remove ) {
  12338. special.remove.call( elem, handleObj );
  12339. }
  12340. }
  12341. }
  12342. // Remove generic event handler if we removed something and no more handlers exist
  12343. // (avoids potential for endless recursion during removal of special event handlers)
  12344. if ( origCount && !handlers.length ) {
  12345. if ( !special.teardown ||
  12346. special.teardown.call( elem, namespaces, elemData.handle ) === false ) {
  12347. jQuery.removeEvent( elem, type, elemData.handle );
  12348. }
  12349. delete events[ type ];
  12350. }
  12351. }
  12352. // Remove data and the expando if it's no longer used
  12353. if ( jQuery.isEmptyObject( events ) ) {
  12354. dataPriv.remove( elem, "handle events" );
  12355. }
  12356. },
  12357. dispatch: function( nativeEvent ) {
  12358. // Make a writable jQuery.Event from the native event object
  12359. var event = jQuery.event.fix( nativeEvent );
  12360. var i, j, ret, matched, handleObj, handlerQueue,
  12361. args = new Array( arguments.length ),
  12362. handlers = ( dataPriv.get( this, "events" ) || {} )[ event.type ] || [],
  12363. special = jQuery.event.special[ event.type ] || {};
  12364. // Use the fix-ed jQuery.Event rather than the (read-only) native event
  12365. args[ 0 ] = event;
  12366. for ( i = 1; i < arguments.length; i++ ) {
  12367. args[ i ] = arguments[ i ];
  12368. }
  12369. event.delegateTarget = this;
  12370. // Call the preDispatch hook for the mapped type, and let it bail if desired
  12371. if ( special.preDispatch && special.preDispatch.call( this, event ) === false ) {
  12372. return;
  12373. }
  12374. // Determine handlers
  12375. handlerQueue = jQuery.event.handlers.call( this, event, handlers );
  12376. // Run delegates first; they may want to stop propagation beneath us
  12377. i = 0;
  12378. while ( ( matched = handlerQueue[ i++ ] ) && !event.isPropagationStopped() ) {
  12379. event.currentTarget = matched.elem;
  12380. j = 0;
  12381. while ( ( handleObj = matched.handlers[ j++ ] ) &&
  12382. !event.isImmediatePropagationStopped() ) {
  12383. // If the event is namespaced, then each handler is only invoked if it is
  12384. // specially universal or its namespaces are a superset of the event's.
  12385. if ( !event.rnamespace || handleObj.namespace === false ||
  12386. event.rnamespace.test( handleObj.namespace ) ) {
  12387. event.handleObj = handleObj;
  12388. event.data = handleObj.data;
  12389. ret = ( ( jQuery.event.special[ handleObj.origType ] || {} ).handle ||
  12390. handleObj.handler ).apply( matched.elem, args );
  12391. if ( ret !== undefined ) {
  12392. if ( ( event.result = ret ) === false ) {
  12393. event.preventDefault();
  12394. event.stopPropagation();
  12395. }
  12396. }
  12397. }
  12398. }
  12399. }
  12400. // Call the postDispatch hook for the mapped type
  12401. if ( special.postDispatch ) {
  12402. special.postDispatch.call( this, event );
  12403. }
  12404. return event.result;
  12405. },
  12406. handlers: function( event, handlers ) {
  12407. var i, handleObj, sel, matchedHandlers, matchedSelectors,
  12408. handlerQueue = [],
  12409. delegateCount = handlers.delegateCount,
  12410. cur = event.target;
  12411. // Find delegate handlers
  12412. if ( delegateCount &&
  12413. // Support: IE <=9
  12414. // Black-hole SVG <use> instance trees (trac-13180)
  12415. cur.nodeType &&
  12416. // Support: Firefox <=42
  12417. // Suppress spec-violating clicks indicating a non-primary pointer button (trac-3861)
  12418. // https://www.w3.org/TR/DOM-Level-3-Events/#event-type-click
  12419. // Support: IE 11 only
  12420. // ...but not arrow key "clicks" of radio inputs, which can have `button` -1 (gh-2343)
  12421. !( event.type === "click" && event.button >= 1 ) ) {
  12422. for ( ; cur !== this; cur = cur.parentNode || this ) {
  12423. // Don't check non-elements (#13208)
  12424. // Don't process clicks on disabled elements (#6911, #8165, #11382, #11764)
  12425. if ( cur.nodeType === 1 && !( event.type === "click" && cur.disabled === true ) ) {
  12426. matchedHandlers = [];
  12427. matchedSelectors = {};
  12428. for ( i = 0; i < delegateCount; i++ ) {
  12429. handleObj = handlers[ i ];
  12430. // Don't conflict with Object.prototype properties (#13203)
  12431. sel = handleObj.selector + " ";
  12432. if ( matchedSelectors[ sel ] === undefined ) {
  12433. matchedSelectors[ sel ] = handleObj.needsContext ?
  12434. jQuery( sel, this ).index( cur ) > -1 :
  12435. jQuery.find( sel, this, null, [ cur ] ).length;
  12436. }
  12437. if ( matchedSelectors[ sel ] ) {
  12438. matchedHandlers.push( handleObj );
  12439. }
  12440. }
  12441. if ( matchedHandlers.length ) {
  12442. handlerQueue.push( { elem: cur, handlers: matchedHandlers } );
  12443. }
  12444. }
  12445. }
  12446. }
  12447. // Add the remaining (directly-bound) handlers
  12448. cur = this;
  12449. if ( delegateCount < handlers.length ) {
  12450. handlerQueue.push( { elem: cur, handlers: handlers.slice( delegateCount ) } );
  12451. }
  12452. return handlerQueue;
  12453. },
  12454. addProp: function( name, hook ) {
  12455. Object.defineProperty( jQuery.Event.prototype, name, {
  12456. enumerable: true,
  12457. configurable: true,
  12458. get: isFunction( hook ) ?
  12459. function() {
  12460. if ( this.originalEvent ) {
  12461. return hook( this.originalEvent );
  12462. }
  12463. } :
  12464. function() {
  12465. if ( this.originalEvent ) {
  12466. return this.originalEvent[ name ];
  12467. }
  12468. },
  12469. set: function( value ) {
  12470. Object.defineProperty( this, name, {
  12471. enumerable: true,
  12472. configurable: true,
  12473. writable: true,
  12474. value: value
  12475. } );
  12476. }
  12477. } );
  12478. },
  12479. fix: function( originalEvent ) {
  12480. return originalEvent[ jQuery.expando ] ?
  12481. originalEvent :
  12482. new jQuery.Event( originalEvent );
  12483. },
  12484. special: {
  12485. load: {
  12486. // Prevent triggered image.load events from bubbling to window.load
  12487. noBubble: true
  12488. },
  12489. click: {
  12490. // Utilize native event to ensure correct state for checkable inputs
  12491. setup: function( data ) {
  12492. // For mutual compressibility with _default, replace `this` access with a local var.
  12493. // `|| data` is dead code meant only to preserve the variable through minification.
  12494. var el = this || data;
  12495. // Claim the first handler
  12496. if ( rcheckableType.test( el.type ) &&
  12497. el.click && nodeName( el, "input" ) ) {
  12498. // dataPriv.set( el, "click", ... )
  12499. leverageNative( el, "click", returnTrue );
  12500. }
  12501. // Return false to allow normal processing in the caller
  12502. return false;
  12503. },
  12504. trigger: function( data ) {
  12505. // For mutual compressibility with _default, replace `this` access with a local var.
  12506. // `|| data` is dead code meant only to preserve the variable through minification.
  12507. var el = this || data;
  12508. // Force setup before triggering a click
  12509. if ( rcheckableType.test( el.type ) &&
  12510. el.click && nodeName( el, "input" ) ) {
  12511. leverageNative( el, "click" );
  12512. }
  12513. // Return non-false to allow normal event-path propagation
  12514. return true;
  12515. },
  12516. // For cross-browser consistency, suppress native .click() on links
  12517. // Also prevent it if we're currently inside a leveraged native-event stack
  12518. _default: function( event ) {
  12519. var target = event.target;
  12520. return rcheckableType.test( target.type ) &&
  12521. target.click && nodeName( target, "input" ) &&
  12522. dataPriv.get( target, "click" ) ||
  12523. nodeName( target, "a" );
  12524. }
  12525. },
  12526. beforeunload: {
  12527. postDispatch: function( event ) {
  12528. // Support: Firefox 20+
  12529. // Firefox doesn't alert if the returnValue field is not set.
  12530. if ( event.result !== undefined && event.originalEvent ) {
  12531. event.originalEvent.returnValue = event.result;
  12532. }
  12533. }
  12534. }
  12535. }
  12536. };
  12537. // Ensure the presence of an event listener that handles manually-triggered
  12538. // synthetic events by interrupting progress until reinvoked in response to
  12539. // *native* events that it fires directly, ensuring that state changes have
  12540. // already occurred before other listeners are invoked.
  12541. function leverageNative( el, type, expectSync ) {
  12542. // Missing expectSync indicates a trigger call, which must force setup through jQuery.event.add
  12543. if ( !expectSync ) {
  12544. if ( dataPriv.get( el, type ) === undefined ) {
  12545. jQuery.event.add( el, type, returnTrue );
  12546. }
  12547. return;
  12548. }
  12549. // Register the controller as a special universal handler for all event namespaces
  12550. dataPriv.set( el, type, false );
  12551. jQuery.event.add( el, type, {
  12552. namespace: false,
  12553. handler: function( event ) {
  12554. var notAsync, result,
  12555. saved = dataPriv.get( this, type );
  12556. if ( ( event.isTrigger & 1 ) && this[ type ] ) {
  12557. // Interrupt processing of the outer synthetic .trigger()ed event
  12558. // Saved data should be false in such cases, but might be a leftover capture object
  12559. // from an async native handler (gh-4350)
  12560. if ( !saved.length ) {
  12561. // Store arguments for use when handling the inner native event
  12562. // There will always be at least one argument (an event object), so this array
  12563. // will not be confused with a leftover capture object.
  12564. saved = slice.call( arguments );
  12565. dataPriv.set( this, type, saved );
  12566. // Trigger the native event and capture its result
  12567. // Support: IE <=9 - 11+
  12568. // focus() and blur() are asynchronous
  12569. notAsync = expectSync( this, type );
  12570. this[ type ]();
  12571. result = dataPriv.get( this, type );
  12572. if ( saved !== result || notAsync ) {
  12573. dataPriv.set( this, type, false );
  12574. } else {
  12575. result = {};
  12576. }
  12577. if ( saved !== result ) {
  12578. // Cancel the outer synthetic event
  12579. event.stopImmediatePropagation();
  12580. event.preventDefault();
  12581. return result.value;
  12582. }
  12583. // If this is an inner synthetic event for an event with a bubbling surrogate
  12584. // (focus or blur), assume that the surrogate already propagated from triggering the
  12585. // native event and prevent that from happening again here.
  12586. // This technically gets the ordering wrong w.r.t. to `.trigger()` (in which the
  12587. // bubbling surrogate propagates *after* the non-bubbling base), but that seems
  12588. // less bad than duplication.
  12589. } else if ( ( jQuery.event.special[ type ] || {} ).delegateType ) {
  12590. event.stopPropagation();
  12591. }
  12592. // If this is a native event triggered above, everything is now in order
  12593. // Fire an inner synthetic event with the original arguments
  12594. } else if ( saved.length ) {
  12595. // ...and capture the result
  12596. dataPriv.set( this, type, {
  12597. value: jQuery.event.trigger(
  12598. // Support: IE <=9 - 11+
  12599. // Extend with the prototype to reset the above stopImmediatePropagation()
  12600. jQuery.extend( saved[ 0 ], jQuery.Event.prototype ),
  12601. saved.slice( 1 ),
  12602. this
  12603. )
  12604. } );
  12605. // Abort handling of the native event
  12606. event.stopImmediatePropagation();
  12607. }
  12608. }
  12609. } );
  12610. }
  12611. jQuery.removeEvent = function( elem, type, handle ) {
  12612. // This "if" is needed for plain objects
  12613. if ( elem.removeEventListener ) {
  12614. elem.removeEventListener( type, handle );
  12615. }
  12616. };
  12617. jQuery.Event = function( src, props ) {
  12618. // Allow instantiation without the 'new' keyword
  12619. if ( !( this instanceof jQuery.Event ) ) {
  12620. return new jQuery.Event( src, props );
  12621. }
  12622. // Event object
  12623. if ( src && src.type ) {
  12624. this.originalEvent = src;
  12625. this.type = src.type;
  12626. // Events bubbling up the document may have been marked as prevented
  12627. // by a handler lower down the tree; reflect the correct value.
  12628. this.isDefaultPrevented = src.defaultPrevented ||
  12629. src.defaultPrevented === undefined &&
  12630. // Support: Android <=2.3 only
  12631. src.returnValue === false ?
  12632. returnTrue :
  12633. returnFalse;
  12634. // Create target properties
  12635. // Support: Safari <=6 - 7 only
  12636. // Target should not be a text node (#504, #13143)
  12637. this.target = ( src.target && src.target.nodeType === 3 ) ?
  12638. src.target.parentNode :
  12639. src.target;
  12640. this.currentTarget = src.currentTarget;
  12641. this.relatedTarget = src.relatedTarget;
  12642. // Event type
  12643. } else {
  12644. this.type = src;
  12645. }
  12646. // Put explicitly provided properties onto the event object
  12647. if ( props ) {
  12648. jQuery.extend( this, props );
  12649. }
  12650. // Create a timestamp if incoming event doesn't have one
  12651. this.timeStamp = src && src.timeStamp || Date.now();
  12652. // Mark it as fixed
  12653. this[ jQuery.expando ] = true;
  12654. };
  12655. // jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding
  12656. // https://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html
  12657. jQuery.Event.prototype = {
  12658. constructor: jQuery.Event,
  12659. isDefaultPrevented: returnFalse,
  12660. isPropagationStopped: returnFalse,
  12661. isImmediatePropagationStopped: returnFalse,
  12662. isSimulated: false,
  12663. preventDefault: function() {
  12664. var e = this.originalEvent;
  12665. this.isDefaultPrevented = returnTrue;
  12666. if ( e && !this.isSimulated ) {
  12667. e.preventDefault();
  12668. }
  12669. },
  12670. stopPropagation: function() {
  12671. var e = this.originalEvent;
  12672. this.isPropagationStopped = returnTrue;
  12673. if ( e && !this.isSimulated ) {
  12674. e.stopPropagation();
  12675. }
  12676. },
  12677. stopImmediatePropagation: function() {
  12678. var e = this.originalEvent;
  12679. this.isImmediatePropagationStopped = returnTrue;
  12680. if ( e && !this.isSimulated ) {
  12681. e.stopImmediatePropagation();
  12682. }
  12683. this.stopPropagation();
  12684. }
  12685. };
  12686. // Includes all common event props including KeyEvent and MouseEvent specific props
  12687. jQuery.each( {
  12688. altKey: true,
  12689. bubbles: true,
  12690. cancelable: true,
  12691. changedTouches: true,
  12692. ctrlKey: true,
  12693. detail: true,
  12694. eventPhase: true,
  12695. metaKey: true,
  12696. pageX: true,
  12697. pageY: true,
  12698. shiftKey: true,
  12699. view: true,
  12700. "char": true,
  12701. code: true,
  12702. charCode: true,
  12703. key: true,
  12704. keyCode: true,
  12705. button: true,
  12706. buttons: true,
  12707. clientX: true,
  12708. clientY: true,
  12709. offsetX: true,
  12710. offsetY: true,
  12711. pointerId: true,
  12712. pointerType: true,
  12713. screenX: true,
  12714. screenY: true,
  12715. targetTouches: true,
  12716. toElement: true,
  12717. touches: true,
  12718. which: function( event ) {
  12719. var button = event.button;
  12720. // Add which for key events
  12721. if ( event.which == null && rkeyEvent.test( event.type ) ) {
  12722. return event.charCode != null ? event.charCode : event.keyCode;
  12723. }
  12724. // Add which for click: 1 === left; 2 === middle; 3 === right
  12725. if ( !event.which && button !== undefined && rmouseEvent.test( event.type ) ) {
  12726. if ( button & 1 ) {
  12727. return 1;
  12728. }
  12729. if ( button & 2 ) {
  12730. return 3;
  12731. }
  12732. if ( button & 4 ) {
  12733. return 2;
  12734. }
  12735. return 0;
  12736. }
  12737. return event.which;
  12738. }
  12739. }, jQuery.event.addProp );
  12740. jQuery.each( { focus: "focusin", blur: "focusout" }, function( type, delegateType ) {
  12741. jQuery.event.special[ type ] = {
  12742. // Utilize native event if possible so blur/focus sequence is correct
  12743. setup: function() {
  12744. // Claim the first handler
  12745. // dataPriv.set( this, "focus", ... )
  12746. // dataPriv.set( this, "blur", ... )
  12747. leverageNative( this, type, expectSync );
  12748. // Return false to allow normal processing in the caller
  12749. return false;
  12750. },
  12751. trigger: function() {
  12752. // Force setup before trigger
  12753. leverageNative( this, type );
  12754. // Return non-false to allow normal event-path propagation
  12755. return true;
  12756. },
  12757. delegateType: delegateType
  12758. };
  12759. } );
  12760. // Create mouseenter/leave events using mouseover/out and event-time checks
  12761. // so that event delegation works in jQuery.
  12762. // Do the same for pointerenter/pointerleave and pointerover/pointerout
  12763. //
  12764. // Support: Safari 7 only
  12765. // Safari sends mouseenter too often; see:
  12766. // https://bugs.chromium.org/p/chromium/issues/detail?id=470258
  12767. // for the description of the bug (it existed in older Chrome versions as well).
  12768. jQuery.each( {
  12769. mouseenter: "mouseover",
  12770. mouseleave: "mouseout",
  12771. pointerenter: "pointerover",
  12772. pointerleave: "pointerout"
  12773. }, function( orig, fix ) {
  12774. jQuery.event.special[ orig ] = {
  12775. delegateType: fix,
  12776. bindType: fix,
  12777. handle: function( event ) {
  12778. var ret,
  12779. target = this,
  12780. related = event.relatedTarget,
  12781. handleObj = event.handleObj;
  12782. // For mouseenter/leave call the handler if related is outside the target.
  12783. // NB: No relatedTarget if the mouse left/entered the browser window
  12784. if ( !related || ( related !== target && !jQuery.contains( target, related ) ) ) {
  12785. event.type = handleObj.origType;
  12786. ret = handleObj.handler.apply( this, arguments );
  12787. event.type = fix;
  12788. }
  12789. return ret;
  12790. }
  12791. };
  12792. } );
  12793. jQuery.fn.extend( {
  12794. on: function( types, selector, data, fn ) {
  12795. return on( this, types, selector, data, fn );
  12796. },
  12797. one: function( types, selector, data, fn ) {
  12798. return on( this, types, selector, data, fn, 1 );
  12799. },
  12800. off: function( types, selector, fn ) {
  12801. var handleObj, type;
  12802. if ( types && types.preventDefault && types.handleObj ) {
  12803. // ( event ) dispatched jQuery.Event
  12804. handleObj = types.handleObj;
  12805. jQuery( types.delegateTarget ).off(
  12806. handleObj.namespace ?
  12807. handleObj.origType + "." + handleObj.namespace :
  12808. handleObj.origType,
  12809. handleObj.selector,
  12810. handleObj.handler
  12811. );
  12812. return this;
  12813. }
  12814. if ( typeof types === "object" ) {
  12815. // ( types-object [, selector] )
  12816. for ( type in types ) {
  12817. this.off( type, selector, types[ type ] );
  12818. }
  12819. return this;
  12820. }
  12821. if ( selector === false || typeof selector === "function" ) {
  12822. // ( types [, fn] )
  12823. fn = selector;
  12824. selector = undefined;
  12825. }
  12826. if ( fn === false ) {
  12827. fn = returnFalse;
  12828. }
  12829. return this.each( function() {
  12830. jQuery.event.remove( this, types, fn, selector );
  12831. } );
  12832. }
  12833. } );
  12834. var
  12835. /* eslint-disable max-len */
  12836. // See https://github.com/eslint/eslint/issues/3229
  12837. rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([a-z][^\/\0>\x20\t\r\n\f]*)[^>]*)\/>/gi,
  12838. /* eslint-enable */
  12839. // Support: IE <=10 - 11, Edge 12 - 13 only
  12840. // In IE/Edge using regex groups here causes severe slowdowns.
  12841. // See https://connect.microsoft.com/IE/feedback/details/1736512/
  12842. rnoInnerhtml = /<script|<style|<link/i,
  12843. // checked="checked" or checked
  12844. rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i,
  12845. rcleanScript = /^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g;
  12846. // Prefer a tbody over its parent table for containing new rows
  12847. function manipulationTarget( elem, content ) {
  12848. if ( nodeName( elem, "table" ) &&
  12849. nodeName( content.nodeType !== 11 ? content : content.firstChild, "tr" ) ) {
  12850. return jQuery( elem ).children( "tbody" )[ 0 ] || elem;
  12851. }
  12852. return elem;
  12853. }
  12854. // Replace/restore the type attribute of script elements for safe DOM manipulation
  12855. function disableScript( elem ) {
  12856. elem.type = ( elem.getAttribute( "type" ) !== null ) + "/" + elem.type;
  12857. return elem;
  12858. }
  12859. function restoreScript( elem ) {
  12860. if ( ( elem.type || "" ).slice( 0, 5 ) === "true/" ) {
  12861. elem.type = elem.type.slice( 5 );
  12862. } else {
  12863. elem.removeAttribute( "type" );
  12864. }
  12865. return elem;
  12866. }
  12867. function cloneCopyEvent( src, dest ) {
  12868. var i, l, type, pdataOld, pdataCur, udataOld, udataCur, events;
  12869. if ( dest.nodeType !== 1 ) {
  12870. return;
  12871. }
  12872. // 1. Copy private data: events, handlers, etc.
  12873. if ( dataPriv.hasData( src ) ) {
  12874. pdataOld = dataPriv.access( src );
  12875. pdataCur = dataPriv.set( dest, pdataOld );
  12876. events = pdataOld.events;
  12877. if ( events ) {
  12878. delete pdataCur.handle;
  12879. pdataCur.events = {};
  12880. for ( type in events ) {
  12881. for ( i = 0, l = events[ type ].length; i < l; i++ ) {
  12882. jQuery.event.add( dest, type, events[ type ][ i ] );
  12883. }
  12884. }
  12885. }
  12886. }
  12887. // 2. Copy user data
  12888. if ( dataUser.hasData( src ) ) {
  12889. udataOld = dataUser.access( src );
  12890. udataCur = jQuery.extend( {}, udataOld );
  12891. dataUser.set( dest, udataCur );
  12892. }
  12893. }
  12894. // Fix IE bugs, see support tests
  12895. function fixInput( src, dest ) {
  12896. var nodeName = dest.nodeName.toLowerCase();
  12897. // Fails to persist the checked state of a cloned checkbox or radio button.
  12898. if ( nodeName === "input" && rcheckableType.test( src.type ) ) {
  12899. dest.checked = src.checked;
  12900. // Fails to return the selected option to the default selected state when cloning options
  12901. } else if ( nodeName === "input" || nodeName === "textarea" ) {
  12902. dest.defaultValue = src.defaultValue;
  12903. }
  12904. }
  12905. function domManip( collection, args, callback, ignored ) {
  12906. // Flatten any nested arrays
  12907. args = concat.apply( [], args );
  12908. var fragment, first, scripts, hasScripts, node, doc,
  12909. i = 0,
  12910. l = collection.length,
  12911. iNoClone = l - 1,
  12912. value = args[ 0 ],
  12913. valueIsFunction = isFunction( value );
  12914. // We can't cloneNode fragments that contain checked, in WebKit
  12915. if ( valueIsFunction ||
  12916. ( l > 1 && typeof value === "string" &&
  12917. !support.checkClone && rchecked.test( value ) ) ) {
  12918. return collection.each( function( index ) {
  12919. var self = collection.eq( index );
  12920. if ( valueIsFunction ) {
  12921. args[ 0 ] = value.call( this, index, self.html() );
  12922. }
  12923. domManip( self, args, callback, ignored );
  12924. } );
  12925. }
  12926. if ( l ) {
  12927. fragment = buildFragment( args, collection[ 0 ].ownerDocument, false, collection, ignored );
  12928. first = fragment.firstChild;
  12929. if ( fragment.childNodes.length === 1 ) {
  12930. fragment = first;
  12931. }
  12932. // Require either new content or an interest in ignored elements to invoke the callback
  12933. if ( first || ignored ) {
  12934. scripts = jQuery.map( getAll( fragment, "script" ), disableScript );
  12935. hasScripts = scripts.length;
  12936. // Use the original fragment for the last item
  12937. // instead of the first because it can end up
  12938. // being emptied incorrectly in certain situations (#8070).
  12939. for ( ; i < l; i++ ) {
  12940. node = fragment;
  12941. if ( i !== iNoClone ) {
  12942. node = jQuery.clone( node, true, true );
  12943. // Keep references to cloned scripts for later restoration
  12944. if ( hasScripts ) {
  12945. // Support: Android <=4.0 only, PhantomJS 1 only
  12946. // push.apply(_, arraylike) throws on ancient WebKit
  12947. jQuery.merge( scripts, getAll( node, "script" ) );
  12948. }
  12949. }
  12950. callback.call( collection[ i ], node, i );
  12951. }
  12952. if ( hasScripts ) {
  12953. doc = scripts[ scripts.length - 1 ].ownerDocument;
  12954. // Reenable scripts
  12955. jQuery.map( scripts, restoreScript );
  12956. // Evaluate executable scripts on first document insertion
  12957. for ( i = 0; i < hasScripts; i++ ) {
  12958. node = scripts[ i ];
  12959. if ( rscriptType.test( node.type || "" ) &&
  12960. !dataPriv.access( node, "globalEval" ) &&
  12961. jQuery.contains( doc, node ) ) {
  12962. if ( node.src && ( node.type || "" ).toLowerCase() !== "module" ) {
  12963. // Optional AJAX dependency, but won't run scripts if not present
  12964. if ( jQuery._evalUrl && !node.noModule ) {
  12965. jQuery._evalUrl( node.src, {
  12966. nonce: node.nonce || node.getAttribute( "nonce" )
  12967. } );
  12968. }
  12969. } else {
  12970. DOMEval( node.textContent.replace( rcleanScript, "" ), node, doc );
  12971. }
  12972. }
  12973. }
  12974. }
  12975. }
  12976. }
  12977. return collection;
  12978. }
  12979. function remove( elem, selector, keepData ) {
  12980. var node,
  12981. nodes = selector ? jQuery.filter( selector, elem ) : elem,
  12982. i = 0;
  12983. for ( ; ( node = nodes[ i ] ) != null; i++ ) {
  12984. if ( !keepData && node.nodeType === 1 ) {
  12985. jQuery.cleanData( getAll( node ) );
  12986. }
  12987. if ( node.parentNode ) {
  12988. if ( keepData && isAttached( node ) ) {
  12989. setGlobalEval( getAll( node, "script" ) );
  12990. }
  12991. node.parentNode.removeChild( node );
  12992. }
  12993. }
  12994. return elem;
  12995. }
  12996. jQuery.extend( {
  12997. htmlPrefilter: function( html ) {
  12998. return html.replace( rxhtmlTag, "<$1></$2>" );
  12999. },
  13000. clone: function( elem, dataAndEvents, deepDataAndEvents ) {
  13001. var i, l, srcElements, destElements,
  13002. clone = elem.cloneNode( true ),
  13003. inPage = isAttached( elem );
  13004. // Fix IE cloning issues
  13005. if ( !support.noCloneChecked && ( elem.nodeType === 1 || elem.nodeType === 11 ) &&
  13006. !jQuery.isXMLDoc( elem ) ) {
  13007. // We eschew Sizzle here for performance reasons: https://jsperf.com/getall-vs-sizzle/2
  13008. destElements = getAll( clone );
  13009. srcElements = getAll( elem );
  13010. for ( i = 0, l = srcElements.length; i < l; i++ ) {
  13011. fixInput( srcElements[ i ], destElements[ i ] );
  13012. }
  13013. }
  13014. // Copy the events from the original to the clone
  13015. if ( dataAndEvents ) {
  13016. if ( deepDataAndEvents ) {
  13017. srcElements = srcElements || getAll( elem );
  13018. destElements = destElements || getAll( clone );
  13019. for ( i = 0, l = srcElements.length; i < l; i++ ) {
  13020. cloneCopyEvent( srcElements[ i ], destElements[ i ] );
  13021. }
  13022. } else {
  13023. cloneCopyEvent( elem, clone );
  13024. }
  13025. }
  13026. // Preserve script evaluation history
  13027. destElements = getAll( clone, "script" );
  13028. if ( destElements.length > 0 ) {
  13029. setGlobalEval( destElements, !inPage && getAll( elem, "script" ) );
  13030. }
  13031. // Return the cloned set
  13032. return clone;
  13033. },
  13034. cleanData: function( elems ) {
  13035. var data, elem, type,
  13036. special = jQuery.event.special,
  13037. i = 0;
  13038. for ( ; ( elem = elems[ i ] ) !== undefined; i++ ) {
  13039. if ( acceptData( elem ) ) {
  13040. if ( ( data = elem[ dataPriv.expando ] ) ) {
  13041. if ( data.events ) {
  13042. for ( type in data.events ) {
  13043. if ( special[ type ] ) {
  13044. jQuery.event.remove( elem, type );
  13045. // This is a shortcut to avoid jQuery.event.remove's overhead
  13046. } else {
  13047. jQuery.removeEvent( elem, type, data.handle );
  13048. }
  13049. }
  13050. }
  13051. // Support: Chrome <=35 - 45+
  13052. // Assign undefined instead of using delete, see Data#remove
  13053. elem[ dataPriv.expando ] = undefined;
  13054. }
  13055. if ( elem[ dataUser.expando ] ) {
  13056. // Support: Chrome <=35 - 45+
  13057. // Assign undefined instead of using delete, see Data#remove
  13058. elem[ dataUser.expando ] = undefined;
  13059. }
  13060. }
  13061. }
  13062. }
  13063. } );
  13064. jQuery.fn.extend( {
  13065. detach: function( selector ) {
  13066. return remove( this, selector, true );
  13067. },
  13068. remove: function( selector ) {
  13069. return remove( this, selector );
  13070. },
  13071. text: function( value ) {
  13072. return access( this, function( value ) {
  13073. return value === undefined ?
  13074. jQuery.text( this ) :
  13075. this.empty().each( function() {
  13076. if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
  13077. this.textContent = value;
  13078. }
  13079. } );
  13080. }, null, value, arguments.length );
  13081. },
  13082. append: function() {
  13083. return domManip( this, arguments, function( elem ) {
  13084. if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
  13085. var target = manipulationTarget( this, elem );
  13086. target.appendChild( elem );
  13087. }
  13088. } );
  13089. },
  13090. prepend: function() {
  13091. return domManip( this, arguments, function( elem ) {
  13092. if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
  13093. var target = manipulationTarget( this, elem );
  13094. target.insertBefore( elem, target.firstChild );
  13095. }
  13096. } );
  13097. },
  13098. before: function() {
  13099. return domManip( this, arguments, function( elem ) {
  13100. if ( this.parentNode ) {
  13101. this.parentNode.insertBefore( elem, this );
  13102. }
  13103. } );
  13104. },
  13105. after: function() {
  13106. return domManip( this, arguments, function( elem ) {
  13107. if ( this.parentNode ) {
  13108. this.parentNode.insertBefore( elem, this.nextSibling );
  13109. }
  13110. } );
  13111. },
  13112. empty: function() {
  13113. var elem,
  13114. i = 0;
  13115. for ( ; ( elem = this[ i ] ) != null; i++ ) {
  13116. if ( elem.nodeType === 1 ) {
  13117. // Prevent memory leaks
  13118. jQuery.cleanData( getAll( elem, false ) );
  13119. // Remove any remaining nodes
  13120. elem.textContent = "";
  13121. }
  13122. }
  13123. return this;
  13124. },
  13125. clone: function( dataAndEvents, deepDataAndEvents ) {
  13126. dataAndEvents = dataAndEvents == null ? false : dataAndEvents;
  13127. deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents;
  13128. return this.map( function() {
  13129. return jQuery.clone( this, dataAndEvents, deepDataAndEvents );
  13130. } );
  13131. },
  13132. html: function( value ) {
  13133. return access( this, function( value ) {
  13134. var elem = this[ 0 ] || {},
  13135. i = 0,
  13136. l = this.length;
  13137. if ( value === undefined && elem.nodeType === 1 ) {
  13138. return elem.innerHTML;
  13139. }
  13140. // See if we can take a shortcut and just use innerHTML
  13141. if ( typeof value === "string" && !rnoInnerhtml.test( value ) &&
  13142. !wrapMap[ ( rtagName.exec( value ) || [ "", "" ] )[ 1 ].toLowerCase() ] ) {
  13143. value = jQuery.htmlPrefilter( value );
  13144. try {
  13145. for ( ; i < l; i++ ) {
  13146. elem = this[ i ] || {};
  13147. // Remove element nodes and prevent memory leaks
  13148. if ( elem.nodeType === 1 ) {
  13149. jQuery.cleanData( getAll( elem, false ) );
  13150. elem.innerHTML = value;
  13151. }
  13152. }
  13153. elem = 0;
  13154. // If using innerHTML throws an exception, use the fallback method
  13155. } catch ( e ) {}
  13156. }
  13157. if ( elem ) {
  13158. this.empty().append( value );
  13159. }
  13160. }, null, value, arguments.length );
  13161. },
  13162. replaceWith: function() {
  13163. var ignored = [];
  13164. // Make the changes, replacing each non-ignored context element with the new content
  13165. return domManip( this, arguments, function( elem ) {
  13166. var parent = this.parentNode;
  13167. if ( jQuery.inArray( this, ignored ) < 0 ) {
  13168. jQuery.cleanData( getAll( this ) );
  13169. if ( parent ) {
  13170. parent.replaceChild( elem, this );
  13171. }
  13172. }
  13173. // Force callback invocation
  13174. }, ignored );
  13175. }
  13176. } );
  13177. jQuery.each( {
  13178. appendTo: "append",
  13179. prependTo: "prepend",
  13180. insertBefore: "before",
  13181. insertAfter: "after",
  13182. replaceAll: "replaceWith"
  13183. }, function( name, original ) {
  13184. jQuery.fn[ name ] = function( selector ) {
  13185. var elems,
  13186. ret = [],
  13187. insert = jQuery( selector ),
  13188. last = insert.length - 1,
  13189. i = 0;
  13190. for ( ; i <= last; i++ ) {
  13191. elems = i === last ? this : this.clone( true );
  13192. jQuery( insert[ i ] )[ original ]( elems );
  13193. // Support: Android <=4.0 only, PhantomJS 1 only
  13194. // .get() because push.apply(_, arraylike) throws on ancient WebKit
  13195. push.apply( ret, elems.get() );
  13196. }
  13197. return this.pushStack( ret );
  13198. };
  13199. } );
  13200. var rnumnonpx = new RegExp( "^(" + pnum + ")(?!px)[a-z%]+$", "i" );
  13201. var getStyles = function( elem ) {
  13202. // Support: IE <=11 only, Firefox <=30 (#15098, #14150)
  13203. // IE throws on elements created in popups
  13204. // FF meanwhile throws on frame elements through "defaultView.getComputedStyle"
  13205. var view = elem.ownerDocument.defaultView;
  13206. if ( !view || !view.opener ) {
  13207. view = window;
  13208. }
  13209. return view.getComputedStyle( elem );
  13210. };
  13211. var rboxStyle = new RegExp( cssExpand.join( "|" ), "i" );
  13212. ( function() {
  13213. // Executing both pixelPosition & boxSizingReliable tests require only one layout
  13214. // so they're executed at the same time to save the second computation.
  13215. function computeStyleTests() {
  13216. // This is a singleton, we need to execute it only once
  13217. if ( !div ) {
  13218. return;
  13219. }
  13220. container.style.cssText = "position:absolute;left:-11111px;width:60px;" +
  13221. "margin-top:1px;padding:0;border:0";
  13222. div.style.cssText =
  13223. "position:relative;display:block;box-sizing:border-box;overflow:scroll;" +
  13224. "margin:auto;border:1px;padding:1px;" +
  13225. "width:60%;top:1%";
  13226. documentElement.appendChild( container ).appendChild( div );
  13227. var divStyle = window.getComputedStyle( div );
  13228. pixelPositionVal = divStyle.top !== "1%";
  13229. // Support: Android 4.0 - 4.3 only, Firefox <=3 - 44
  13230. reliableMarginLeftVal = roundPixelMeasures( divStyle.marginLeft ) === 12;
  13231. // Support: Android 4.0 - 4.3 only, Safari <=9.1 - 10.1, iOS <=7.0 - 9.3
  13232. // Some styles come back with percentage values, even though they shouldn't
  13233. div.style.right = "60%";
  13234. pixelBoxStylesVal = roundPixelMeasures( divStyle.right ) === 36;
  13235. // Support: IE 9 - 11 only
  13236. // Detect misreporting of content dimensions for box-sizing:border-box elements
  13237. boxSizingReliableVal = roundPixelMeasures( divStyle.width ) === 36;
  13238. // Support: IE 9 only
  13239. // Detect overflow:scroll screwiness (gh-3699)
  13240. // Support: Chrome <=64
  13241. // Don't get tricked when zoom affects offsetWidth (gh-4029)
  13242. div.style.position = "absolute";
  13243. scrollboxSizeVal = roundPixelMeasures( div.offsetWidth / 3 ) === 12;
  13244. documentElement.removeChild( container );
  13245. // Nullify the div so it wouldn't be stored in the memory and
  13246. // it will also be a sign that checks already performed
  13247. div = null;
  13248. }
  13249. function roundPixelMeasures( measure ) {
  13250. return Math.round( parseFloat( measure ) );
  13251. }
  13252. var pixelPositionVal, boxSizingReliableVal, scrollboxSizeVal, pixelBoxStylesVal,
  13253. reliableMarginLeftVal,
  13254. container = document.createElement( "div" ),
  13255. div = document.createElement( "div" );
  13256. // Finish early in limited (non-browser) environments
  13257. if ( !div.style ) {
  13258. return;
  13259. }
  13260. // Support: IE <=9 - 11 only
  13261. // Style of cloned element affects source element cloned (#8908)
  13262. div.style.backgroundClip = "content-box";
  13263. div.cloneNode( true ).style.backgroundClip = "";
  13264. support.clearCloneStyle = div.style.backgroundClip === "content-box";
  13265. jQuery.extend( support, {
  13266. boxSizingReliable: function() {
  13267. computeStyleTests();
  13268. return boxSizingReliableVal;
  13269. },
  13270. pixelBoxStyles: function() {
  13271. computeStyleTests();
  13272. return pixelBoxStylesVal;
  13273. },
  13274. pixelPosition: function() {
  13275. computeStyleTests();
  13276. return pixelPositionVal;
  13277. },
  13278. reliableMarginLeft: function() {
  13279. computeStyleTests();
  13280. return reliableMarginLeftVal;
  13281. },
  13282. scrollboxSize: function() {
  13283. computeStyleTests();
  13284. return scrollboxSizeVal;
  13285. }
  13286. } );
  13287. } )();
  13288. function curCSS( elem, name, computed ) {
  13289. var width, minWidth, maxWidth, ret,
  13290. // Support: Firefox 51+
  13291. // Retrieving style before computed somehow
  13292. // fixes an issue with getting wrong values
  13293. // on detached elements
  13294. style = elem.style;
  13295. computed = computed || getStyles( elem );
  13296. // getPropertyValue is needed for:
  13297. // .css('filter') (IE 9 only, #12537)
  13298. // .css('--customProperty) (#3144)
  13299. if ( computed ) {
  13300. ret = computed.getPropertyValue( name ) || computed[ name ];
  13301. if ( ret === "" && !isAttached( elem ) ) {
  13302. ret = jQuery.style( elem, name );
  13303. }
  13304. // A tribute to the "awesome hack by Dean Edwards"
  13305. // Android Browser returns percentage for some values,
  13306. // but width seems to be reliably pixels.
  13307. // This is against the CSSOM draft spec:
  13308. // https://drafts.csswg.org/cssom/#resolved-values
  13309. if ( !support.pixelBoxStyles() && rnumnonpx.test( ret ) && rboxStyle.test( name ) ) {
  13310. // Remember the original values
  13311. width = style.width;
  13312. minWidth = style.minWidth;
  13313. maxWidth = style.maxWidth;
  13314. // Put in the new values to get a computed value out
  13315. style.minWidth = style.maxWidth = style.width = ret;
  13316. ret = computed.width;
  13317. // Revert the changed values
  13318. style.width = width;
  13319. style.minWidth = minWidth;
  13320. style.maxWidth = maxWidth;
  13321. }
  13322. }
  13323. return ret !== undefined ?
  13324. // Support: IE <=9 - 11 only
  13325. // IE returns zIndex value as an integer.
  13326. ret + "" :
  13327. ret;
  13328. }
  13329. function addGetHookIf( conditionFn, hookFn ) {
  13330. // Define the hook, we'll check on the first run if it's really needed.
  13331. return {
  13332. get: function() {
  13333. if ( conditionFn() ) {
  13334. // Hook not needed (or it's not possible to use it due
  13335. // to missing dependency), remove it.
  13336. delete this.get;
  13337. return;
  13338. }
  13339. // Hook needed; redefine it so that the support test is not executed again.
  13340. return ( this.get = hookFn ).apply( this, arguments );
  13341. }
  13342. };
  13343. }
  13344. var cssPrefixes = [ "Webkit", "Moz", "ms" ],
  13345. emptyStyle = document.createElement( "div" ).style,
  13346. vendorProps = {};
  13347. // Return a vendor-prefixed property or undefined
  13348. function vendorPropName( name ) {
  13349. // Check for vendor prefixed names
  13350. var capName = name[ 0 ].toUpperCase() + name.slice( 1 ),
  13351. i = cssPrefixes.length;
  13352. while ( i-- ) {
  13353. name = cssPrefixes[ i ] + capName;
  13354. if ( name in emptyStyle ) {
  13355. return name;
  13356. }
  13357. }
  13358. }
  13359. // Return a potentially-mapped jQuery.cssProps or vendor prefixed property
  13360. function finalPropName( name ) {
  13361. var final = jQuery.cssProps[ name ] || vendorProps[ name ];
  13362. if ( final ) {
  13363. return final;
  13364. }
  13365. if ( name in emptyStyle ) {
  13366. return name;
  13367. }
  13368. return vendorProps[ name ] = vendorPropName( name ) || name;
  13369. }
  13370. var
  13371. // Swappable if display is none or starts with table
  13372. // except "table", "table-cell", or "table-caption"
  13373. // See here for display values: https://developer.mozilla.org/en-US/docs/CSS/display
  13374. rdisplayswap = /^(none|table(?!-c[ea]).+)/,
  13375. rcustomProp = /^--/,
  13376. cssShow = { position: "absolute", visibility: "hidden", display: "block" },
  13377. cssNormalTransform = {
  13378. letterSpacing: "0",
  13379. fontWeight: "400"
  13380. };
  13381. function setPositiveNumber( elem, value, subtract ) {
  13382. // Any relative (+/-) values have already been
  13383. // normalized at this point
  13384. var matches = rcssNum.exec( value );
  13385. return matches ?
  13386. // Guard against undefined "subtract", e.g., when used as in cssHooks
  13387. Math.max( 0, matches[ 2 ] - ( subtract || 0 ) ) + ( matches[ 3 ] || "px" ) :
  13388. value;
  13389. }
  13390. function boxModelAdjustment( elem, dimension, box, isBorderBox, styles, computedVal ) {
  13391. var i = dimension === "width" ? 1 : 0,
  13392. extra = 0,
  13393. delta = 0;
  13394. // Adjustment may not be necessary
  13395. if ( box === ( isBorderBox ? "border" : "content" ) ) {
  13396. return 0;
  13397. }
  13398. for ( ; i < 4; i += 2 ) {
  13399. // Both box models exclude margin
  13400. if ( box === "margin" ) {
  13401. delta += jQuery.css( elem, box + cssExpand[ i ], true, styles );
  13402. }
  13403. // If we get here with a content-box, we're seeking "padding" or "border" or "margin"
  13404. if ( !isBorderBox ) {
  13405. // Add padding
  13406. delta += jQuery.css( elem, "padding" + cssExpand[ i ], true, styles );
  13407. // For "border" or "margin", add border
  13408. if ( box !== "padding" ) {
  13409. delta += jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
  13410. // But still keep track of it otherwise
  13411. } else {
  13412. extra += jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
  13413. }
  13414. // If we get here with a border-box (content + padding + border), we're seeking "content" or
  13415. // "padding" or "margin"
  13416. } else {
  13417. // For "content", subtract padding
  13418. if ( box === "content" ) {
  13419. delta -= jQuery.css( elem, "padding" + cssExpand[ i ], true, styles );
  13420. }
  13421. // For "content" or "padding", subtract border
  13422. if ( box !== "margin" ) {
  13423. delta -= jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
  13424. }
  13425. }
  13426. }
  13427. // Account for positive content-box scroll gutter when requested by providing computedVal
  13428. if ( !isBorderBox && computedVal >= 0 ) {
  13429. // offsetWidth/offsetHeight is a rounded sum of content, padding, scroll gutter, and border
  13430. // Assuming integer scroll gutter, subtract the rest and round down
  13431. delta += Math.max( 0, Math.ceil(
  13432. elem[ "offset" + dimension[ 0 ].toUpperCase() + dimension.slice( 1 ) ] -
  13433. computedVal -
  13434. delta -
  13435. extra -
  13436. 0.5
  13437. // If offsetWidth/offsetHeight is unknown, then we can't determine content-box scroll gutter
  13438. // Use an explicit zero to avoid NaN (gh-3964)
  13439. ) ) || 0;
  13440. }
  13441. return delta;
  13442. }
  13443. function getWidthOrHeight( elem, dimension, extra ) {
  13444. // Start with computed style
  13445. var styles = getStyles( elem ),
  13446. // To avoid forcing a reflow, only fetch boxSizing if we need it (gh-4322).
  13447. // Fake content-box until we know it's needed to know the true value.
  13448. boxSizingNeeded = !support.boxSizingReliable() || extra,
  13449. isBorderBox = boxSizingNeeded &&
  13450. jQuery.css( elem, "boxSizing", false, styles ) === "border-box",
  13451. valueIsBorderBox = isBorderBox,
  13452. val = curCSS( elem, dimension, styles ),
  13453. offsetProp = "offset" + dimension[ 0 ].toUpperCase() + dimension.slice( 1 );
  13454. // Support: Firefox <=54
  13455. // Return a confounding non-pixel value or feign ignorance, as appropriate.
  13456. if ( rnumnonpx.test( val ) ) {
  13457. if ( !extra ) {
  13458. return val;
  13459. }
  13460. val = "auto";
  13461. }
  13462. // Fall back to offsetWidth/offsetHeight when value is "auto"
  13463. // This happens for inline elements with no explicit setting (gh-3571)
  13464. // Support: Android <=4.1 - 4.3 only
  13465. // Also use offsetWidth/offsetHeight for misreported inline dimensions (gh-3602)
  13466. // Support: IE 9-11 only
  13467. // Also use offsetWidth/offsetHeight for when box sizing is unreliable
  13468. // We use getClientRects() to check for hidden/disconnected.
  13469. // In those cases, the computed value can be trusted to be border-box
  13470. if ( ( !support.boxSizingReliable() && isBorderBox ||
  13471. val === "auto" ||
  13472. !parseFloat( val ) && jQuery.css( elem, "display", false, styles ) === "inline" ) &&
  13473. elem.getClientRects().length ) {
  13474. isBorderBox = jQuery.css( elem, "boxSizing", false, styles ) === "border-box";
  13475. // Where available, offsetWidth/offsetHeight approximate border box dimensions.
  13476. // Where not available (e.g., SVG), assume unreliable box-sizing and interpret the
  13477. // retrieved value as a content box dimension.
  13478. valueIsBorderBox = offsetProp in elem;
  13479. if ( valueIsBorderBox ) {
  13480. val = elem[ offsetProp ];
  13481. }
  13482. }
  13483. // Normalize "" and auto
  13484. val = parseFloat( val ) || 0;
  13485. // Adjust for the element's box model
  13486. return ( val +
  13487. boxModelAdjustment(
  13488. elem,
  13489. dimension,
  13490. extra || ( isBorderBox ? "border" : "content" ),
  13491. valueIsBorderBox,
  13492. styles,
  13493. // Provide the current computed size to request scroll gutter calculation (gh-3589)
  13494. val
  13495. )
  13496. ) + "px";
  13497. }
  13498. jQuery.extend( {
  13499. // Add in style property hooks for overriding the default
  13500. // behavior of getting and setting a style property
  13501. cssHooks: {
  13502. opacity: {
  13503. get: function( elem, computed ) {
  13504. if ( computed ) {
  13505. // We should always get a number back from opacity
  13506. var ret = curCSS( elem, "opacity" );
  13507. return ret === "" ? "1" : ret;
  13508. }
  13509. }
  13510. }
  13511. },
  13512. // Don't automatically add "px" to these possibly-unitless properties
  13513. cssNumber: {
  13514. "animationIterationCount": true,
  13515. "columnCount": true,
  13516. "fillOpacity": true,
  13517. "flexGrow": true,
  13518. "flexShrink": true,
  13519. "fontWeight": true,
  13520. "gridArea": true,
  13521. "gridColumn": true,
  13522. "gridColumnEnd": true,
  13523. "gridColumnStart": true,
  13524. "gridRow": true,
  13525. "gridRowEnd": true,
  13526. "gridRowStart": true,
  13527. "lineHeight": true,
  13528. "opacity": true,
  13529. "order": true,
  13530. "orphans": true,
  13531. "widows": true,
  13532. "zIndex": true,
  13533. "zoom": true
  13534. },
  13535. // Add in properties whose names you wish to fix before
  13536. // setting or getting the value
  13537. cssProps: {},
  13538. // Get and set the style property on a DOM Node
  13539. style: function( elem, name, value, extra ) {
  13540. // Don't set styles on text and comment nodes
  13541. if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 || !elem.style ) {
  13542. return;
  13543. }
  13544. // Make sure that we're working with the right name
  13545. var ret, type, hooks,
  13546. origName = camelCase( name ),
  13547. isCustomProp = rcustomProp.test( name ),
  13548. style = elem.style;
  13549. // Make sure that we're working with the right name. We don't
  13550. // want to query the value if it is a CSS custom property
  13551. // since they are user-defined.
  13552. if ( !isCustomProp ) {
  13553. name = finalPropName( origName );
  13554. }
  13555. // Gets hook for the prefixed version, then unprefixed version
  13556. hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
  13557. // Check if we're setting a value
  13558. if ( value !== undefined ) {
  13559. type = typeof value;
  13560. // Convert "+=" or "-=" to relative numbers (#7345)
  13561. if ( type === "string" && ( ret = rcssNum.exec( value ) ) && ret[ 1 ] ) {
  13562. value = adjustCSS( elem, name, ret );
  13563. // Fixes bug #9237
  13564. type = "number";
  13565. }
  13566. // Make sure that null and NaN values aren't set (#7116)
  13567. if ( value == null || value !== value ) {
  13568. return;
  13569. }
  13570. // If a number was passed in, add the unit (except for certain CSS properties)
  13571. // The isCustomProp check can be removed in jQuery 4.0 when we only auto-append
  13572. // "px" to a few hardcoded values.
  13573. if ( type === "number" && !isCustomProp ) {
  13574. value += ret && ret[ 3 ] || ( jQuery.cssNumber[ origName ] ? "" : "px" );
  13575. }
  13576. // background-* props affect original clone's values
  13577. if ( !support.clearCloneStyle && value === "" && name.indexOf( "background" ) === 0 ) {
  13578. style[ name ] = "inherit";
  13579. }
  13580. // If a hook was provided, use that value, otherwise just set the specified value
  13581. if ( !hooks || !( "set" in hooks ) ||
  13582. ( value = hooks.set( elem, value, extra ) ) !== undefined ) {
  13583. if ( isCustomProp ) {
  13584. style.setProperty( name, value );
  13585. } else {
  13586. style[ name ] = value;
  13587. }
  13588. }
  13589. } else {
  13590. // If a hook was provided get the non-computed value from there
  13591. if ( hooks && "get" in hooks &&
  13592. ( ret = hooks.get( elem, false, extra ) ) !== undefined ) {
  13593. return ret;
  13594. }
  13595. // Otherwise just get the value from the style object
  13596. return style[ name ];
  13597. }
  13598. },
  13599. css: function( elem, name, extra, styles ) {
  13600. var val, num, hooks,
  13601. origName = camelCase( name ),
  13602. isCustomProp = rcustomProp.test( name );
  13603. // Make sure that we're working with the right name. We don't
  13604. // want to modify the value if it is a CSS custom property
  13605. // since they are user-defined.
  13606. if ( !isCustomProp ) {
  13607. name = finalPropName( origName );
  13608. }
  13609. // Try prefixed name followed by the unprefixed name
  13610. hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
  13611. // If a hook was provided get the computed value from there
  13612. if ( hooks && "get" in hooks ) {
  13613. val = hooks.get( elem, true, extra );
  13614. }
  13615. // Otherwise, if a way to get the computed value exists, use that
  13616. if ( val === undefined ) {
  13617. val = curCSS( elem, name, styles );
  13618. }
  13619. // Convert "normal" to computed value
  13620. if ( val === "normal" && name in cssNormalTransform ) {
  13621. val = cssNormalTransform[ name ];
  13622. }
  13623. // Make numeric if forced or a qualifier was provided and val looks numeric
  13624. if ( extra === "" || extra ) {
  13625. num = parseFloat( val );
  13626. return extra === true || isFinite( num ) ? num || 0 : val;
  13627. }
  13628. return val;
  13629. }
  13630. } );
  13631. jQuery.each( [ "height", "width" ], function( i, dimension ) {
  13632. jQuery.cssHooks[ dimension ] = {
  13633. get: function( elem, computed, extra ) {
  13634. if ( computed ) {
  13635. // Certain elements can have dimension info if we invisibly show them
  13636. // but it must have a current display style that would benefit
  13637. return rdisplayswap.test( jQuery.css( elem, "display" ) ) &&
  13638. // Support: Safari 8+
  13639. // Table columns in Safari have non-zero offsetWidth & zero
  13640. // getBoundingClientRect().width unless display is changed.
  13641. // Support: IE <=11 only
  13642. // Running getBoundingClientRect on a disconnected node
  13643. // in IE throws an error.
  13644. ( !elem.getClientRects().length || !elem.getBoundingClientRect().width ) ?
  13645. swap( elem, cssShow, function() {
  13646. return getWidthOrHeight( elem, dimension, extra );
  13647. } ) :
  13648. getWidthOrHeight( elem, dimension, extra );
  13649. }
  13650. },
  13651. set: function( elem, value, extra ) {
  13652. var matches,
  13653. styles = getStyles( elem ),
  13654. // Only read styles.position if the test has a chance to fail
  13655. // to avoid forcing a reflow.
  13656. scrollboxSizeBuggy = !support.scrollboxSize() &&
  13657. styles.position === "absolute",
  13658. // To avoid forcing a reflow, only fetch boxSizing if we need it (gh-3991)
  13659. boxSizingNeeded = scrollboxSizeBuggy || extra,
  13660. isBorderBox = boxSizingNeeded &&
  13661. jQuery.css( elem, "boxSizing", false, styles ) === "border-box",
  13662. subtract = extra ?
  13663. boxModelAdjustment(
  13664. elem,
  13665. dimension,
  13666. extra,
  13667. isBorderBox,
  13668. styles
  13669. ) :
  13670. 0;
  13671. // Account for unreliable border-box dimensions by comparing offset* to computed and
  13672. // faking a content-box to get border and padding (gh-3699)
  13673. if ( isBorderBox && scrollboxSizeBuggy ) {
  13674. subtract -= Math.ceil(
  13675. elem[ "offset" + dimension[ 0 ].toUpperCase() + dimension.slice( 1 ) ] -
  13676. parseFloat( styles[ dimension ] ) -
  13677. boxModelAdjustment( elem, dimension, "border", false, styles ) -
  13678. 0.5
  13679. );
  13680. }
  13681. // Convert to pixels if value adjustment is needed
  13682. if ( subtract && ( matches = rcssNum.exec( value ) ) &&
  13683. ( matches[ 3 ] || "px" ) !== "px" ) {
  13684. elem.style[ dimension ] = value;
  13685. value = jQuery.css( elem, dimension );
  13686. }
  13687. return setPositiveNumber( elem, value, subtract );
  13688. }
  13689. };
  13690. } );
  13691. jQuery.cssHooks.marginLeft = addGetHookIf( support.reliableMarginLeft,
  13692. function( elem, computed ) {
  13693. if ( computed ) {
  13694. return ( parseFloat( curCSS( elem, "marginLeft" ) ) ||
  13695. elem.getBoundingClientRect().left -
  13696. swap( elem, { marginLeft: 0 }, function() {
  13697. return elem.getBoundingClientRect().left;
  13698. } )
  13699. ) + "px";
  13700. }
  13701. }
  13702. );
  13703. // These hooks are used by animate to expand properties
  13704. jQuery.each( {
  13705. margin: "",
  13706. padding: "",
  13707. border: "Width"
  13708. }, function( prefix, suffix ) {
  13709. jQuery.cssHooks[ prefix + suffix ] = {
  13710. expand: function( value ) {
  13711. var i = 0,
  13712. expanded = {},
  13713. // Assumes a single number if not a string
  13714. parts = typeof value === "string" ? value.split( " " ) : [ value ];
  13715. for ( ; i < 4; i++ ) {
  13716. expanded[ prefix + cssExpand[ i ] + suffix ] =
  13717. parts[ i ] || parts[ i - 2 ] || parts[ 0 ];
  13718. }
  13719. return expanded;
  13720. }
  13721. };
  13722. if ( prefix !== "margin" ) {
  13723. jQuery.cssHooks[ prefix + suffix ].set = setPositiveNumber;
  13724. }
  13725. } );
  13726. jQuery.fn.extend( {
  13727. css: function( name, value ) {
  13728. return access( this, function( elem, name, value ) {
  13729. var styles, len,
  13730. map = {},
  13731. i = 0;
  13732. if ( Array.isArray( name ) ) {
  13733. styles = getStyles( elem );
  13734. len = name.length;
  13735. for ( ; i < len; i++ ) {
  13736. map[ name[ i ] ] = jQuery.css( elem, name[ i ], false, styles );
  13737. }
  13738. return map;
  13739. }
  13740. return value !== undefined ?
  13741. jQuery.style( elem, name, value ) :
  13742. jQuery.css( elem, name );
  13743. }, name, value, arguments.length > 1 );
  13744. }
  13745. } );
  13746. function Tween( elem, options, prop, end, easing ) {
  13747. return new Tween.prototype.init( elem, options, prop, end, easing );
  13748. }
  13749. jQuery.Tween = Tween;
  13750. Tween.prototype = {
  13751. constructor: Tween,
  13752. init: function( elem, options, prop, end, easing, unit ) {
  13753. this.elem = elem;
  13754. this.prop = prop;
  13755. this.easing = easing || jQuery.easing._default;
  13756. this.options = options;
  13757. this.start = this.now = this.cur();
  13758. this.end = end;
  13759. this.unit = unit || ( jQuery.cssNumber[ prop ] ? "" : "px" );
  13760. },
  13761. cur: function() {
  13762. var hooks = Tween.propHooks[ this.prop ];
  13763. return hooks && hooks.get ?
  13764. hooks.get( this ) :
  13765. Tween.propHooks._default.get( this );
  13766. },
  13767. run: function( percent ) {
  13768. var eased,
  13769. hooks = Tween.propHooks[ this.prop ];
  13770. if ( this.options.duration ) {
  13771. this.pos = eased = jQuery.easing[ this.easing ](
  13772. percent, this.options.duration * percent, 0, 1, this.options.duration
  13773. );
  13774. } else {
  13775. this.pos = eased = percent;
  13776. }
  13777. this.now = ( this.end - this.start ) * eased + this.start;
  13778. if ( this.options.step ) {
  13779. this.options.step.call( this.elem, this.now, this );
  13780. }
  13781. if ( hooks && hooks.set ) {
  13782. hooks.set( this );
  13783. } else {
  13784. Tween.propHooks._default.set( this );
  13785. }
  13786. return this;
  13787. }
  13788. };
  13789. Tween.prototype.init.prototype = Tween.prototype;
  13790. Tween.propHooks = {
  13791. _default: {
  13792. get: function( tween ) {
  13793. var result;
  13794. // Use a property on the element directly when it is not a DOM element,
  13795. // or when there is no matching style property that exists.
  13796. if ( tween.elem.nodeType !== 1 ||
  13797. tween.elem[ tween.prop ] != null && tween.elem.style[ tween.prop ] == null ) {
  13798. return tween.elem[ tween.prop ];
  13799. }
  13800. // Passing an empty string as a 3rd parameter to .css will automatically
  13801. // attempt a parseFloat and fallback to a string if the parse fails.
  13802. // Simple values such as "10px" are parsed to Float;
  13803. // complex values such as "rotate(1rad)" are returned as-is.
  13804. result = jQuery.css( tween.elem, tween.prop, "" );
  13805. // Empty strings, null, undefined and "auto" are converted to 0.
  13806. return !result || result === "auto" ? 0 : result;
  13807. },
  13808. set: function( tween ) {
  13809. // Use step hook for back compat.
  13810. // Use cssHook if its there.
  13811. // Use .style if available and use plain properties where available.
  13812. if ( jQuery.fx.step[ tween.prop ] ) {
  13813. jQuery.fx.step[ tween.prop ]( tween );
  13814. } else if ( tween.elem.nodeType === 1 && (
  13815. jQuery.cssHooks[ tween.prop ] ||
  13816. tween.elem.style[ finalPropName( tween.prop ) ] != null ) ) {
  13817. jQuery.style( tween.elem, tween.prop, tween.now + tween.unit );
  13818. } else {
  13819. tween.elem[ tween.prop ] = tween.now;
  13820. }
  13821. }
  13822. }
  13823. };
  13824. // Support: IE <=9 only
  13825. // Panic based approach to setting things on disconnected nodes
  13826. Tween.propHooks.scrollTop = Tween.propHooks.scrollLeft = {
  13827. set: function( tween ) {
  13828. if ( tween.elem.nodeType && tween.elem.parentNode ) {
  13829. tween.elem[ tween.prop ] = tween.now;
  13830. }
  13831. }
  13832. };
  13833. jQuery.easing = {
  13834. linear: function( p ) {
  13835. return p;
  13836. },
  13837. swing: function( p ) {
  13838. return 0.5 - Math.cos( p * Math.PI ) / 2;
  13839. },
  13840. _default: "swing"
  13841. };
  13842. jQuery.fx = Tween.prototype.init;
  13843. // Back compat <1.8 extension point
  13844. jQuery.fx.step = {};
  13845. var
  13846. fxNow, inProgress,
  13847. rfxtypes = /^(?:toggle|show|hide)$/,
  13848. rrun = /queueHooks$/;
  13849. function schedule() {
  13850. if ( inProgress ) {
  13851. if ( document.hidden === false && window.requestAnimationFrame ) {
  13852. window.requestAnimationFrame( schedule );
  13853. } else {
  13854. window.setTimeout( schedule, jQuery.fx.interval );
  13855. }
  13856. jQuery.fx.tick();
  13857. }
  13858. }
  13859. // Animations created synchronously will run synchronously
  13860. function createFxNow() {
  13861. window.setTimeout( function() {
  13862. fxNow = undefined;
  13863. } );
  13864. return ( fxNow = Date.now() );
  13865. }
  13866. // Generate parameters to create a standard animation
  13867. function genFx( type, includeWidth ) {
  13868. var which,
  13869. i = 0,
  13870. attrs = { height: type };
  13871. // If we include width, step value is 1 to do all cssExpand values,
  13872. // otherwise step value is 2 to skip over Left and Right
  13873. includeWidth = includeWidth ? 1 : 0;
  13874. for ( ; i < 4; i += 2 - includeWidth ) {
  13875. which = cssExpand[ i ];
  13876. attrs[ "margin" + which ] = attrs[ "padding" + which ] = type;
  13877. }
  13878. if ( includeWidth ) {
  13879. attrs.opacity = attrs.width = type;
  13880. }
  13881. return attrs;
  13882. }
  13883. function createTween( value, prop, animation ) {
  13884. var tween,
  13885. collection = ( Animation.tweeners[ prop ] || [] ).concat( Animation.tweeners[ "*" ] ),
  13886. index = 0,
  13887. length = collection.length;
  13888. for ( ; index < length; index++ ) {
  13889. if ( ( tween = collection[ index ].call( animation, prop, value ) ) ) {
  13890. // We're done with this property
  13891. return tween;
  13892. }
  13893. }
  13894. }
  13895. function defaultPrefilter( elem, props, opts ) {
  13896. var prop, value, toggle, hooks, oldfire, propTween, restoreDisplay, display,
  13897. isBox = "width" in props || "height" in props,
  13898. anim = this,
  13899. orig = {},
  13900. style = elem.style,
  13901. hidden = elem.nodeType && isHiddenWithinTree( elem ),
  13902. dataShow = dataPriv.get( elem, "fxshow" );
  13903. // Queue-skipping animations hijack the fx hooks
  13904. if ( !opts.queue ) {
  13905. hooks = jQuery._queueHooks( elem, "fx" );
  13906. if ( hooks.unqueued == null ) {
  13907. hooks.unqueued = 0;
  13908. oldfire = hooks.empty.fire;
  13909. hooks.empty.fire = function() {
  13910. if ( !hooks.unqueued ) {
  13911. oldfire();
  13912. }
  13913. };
  13914. }
  13915. hooks.unqueued++;
  13916. anim.always( function() {
  13917. // Ensure the complete handler is called before this completes
  13918. anim.always( function() {
  13919. hooks.unqueued--;
  13920. if ( !jQuery.queue( elem, "fx" ).length ) {
  13921. hooks.empty.fire();
  13922. }
  13923. } );
  13924. } );
  13925. }
  13926. // Detect show/hide animations
  13927. for ( prop in props ) {
  13928. value = props[ prop ];
  13929. if ( rfxtypes.test( value ) ) {
  13930. delete props[ prop ];
  13931. toggle = toggle || value === "toggle";
  13932. if ( value === ( hidden ? "hide" : "show" ) ) {
  13933. // Pretend to be hidden if this is a "show" and
  13934. // there is still data from a stopped show/hide
  13935. if ( value === "show" && dataShow && dataShow[ prop ] !== undefined ) {
  13936. hidden = true;
  13937. // Ignore all other no-op show/hide data
  13938. } else {
  13939. continue;
  13940. }
  13941. }
  13942. orig[ prop ] = dataShow && dataShow[ prop ] || jQuery.style( elem, prop );
  13943. }
  13944. }
  13945. // Bail out if this is a no-op like .hide().hide()
  13946. propTween = !jQuery.isEmptyObject( props );
  13947. if ( !propTween && jQuery.isEmptyObject( orig ) ) {
  13948. return;
  13949. }
  13950. // Restrict "overflow" and "display" styles during box animations
  13951. if ( isBox && elem.nodeType === 1 ) {
  13952. // Support: IE <=9 - 11, Edge 12 - 15
  13953. // Record all 3 overflow attributes because IE does not infer the shorthand
  13954. // from identically-valued overflowX and overflowY and Edge just mirrors
  13955. // the overflowX value there.
  13956. opts.overflow = [ style.overflow, style.overflowX, style.overflowY ];
  13957. // Identify a display type, preferring old show/hide data over the CSS cascade
  13958. restoreDisplay = dataShow && dataShow.display;
  13959. if ( restoreDisplay == null ) {
  13960. restoreDisplay = dataPriv.get( elem, "display" );
  13961. }
  13962. display = jQuery.css( elem, "display" );
  13963. if ( display === "none" ) {
  13964. if ( restoreDisplay ) {
  13965. display = restoreDisplay;
  13966. } else {
  13967. // Get nonempty value(s) by temporarily forcing visibility
  13968. showHide( [ elem ], true );
  13969. restoreDisplay = elem.style.display || restoreDisplay;
  13970. display = jQuery.css( elem, "display" );
  13971. showHide( [ elem ] );
  13972. }
  13973. }
  13974. // Animate inline elements as inline-block
  13975. if ( display === "inline" || display === "inline-block" && restoreDisplay != null ) {
  13976. if ( jQuery.css( elem, "float" ) === "none" ) {
  13977. // Restore the original display value at the end of pure show/hide animations
  13978. if ( !propTween ) {
  13979. anim.done( function() {
  13980. style.display = restoreDisplay;
  13981. } );
  13982. if ( restoreDisplay == null ) {
  13983. display = style.display;
  13984. restoreDisplay = display === "none" ? "" : display;
  13985. }
  13986. }
  13987. style.display = "inline-block";
  13988. }
  13989. }
  13990. }
  13991. if ( opts.overflow ) {
  13992. style.overflow = "hidden";
  13993. anim.always( function() {
  13994. style.overflow = opts.overflow[ 0 ];
  13995. style.overflowX = opts.overflow[ 1 ];
  13996. style.overflowY = opts.overflow[ 2 ];
  13997. } );
  13998. }
  13999. // Implement show/hide animations
  14000. propTween = false;
  14001. for ( prop in orig ) {
  14002. // General show/hide setup for this element animation
  14003. if ( !propTween ) {
  14004. if ( dataShow ) {
  14005. if ( "hidden" in dataShow ) {
  14006. hidden = dataShow.hidden;
  14007. }
  14008. } else {
  14009. dataShow = dataPriv.access( elem, "fxshow", { display: restoreDisplay } );
  14010. }
  14011. // Store hidden/visible for toggle so `.stop().toggle()` "reverses"
  14012. if ( toggle ) {
  14013. dataShow.hidden = !hidden;
  14014. }
  14015. // Show elements before animating them
  14016. if ( hidden ) {
  14017. showHide( [ elem ], true );
  14018. }
  14019. /* eslint-disable no-loop-func */
  14020. anim.done( function() {
  14021. /* eslint-enable no-loop-func */
  14022. // The final step of a "hide" animation is actually hiding the element
  14023. if ( !hidden ) {
  14024. showHide( [ elem ] );
  14025. }
  14026. dataPriv.remove( elem, "fxshow" );
  14027. for ( prop in orig ) {
  14028. jQuery.style( elem, prop, orig[ prop ] );
  14029. }
  14030. } );
  14031. }
  14032. // Per-property setup
  14033. propTween = createTween( hidden ? dataShow[ prop ] : 0, prop, anim );
  14034. if ( !( prop in dataShow ) ) {
  14035. dataShow[ prop ] = propTween.start;
  14036. if ( hidden ) {
  14037. propTween.end = propTween.start;
  14038. propTween.start = 0;
  14039. }
  14040. }
  14041. }
  14042. }
  14043. function propFilter( props, specialEasing ) {
  14044. var index, name, easing, value, hooks;
  14045. // camelCase, specialEasing and expand cssHook pass
  14046. for ( index in props ) {
  14047. name = camelCase( index );
  14048. easing = specialEasing[ name ];
  14049. value = props[ index ];
  14050. if ( Array.isArray( value ) ) {
  14051. easing = value[ 1 ];
  14052. value = props[ index ] = value[ 0 ];
  14053. }
  14054. if ( index !== name ) {
  14055. props[ name ] = value;
  14056. delete props[ index ];
  14057. }
  14058. hooks = jQuery.cssHooks[ name ];
  14059. if ( hooks && "expand" in hooks ) {
  14060. value = hooks.expand( value );
  14061. delete props[ name ];
  14062. // Not quite $.extend, this won't overwrite existing keys.
  14063. // Reusing 'index' because we have the correct "name"
  14064. for ( index in value ) {
  14065. if ( !( index in props ) ) {
  14066. props[ index ] = value[ index ];
  14067. specialEasing[ index ] = easing;
  14068. }
  14069. }
  14070. } else {
  14071. specialEasing[ name ] = easing;
  14072. }
  14073. }
  14074. }
  14075. function Animation( elem, properties, options ) {
  14076. var result,
  14077. stopped,
  14078. index = 0,
  14079. length = Animation.prefilters.length,
  14080. deferred = jQuery.Deferred().always( function() {
  14081. // Don't match elem in the :animated selector
  14082. delete tick.elem;
  14083. } ),
  14084. tick = function() {
  14085. if ( stopped ) {
  14086. return false;
  14087. }
  14088. var currentTime = fxNow || createFxNow(),
  14089. remaining = Math.max( 0, animation.startTime + animation.duration - currentTime ),
  14090. // Support: Android 2.3 only
  14091. // Archaic crash bug won't allow us to use `1 - ( 0.5 || 0 )` (#12497)
  14092. temp = remaining / animation.duration || 0,
  14093. percent = 1 - temp,
  14094. index = 0,
  14095. length = animation.tweens.length;
  14096. for ( ; index < length; index++ ) {
  14097. animation.tweens[ index ].run( percent );
  14098. }
  14099. deferred.notifyWith( elem, [ animation, percent, remaining ] );
  14100. // If there's more to do, yield
  14101. if ( percent < 1 && length ) {
  14102. return remaining;
  14103. }
  14104. // If this was an empty animation, synthesize a final progress notification
  14105. if ( !length ) {
  14106. deferred.notifyWith( elem, [ animation, 1, 0 ] );
  14107. }
  14108. // Resolve the animation and report its conclusion
  14109. deferred.resolveWith( elem, [ animation ] );
  14110. return false;
  14111. },
  14112. animation = deferred.promise( {
  14113. elem: elem,
  14114. props: jQuery.extend( {}, properties ),
  14115. opts: jQuery.extend( true, {
  14116. specialEasing: {},
  14117. easing: jQuery.easing._default
  14118. }, options ),
  14119. originalProperties: properties,
  14120. originalOptions: options,
  14121. startTime: fxNow || createFxNow(),
  14122. duration: options.duration,
  14123. tweens: [],
  14124. createTween: function( prop, end ) {
  14125. var tween = jQuery.Tween( elem, animation.opts, prop, end,
  14126. animation.opts.specialEasing[ prop ] || animation.opts.easing );
  14127. animation.tweens.push( tween );
  14128. return tween;
  14129. },
  14130. stop: function( gotoEnd ) {
  14131. var index = 0,
  14132. // If we are going to the end, we want to run all the tweens
  14133. // otherwise we skip this part
  14134. length = gotoEnd ? animation.tweens.length : 0;
  14135. if ( stopped ) {
  14136. return this;
  14137. }
  14138. stopped = true;
  14139. for ( ; index < length; index++ ) {
  14140. animation.tweens[ index ].run( 1 );
  14141. }
  14142. // Resolve when we played the last frame; otherwise, reject
  14143. if ( gotoEnd ) {
  14144. deferred.notifyWith( elem, [ animation, 1, 0 ] );
  14145. deferred.resolveWith( elem, [ animation, gotoEnd ] );
  14146. } else {
  14147. deferred.rejectWith( elem, [ animation, gotoEnd ] );
  14148. }
  14149. return this;
  14150. }
  14151. } ),
  14152. props = animation.props;
  14153. propFilter( props, animation.opts.specialEasing );
  14154. for ( ; index < length; index++ ) {
  14155. result = Animation.prefilters[ index ].call( animation, elem, props, animation.opts );
  14156. if ( result ) {
  14157. if ( isFunction( result.stop ) ) {
  14158. jQuery._queueHooks( animation.elem, animation.opts.queue ).stop =
  14159. result.stop.bind( result );
  14160. }
  14161. return result;
  14162. }
  14163. }
  14164. jQuery.map( props, createTween, animation );
  14165. if ( isFunction( animation.opts.start ) ) {
  14166. animation.opts.start.call( elem, animation );
  14167. }
  14168. // Attach callbacks from options
  14169. animation
  14170. .progress( animation.opts.progress )
  14171. .done( animation.opts.done, animation.opts.complete )
  14172. .fail( animation.opts.fail )
  14173. .always( animation.opts.always );
  14174. jQuery.fx.timer(
  14175. jQuery.extend( tick, {
  14176. elem: elem,
  14177. anim: animation,
  14178. queue: animation.opts.queue
  14179. } )
  14180. );
  14181. return animation;
  14182. }
  14183. jQuery.Animation = jQuery.extend( Animation, {
  14184. tweeners: {
  14185. "*": [ function( prop, value ) {
  14186. var tween = this.createTween( prop, value );
  14187. adjustCSS( tween.elem, prop, rcssNum.exec( value ), tween );
  14188. return tween;
  14189. } ]
  14190. },
  14191. tweener: function( props, callback ) {
  14192. if ( isFunction( props ) ) {
  14193. callback = props;
  14194. props = [ "*" ];
  14195. } else {
  14196. props = props.match( rnothtmlwhite );
  14197. }
  14198. var prop,
  14199. index = 0,
  14200. length = props.length;
  14201. for ( ; index < length; index++ ) {
  14202. prop = props[ index ];
  14203. Animation.tweeners[ prop ] = Animation.tweeners[ prop ] || [];
  14204. Animation.tweeners[ prop ].unshift( callback );
  14205. }
  14206. },
  14207. prefilters: [ defaultPrefilter ],
  14208. prefilter: function( callback, prepend ) {
  14209. if ( prepend ) {
  14210. Animation.prefilters.unshift( callback );
  14211. } else {
  14212. Animation.prefilters.push( callback );
  14213. }
  14214. }
  14215. } );
  14216. jQuery.speed = function( speed, easing, fn ) {
  14217. var opt = speed && typeof speed === "object" ? jQuery.extend( {}, speed ) : {
  14218. complete: fn || !fn && easing ||
  14219. isFunction( speed ) && speed,
  14220. duration: speed,
  14221. easing: fn && easing || easing && !isFunction( easing ) && easing
  14222. };
  14223. // Go to the end state if fx are off
  14224. if ( jQuery.fx.off ) {
  14225. opt.duration = 0;
  14226. } else {
  14227. if ( typeof opt.duration !== "number" ) {
  14228. if ( opt.duration in jQuery.fx.speeds ) {
  14229. opt.duration = jQuery.fx.speeds[ opt.duration ];
  14230. } else {
  14231. opt.duration = jQuery.fx.speeds._default;
  14232. }
  14233. }
  14234. }
  14235. // Normalize opt.queue - true/undefined/null -> "fx"
  14236. if ( opt.queue == null || opt.queue === true ) {
  14237. opt.queue = "fx";
  14238. }
  14239. // Queueing
  14240. opt.old = opt.complete;
  14241. opt.complete = function() {
  14242. if ( isFunction( opt.old ) ) {
  14243. opt.old.call( this );
  14244. }
  14245. if ( opt.queue ) {
  14246. jQuery.dequeue( this, opt.queue );
  14247. }
  14248. };
  14249. return opt;
  14250. };
  14251. jQuery.fn.extend( {
  14252. fadeTo: function( speed, to, easing, callback ) {
  14253. // Show any hidden elements after setting opacity to 0
  14254. return this.filter( isHiddenWithinTree ).css( "opacity", 0 ).show()
  14255. // Animate to the value specified
  14256. .end().animate( { opacity: to }, speed, easing, callback );
  14257. },
  14258. animate: function( prop, speed, easing, callback ) {
  14259. var empty = jQuery.isEmptyObject( prop ),
  14260. optall = jQuery.speed( speed, easing, callback ),
  14261. doAnimation = function() {
  14262. // Operate on a copy of prop so per-property easing won't be lost
  14263. var anim = Animation( this, jQuery.extend( {}, prop ), optall );
  14264. // Empty animations, or finishing resolves immediately
  14265. if ( empty || dataPriv.get( this, "finish" ) ) {
  14266. anim.stop( true );
  14267. }
  14268. };
  14269. doAnimation.finish = doAnimation;
  14270. return empty || optall.queue === false ?
  14271. this.each( doAnimation ) :
  14272. this.queue( optall.queue, doAnimation );
  14273. },
  14274. stop: function( type, clearQueue, gotoEnd ) {
  14275. var stopQueue = function( hooks ) {
  14276. var stop = hooks.stop;
  14277. delete hooks.stop;
  14278. stop( gotoEnd );
  14279. };
  14280. if ( typeof type !== "string" ) {
  14281. gotoEnd = clearQueue;
  14282. clearQueue = type;
  14283. type = undefined;
  14284. }
  14285. if ( clearQueue && type !== false ) {
  14286. this.queue( type || "fx", [] );
  14287. }
  14288. return this.each( function() {
  14289. var dequeue = true,
  14290. index = type != null && type + "queueHooks",
  14291. timers = jQuery.timers,
  14292. data = dataPriv.get( this );
  14293. if ( index ) {
  14294. if ( data[ index ] && data[ index ].stop ) {
  14295. stopQueue( data[ index ] );
  14296. }
  14297. } else {
  14298. for ( index in data ) {
  14299. if ( data[ index ] && data[ index ].stop && rrun.test( index ) ) {
  14300. stopQueue( data[ index ] );
  14301. }
  14302. }
  14303. }
  14304. for ( index = timers.length; index--; ) {
  14305. if ( timers[ index ].elem === this &&
  14306. ( type == null || timers[ index ].queue === type ) ) {
  14307. timers[ index ].anim.stop( gotoEnd );
  14308. dequeue = false;
  14309. timers.splice( index, 1 );
  14310. }
  14311. }
  14312. // Start the next in the queue if the last step wasn't forced.
  14313. // Timers currently will call their complete callbacks, which
  14314. // will dequeue but only if they were gotoEnd.
  14315. if ( dequeue || !gotoEnd ) {
  14316. jQuery.dequeue( this, type );
  14317. }
  14318. } );
  14319. },
  14320. finish: function( type ) {
  14321. if ( type !== false ) {
  14322. type = type || "fx";
  14323. }
  14324. return this.each( function() {
  14325. var index,
  14326. data = dataPriv.get( this ),
  14327. queue = data[ type + "queue" ],
  14328. hooks = data[ type + "queueHooks" ],
  14329. timers = jQuery.timers,
  14330. length = queue ? queue.length : 0;
  14331. // Enable finishing flag on private data
  14332. data.finish = true;
  14333. // Empty the queue first
  14334. jQuery.queue( this, type, [] );
  14335. if ( hooks && hooks.stop ) {
  14336. hooks.stop.call( this, true );
  14337. }
  14338. // Look for any active animations, and finish them
  14339. for ( index = timers.length; index--; ) {
  14340. if ( timers[ index ].elem === this && timers[ index ].queue === type ) {
  14341. timers[ index ].anim.stop( true );
  14342. timers.splice( index, 1 );
  14343. }
  14344. }
  14345. // Look for any animations in the old queue and finish them
  14346. for ( index = 0; index < length; index++ ) {
  14347. if ( queue[ index ] && queue[ index ].finish ) {
  14348. queue[ index ].finish.call( this );
  14349. }
  14350. }
  14351. // Turn off finishing flag
  14352. delete data.finish;
  14353. } );
  14354. }
  14355. } );
  14356. jQuery.each( [ "toggle", "show", "hide" ], function( i, name ) {
  14357. var cssFn = jQuery.fn[ name ];
  14358. jQuery.fn[ name ] = function( speed, easing, callback ) {
  14359. return speed == null || typeof speed === "boolean" ?
  14360. cssFn.apply( this, arguments ) :
  14361. this.animate( genFx( name, true ), speed, easing, callback );
  14362. };
  14363. } );
  14364. // Generate shortcuts for custom animations
  14365. jQuery.each( {
  14366. slideDown: genFx( "show" ),
  14367. slideUp: genFx( "hide" ),
  14368. slideToggle: genFx( "toggle" ),
  14369. fadeIn: { opacity: "show" },
  14370. fadeOut: { opacity: "hide" },
  14371. fadeToggle: { opacity: "toggle" }
  14372. }, function( name, props ) {
  14373. jQuery.fn[ name ] = function( speed, easing, callback ) {
  14374. return this.animate( props, speed, easing, callback );
  14375. };
  14376. } );
  14377. jQuery.timers = [];
  14378. jQuery.fx.tick = function() {
  14379. var timer,
  14380. i = 0,
  14381. timers = jQuery.timers;
  14382. fxNow = Date.now();
  14383. for ( ; i < timers.length; i++ ) {
  14384. timer = timers[ i ];
  14385. // Run the timer and safely remove it when done (allowing for external removal)
  14386. if ( !timer() && timers[ i ] === timer ) {
  14387. timers.splice( i--, 1 );
  14388. }
  14389. }
  14390. if ( !timers.length ) {
  14391. jQuery.fx.stop();
  14392. }
  14393. fxNow = undefined;
  14394. };
  14395. jQuery.fx.timer = function( timer ) {
  14396. jQuery.timers.push( timer );
  14397. jQuery.fx.start();
  14398. };
  14399. jQuery.fx.interval = 13;
  14400. jQuery.fx.start = function() {
  14401. if ( inProgress ) {
  14402. return;
  14403. }
  14404. inProgress = true;
  14405. schedule();
  14406. };
  14407. jQuery.fx.stop = function() {
  14408. inProgress = null;
  14409. };
  14410. jQuery.fx.speeds = {
  14411. slow: 600,
  14412. fast: 200,
  14413. // Default speed
  14414. _default: 400
  14415. };
  14416. // Based off of the plugin by Clint Helfers, with permission.
  14417. // https://web.archive.org/web/20100324014747/http://blindsignals.com/index.php/2009/07/jquery-delay/
  14418. jQuery.fn.delay = function( time, type ) {
  14419. time = jQuery.fx ? jQuery.fx.speeds[ time ] || time : time;
  14420. type = type || "fx";
  14421. return this.queue( type, function( next, hooks ) {
  14422. var timeout = window.setTimeout( next, time );
  14423. hooks.stop = function() {
  14424. window.clearTimeout( timeout );
  14425. };
  14426. } );
  14427. };
  14428. ( function() {
  14429. var input = document.createElement( "input" ),
  14430. select = document.createElement( "select" ),
  14431. opt = select.appendChild( document.createElement( "option" ) );
  14432. input.type = "checkbox";
  14433. // Support: Android <=4.3 only
  14434. // Default value for a checkbox should be "on"
  14435. support.checkOn = input.value !== "";
  14436. // Support: IE <=11 only
  14437. // Must access selectedIndex to make default options select
  14438. support.optSelected = opt.selected;
  14439. // Support: IE <=11 only
  14440. // An input loses its value after becoming a radio
  14441. input = document.createElement( "input" );
  14442. input.value = "t";
  14443. input.type = "radio";
  14444. support.radioValue = input.value === "t";
  14445. } )();
  14446. var boolHook,
  14447. attrHandle = jQuery.expr.attrHandle;
  14448. jQuery.fn.extend( {
  14449. attr: function( name, value ) {
  14450. return access( this, jQuery.attr, name, value, arguments.length > 1 );
  14451. },
  14452. removeAttr: function( name ) {
  14453. return this.each( function() {
  14454. jQuery.removeAttr( this, name );
  14455. } );
  14456. }
  14457. } );
  14458. jQuery.extend( {
  14459. attr: function( elem, name, value ) {
  14460. var ret, hooks,
  14461. nType = elem.nodeType;
  14462. // Don't get/set attributes on text, comment and attribute nodes
  14463. if ( nType === 3 || nType === 8 || nType === 2 ) {
  14464. return;
  14465. }
  14466. // Fallback to prop when attributes are not supported
  14467. if ( typeof elem.getAttribute === "undefined" ) {
  14468. return jQuery.prop( elem, name, value );
  14469. }
  14470. // Attribute hooks are determined by the lowercase version
  14471. // Grab necessary hook if one is defined
  14472. if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) {
  14473. hooks = jQuery.attrHooks[ name.toLowerCase() ] ||
  14474. ( jQuery.expr.match.bool.test( name ) ? boolHook : undefined );
  14475. }
  14476. if ( value !== undefined ) {
  14477. if ( value === null ) {
  14478. jQuery.removeAttr( elem, name );
  14479. return;
  14480. }
  14481. if ( hooks && "set" in hooks &&
  14482. ( ret = hooks.set( elem, value, name ) ) !== undefined ) {
  14483. return ret;
  14484. }
  14485. elem.setAttribute( name, value + "" );
  14486. return value;
  14487. }
  14488. if ( hooks && "get" in hooks && ( ret = hooks.get( elem, name ) ) !== null ) {
  14489. return ret;
  14490. }
  14491. ret = jQuery.find.attr( elem, name );
  14492. // Non-existent attributes return null, we normalize to undefined
  14493. return ret == null ? undefined : ret;
  14494. },
  14495. attrHooks: {
  14496. type: {
  14497. set: function( elem, value ) {
  14498. if ( !support.radioValue && value === "radio" &&
  14499. nodeName( elem, "input" ) ) {
  14500. var val = elem.value;
  14501. elem.setAttribute( "type", value );
  14502. if ( val ) {
  14503. elem.value = val;
  14504. }
  14505. return value;
  14506. }
  14507. }
  14508. }
  14509. },
  14510. removeAttr: function( elem, value ) {
  14511. var name,
  14512. i = 0,
  14513. // Attribute names can contain non-HTML whitespace characters
  14514. // https://html.spec.whatwg.org/multipage/syntax.html#attributes-2
  14515. attrNames = value && value.match( rnothtmlwhite );
  14516. if ( attrNames && elem.nodeType === 1 ) {
  14517. while ( ( name = attrNames[ i++ ] ) ) {
  14518. elem.removeAttribute( name );
  14519. }
  14520. }
  14521. }
  14522. } );
  14523. // Hooks for boolean attributes
  14524. boolHook = {
  14525. set: function( elem, value, name ) {
  14526. if ( value === false ) {
  14527. // Remove boolean attributes when set to false
  14528. jQuery.removeAttr( elem, name );
  14529. } else {
  14530. elem.setAttribute( name, name );
  14531. }
  14532. return name;
  14533. }
  14534. };
  14535. jQuery.each( jQuery.expr.match.bool.source.match( /\w+/g ), function( i, name ) {
  14536. var getter = attrHandle[ name ] || jQuery.find.attr;
  14537. attrHandle[ name ] = function( elem, name, isXML ) {
  14538. var ret, handle,
  14539. lowercaseName = name.toLowerCase();
  14540. if ( !isXML ) {
  14541. // Avoid an infinite loop by temporarily removing this function from the getter
  14542. handle = attrHandle[ lowercaseName ];
  14543. attrHandle[ lowercaseName ] = ret;
  14544. ret = getter( elem, name, isXML ) != null ?
  14545. lowercaseName :
  14546. null;
  14547. attrHandle[ lowercaseName ] = handle;
  14548. }
  14549. return ret;
  14550. };
  14551. } );
  14552. var rfocusable = /^(?:input|select|textarea|button)$/i,
  14553. rclickable = /^(?:a|area)$/i;
  14554. jQuery.fn.extend( {
  14555. prop: function( name, value ) {
  14556. return access( this, jQuery.prop, name, value, arguments.length > 1 );
  14557. },
  14558. removeProp: function( name ) {
  14559. return this.each( function() {
  14560. delete this[ jQuery.propFix[ name ] || name ];
  14561. } );
  14562. }
  14563. } );
  14564. jQuery.extend( {
  14565. prop: function( elem, name, value ) {
  14566. var ret, hooks,
  14567. nType = elem.nodeType;
  14568. // Don't get/set properties on text, comment and attribute nodes
  14569. if ( nType === 3 || nType === 8 || nType === 2 ) {
  14570. return;
  14571. }
  14572. if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) {
  14573. // Fix name and attach hooks
  14574. name = jQuery.propFix[ name ] || name;
  14575. hooks = jQuery.propHooks[ name ];
  14576. }
  14577. if ( value !== undefined ) {
  14578. if ( hooks && "set" in hooks &&
  14579. ( ret = hooks.set( elem, value, name ) ) !== undefined ) {
  14580. return ret;
  14581. }
  14582. return ( elem[ name ] = value );
  14583. }
  14584. if ( hooks && "get" in hooks && ( ret = hooks.get( elem, name ) ) !== null ) {
  14585. return ret;
  14586. }
  14587. return elem[ name ];
  14588. },
  14589. propHooks: {
  14590. tabIndex: {
  14591. get: function( elem ) {
  14592. // Support: IE <=9 - 11 only
  14593. // elem.tabIndex doesn't always return the
  14594. // correct value when it hasn't been explicitly set
  14595. // https://web.archive.org/web/20141116233347/http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/
  14596. // Use proper attribute retrieval(#12072)
  14597. var tabindex = jQuery.find.attr( elem, "tabindex" );
  14598. if ( tabindex ) {
  14599. return parseInt( tabindex, 10 );
  14600. }
  14601. if (
  14602. rfocusable.test( elem.nodeName ) ||
  14603. rclickable.test( elem.nodeName ) &&
  14604. elem.href
  14605. ) {
  14606. return 0;
  14607. }
  14608. return -1;
  14609. }
  14610. }
  14611. },
  14612. propFix: {
  14613. "for": "htmlFor",
  14614. "class": "className"
  14615. }
  14616. } );
  14617. // Support: IE <=11 only
  14618. // Accessing the selectedIndex property
  14619. // forces the browser to respect setting selected
  14620. // on the option
  14621. // The getter ensures a default option is selected
  14622. // when in an optgroup
  14623. // eslint rule "no-unused-expressions" is disabled for this code
  14624. // since it considers such accessions noop
  14625. if ( !support.optSelected ) {
  14626. jQuery.propHooks.selected = {
  14627. get: function( elem ) {
  14628. /* eslint no-unused-expressions: "off" */
  14629. var parent = elem.parentNode;
  14630. if ( parent && parent.parentNode ) {
  14631. parent.parentNode.selectedIndex;
  14632. }
  14633. return null;
  14634. },
  14635. set: function( elem ) {
  14636. /* eslint no-unused-expressions: "off" */
  14637. var parent = elem.parentNode;
  14638. if ( parent ) {
  14639. parent.selectedIndex;
  14640. if ( parent.parentNode ) {
  14641. parent.parentNode.selectedIndex;
  14642. }
  14643. }
  14644. }
  14645. };
  14646. }
  14647. jQuery.each( [
  14648. "tabIndex",
  14649. "readOnly",
  14650. "maxLength",
  14651. "cellSpacing",
  14652. "cellPadding",
  14653. "rowSpan",
  14654. "colSpan",
  14655. "useMap",
  14656. "frameBorder",
  14657. "contentEditable"
  14658. ], function() {
  14659. jQuery.propFix[ this.toLowerCase() ] = this;
  14660. } );
  14661. // Strip and collapse whitespace according to HTML spec
  14662. // https://infra.spec.whatwg.org/#strip-and-collapse-ascii-whitespace
  14663. function stripAndCollapse( value ) {
  14664. var tokens = value.match( rnothtmlwhite ) || [];
  14665. return tokens.join( " " );
  14666. }
  14667. function getClass( elem ) {
  14668. return elem.getAttribute && elem.getAttribute( "class" ) || "";
  14669. }
  14670. function classesToArray( value ) {
  14671. if ( Array.isArray( value ) ) {
  14672. return value;
  14673. }
  14674. if ( typeof value === "string" ) {
  14675. return value.match( rnothtmlwhite ) || [];
  14676. }
  14677. return [];
  14678. }
  14679. jQuery.fn.extend( {
  14680. addClass: function( value ) {
  14681. var classes, elem, cur, curValue, clazz, j, finalValue,
  14682. i = 0;
  14683. if ( isFunction( value ) ) {
  14684. return this.each( function( j ) {
  14685. jQuery( this ).addClass( value.call( this, j, getClass( this ) ) );
  14686. } );
  14687. }
  14688. classes = classesToArray( value );
  14689. if ( classes.length ) {
  14690. while ( ( elem = this[ i++ ] ) ) {
  14691. curValue = getClass( elem );
  14692. cur = elem.nodeType === 1 && ( " " + stripAndCollapse( curValue ) + " " );
  14693. if ( cur ) {
  14694. j = 0;
  14695. while ( ( clazz = classes[ j++ ] ) ) {
  14696. if ( cur.indexOf( " " + clazz + " " ) < 0 ) {
  14697. cur += clazz + " ";
  14698. }
  14699. }
  14700. // Only assign if different to avoid unneeded rendering.
  14701. finalValue = stripAndCollapse( cur );
  14702. if ( curValue !== finalValue ) {
  14703. elem.setAttribute( "class", finalValue );
  14704. }
  14705. }
  14706. }
  14707. }
  14708. return this;
  14709. },
  14710. removeClass: function( value ) {
  14711. var classes, elem, cur, curValue, clazz, j, finalValue,
  14712. i = 0;
  14713. if ( isFunction( value ) ) {
  14714. return this.each( function( j ) {
  14715. jQuery( this ).removeClass( value.call( this, j, getClass( this ) ) );
  14716. } );
  14717. }
  14718. if ( !arguments.length ) {
  14719. return this.attr( "class", "" );
  14720. }
  14721. classes = classesToArray( value );
  14722. if ( classes.length ) {
  14723. while ( ( elem = this[ i++ ] ) ) {
  14724. curValue = getClass( elem );
  14725. // This expression is here for better compressibility (see addClass)
  14726. cur = elem.nodeType === 1 && ( " " + stripAndCollapse( curValue ) + " " );
  14727. if ( cur ) {
  14728. j = 0;
  14729. while ( ( clazz = classes[ j++ ] ) ) {
  14730. // Remove *all* instances
  14731. while ( cur.indexOf( " " + clazz + " " ) > -1 ) {
  14732. cur = cur.replace( " " + clazz + " ", " " );
  14733. }
  14734. }
  14735. // Only assign if different to avoid unneeded rendering.
  14736. finalValue = stripAndCollapse( cur );
  14737. if ( curValue !== finalValue ) {
  14738. elem.setAttribute( "class", finalValue );
  14739. }
  14740. }
  14741. }
  14742. }
  14743. return this;
  14744. },
  14745. toggleClass: function( value, stateVal ) {
  14746. var type = typeof value,
  14747. isValidValue = type === "string" || Array.isArray( value );
  14748. if ( typeof stateVal === "boolean" && isValidValue ) {
  14749. return stateVal ? this.addClass( value ) : this.removeClass( value );
  14750. }
  14751. if ( isFunction( value ) ) {
  14752. return this.each( function( i ) {
  14753. jQuery( this ).toggleClass(
  14754. value.call( this, i, getClass( this ), stateVal ),
  14755. stateVal
  14756. );
  14757. } );
  14758. }
  14759. return this.each( function() {
  14760. var className, i, self, classNames;
  14761. if ( isValidValue ) {
  14762. // Toggle individual class names
  14763. i = 0;
  14764. self = jQuery( this );
  14765. classNames = classesToArray( value );
  14766. while ( ( className = classNames[ i++ ] ) ) {
  14767. // Check each className given, space separated list
  14768. if ( self.hasClass( className ) ) {
  14769. self.removeClass( className );
  14770. } else {
  14771. self.addClass( className );
  14772. }
  14773. }
  14774. // Toggle whole class name
  14775. } else if ( value === undefined || type === "boolean" ) {
  14776. className = getClass( this );
  14777. if ( className ) {
  14778. // Store className if set
  14779. dataPriv.set( this, "__className__", className );
  14780. }
  14781. // If the element has a class name or if we're passed `false`,
  14782. // then remove the whole classname (if there was one, the above saved it).
  14783. // Otherwise bring back whatever was previously saved (if anything),
  14784. // falling back to the empty string if nothing was stored.
  14785. if ( this.setAttribute ) {
  14786. this.setAttribute( "class",
  14787. className || value === false ?
  14788. "" :
  14789. dataPriv.get( this, "__className__" ) || ""
  14790. );
  14791. }
  14792. }
  14793. } );
  14794. },
  14795. hasClass: function( selector ) {
  14796. var className, elem,
  14797. i = 0;
  14798. className = " " + selector + " ";
  14799. while ( ( elem = this[ i++ ] ) ) {
  14800. if ( elem.nodeType === 1 &&
  14801. ( " " + stripAndCollapse( getClass( elem ) ) + " " ).indexOf( className ) > -1 ) {
  14802. return true;
  14803. }
  14804. }
  14805. return false;
  14806. }
  14807. } );
  14808. var rreturn = /\r/g;
  14809. jQuery.fn.extend( {
  14810. val: function( value ) {
  14811. var hooks, ret, valueIsFunction,
  14812. elem = this[ 0 ];
  14813. if ( !arguments.length ) {
  14814. if ( elem ) {
  14815. hooks = jQuery.valHooks[ elem.type ] ||
  14816. jQuery.valHooks[ elem.nodeName.toLowerCase() ];
  14817. if ( hooks &&
  14818. "get" in hooks &&
  14819. ( ret = hooks.get( elem, "value" ) ) !== undefined
  14820. ) {
  14821. return ret;
  14822. }
  14823. ret = elem.value;
  14824. // Handle most common string cases
  14825. if ( typeof ret === "string" ) {
  14826. return ret.replace( rreturn, "" );
  14827. }
  14828. // Handle cases where value is null/undef or number
  14829. return ret == null ? "" : ret;
  14830. }
  14831. return;
  14832. }
  14833. valueIsFunction = isFunction( value );
  14834. return this.each( function( i ) {
  14835. var val;
  14836. if ( this.nodeType !== 1 ) {
  14837. return;
  14838. }
  14839. if ( valueIsFunction ) {
  14840. val = value.call( this, i, jQuery( this ).val() );
  14841. } else {
  14842. val = value;
  14843. }
  14844. // Treat null/undefined as ""; convert numbers to string
  14845. if ( val == null ) {
  14846. val = "";
  14847. } else if ( typeof val === "number" ) {
  14848. val += "";
  14849. } else if ( Array.isArray( val ) ) {
  14850. val = jQuery.map( val, function( value ) {
  14851. return value == null ? "" : value + "";
  14852. } );
  14853. }
  14854. hooks = jQuery.valHooks[ this.type ] || jQuery.valHooks[ this.nodeName.toLowerCase() ];
  14855. // If set returns undefined, fall back to normal setting
  14856. if ( !hooks || !( "set" in hooks ) || hooks.set( this, val, "value" ) === undefined ) {
  14857. this.value = val;
  14858. }
  14859. } );
  14860. }
  14861. } );
  14862. jQuery.extend( {
  14863. valHooks: {
  14864. option: {
  14865. get: function( elem ) {
  14866. var val = jQuery.find.attr( elem, "value" );
  14867. return val != null ?
  14868. val :
  14869. // Support: IE <=10 - 11 only
  14870. // option.text throws exceptions (#14686, #14858)
  14871. // Strip and collapse whitespace
  14872. // https://html.spec.whatwg.org/#strip-and-collapse-whitespace
  14873. stripAndCollapse( jQuery.text( elem ) );
  14874. }
  14875. },
  14876. select: {
  14877. get: function( elem ) {
  14878. var value, option, i,
  14879. options = elem.options,
  14880. index = elem.selectedIndex,
  14881. one = elem.type === "select-one",
  14882. values = one ? null : [],
  14883. max = one ? index + 1 : options.length;
  14884. if ( index < 0 ) {
  14885. i = max;
  14886. } else {
  14887. i = one ? index : 0;
  14888. }
  14889. // Loop through all the selected options
  14890. for ( ; i < max; i++ ) {
  14891. option = options[ i ];
  14892. // Support: IE <=9 only
  14893. // IE8-9 doesn't update selected after form reset (#2551)
  14894. if ( ( option.selected || i === index ) &&
  14895. // Don't return options that are disabled or in a disabled optgroup
  14896. !option.disabled &&
  14897. ( !option.parentNode.disabled ||
  14898. !nodeName( option.parentNode, "optgroup" ) ) ) {
  14899. // Get the specific value for the option
  14900. value = jQuery( option ).val();
  14901. // We don't need an array for one selects
  14902. if ( one ) {
  14903. return value;
  14904. }
  14905. // Multi-Selects return an array
  14906. values.push( value );
  14907. }
  14908. }
  14909. return values;
  14910. },
  14911. set: function( elem, value ) {
  14912. var optionSet, option,
  14913. options = elem.options,
  14914. values = jQuery.makeArray( value ),
  14915. i = options.length;
  14916. while ( i-- ) {
  14917. option = options[ i ];
  14918. /* eslint-disable no-cond-assign */
  14919. if ( option.selected =
  14920. jQuery.inArray( jQuery.valHooks.option.get( option ), values ) > -1
  14921. ) {
  14922. optionSet = true;
  14923. }
  14924. /* eslint-enable no-cond-assign */
  14925. }
  14926. // Force browsers to behave consistently when non-matching value is set
  14927. if ( !optionSet ) {
  14928. elem.selectedIndex = -1;
  14929. }
  14930. return values;
  14931. }
  14932. }
  14933. }
  14934. } );
  14935. // Radios and checkboxes getter/setter
  14936. jQuery.each( [ "radio", "checkbox" ], function() {
  14937. jQuery.valHooks[ this ] = {
  14938. set: function( elem, value ) {
  14939. if ( Array.isArray( value ) ) {
  14940. return ( elem.checked = jQuery.inArray( jQuery( elem ).val(), value ) > -1 );
  14941. }
  14942. }
  14943. };
  14944. if ( !support.checkOn ) {
  14945. jQuery.valHooks[ this ].get = function( elem ) {
  14946. return elem.getAttribute( "value" ) === null ? "on" : elem.value;
  14947. };
  14948. }
  14949. } );
  14950. // Return jQuery for attributes-only inclusion
  14951. support.focusin = "onfocusin" in window;
  14952. var rfocusMorph = /^(?:focusinfocus|focusoutblur)$/,
  14953. stopPropagationCallback = function( e ) {
  14954. e.stopPropagation();
  14955. };
  14956. jQuery.extend( jQuery.event, {
  14957. trigger: function( event, data, elem, onlyHandlers ) {
  14958. var i, cur, tmp, bubbleType, ontype, handle, special, lastElement,
  14959. eventPath = [ elem || document ],
  14960. type = hasOwn.call( event, "type" ) ? event.type : event,
  14961. namespaces = hasOwn.call( event, "namespace" ) ? event.namespace.split( "." ) : [];
  14962. cur = lastElement = tmp = elem = elem || document;
  14963. // Don't do events on text and comment nodes
  14964. if ( elem.nodeType === 3 || elem.nodeType === 8 ) {
  14965. return;
  14966. }
  14967. // focus/blur morphs to focusin/out; ensure we're not firing them right now
  14968. if ( rfocusMorph.test( type + jQuery.event.triggered ) ) {
  14969. return;
  14970. }
  14971. if ( type.indexOf( "." ) > -1 ) {
  14972. // Namespaced trigger; create a regexp to match event type in handle()
  14973. namespaces = type.split( "." );
  14974. type = namespaces.shift();
  14975. namespaces.sort();
  14976. }
  14977. ontype = type.indexOf( ":" ) < 0 && "on" + type;
  14978. // Caller can pass in a jQuery.Event object, Object, or just an event type string
  14979. event = event[ jQuery.expando ] ?
  14980. event :
  14981. new jQuery.Event( type, typeof event === "object" && event );
  14982. // Trigger bitmask: & 1 for native handlers; & 2 for jQuery (always true)
  14983. event.isTrigger = onlyHandlers ? 2 : 3;
  14984. event.namespace = namespaces.join( "." );
  14985. event.rnamespace = event.namespace ?
  14986. new RegExp( "(^|\\.)" + namespaces.join( "\\.(?:.*\\.|)" ) + "(\\.|$)" ) :
  14987. null;
  14988. // Clean up the event in case it is being reused
  14989. event.result = undefined;
  14990. if ( !event.target ) {
  14991. event.target = elem;
  14992. }
  14993. // Clone any incoming data and prepend the event, creating the handler arg list
  14994. data = data == null ?
  14995. [ event ] :
  14996. jQuery.makeArray( data, [ event ] );
  14997. // Allow special events to draw outside the lines
  14998. special = jQuery.event.special[ type ] || {};
  14999. if ( !onlyHandlers && special.trigger && special.trigger.apply( elem, data ) === false ) {
  15000. return;
  15001. }
  15002. // Determine event propagation path in advance, per W3C events spec (#9951)
  15003. // Bubble up to document, then to window; watch for a global ownerDocument var (#9724)
  15004. if ( !onlyHandlers && !special.noBubble && !isWindow( elem ) ) {
  15005. bubbleType = special.delegateType || type;
  15006. if ( !rfocusMorph.test( bubbleType + type ) ) {
  15007. cur = cur.parentNode;
  15008. }
  15009. for ( ; cur; cur = cur.parentNode ) {
  15010. eventPath.push( cur );
  15011. tmp = cur;
  15012. }
  15013. // Only add window if we got to document (e.g., not plain obj or detached DOM)
  15014. if ( tmp === ( elem.ownerDocument || document ) ) {
  15015. eventPath.push( tmp.defaultView || tmp.parentWindow || window );
  15016. }
  15017. }
  15018. // Fire handlers on the event path
  15019. i = 0;
  15020. while ( ( cur = eventPath[ i++ ] ) && !event.isPropagationStopped() ) {
  15021. lastElement = cur;
  15022. event.type = i > 1 ?
  15023. bubbleType :
  15024. special.bindType || type;
  15025. // jQuery handler
  15026. handle = ( dataPriv.get( cur, "events" ) || {} )[ event.type ] &&
  15027. dataPriv.get( cur, "handle" );
  15028. if ( handle ) {
  15029. handle.apply( cur, data );
  15030. }
  15031. // Native handler
  15032. handle = ontype && cur[ ontype ];
  15033. if ( handle && handle.apply && acceptData( cur ) ) {
  15034. event.result = handle.apply( cur, data );
  15035. if ( event.result === false ) {
  15036. event.preventDefault();
  15037. }
  15038. }
  15039. }
  15040. event.type = type;
  15041. // If nobody prevented the default action, do it now
  15042. if ( !onlyHandlers && !event.isDefaultPrevented() ) {
  15043. if ( ( !special._default ||
  15044. special._default.apply( eventPath.pop(), data ) === false ) &&
  15045. acceptData( elem ) ) {
  15046. // Call a native DOM method on the target with the same name as the event.
  15047. // Don't do default actions on window, that's where global variables be (#6170)
  15048. if ( ontype && isFunction( elem[ type ] ) && !isWindow( elem ) ) {
  15049. // Don't re-trigger an onFOO event when we call its FOO() method
  15050. tmp = elem[ ontype ];
  15051. if ( tmp ) {
  15052. elem[ ontype ] = null;
  15053. }
  15054. // Prevent re-triggering of the same event, since we already bubbled it above
  15055. jQuery.event.triggered = type;
  15056. if ( event.isPropagationStopped() ) {
  15057. lastElement.addEventListener( type, stopPropagationCallback );
  15058. }
  15059. elem[ type ]();
  15060. if ( event.isPropagationStopped() ) {
  15061. lastElement.removeEventListener( type, stopPropagationCallback );
  15062. }
  15063. jQuery.event.triggered = undefined;
  15064. if ( tmp ) {
  15065. elem[ ontype ] = tmp;
  15066. }
  15067. }
  15068. }
  15069. }
  15070. return event.result;
  15071. },
  15072. // Piggyback on a donor event to simulate a different one
  15073. // Used only for `focus(in | out)` events
  15074. simulate: function( type, elem, event ) {
  15075. var e = jQuery.extend(
  15076. new jQuery.Event(),
  15077. event,
  15078. {
  15079. type: type,
  15080. isSimulated: true
  15081. }
  15082. );
  15083. jQuery.event.trigger( e, null, elem );
  15084. }
  15085. } );
  15086. jQuery.fn.extend( {
  15087. trigger: function( type, data ) {
  15088. return this.each( function() {
  15089. jQuery.event.trigger( type, data, this );
  15090. } );
  15091. },
  15092. triggerHandler: function( type, data ) {
  15093. var elem = this[ 0 ];
  15094. if ( elem ) {
  15095. return jQuery.event.trigger( type, data, elem, true );
  15096. }
  15097. }
  15098. } );
  15099. // Support: Firefox <=44
  15100. // Firefox doesn't have focus(in | out) events
  15101. // Related ticket - https://bugzilla.mozilla.org/show_bug.cgi?id=687787
  15102. //
  15103. // Support: Chrome <=48 - 49, Safari <=9.0 - 9.1
  15104. // focus(in | out) events fire after focus & blur events,
  15105. // which is spec violation - http://www.w3.org/TR/DOM-Level-3-Events/#events-focusevent-event-order
  15106. // Related ticket - https://bugs.chromium.org/p/chromium/issues/detail?id=449857
  15107. if ( !support.focusin ) {
  15108. jQuery.each( { focus: "focusin", blur: "focusout" }, function( orig, fix ) {
  15109. // Attach a single capturing handler on the document while someone wants focusin/focusout
  15110. var handler = function( event ) {
  15111. jQuery.event.simulate( fix, event.target, jQuery.event.fix( event ) );
  15112. };
  15113. jQuery.event.special[ fix ] = {
  15114. setup: function() {
  15115. var doc = this.ownerDocument || this,
  15116. attaches = dataPriv.access( doc, fix );
  15117. if ( !attaches ) {
  15118. doc.addEventListener( orig, handler, true );
  15119. }
  15120. dataPriv.access( doc, fix, ( attaches || 0 ) + 1 );
  15121. },
  15122. teardown: function() {
  15123. var doc = this.ownerDocument || this,
  15124. attaches = dataPriv.access( doc, fix ) - 1;
  15125. if ( !attaches ) {
  15126. doc.removeEventListener( orig, handler, true );
  15127. dataPriv.remove( doc, fix );
  15128. } else {
  15129. dataPriv.access( doc, fix, attaches );
  15130. }
  15131. }
  15132. };
  15133. } );
  15134. }
  15135. var location = window.location;
  15136. var nonce = Date.now();
  15137. var rquery = ( /\?/ );
  15138. // Cross-browser xml parsing
  15139. jQuery.parseXML = function( data ) {
  15140. var xml;
  15141. if ( !data || typeof data !== "string" ) {
  15142. return null;
  15143. }
  15144. // Support: IE 9 - 11 only
  15145. // IE throws on parseFromString with invalid input.
  15146. try {
  15147. xml = ( new window.DOMParser() ).parseFromString( data, "text/xml" );
  15148. } catch ( e ) {
  15149. xml = undefined;
  15150. }
  15151. if ( !xml || xml.getElementsByTagName( "parsererror" ).length ) {
  15152. jQuery.error( "Invalid XML: " + data );
  15153. }
  15154. return xml;
  15155. };
  15156. var
  15157. rbracket = /\[\]$/,
  15158. rCRLF = /\r?\n/g,
  15159. rsubmitterTypes = /^(?:submit|button|image|reset|file)$/i,
  15160. rsubmittable = /^(?:input|select|textarea|keygen)/i;
  15161. function buildParams( prefix, obj, traditional, add ) {
  15162. var name;
  15163. if ( Array.isArray( obj ) ) {
  15164. // Serialize array item.
  15165. jQuery.each( obj, function( i, v ) {
  15166. if ( traditional || rbracket.test( prefix ) ) {
  15167. // Treat each array item as a scalar.
  15168. add( prefix, v );
  15169. } else {
  15170. // Item is non-scalar (array or object), encode its numeric index.
  15171. buildParams(
  15172. prefix + "[" + ( typeof v === "object" && v != null ? i : "" ) + "]",
  15173. v,
  15174. traditional,
  15175. add
  15176. );
  15177. }
  15178. } );
  15179. } else if ( !traditional && toType( obj ) === "object" ) {
  15180. // Serialize object item.
  15181. for ( name in obj ) {
  15182. buildParams( prefix + "[" + name + "]", obj[ name ], traditional, add );
  15183. }
  15184. } else {
  15185. // Serialize scalar item.
  15186. add( prefix, obj );
  15187. }
  15188. }
  15189. // Serialize an array of form elements or a set of
  15190. // key/values into a query string
  15191. jQuery.param = function( a, traditional ) {
  15192. var prefix,
  15193. s = [],
  15194. add = function( key, valueOrFunction ) {
  15195. // If value is a function, invoke it and use its return value
  15196. var value = isFunction( valueOrFunction ) ?
  15197. valueOrFunction() :
  15198. valueOrFunction;
  15199. s[ s.length ] = encodeURIComponent( key ) + "=" +
  15200. encodeURIComponent( value == null ? "" : value );
  15201. };
  15202. if ( a == null ) {
  15203. return "";
  15204. }
  15205. // If an array was passed in, assume that it is an array of form elements.
  15206. if ( Array.isArray( a ) || ( a.jquery && !jQuery.isPlainObject( a ) ) ) {
  15207. // Serialize the form elements
  15208. jQuery.each( a, function() {
  15209. add( this.name, this.value );
  15210. } );
  15211. } else {
  15212. // If traditional, encode the "old" way (the way 1.3.2 or older
  15213. // did it), otherwise encode params recursively.
  15214. for ( prefix in a ) {
  15215. buildParams( prefix, a[ prefix ], traditional, add );
  15216. }
  15217. }
  15218. // Return the resulting serialization
  15219. return s.join( "&" );
  15220. };
  15221. jQuery.fn.extend( {
  15222. serialize: function() {
  15223. return jQuery.param( this.serializeArray() );
  15224. },
  15225. serializeArray: function() {
  15226. return this.map( function() {
  15227. // Can add propHook for "elements" to filter or add form elements
  15228. var elements = jQuery.prop( this, "elements" );
  15229. return elements ? jQuery.makeArray( elements ) : this;
  15230. } )
  15231. .filter( function() {
  15232. var type = this.type;
  15233. // Use .is( ":disabled" ) so that fieldset[disabled] works
  15234. return this.name && !jQuery( this ).is( ":disabled" ) &&
  15235. rsubmittable.test( this.nodeName ) && !rsubmitterTypes.test( type ) &&
  15236. ( this.checked || !rcheckableType.test( type ) );
  15237. } )
  15238. .map( function( i, elem ) {
  15239. var val = jQuery( this ).val();
  15240. if ( val == null ) {
  15241. return null;
  15242. }
  15243. if ( Array.isArray( val ) ) {
  15244. return jQuery.map( val, function( val ) {
  15245. return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
  15246. } );
  15247. }
  15248. return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
  15249. } ).get();
  15250. }
  15251. } );
  15252. var
  15253. r20 = /%20/g,
  15254. rhash = /#.*$/,
  15255. rantiCache = /([?&])_=[^&]*/,
  15256. rheaders = /^(.*?):[ \t]*([^\r\n]*)$/mg,
  15257. // #7653, #8125, #8152: local protocol detection
  15258. rlocalProtocol = /^(?:about|app|app-storage|.+-extension|file|res|widget):$/,
  15259. rnoContent = /^(?:GET|HEAD)$/,
  15260. rprotocol = /^\/\//,
  15261. /* Prefilters
  15262. * 1) They are useful to introduce custom dataTypes (see ajax/jsonp.js for an example)
  15263. * 2) These are called:
  15264. * - BEFORE asking for a transport
  15265. * - AFTER param serialization (s.data is a string if s.processData is true)
  15266. * 3) key is the dataType
  15267. * 4) the catchall symbol "*" can be used
  15268. * 5) execution will start with transport dataType and THEN continue down to "*" if needed
  15269. */
  15270. prefilters = {},
  15271. /* Transports bindings
  15272. * 1) key is the dataType
  15273. * 2) the catchall symbol "*" can be used
  15274. * 3) selection will start with transport dataType and THEN go to "*" if needed
  15275. */
  15276. transports = {},
  15277. // Avoid comment-prolog char sequence (#10098); must appease lint and evade compression
  15278. allTypes = "*/".concat( "*" ),
  15279. // Anchor tag for parsing the document origin
  15280. originAnchor = document.createElement( "a" );
  15281. originAnchor.href = location.href;
  15282. // Base "constructor" for jQuery.ajaxPrefilter and jQuery.ajaxTransport
  15283. function addToPrefiltersOrTransports( structure ) {
  15284. // dataTypeExpression is optional and defaults to "*"
  15285. return function( dataTypeExpression, func ) {
  15286. if ( typeof dataTypeExpression !== "string" ) {
  15287. func = dataTypeExpression;
  15288. dataTypeExpression = "*";
  15289. }
  15290. var dataType,
  15291. i = 0,
  15292. dataTypes = dataTypeExpression.toLowerCase().match( rnothtmlwhite ) || [];
  15293. if ( isFunction( func ) ) {
  15294. // For each dataType in the dataTypeExpression
  15295. while ( ( dataType = dataTypes[ i++ ] ) ) {
  15296. // Prepend if requested
  15297. if ( dataType[ 0 ] === "+" ) {
  15298. dataType = dataType.slice( 1 ) || "*";
  15299. ( structure[ dataType ] = structure[ dataType ] || [] ).unshift( func );
  15300. // Otherwise append
  15301. } else {
  15302. ( structure[ dataType ] = structure[ dataType ] || [] ).push( func );
  15303. }
  15304. }
  15305. }
  15306. };
  15307. }
  15308. // Base inspection function for prefilters and transports
  15309. function inspectPrefiltersOrTransports( structure, options, originalOptions, jqXHR ) {
  15310. var inspected = {},
  15311. seekingTransport = ( structure === transports );
  15312. function inspect( dataType ) {
  15313. var selected;
  15314. inspected[ dataType ] = true;
  15315. jQuery.each( structure[ dataType ] || [], function( _, prefilterOrFactory ) {
  15316. var dataTypeOrTransport = prefilterOrFactory( options, originalOptions, jqXHR );
  15317. if ( typeof dataTypeOrTransport === "string" &&
  15318. !seekingTransport && !inspected[ dataTypeOrTransport ] ) {
  15319. options.dataTypes.unshift( dataTypeOrTransport );
  15320. inspect( dataTypeOrTransport );
  15321. return false;
  15322. } else if ( seekingTransport ) {
  15323. return !( selected = dataTypeOrTransport );
  15324. }
  15325. } );
  15326. return selected;
  15327. }
  15328. return inspect( options.dataTypes[ 0 ] ) || !inspected[ "*" ] && inspect( "*" );
  15329. }
  15330. // A special extend for ajax options
  15331. // that takes "flat" options (not to be deep extended)
  15332. // Fixes #9887
  15333. function ajaxExtend( target, src ) {
  15334. var key, deep,
  15335. flatOptions = jQuery.ajaxSettings.flatOptions || {};
  15336. for ( key in src ) {
  15337. if ( src[ key ] !== undefined ) {
  15338. ( flatOptions[ key ] ? target : ( deep || ( deep = {} ) ) )[ key ] = src[ key ];
  15339. }
  15340. }
  15341. if ( deep ) {
  15342. jQuery.extend( true, target, deep );
  15343. }
  15344. return target;
  15345. }
  15346. /* Handles responses to an ajax request:
  15347. * - finds the right dataType (mediates between content-type and expected dataType)
  15348. * - returns the corresponding response
  15349. */
  15350. function ajaxHandleResponses( s, jqXHR, responses ) {
  15351. var ct, type, finalDataType, firstDataType,
  15352. contents = s.contents,
  15353. dataTypes = s.dataTypes;
  15354. // Remove auto dataType and get content-type in the process
  15355. while ( dataTypes[ 0 ] === "*" ) {
  15356. dataTypes.shift();
  15357. if ( ct === undefined ) {
  15358. ct = s.mimeType || jqXHR.getResponseHeader( "Content-Type" );
  15359. }
  15360. }
  15361. // Check if we're dealing with a known content-type
  15362. if ( ct ) {
  15363. for ( type in contents ) {
  15364. if ( contents[ type ] && contents[ type ].test( ct ) ) {
  15365. dataTypes.unshift( type );
  15366. break;
  15367. }
  15368. }
  15369. }
  15370. // Check to see if we have a response for the expected dataType
  15371. if ( dataTypes[ 0 ] in responses ) {
  15372. finalDataType = dataTypes[ 0 ];
  15373. } else {
  15374. // Try convertible dataTypes
  15375. for ( type in responses ) {
  15376. if ( !dataTypes[ 0 ] || s.converters[ type + " " + dataTypes[ 0 ] ] ) {
  15377. finalDataType = type;
  15378. break;
  15379. }
  15380. if ( !firstDataType ) {
  15381. firstDataType = type;
  15382. }
  15383. }
  15384. // Or just use first one
  15385. finalDataType = finalDataType || firstDataType;
  15386. }
  15387. // If we found a dataType
  15388. // We add the dataType to the list if needed
  15389. // and return the corresponding response
  15390. if ( finalDataType ) {
  15391. if ( finalDataType !== dataTypes[ 0 ] ) {
  15392. dataTypes.unshift( finalDataType );
  15393. }
  15394. return responses[ finalDataType ];
  15395. }
  15396. }
  15397. /* Chain conversions given the request and the original response
  15398. * Also sets the responseXXX fields on the jqXHR instance
  15399. */
  15400. function ajaxConvert( s, response, jqXHR, isSuccess ) {
  15401. var conv2, current, conv, tmp, prev,
  15402. converters = {},
  15403. // Work with a copy of dataTypes in case we need to modify it for conversion
  15404. dataTypes = s.dataTypes.slice();
  15405. // Create converters map with lowercased keys
  15406. if ( dataTypes[ 1 ] ) {
  15407. for ( conv in s.converters ) {
  15408. converters[ conv.toLowerCase() ] = s.converters[ conv ];
  15409. }
  15410. }
  15411. current = dataTypes.shift();
  15412. // Convert to each sequential dataType
  15413. while ( current ) {
  15414. if ( s.responseFields[ current ] ) {
  15415. jqXHR[ s.responseFields[ current ] ] = response;
  15416. }
  15417. // Apply the dataFilter if provided
  15418. if ( !prev && isSuccess && s.dataFilter ) {
  15419. response = s.dataFilter( response, s.dataType );
  15420. }
  15421. prev = current;
  15422. current = dataTypes.shift();
  15423. if ( current ) {
  15424. // There's only work to do if current dataType is non-auto
  15425. if ( current === "*" ) {
  15426. current = prev;
  15427. // Convert response if prev dataType is non-auto and differs from current
  15428. } else if ( prev !== "*" && prev !== current ) {
  15429. // Seek a direct converter
  15430. conv = converters[ prev + " " + current ] || converters[ "* " + current ];
  15431. // If none found, seek a pair
  15432. if ( !conv ) {
  15433. for ( conv2 in converters ) {
  15434. // If conv2 outputs current
  15435. tmp = conv2.split( " " );
  15436. if ( tmp[ 1 ] === current ) {
  15437. // If prev can be converted to accepted input
  15438. conv = converters[ prev + " " + tmp[ 0 ] ] ||
  15439. converters[ "* " + tmp[ 0 ] ];
  15440. if ( conv ) {
  15441. // Condense equivalence converters
  15442. if ( conv === true ) {
  15443. conv = converters[ conv2 ];
  15444. // Otherwise, insert the intermediate dataType
  15445. } else if ( converters[ conv2 ] !== true ) {
  15446. current = tmp[ 0 ];
  15447. dataTypes.unshift( tmp[ 1 ] );
  15448. }
  15449. break;
  15450. }
  15451. }
  15452. }
  15453. }
  15454. // Apply converter (if not an equivalence)
  15455. if ( conv !== true ) {
  15456. // Unless errors are allowed to bubble, catch and return them
  15457. if ( conv && s.throws ) {
  15458. response = conv( response );
  15459. } else {
  15460. try {
  15461. response = conv( response );
  15462. } catch ( e ) {
  15463. return {
  15464. state: "parsererror",
  15465. error: conv ? e : "No conversion from " + prev + " to " + current
  15466. };
  15467. }
  15468. }
  15469. }
  15470. }
  15471. }
  15472. }
  15473. return { state: "success", data: response };
  15474. }
  15475. jQuery.extend( {
  15476. // Counter for holding the number of active queries
  15477. active: 0,
  15478. // Last-Modified header cache for next request
  15479. lastModified: {},
  15480. etag: {},
  15481. ajaxSettings: {
  15482. url: location.href,
  15483. type: "GET",
  15484. isLocal: rlocalProtocol.test( location.protocol ),
  15485. global: true,
  15486. processData: true,
  15487. async: true,
  15488. contentType: "application/x-www-form-urlencoded; charset=UTF-8",
  15489. /*
  15490. timeout: 0,
  15491. data: null,
  15492. dataType: null,
  15493. username: null,
  15494. password: null,
  15495. cache: null,
  15496. throws: false,
  15497. traditional: false,
  15498. headers: {},
  15499. */
  15500. accepts: {
  15501. "*": allTypes,
  15502. text: "text/plain",
  15503. html: "text/html",
  15504. xml: "application/xml, text/xml",
  15505. json: "application/json, text/javascript"
  15506. },
  15507. contents: {
  15508. xml: /\bxml\b/,
  15509. html: /\bhtml/,
  15510. json: /\bjson\b/
  15511. },
  15512. responseFields: {
  15513. xml: "responseXML",
  15514. text: "responseText",
  15515. json: "responseJSON"
  15516. },
  15517. // Data converters
  15518. // Keys separate source (or catchall "*") and destination types with a single space
  15519. converters: {
  15520. // Convert anything to text
  15521. "* text": String,
  15522. // Text to html (true = no transformation)
  15523. "text html": true,
  15524. // Evaluate text as a json expression
  15525. "text json": JSON.parse,
  15526. // Parse text as xml
  15527. "text xml": jQuery.parseXML
  15528. },
  15529. // For options that shouldn't be deep extended:
  15530. // you can add your own custom options here if
  15531. // and when you create one that shouldn't be
  15532. // deep extended (see ajaxExtend)
  15533. flatOptions: {
  15534. url: true,
  15535. context: true
  15536. }
  15537. },
  15538. // Creates a full fledged settings object into target
  15539. // with both ajaxSettings and settings fields.
  15540. // If target is omitted, writes into ajaxSettings.
  15541. ajaxSetup: function( target, settings ) {
  15542. return settings ?
  15543. // Building a settings object
  15544. ajaxExtend( ajaxExtend( target, jQuery.ajaxSettings ), settings ) :
  15545. // Extending ajaxSettings
  15546. ajaxExtend( jQuery.ajaxSettings, target );
  15547. },
  15548. ajaxPrefilter: addToPrefiltersOrTransports( prefilters ),
  15549. ajaxTransport: addToPrefiltersOrTransports( transports ),
  15550. // Main method
  15551. ajax: function( url, options ) {
  15552. // If url is an object, simulate pre-1.5 signature
  15553. if ( typeof url === "object" ) {
  15554. options = url;
  15555. url = undefined;
  15556. }
  15557. // Force options to be an object
  15558. options = options || {};
  15559. var transport,
  15560. // URL without anti-cache param
  15561. cacheURL,
  15562. // Response headers
  15563. responseHeadersString,
  15564. responseHeaders,
  15565. // timeout handle
  15566. timeoutTimer,
  15567. // Url cleanup var
  15568. urlAnchor,
  15569. // Request state (becomes false upon send and true upon completion)
  15570. completed,
  15571. // To know if global events are to be dispatched
  15572. fireGlobals,
  15573. // Loop variable
  15574. i,
  15575. // uncached part of the url
  15576. uncached,
  15577. // Create the final options object
  15578. s = jQuery.ajaxSetup( {}, options ),
  15579. // Callbacks context
  15580. callbackContext = s.context || s,
  15581. // Context for global events is callbackContext if it is a DOM node or jQuery collection
  15582. globalEventContext = s.context &&
  15583. ( callbackContext.nodeType || callbackContext.jquery ) ?
  15584. jQuery( callbackContext ) :
  15585. jQuery.event,
  15586. // Deferreds
  15587. deferred = jQuery.Deferred(),
  15588. completeDeferred = jQuery.Callbacks( "once memory" ),
  15589. // Status-dependent callbacks
  15590. statusCode = s.statusCode || {},
  15591. // Headers (they are sent all at once)
  15592. requestHeaders = {},
  15593. requestHeadersNames = {},
  15594. // Default abort message
  15595. strAbort = "canceled",
  15596. // Fake xhr
  15597. jqXHR = {
  15598. readyState: 0,
  15599. // Builds headers hashtable if needed
  15600. getResponseHeader: function( key ) {
  15601. var match;
  15602. if ( completed ) {
  15603. if ( !responseHeaders ) {
  15604. responseHeaders = {};
  15605. while ( ( match = rheaders.exec( responseHeadersString ) ) ) {
  15606. responseHeaders[ match[ 1 ].toLowerCase() + " " ] =
  15607. ( responseHeaders[ match[ 1 ].toLowerCase() + " " ] || [] )
  15608. .concat( match[ 2 ] );
  15609. }
  15610. }
  15611. match = responseHeaders[ key.toLowerCase() + " " ];
  15612. }
  15613. return match == null ? null : match.join( ", " );
  15614. },
  15615. // Raw string
  15616. getAllResponseHeaders: function() {
  15617. return completed ? responseHeadersString : null;
  15618. },
  15619. // Caches the header
  15620. setRequestHeader: function( name, value ) {
  15621. if ( completed == null ) {
  15622. name = requestHeadersNames[ name.toLowerCase() ] =
  15623. requestHeadersNames[ name.toLowerCase() ] || name;
  15624. requestHeaders[ name ] = value;
  15625. }
  15626. return this;
  15627. },
  15628. // Overrides response content-type header
  15629. overrideMimeType: function( type ) {
  15630. if ( completed == null ) {
  15631. s.mimeType = type;
  15632. }
  15633. return this;
  15634. },
  15635. // Status-dependent callbacks
  15636. statusCode: function( map ) {
  15637. var code;
  15638. if ( map ) {
  15639. if ( completed ) {
  15640. // Execute the appropriate callbacks
  15641. jqXHR.always( map[ jqXHR.status ] );
  15642. } else {
  15643. // Lazy-add the new callbacks in a way that preserves old ones
  15644. for ( code in map ) {
  15645. statusCode[ code ] = [ statusCode[ code ], map[ code ] ];
  15646. }
  15647. }
  15648. }
  15649. return this;
  15650. },
  15651. // Cancel the request
  15652. abort: function( statusText ) {
  15653. var finalText = statusText || strAbort;
  15654. if ( transport ) {
  15655. transport.abort( finalText );
  15656. }
  15657. done( 0, finalText );
  15658. return this;
  15659. }
  15660. };
  15661. // Attach deferreds
  15662. deferred.promise( jqXHR );
  15663. // Add protocol if not provided (prefilters might expect it)
  15664. // Handle falsy url in the settings object (#10093: consistency with old signature)
  15665. // We also use the url parameter if available
  15666. s.url = ( ( url || s.url || location.href ) + "" )
  15667. .replace( rprotocol, location.protocol + "//" );
  15668. // Alias method option to type as per ticket #12004
  15669. s.type = options.method || options.type || s.method || s.type;
  15670. // Extract dataTypes list
  15671. s.dataTypes = ( s.dataType || "*" ).toLowerCase().match( rnothtmlwhite ) || [ "" ];
  15672. // A cross-domain request is in order when the origin doesn't match the current origin.
  15673. if ( s.crossDomain == null ) {
  15674. urlAnchor = document.createElement( "a" );
  15675. // Support: IE <=8 - 11, Edge 12 - 15
  15676. // IE throws exception on accessing the href property if url is malformed,
  15677. // e.g. http://example.com:80x/
  15678. try {
  15679. urlAnchor.href = s.url;
  15680. // Support: IE <=8 - 11 only
  15681. // Anchor's host property isn't correctly set when s.url is relative
  15682. urlAnchor.href = urlAnchor.href;
  15683. s.crossDomain = originAnchor.protocol + "//" + originAnchor.host !==
  15684. urlAnchor.protocol + "//" + urlAnchor.host;
  15685. } catch ( e ) {
  15686. // If there is an error parsing the URL, assume it is crossDomain,
  15687. // it can be rejected by the transport if it is invalid
  15688. s.crossDomain = true;
  15689. }
  15690. }
  15691. // Convert data if not already a string
  15692. if ( s.data && s.processData && typeof s.data !== "string" ) {
  15693. s.data = jQuery.param( s.data, s.traditional );
  15694. }
  15695. // Apply prefilters
  15696. inspectPrefiltersOrTransports( prefilters, s, options, jqXHR );
  15697. // If request was aborted inside a prefilter, stop there
  15698. if ( completed ) {
  15699. return jqXHR;
  15700. }
  15701. // We can fire global events as of now if asked to
  15702. // Don't fire events if jQuery.event is undefined in an AMD-usage scenario (#15118)
  15703. fireGlobals = jQuery.event && s.global;
  15704. // Watch for a new set of requests
  15705. if ( fireGlobals && jQuery.active++ === 0 ) {
  15706. jQuery.event.trigger( "ajaxStart" );
  15707. }
  15708. // Uppercase the type
  15709. s.type = s.type.toUpperCase();
  15710. // Determine if request has content
  15711. s.hasContent = !rnoContent.test( s.type );
  15712. // Save the URL in case we're toying with the If-Modified-Since
  15713. // and/or If-None-Match header later on
  15714. // Remove hash to simplify url manipulation
  15715. cacheURL = s.url.replace( rhash, "" );
  15716. // More options handling for requests with no content
  15717. if ( !s.hasContent ) {
  15718. // Remember the hash so we can put it back
  15719. uncached = s.url.slice( cacheURL.length );
  15720. // If data is available and should be processed, append data to url
  15721. if ( s.data && ( s.processData || typeof s.data === "string" ) ) {
  15722. cacheURL += ( rquery.test( cacheURL ) ? "&" : "?" ) + s.data;
  15723. // #9682: remove data so that it's not used in an eventual retry
  15724. delete s.data;
  15725. }
  15726. // Add or update anti-cache param if needed
  15727. if ( s.cache === false ) {
  15728. cacheURL = cacheURL.replace( rantiCache, "$1" );
  15729. uncached = ( rquery.test( cacheURL ) ? "&" : "?" ) + "_=" + ( nonce++ ) + uncached;
  15730. }
  15731. // Put hash and anti-cache on the URL that will be requested (gh-1732)
  15732. s.url = cacheURL + uncached;
  15733. // Change '%20' to '+' if this is encoded form body content (gh-2658)
  15734. } else if ( s.data && s.processData &&
  15735. ( s.contentType || "" ).indexOf( "application/x-www-form-urlencoded" ) === 0 ) {
  15736. s.data = s.data.replace( r20, "+" );
  15737. }
  15738. // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
  15739. if ( s.ifModified ) {
  15740. if ( jQuery.lastModified[ cacheURL ] ) {
  15741. jqXHR.setRequestHeader( "If-Modified-Since", jQuery.lastModified[ cacheURL ] );
  15742. }
  15743. if ( jQuery.etag[ cacheURL ] ) {
  15744. jqXHR.setRequestHeader( "If-None-Match", jQuery.etag[ cacheURL ] );
  15745. }
  15746. }
  15747. // Set the correct header, if data is being sent
  15748. if ( s.data && s.hasContent && s.contentType !== false || options.contentType ) {
  15749. jqXHR.setRequestHeader( "Content-Type", s.contentType );
  15750. }
  15751. // Set the Accepts header for the server, depending on the dataType
  15752. jqXHR.setRequestHeader(
  15753. "Accept",
  15754. s.dataTypes[ 0 ] && s.accepts[ s.dataTypes[ 0 ] ] ?
  15755. s.accepts[ s.dataTypes[ 0 ] ] +
  15756. ( s.dataTypes[ 0 ] !== "*" ? ", " + allTypes + "; q=0.01" : "" ) :
  15757. s.accepts[ "*" ]
  15758. );
  15759. // Check for headers option
  15760. for ( i in s.headers ) {
  15761. jqXHR.setRequestHeader( i, s.headers[ i ] );
  15762. }
  15763. // Allow custom headers/mimetypes and early abort
  15764. if ( s.beforeSend &&
  15765. ( s.beforeSend.call( callbackContext, jqXHR, s ) === false || completed ) ) {
  15766. // Abort if not done already and return
  15767. return jqXHR.abort();
  15768. }
  15769. // Aborting is no longer a cancellation
  15770. strAbort = "abort";
  15771. // Install callbacks on deferreds
  15772. completeDeferred.add( s.complete );
  15773. jqXHR.done( s.success );
  15774. jqXHR.fail( s.error );
  15775. // Get transport
  15776. transport = inspectPrefiltersOrTransports( transports, s, options, jqXHR );
  15777. // If no transport, we auto-abort
  15778. if ( !transport ) {
  15779. done( -1, "No Transport" );
  15780. } else {
  15781. jqXHR.readyState = 1;
  15782. // Send global event
  15783. if ( fireGlobals ) {
  15784. globalEventContext.trigger( "ajaxSend", [ jqXHR, s ] );
  15785. }
  15786. // If request was aborted inside ajaxSend, stop there
  15787. if ( completed ) {
  15788. return jqXHR;
  15789. }
  15790. // Timeout
  15791. if ( s.async && s.timeout > 0 ) {
  15792. timeoutTimer = window.setTimeout( function() {
  15793. jqXHR.abort( "timeout" );
  15794. }, s.timeout );
  15795. }
  15796. try {
  15797. completed = false;
  15798. transport.send( requestHeaders, done );
  15799. } catch ( e ) {
  15800. // Rethrow post-completion exceptions
  15801. if ( completed ) {
  15802. throw e;
  15803. }
  15804. // Propagate others as results
  15805. done( -1, e );
  15806. }
  15807. }
  15808. // Callback for when everything is done
  15809. function done( status, nativeStatusText, responses, headers ) {
  15810. var isSuccess, success, error, response, modified,
  15811. statusText = nativeStatusText;
  15812. // Ignore repeat invocations
  15813. if ( completed ) {
  15814. return;
  15815. }
  15816. completed = true;
  15817. // Clear timeout if it exists
  15818. if ( timeoutTimer ) {
  15819. window.clearTimeout( timeoutTimer );
  15820. }
  15821. // Dereference transport for early garbage collection
  15822. // (no matter how long the jqXHR object will be used)
  15823. transport = undefined;
  15824. // Cache response headers
  15825. responseHeadersString = headers || "";
  15826. // Set readyState
  15827. jqXHR.readyState = status > 0 ? 4 : 0;
  15828. // Determine if successful
  15829. isSuccess = status >= 200 && status < 300 || status === 304;
  15830. // Get response data
  15831. if ( responses ) {
  15832. response = ajaxHandleResponses( s, jqXHR, responses );
  15833. }
  15834. // Convert no matter what (that way responseXXX fields are always set)
  15835. response = ajaxConvert( s, response, jqXHR, isSuccess );
  15836. // If successful, handle type chaining
  15837. if ( isSuccess ) {
  15838. // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
  15839. if ( s.ifModified ) {
  15840. modified = jqXHR.getResponseHeader( "Last-Modified" );
  15841. if ( modified ) {
  15842. jQuery.lastModified[ cacheURL ] = modified;
  15843. }
  15844. modified = jqXHR.getResponseHeader( "etag" );
  15845. if ( modified ) {
  15846. jQuery.etag[ cacheURL ] = modified;
  15847. }
  15848. }
  15849. // if no content
  15850. if ( status === 204 || s.type === "HEAD" ) {
  15851. statusText = "nocontent";
  15852. // if not modified
  15853. } else if ( status === 304 ) {
  15854. statusText = "notmodified";
  15855. // If we have data, let's convert it
  15856. } else {
  15857. statusText = response.state;
  15858. success = response.data;
  15859. error = response.error;
  15860. isSuccess = !error;
  15861. }
  15862. } else {
  15863. // Extract error from statusText and normalize for non-aborts
  15864. error = statusText;
  15865. if ( status || !statusText ) {
  15866. statusText = "error";
  15867. if ( status < 0 ) {
  15868. status = 0;
  15869. }
  15870. }
  15871. }
  15872. // Set data for the fake xhr object
  15873. jqXHR.status = status;
  15874. jqXHR.statusText = ( nativeStatusText || statusText ) + "";
  15875. // Success/Error
  15876. if ( isSuccess ) {
  15877. deferred.resolveWith( callbackContext, [ success, statusText, jqXHR ] );
  15878. } else {
  15879. deferred.rejectWith( callbackContext, [ jqXHR, statusText, error ] );
  15880. }
  15881. // Status-dependent callbacks
  15882. jqXHR.statusCode( statusCode );
  15883. statusCode = undefined;
  15884. if ( fireGlobals ) {
  15885. globalEventContext.trigger( isSuccess ? "ajaxSuccess" : "ajaxError",
  15886. [ jqXHR, s, isSuccess ? success : error ] );
  15887. }
  15888. // Complete
  15889. completeDeferred.fireWith( callbackContext, [ jqXHR, statusText ] );
  15890. if ( fireGlobals ) {
  15891. globalEventContext.trigger( "ajaxComplete", [ jqXHR, s ] );
  15892. // Handle the global AJAX counter
  15893. if ( !( --jQuery.active ) ) {
  15894. jQuery.event.trigger( "ajaxStop" );
  15895. }
  15896. }
  15897. }
  15898. return jqXHR;
  15899. },
  15900. getJSON: function( url, data, callback ) {
  15901. return jQuery.get( url, data, callback, "json" );
  15902. },
  15903. getScript: function( url, callback ) {
  15904. return jQuery.get( url, undefined, callback, "script" );
  15905. }
  15906. } );
  15907. jQuery.each( [ "get", "post" ], function( i, method ) {
  15908. jQuery[ method ] = function( url, data, callback, type ) {
  15909. // Shift arguments if data argument was omitted
  15910. if ( isFunction( data ) ) {
  15911. type = type || callback;
  15912. callback = data;
  15913. data = undefined;
  15914. }
  15915. // The url can be an options object (which then must have .url)
  15916. return jQuery.ajax( jQuery.extend( {
  15917. url: url,
  15918. type: method,
  15919. dataType: type,
  15920. data: data,
  15921. success: callback
  15922. }, jQuery.isPlainObject( url ) && url ) );
  15923. };
  15924. } );
  15925. jQuery._evalUrl = function( url, options ) {
  15926. return jQuery.ajax( {
  15927. url: url,
  15928. // Make this explicit, since user can override this through ajaxSetup (#11264)
  15929. type: "GET",
  15930. dataType: "script",
  15931. cache: true,
  15932. async: false,
  15933. global: false,
  15934. // Only evaluate the response if it is successful (gh-4126)
  15935. // dataFilter is not invoked for failure responses, so using it instead
  15936. // of the default converter is kludgy but it works.
  15937. converters: {
  15938. "text script": function() {}
  15939. },
  15940. dataFilter: function( response ) {
  15941. jQuery.globalEval( response, options );
  15942. }
  15943. } );
  15944. };
  15945. jQuery.fn.extend( {
  15946. wrapAll: function( html ) {
  15947. var wrap;
  15948. if ( this[ 0 ] ) {
  15949. if ( isFunction( html ) ) {
  15950. html = html.call( this[ 0 ] );
  15951. }
  15952. // The elements to wrap the target around
  15953. wrap = jQuery( html, this[ 0 ].ownerDocument ).eq( 0 ).clone( true );
  15954. if ( this[ 0 ].parentNode ) {
  15955. wrap.insertBefore( this[ 0 ] );
  15956. }
  15957. wrap.map( function() {
  15958. var elem = this;
  15959. while ( elem.firstElementChild ) {
  15960. elem = elem.firstElementChild;
  15961. }
  15962. return elem;
  15963. } ).append( this );
  15964. }
  15965. return this;
  15966. },
  15967. wrapInner: function( html ) {
  15968. if ( isFunction( html ) ) {
  15969. return this.each( function( i ) {
  15970. jQuery( this ).wrapInner( html.call( this, i ) );
  15971. } );
  15972. }
  15973. return this.each( function() {
  15974. var self = jQuery( this ),
  15975. contents = self.contents();
  15976. if ( contents.length ) {
  15977. contents.wrapAll( html );
  15978. } else {
  15979. self.append( html );
  15980. }
  15981. } );
  15982. },
  15983. wrap: function( html ) {
  15984. var htmlIsFunction = isFunction( html );
  15985. return this.each( function( i ) {
  15986. jQuery( this ).wrapAll( htmlIsFunction ? html.call( this, i ) : html );
  15987. } );
  15988. },
  15989. unwrap: function( selector ) {
  15990. this.parent( selector ).not( "body" ).each( function() {
  15991. jQuery( this ).replaceWith( this.childNodes );
  15992. } );
  15993. return this;
  15994. }
  15995. } );
  15996. jQuery.expr.pseudos.hidden = function( elem ) {
  15997. return !jQuery.expr.pseudos.visible( elem );
  15998. };
  15999. jQuery.expr.pseudos.visible = function( elem ) {
  16000. return !!( elem.offsetWidth || elem.offsetHeight || elem.getClientRects().length );
  16001. };
  16002. jQuery.ajaxSettings.xhr = function() {
  16003. try {
  16004. return new window.XMLHttpRequest();
  16005. } catch ( e ) {}
  16006. };
  16007. var xhrSuccessStatus = {
  16008. // File protocol always yields status code 0, assume 200
  16009. 0: 200,
  16010. // Support: IE <=9 only
  16011. // #1450: sometimes IE returns 1223 when it should be 204
  16012. 1223: 204
  16013. },
  16014. xhrSupported = jQuery.ajaxSettings.xhr();
  16015. support.cors = !!xhrSupported && ( "withCredentials" in xhrSupported );
  16016. support.ajax = xhrSupported = !!xhrSupported;
  16017. jQuery.ajaxTransport( function( options ) {
  16018. var callback, errorCallback;
  16019. // Cross domain only allowed if supported through XMLHttpRequest
  16020. if ( support.cors || xhrSupported && !options.crossDomain ) {
  16021. return {
  16022. send: function( headers, complete ) {
  16023. var i,
  16024. xhr = options.xhr();
  16025. xhr.open(
  16026. options.type,
  16027. options.url,
  16028. options.async,
  16029. options.username,
  16030. options.password
  16031. );
  16032. // Apply custom fields if provided
  16033. if ( options.xhrFields ) {
  16034. for ( i in options.xhrFields ) {
  16035. xhr[ i ] = options.xhrFields[ i ];
  16036. }
  16037. }
  16038. // Override mime type if needed
  16039. if ( options.mimeType && xhr.overrideMimeType ) {
  16040. xhr.overrideMimeType( options.mimeType );
  16041. }
  16042. // X-Requested-With header
  16043. // For cross-domain requests, seeing as conditions for a preflight are
  16044. // akin to a jigsaw puzzle, we simply never set it to be sure.
  16045. // (it can always be set on a per-request basis or even using ajaxSetup)
  16046. // For same-domain requests, won't change header if already provided.
  16047. if ( !options.crossDomain && !headers[ "X-Requested-With" ] ) {
  16048. headers[ "X-Requested-With" ] = "XMLHttpRequest";
  16049. }
  16050. // Set headers
  16051. for ( i in headers ) {
  16052. xhr.setRequestHeader( i, headers[ i ] );
  16053. }
  16054. // Callback
  16055. callback = function( type ) {
  16056. return function() {
  16057. if ( callback ) {
  16058. callback = errorCallback = xhr.onload =
  16059. xhr.onerror = xhr.onabort = xhr.ontimeout =
  16060. xhr.onreadystatechange = null;
  16061. if ( type === "abort" ) {
  16062. xhr.abort();
  16063. } else if ( type === "error" ) {
  16064. // Support: IE <=9 only
  16065. // On a manual native abort, IE9 throws
  16066. // errors on any property access that is not readyState
  16067. if ( typeof xhr.status !== "number" ) {
  16068. complete( 0, "error" );
  16069. } else {
  16070. complete(
  16071. // File: protocol always yields status 0; see #8605, #14207
  16072. xhr.status,
  16073. xhr.statusText
  16074. );
  16075. }
  16076. } else {
  16077. complete(
  16078. xhrSuccessStatus[ xhr.status ] || xhr.status,
  16079. xhr.statusText,
  16080. // Support: IE <=9 only
  16081. // IE9 has no XHR2 but throws on binary (trac-11426)
  16082. // For XHR2 non-text, let the caller handle it (gh-2498)
  16083. ( xhr.responseType || "text" ) !== "text" ||
  16084. typeof xhr.responseText !== "string" ?
  16085. { binary: xhr.response } :
  16086. { text: xhr.responseText },
  16087. xhr.getAllResponseHeaders()
  16088. );
  16089. }
  16090. }
  16091. };
  16092. };
  16093. // Listen to events
  16094. xhr.onload = callback();
  16095. errorCallback = xhr.onerror = xhr.ontimeout = callback( "error" );
  16096. // Support: IE 9 only
  16097. // Use onreadystatechange to replace onabort
  16098. // to handle uncaught aborts
  16099. if ( xhr.onabort !== undefined ) {
  16100. xhr.onabort = errorCallback;
  16101. } else {
  16102. xhr.onreadystatechange = function() {
  16103. // Check readyState before timeout as it changes
  16104. if ( xhr.readyState === 4 ) {
  16105. // Allow onerror to be called first,
  16106. // but that will not handle a native abort
  16107. // Also, save errorCallback to a variable
  16108. // as xhr.onerror cannot be accessed
  16109. window.setTimeout( function() {
  16110. if ( callback ) {
  16111. errorCallback();
  16112. }
  16113. } );
  16114. }
  16115. };
  16116. }
  16117. // Create the abort callback
  16118. callback = callback( "abort" );
  16119. try {
  16120. // Do send the request (this may raise an exception)
  16121. xhr.send( options.hasContent && options.data || null );
  16122. } catch ( e ) {
  16123. // #14683: Only rethrow if this hasn't been notified as an error yet
  16124. if ( callback ) {
  16125. throw e;
  16126. }
  16127. }
  16128. },
  16129. abort: function() {
  16130. if ( callback ) {
  16131. callback();
  16132. }
  16133. }
  16134. };
  16135. }
  16136. } );
  16137. // Prevent auto-execution of scripts when no explicit dataType was provided (See gh-2432)
  16138. jQuery.ajaxPrefilter( function( s ) {
  16139. if ( s.crossDomain ) {
  16140. s.contents.script = false;
  16141. }
  16142. } );
  16143. // Install script dataType
  16144. jQuery.ajaxSetup( {
  16145. accepts: {
  16146. script: "text/javascript, application/javascript, " +
  16147. "application/ecmascript, application/x-ecmascript"
  16148. },
  16149. contents: {
  16150. script: /\b(?:java|ecma)script\b/
  16151. },
  16152. converters: {
  16153. "text script": function( text ) {
  16154. jQuery.globalEval( text );
  16155. return text;
  16156. }
  16157. }
  16158. } );
  16159. // Handle cache's special case and crossDomain
  16160. jQuery.ajaxPrefilter( "script", function( s ) {
  16161. if ( s.cache === undefined ) {
  16162. s.cache = false;
  16163. }
  16164. if ( s.crossDomain ) {
  16165. s.type = "GET";
  16166. }
  16167. } );
  16168. // Bind script tag hack transport
  16169. jQuery.ajaxTransport( "script", function( s ) {
  16170. // This transport only deals with cross domain or forced-by-attrs requests
  16171. if ( s.crossDomain || s.scriptAttrs ) {
  16172. var script, callback;
  16173. return {
  16174. send: function( _, complete ) {
  16175. script = jQuery( "<script>" )
  16176. .attr( s.scriptAttrs || {} )
  16177. .prop( { charset: s.scriptCharset, src: s.url } )
  16178. .on( "load error", callback = function( evt ) {
  16179. script.remove();
  16180. callback = null;
  16181. if ( evt ) {
  16182. complete( evt.type === "error" ? 404 : 200, evt.type );
  16183. }
  16184. } );
  16185. // Use native DOM manipulation to avoid our domManip AJAX trickery
  16186. document.head.appendChild( script[ 0 ] );
  16187. },
  16188. abort: function() {
  16189. if ( callback ) {
  16190. callback();
  16191. }
  16192. }
  16193. };
  16194. }
  16195. } );
  16196. var oldCallbacks = [],
  16197. rjsonp = /(=)\?(?=&|$)|\?\?/;
  16198. // Default jsonp settings
  16199. jQuery.ajaxSetup( {
  16200. jsonp: "callback",
  16201. jsonpCallback: function() {
  16202. var callback = oldCallbacks.pop() || ( jQuery.expando + "_" + ( nonce++ ) );
  16203. this[ callback ] = true;
  16204. return callback;
  16205. }
  16206. } );
  16207. // Detect, normalize options and install callbacks for jsonp requests
  16208. jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) {
  16209. var callbackName, overwritten, responseContainer,
  16210. jsonProp = s.jsonp !== false && ( rjsonp.test( s.url ) ?
  16211. "url" :
  16212. typeof s.data === "string" &&
  16213. ( s.contentType || "" )
  16214. .indexOf( "application/x-www-form-urlencoded" ) === 0 &&
  16215. rjsonp.test( s.data ) && "data"
  16216. );
  16217. // Handle iff the expected data type is "jsonp" or we have a parameter to set
  16218. if ( jsonProp || s.dataTypes[ 0 ] === "jsonp" ) {
  16219. // Get callback name, remembering preexisting value associated with it
  16220. callbackName = s.jsonpCallback = isFunction( s.jsonpCallback ) ?
  16221. s.jsonpCallback() :
  16222. s.jsonpCallback;
  16223. // Insert callback into url or form data
  16224. if ( jsonProp ) {
  16225. s[ jsonProp ] = s[ jsonProp ].replace( rjsonp, "$1" + callbackName );
  16226. } else if ( s.jsonp !== false ) {
  16227. s.url += ( rquery.test( s.url ) ? "&" : "?" ) + s.jsonp + "=" + callbackName;
  16228. }
  16229. // Use data converter to retrieve json after script execution
  16230. s.converters[ "script json" ] = function() {
  16231. if ( !responseContainer ) {
  16232. jQuery.error( callbackName + " was not called" );
  16233. }
  16234. return responseContainer[ 0 ];
  16235. };
  16236. // Force json dataType
  16237. s.dataTypes[ 0 ] = "json";
  16238. // Install callback
  16239. overwritten = window[ callbackName ];
  16240. window[ callbackName ] = function() {
  16241. responseContainer = arguments;
  16242. };
  16243. // Clean-up function (fires after converters)
  16244. jqXHR.always( function() {
  16245. // If previous value didn't exist - remove it
  16246. if ( overwritten === undefined ) {
  16247. jQuery( window ).removeProp( callbackName );
  16248. // Otherwise restore preexisting value
  16249. } else {
  16250. window[ callbackName ] = overwritten;
  16251. }
  16252. // Save back as free
  16253. if ( s[ callbackName ] ) {
  16254. // Make sure that re-using the options doesn't screw things around
  16255. s.jsonpCallback = originalSettings.jsonpCallback;
  16256. // Save the callback name for future use
  16257. oldCallbacks.push( callbackName );
  16258. }
  16259. // Call if it was a function and we have a response
  16260. if ( responseContainer && isFunction( overwritten ) ) {
  16261. overwritten( responseContainer[ 0 ] );
  16262. }
  16263. responseContainer = overwritten = undefined;
  16264. } );
  16265. // Delegate to script
  16266. return "script";
  16267. }
  16268. } );
  16269. // Support: Safari 8 only
  16270. // In Safari 8 documents created via document.implementation.createHTMLDocument
  16271. // collapse sibling forms: the second one becomes a child of the first one.
  16272. // Because of that, this security measure has to be disabled in Safari 8.
  16273. // https://bugs.webkit.org/show_bug.cgi?id=137337
  16274. support.createHTMLDocument = ( function() {
  16275. var body = document.implementation.createHTMLDocument( "" ).body;
  16276. body.innerHTML = "<form></form><form></form>";
  16277. return body.childNodes.length === 2;
  16278. } )();
  16279. // Argument "data" should be string of html
  16280. // context (optional): If specified, the fragment will be created in this context,
  16281. // defaults to document
  16282. // keepScripts (optional): If true, will include scripts passed in the html string
  16283. jQuery.parseHTML = function( data, context, keepScripts ) {
  16284. if ( typeof data !== "string" ) {
  16285. return [];
  16286. }
  16287. if ( typeof context === "boolean" ) {
  16288. keepScripts = context;
  16289. context = false;
  16290. }
  16291. var base, parsed, scripts;
  16292. if ( !context ) {
  16293. // Stop scripts or inline event handlers from being executed immediately
  16294. // by using document.implementation
  16295. if ( support.createHTMLDocument ) {
  16296. context = document.implementation.createHTMLDocument( "" );
  16297. // Set the base href for the created document
  16298. // so any parsed elements with URLs
  16299. // are based on the document's URL (gh-2965)
  16300. base = context.createElement( "base" );
  16301. base.href = document.location.href;
  16302. context.head.appendChild( base );
  16303. } else {
  16304. context = document;
  16305. }
  16306. }
  16307. parsed = rsingleTag.exec( data );
  16308. scripts = !keepScripts && [];
  16309. // Single tag
  16310. if ( parsed ) {
  16311. return [ context.createElement( parsed[ 1 ] ) ];
  16312. }
  16313. parsed = buildFragment( [ data ], context, scripts );
  16314. if ( scripts && scripts.length ) {
  16315. jQuery( scripts ).remove();
  16316. }
  16317. return jQuery.merge( [], parsed.childNodes );
  16318. };
  16319. /**
  16320. * Load a url into a page
  16321. */
  16322. jQuery.fn.load = function( url, params, callback ) {
  16323. var selector, type, response,
  16324. self = this,
  16325. off = url.indexOf( " " );
  16326. if ( off > -1 ) {
  16327. selector = stripAndCollapse( url.slice( off ) );
  16328. url = url.slice( 0, off );
  16329. }
  16330. // If it's a function
  16331. if ( isFunction( params ) ) {
  16332. // We assume that it's the callback
  16333. callback = params;
  16334. params = undefined;
  16335. // Otherwise, build a param string
  16336. } else if ( params && typeof params === "object" ) {
  16337. type = "POST";
  16338. }
  16339. // If we have elements to modify, make the request
  16340. if ( self.length > 0 ) {
  16341. jQuery.ajax( {
  16342. url: url,
  16343. // If "type" variable is undefined, then "GET" method will be used.
  16344. // Make value of this field explicit since
  16345. // user can override it through ajaxSetup method
  16346. type: type || "GET",
  16347. dataType: "html",
  16348. data: params
  16349. } ).done( function( responseText ) {
  16350. // Save response for use in complete callback
  16351. response = arguments;
  16352. self.html( selector ?
  16353. // If a selector was specified, locate the right elements in a dummy div
  16354. // Exclude scripts to avoid IE 'Permission Denied' errors
  16355. jQuery( "<div>" ).append( jQuery.parseHTML( responseText ) ).find( selector ) :
  16356. // Otherwise use the full result
  16357. responseText );
  16358. // If the request succeeds, this function gets "data", "status", "jqXHR"
  16359. // but they are ignored because response was set above.
  16360. // If it fails, this function gets "jqXHR", "status", "error"
  16361. } ).always( callback && function( jqXHR, status ) {
  16362. self.each( function() {
  16363. callback.apply( this, response || [ jqXHR.responseText, status, jqXHR ] );
  16364. } );
  16365. } );
  16366. }
  16367. return this;
  16368. };
  16369. // Attach a bunch of functions for handling common AJAX events
  16370. jQuery.each( [
  16371. "ajaxStart",
  16372. "ajaxStop",
  16373. "ajaxComplete",
  16374. "ajaxError",
  16375. "ajaxSuccess",
  16376. "ajaxSend"
  16377. ], function( i, type ) {
  16378. jQuery.fn[ type ] = function( fn ) {
  16379. return this.on( type, fn );
  16380. };
  16381. } );
  16382. jQuery.expr.pseudos.animated = function( elem ) {
  16383. return jQuery.grep( jQuery.timers, function( fn ) {
  16384. return elem === fn.elem;
  16385. } ).length;
  16386. };
  16387. jQuery.offset = {
  16388. setOffset: function( elem, options, i ) {
  16389. var curPosition, curLeft, curCSSTop, curTop, curOffset, curCSSLeft, calculatePosition,
  16390. position = jQuery.css( elem, "position" ),
  16391. curElem = jQuery( elem ),
  16392. props = {};
  16393. // Set position first, in-case top/left are set even on static elem
  16394. if ( position === "static" ) {
  16395. elem.style.position = "relative";
  16396. }
  16397. curOffset = curElem.offset();
  16398. curCSSTop = jQuery.css( elem, "top" );
  16399. curCSSLeft = jQuery.css( elem, "left" );
  16400. calculatePosition = ( position === "absolute" || position === "fixed" ) &&
  16401. ( curCSSTop + curCSSLeft ).indexOf( "auto" ) > -1;
  16402. // Need to be able to calculate position if either
  16403. // top or left is auto and position is either absolute or fixed
  16404. if ( calculatePosition ) {
  16405. curPosition = curElem.position();
  16406. curTop = curPosition.top;
  16407. curLeft = curPosition.left;
  16408. } else {
  16409. curTop = parseFloat( curCSSTop ) || 0;
  16410. curLeft = parseFloat( curCSSLeft ) || 0;
  16411. }
  16412. if ( isFunction( options ) ) {
  16413. // Use jQuery.extend here to allow modification of coordinates argument (gh-1848)
  16414. options = options.call( elem, i, jQuery.extend( {}, curOffset ) );
  16415. }
  16416. if ( options.top != null ) {
  16417. props.top = ( options.top - curOffset.top ) + curTop;
  16418. }
  16419. if ( options.left != null ) {
  16420. props.left = ( options.left - curOffset.left ) + curLeft;
  16421. }
  16422. if ( "using" in options ) {
  16423. options.using.call( elem, props );
  16424. } else {
  16425. curElem.css( props );
  16426. }
  16427. }
  16428. };
  16429. jQuery.fn.extend( {
  16430. // offset() relates an element's border box to the document origin
  16431. offset: function( options ) {
  16432. // Preserve chaining for setter
  16433. if ( arguments.length ) {
  16434. return options === undefined ?
  16435. this :
  16436. this.each( function( i ) {
  16437. jQuery.offset.setOffset( this, options, i );
  16438. } );
  16439. }
  16440. var rect, win,
  16441. elem = this[ 0 ];
  16442. if ( !elem ) {
  16443. return;
  16444. }
  16445. // Return zeros for disconnected and hidden (display: none) elements (gh-2310)
  16446. // Support: IE <=11 only
  16447. // Running getBoundingClientRect on a
  16448. // disconnected node in IE throws an error
  16449. if ( !elem.getClientRects().length ) {
  16450. return { top: 0, left: 0 };
  16451. }
  16452. // Get document-relative position by adding viewport scroll to viewport-relative gBCR
  16453. rect = elem.getBoundingClientRect();
  16454. win = elem.ownerDocument.defaultView;
  16455. return {
  16456. top: rect.top + win.pageYOffset,
  16457. left: rect.left + win.pageXOffset
  16458. };
  16459. },
  16460. // position() relates an element's margin box to its offset parent's padding box
  16461. // This corresponds to the behavior of CSS absolute positioning
  16462. position: function() {
  16463. if ( !this[ 0 ] ) {
  16464. return;
  16465. }
  16466. var offsetParent, offset, doc,
  16467. elem = this[ 0 ],
  16468. parentOffset = { top: 0, left: 0 };
  16469. // position:fixed elements are offset from the viewport, which itself always has zero offset
  16470. if ( jQuery.css( elem, "position" ) === "fixed" ) {
  16471. // Assume position:fixed implies availability of getBoundingClientRect
  16472. offset = elem.getBoundingClientRect();
  16473. } else {
  16474. offset = this.offset();
  16475. // Account for the *real* offset parent, which can be the document or its root element
  16476. // when a statically positioned element is identified
  16477. doc = elem.ownerDocument;
  16478. offsetParent = elem.offsetParent || doc.documentElement;
  16479. while ( offsetParent &&
  16480. ( offsetParent === doc.body || offsetParent === doc.documentElement ) &&
  16481. jQuery.css( offsetParent, "position" ) === "static" ) {
  16482. offsetParent = offsetParent.parentNode;
  16483. }
  16484. if ( offsetParent && offsetParent !== elem && offsetParent.nodeType === 1 ) {
  16485. // Incorporate borders into its offset, since they are outside its content origin
  16486. parentOffset = jQuery( offsetParent ).offset();
  16487. parentOffset.top += jQuery.css( offsetParent, "borderTopWidth", true );
  16488. parentOffset.left += jQuery.css( offsetParent, "borderLeftWidth", true );
  16489. }
  16490. }
  16491. // Subtract parent offsets and element margins
  16492. return {
  16493. top: offset.top - parentOffset.top - jQuery.css( elem, "marginTop", true ),
  16494. left: offset.left - parentOffset.left - jQuery.css( elem, "marginLeft", true )
  16495. };
  16496. },
  16497. // This method will return documentElement in the following cases:
  16498. // 1) For the element inside the iframe without offsetParent, this method will return
  16499. // documentElement of the parent window
  16500. // 2) For the hidden or detached element
  16501. // 3) For body or html element, i.e. in case of the html node - it will return itself
  16502. //
  16503. // but those exceptions were never presented as a real life use-cases
  16504. // and might be considered as more preferable results.
  16505. //
  16506. // This logic, however, is not guaranteed and can change at any point in the future
  16507. offsetParent: function() {
  16508. return this.map( function() {
  16509. var offsetParent = this.offsetParent;
  16510. while ( offsetParent && jQuery.css( offsetParent, "position" ) === "static" ) {
  16511. offsetParent = offsetParent.offsetParent;
  16512. }
  16513. return offsetParent || documentElement;
  16514. } );
  16515. }
  16516. } );
  16517. // Create scrollLeft and scrollTop methods
  16518. jQuery.each( { scrollLeft: "pageXOffset", scrollTop: "pageYOffset" }, function( method, prop ) {
  16519. var top = "pageYOffset" === prop;
  16520. jQuery.fn[ method ] = function( val ) {
  16521. return access( this, function( elem, method, val ) {
  16522. // Coalesce documents and windows
  16523. var win;
  16524. if ( isWindow( elem ) ) {
  16525. win = elem;
  16526. } else if ( elem.nodeType === 9 ) {
  16527. win = elem.defaultView;
  16528. }
  16529. if ( val === undefined ) {
  16530. return win ? win[ prop ] : elem[ method ];
  16531. }
  16532. if ( win ) {
  16533. win.scrollTo(
  16534. !top ? val : win.pageXOffset,
  16535. top ? val : win.pageYOffset
  16536. );
  16537. } else {
  16538. elem[ method ] = val;
  16539. }
  16540. }, method, val, arguments.length );
  16541. };
  16542. } );
  16543. // Support: Safari <=7 - 9.1, Chrome <=37 - 49
  16544. // Add the top/left cssHooks using jQuery.fn.position
  16545. // Webkit bug: https://bugs.webkit.org/show_bug.cgi?id=29084
  16546. // Blink bug: https://bugs.chromium.org/p/chromium/issues/detail?id=589347
  16547. // getComputedStyle returns percent when specified for top/left/bottom/right;
  16548. // rather than make the css module depend on the offset module, just check for it here
  16549. jQuery.each( [ "top", "left" ], function( i, prop ) {
  16550. jQuery.cssHooks[ prop ] = addGetHookIf( support.pixelPosition,
  16551. function( elem, computed ) {
  16552. if ( computed ) {
  16553. computed = curCSS( elem, prop );
  16554. // If curCSS returns percentage, fallback to offset
  16555. return rnumnonpx.test( computed ) ?
  16556. jQuery( elem ).position()[ prop ] + "px" :
  16557. computed;
  16558. }
  16559. }
  16560. );
  16561. } );
  16562. // Create innerHeight, innerWidth, height, width, outerHeight and outerWidth methods
  16563. jQuery.each( { Height: "height", Width: "width" }, function( name, type ) {
  16564. jQuery.each( { padding: "inner" + name, content: type, "": "outer" + name },
  16565. function( defaultExtra, funcName ) {
  16566. // Margin is only for outerHeight, outerWidth
  16567. jQuery.fn[ funcName ] = function( margin, value ) {
  16568. var chainable = arguments.length && ( defaultExtra || typeof margin !== "boolean" ),
  16569. extra = defaultExtra || ( margin === true || value === true ? "margin" : "border" );
  16570. return access( this, function( elem, type, value ) {
  16571. var doc;
  16572. if ( isWindow( elem ) ) {
  16573. // $( window ).outerWidth/Height return w/h including scrollbars (gh-1729)
  16574. return funcName.indexOf( "outer" ) === 0 ?
  16575. elem[ "inner" + name ] :
  16576. elem.document.documentElement[ "client" + name ];
  16577. }
  16578. // Get document width or height
  16579. if ( elem.nodeType === 9 ) {
  16580. doc = elem.documentElement;
  16581. // Either scroll[Width/Height] or offset[Width/Height] or client[Width/Height],
  16582. // whichever is greatest
  16583. return Math.max(
  16584. elem.body[ "scroll" + name ], doc[ "scroll" + name ],
  16585. elem.body[ "offset" + name ], doc[ "offset" + name ],
  16586. doc[ "client" + name ]
  16587. );
  16588. }
  16589. return value === undefined ?
  16590. // Get width or height on the element, requesting but not forcing parseFloat
  16591. jQuery.css( elem, type, extra ) :
  16592. // Set width or height on the element
  16593. jQuery.style( elem, type, value, extra );
  16594. }, type, chainable ? margin : undefined, chainable );
  16595. };
  16596. } );
  16597. } );
  16598. jQuery.each( ( "blur focus focusin focusout resize scroll click dblclick " +
  16599. "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " +
  16600. "change select submit keydown keypress keyup contextmenu" ).split( " " ),
  16601. function( i, name ) {
  16602. // Handle event binding
  16603. jQuery.fn[ name ] = function( data, fn ) {
  16604. return arguments.length > 0 ?
  16605. this.on( name, null, data, fn ) :
  16606. this.trigger( name );
  16607. };
  16608. } );
  16609. jQuery.fn.extend( {
  16610. hover: function( fnOver, fnOut ) {
  16611. return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver );
  16612. }
  16613. } );
  16614. jQuery.fn.extend( {
  16615. bind: function( types, data, fn ) {
  16616. return this.on( types, null, data, fn );
  16617. },
  16618. unbind: function( types, fn ) {
  16619. return this.off( types, null, fn );
  16620. },
  16621. delegate: function( selector, types, data, fn ) {
  16622. return this.on( types, selector, data, fn );
  16623. },
  16624. undelegate: function( selector, types, fn ) {
  16625. // ( namespace ) or ( selector, types [, fn] )
  16626. return arguments.length === 1 ?
  16627. this.off( selector, "**" ) :
  16628. this.off( types, selector || "**", fn );
  16629. }
  16630. } );
  16631. // Bind a function to a context, optionally partially applying any
  16632. // arguments.
  16633. // jQuery.proxy is deprecated to promote standards (specifically Function#bind)
  16634. // However, it is not slated for removal any time soon
  16635. jQuery.proxy = function( fn, context ) {
  16636. var tmp, args, proxy;
  16637. if ( typeof context === "string" ) {
  16638. tmp = fn[ context ];
  16639. context = fn;
  16640. fn = tmp;
  16641. }
  16642. // Quick check to determine if target is callable, in the spec
  16643. // this throws a TypeError, but we will just return undefined.
  16644. if ( !isFunction( fn ) ) {
  16645. return undefined;
  16646. }
  16647. // Simulated bind
  16648. args = slice.call( arguments, 2 );
  16649. proxy = function() {
  16650. return fn.apply( context || this, args.concat( slice.call( arguments ) ) );
  16651. };
  16652. // Set the guid of unique handler to the same of original handler, so it can be removed
  16653. proxy.guid = fn.guid = fn.guid || jQuery.guid++;
  16654. return proxy;
  16655. };
  16656. jQuery.holdReady = function( hold ) {
  16657. if ( hold ) {
  16658. jQuery.readyWait++;
  16659. } else {
  16660. jQuery.ready( true );
  16661. }
  16662. };
  16663. jQuery.isArray = Array.isArray;
  16664. jQuery.parseJSON = JSON.parse;
  16665. jQuery.nodeName = nodeName;
  16666. jQuery.isFunction = isFunction;
  16667. jQuery.isWindow = isWindow;
  16668. jQuery.camelCase = camelCase;
  16669. jQuery.type = toType;
  16670. jQuery.now = Date.now;
  16671. jQuery.isNumeric = function( obj ) {
  16672. // As of jQuery 3.0, isNumeric is limited to
  16673. // strings and numbers (primitives or objects)
  16674. // that can be coerced to finite numbers (gh-2662)
  16675. var type = jQuery.type( obj );
  16676. return ( type === "number" || type === "string" ) &&
  16677. // parseFloat NaNs numeric-cast false positives ("")
  16678. // ...but misinterprets leading-number strings, particularly hex literals ("0x...")
  16679. // subtraction forces infinities to NaN
  16680. !isNaN( obj - parseFloat( obj ) );
  16681. };
  16682. // Register as a named AMD module, since jQuery can be concatenated with other
  16683. // files that may use define, but not via a proper concatenation script that
  16684. // understands anonymous AMD modules. A named AMD is safest and most robust
  16685. // way to register. Lowercase jquery is used because AMD module names are
  16686. // derived from file names, and jQuery is normally delivered in a lowercase
  16687. // file name. Do this after creating the global so that if an AMD module wants
  16688. // to call noConflict to hide this version of jQuery, it will work.
  16689. // Note that for maximum portability, libraries that are not jQuery should
  16690. // declare themselves as anonymous modules, and avoid setting a global if an
  16691. // AMD loader is present. jQuery is a special case. For more information, see
  16692. // https://github.com/jrburke/requirejs/wiki/Updating-existing-libraries#wiki-anon
  16693. if ( true ) {
  16694. !(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_RESULT__ = (function() {
  16695. return jQuery;
  16696. }).apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__),
  16697. __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
  16698. }
  16699. var
  16700. // Map over jQuery in case of overwrite
  16701. _jQuery = window.jQuery,
  16702. // Map over the $ in case of overwrite
  16703. _$ = window.$;
  16704. jQuery.noConflict = function( deep ) {
  16705. if ( window.$ === jQuery ) {
  16706. window.$ = _$;
  16707. }
  16708. if ( deep && window.jQuery === jQuery ) {
  16709. window.jQuery = _jQuery;
  16710. }
  16711. return jQuery;
  16712. };
  16713. // Expose jQuery and $ identifiers, even in AMD
  16714. // (#7102#comment:10, https://github.com/jquery/jquery/pull/557)
  16715. // and CommonJS for browser emulators (#13566)
  16716. if ( !noGlobal ) {
  16717. window.jQuery = window.$ = jQuery;
  16718. }
  16719. return jQuery;
  16720. } );
  16721. /***/ }),
  16722. /***/ "./node_modules/laravel-echo/dist/echo.js":
  16723. /*!************************************************!*\
  16724. !*** ./node_modules/laravel-echo/dist/echo.js ***!
  16725. \************************************************/
  16726. /*! exports provided: default */
  16727. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  16728. "use strict";
  16729. __webpack_require__.r(__webpack_exports__);
  16730. var classCallCheck = function (instance, Constructor) {
  16731. if (!(instance instanceof Constructor)) {
  16732. throw new TypeError("Cannot call a class as a function");
  16733. }
  16734. };
  16735. var createClass = function () {
  16736. function defineProperties(target, props) {
  16737. for (var i = 0; i < props.length; i++) {
  16738. var descriptor = props[i];
  16739. descriptor.enumerable = descriptor.enumerable || false;
  16740. descriptor.configurable = true;
  16741. if ("value" in descriptor) descriptor.writable = true;
  16742. Object.defineProperty(target, descriptor.key, descriptor);
  16743. }
  16744. }
  16745. return function (Constructor, protoProps, staticProps) {
  16746. if (protoProps) defineProperties(Constructor.prototype, protoProps);
  16747. if (staticProps) defineProperties(Constructor, staticProps);
  16748. return Constructor;
  16749. };
  16750. }();
  16751. var _extends = Object.assign || function (target) {
  16752. for (var i = 1; i < arguments.length; i++) {
  16753. var source = arguments[i];
  16754. for (var key in source) {
  16755. if (Object.prototype.hasOwnProperty.call(source, key)) {
  16756. target[key] = source[key];
  16757. }
  16758. }
  16759. }
  16760. return target;
  16761. };
  16762. var inherits = function (subClass, superClass) {
  16763. if (typeof superClass !== "function" && superClass !== null) {
  16764. throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
  16765. }
  16766. subClass.prototype = Object.create(superClass && superClass.prototype, {
  16767. constructor: {
  16768. value: subClass,
  16769. enumerable: false,
  16770. writable: true,
  16771. configurable: true
  16772. }
  16773. });
  16774. if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass;
  16775. };
  16776. var possibleConstructorReturn = function (self, call) {
  16777. if (!self) {
  16778. throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
  16779. }
  16780. return call && (typeof call === "object" || typeof call === "function") ? call : self;
  16781. };
  16782. var Connector = function () {
  16783. /**
  16784. * Create a new class instance.
  16785. */
  16786. function Connector(options) {
  16787. classCallCheck(this, Connector);
  16788. /**
  16789. * Default connector options.
  16790. */
  16791. this._defaultOptions = {
  16792. auth: {
  16793. headers: {}
  16794. },
  16795. authEndpoint: '/broadcasting/auth',
  16796. broadcaster: 'pusher',
  16797. csrfToken: null,
  16798. host: null,
  16799. key: null,
  16800. namespace: 'App.Events'
  16801. };
  16802. this.setOptions(options);
  16803. this.connect();
  16804. }
  16805. /**
  16806. * Merge the custom options with the defaults.
  16807. */
  16808. createClass(Connector, [{
  16809. key: 'setOptions',
  16810. value: function setOptions(options) {
  16811. this.options = _extends(this._defaultOptions, options);
  16812. if (this.csrfToken()) {
  16813. this.options.auth.headers['X-CSRF-TOKEN'] = this.csrfToken();
  16814. }
  16815. return options;
  16816. }
  16817. /**
  16818. * Extract the CSRF token from the page.
  16819. */
  16820. }, {
  16821. key: 'csrfToken',
  16822. value: function csrfToken() {
  16823. var selector = void 0;
  16824. if (typeof window !== 'undefined' && window['Laravel'] && window['Laravel'].csrfToken) {
  16825. return window['Laravel'].csrfToken;
  16826. } else if (this.options.csrfToken) {
  16827. return this.options.csrfToken;
  16828. } else if (typeof document !== 'undefined' && typeof document.querySelector === 'function' && (selector = document.querySelector('meta[name="csrf-token"]'))) {
  16829. return selector.getAttribute('content');
  16830. }
  16831. return null;
  16832. }
  16833. }]);
  16834. return Connector;
  16835. }();
  16836. /**
  16837. * This class represents a basic channel.
  16838. */
  16839. var Channel = function () {
  16840. function Channel() {
  16841. classCallCheck(this, Channel);
  16842. }
  16843. createClass(Channel, [{
  16844. key: 'listenForWhisper',
  16845. /**
  16846. * Listen for a whisper event on the channel instance.
  16847. */
  16848. value: function listenForWhisper(event, callback) {
  16849. return this.listen('.client-' + event, callback);
  16850. }
  16851. /**
  16852. * Listen for an event on the channel instance.
  16853. */
  16854. }, {
  16855. key: 'notification',
  16856. value: function notification(callback) {
  16857. return this.listen('.Illuminate\\Notifications\\Events\\BroadcastNotificationCreated', callback);
  16858. }
  16859. /**
  16860. * Stop listening for a whispser event on the channel instance.
  16861. */
  16862. }, {
  16863. key: 'stopListeningForWhisper',
  16864. value: function stopListeningForWhisper(event) {
  16865. return this.stopListening('.client-' + event);
  16866. }
  16867. }]);
  16868. return Channel;
  16869. }();
  16870. /**
  16871. * Event name formatter
  16872. */
  16873. var EventFormatter = function () {
  16874. /**
  16875. * Create a new class instance.
  16876. */
  16877. function EventFormatter(namespace) {
  16878. classCallCheck(this, EventFormatter);
  16879. this.setNamespace(namespace);
  16880. }
  16881. /**
  16882. * Format the given event name.
  16883. */
  16884. createClass(EventFormatter, [{
  16885. key: 'format',
  16886. value: function format(event) {
  16887. if (event.charAt(0) === '.' || event.charAt(0) === '\\') {
  16888. return event.substr(1);
  16889. } else if (this.namespace) {
  16890. event = this.namespace + '.' + event;
  16891. }
  16892. return event.replace(/\./g, '\\');
  16893. }
  16894. /**
  16895. * Set the event namespace.
  16896. */
  16897. }, {
  16898. key: 'setNamespace',
  16899. value: function setNamespace(value) {
  16900. this.namespace = value;
  16901. }
  16902. }]);
  16903. return EventFormatter;
  16904. }();
  16905. /**
  16906. * This class represents a Pusher channel.
  16907. */
  16908. var PusherChannel = function (_Channel) {
  16909. inherits(PusherChannel, _Channel);
  16910. /**
  16911. * Create a new class instance.
  16912. */
  16913. function PusherChannel(pusher, name, options) {
  16914. classCallCheck(this, PusherChannel);
  16915. var _this = possibleConstructorReturn(this, (PusherChannel.__proto__ || Object.getPrototypeOf(PusherChannel)).call(this));
  16916. _this.name = name;
  16917. _this.pusher = pusher;
  16918. _this.options = options;
  16919. _this.eventFormatter = new EventFormatter(_this.options.namespace);
  16920. _this.subscribe();
  16921. return _this;
  16922. }
  16923. /**
  16924. * Subscribe to a Pusher channel.
  16925. */
  16926. createClass(PusherChannel, [{
  16927. key: 'subscribe',
  16928. value: function subscribe() {
  16929. this.subscription = this.pusher.subscribe(this.name);
  16930. }
  16931. /**
  16932. * Unsubscribe from a Pusher channel.
  16933. */
  16934. }, {
  16935. key: 'unsubscribe',
  16936. value: function unsubscribe() {
  16937. this.pusher.unsubscribe(this.name);
  16938. }
  16939. /**
  16940. * Listen for an event on the channel instance.
  16941. */
  16942. }, {
  16943. key: 'listen',
  16944. value: function listen(event, callback) {
  16945. this.on(this.eventFormatter.format(event), callback);
  16946. return this;
  16947. }
  16948. /**
  16949. * Stop listening for an event on the channel instance.
  16950. */
  16951. }, {
  16952. key: 'stopListening',
  16953. value: function stopListening(event) {
  16954. this.subscription.unbind(this.eventFormatter.format(event));
  16955. return this;
  16956. }
  16957. /**
  16958. * Bind a channel to an event.
  16959. */
  16960. }, {
  16961. key: 'on',
  16962. value: function on(event, callback) {
  16963. this.subscription.bind(event, callback);
  16964. return this;
  16965. }
  16966. }]);
  16967. return PusherChannel;
  16968. }(Channel);
  16969. /**
  16970. * This class represents a Pusher private channel.
  16971. */
  16972. var PusherPrivateChannel = function (_PusherChannel) {
  16973. inherits(PusherPrivateChannel, _PusherChannel);
  16974. function PusherPrivateChannel() {
  16975. classCallCheck(this, PusherPrivateChannel);
  16976. return possibleConstructorReturn(this, (PusherPrivateChannel.__proto__ || Object.getPrototypeOf(PusherPrivateChannel)).apply(this, arguments));
  16977. }
  16978. createClass(PusherPrivateChannel, [{
  16979. key: 'whisper',
  16980. /**
  16981. * Trigger client event on the channel.
  16982. */
  16983. value: function whisper(eventName, data) {
  16984. this.pusher.channels.channels[this.name].trigger('client-' + eventName, data);
  16985. return this;
  16986. }
  16987. }]);
  16988. return PusherPrivateChannel;
  16989. }(PusherChannel);
  16990. /**
  16991. * This class represents a Pusher presence channel.
  16992. */
  16993. var PusherPresenceChannel = function (_PusherChannel) {
  16994. inherits(PusherPresenceChannel, _PusherChannel);
  16995. function PusherPresenceChannel() {
  16996. classCallCheck(this, PusherPresenceChannel);
  16997. return possibleConstructorReturn(this, (PusherPresenceChannel.__proto__ || Object.getPrototypeOf(PusherPresenceChannel)).apply(this, arguments));
  16998. }
  16999. createClass(PusherPresenceChannel, [{
  17000. key: 'here',
  17001. /**
  17002. * Register a callback to be called anytime the member list changes.
  17003. */
  17004. value: function here(callback) {
  17005. this.on('pusher:subscription_succeeded', function (data) {
  17006. callback(Object.keys(data.members).map(function (k) {
  17007. return data.members[k];
  17008. }));
  17009. });
  17010. return this;
  17011. }
  17012. /**
  17013. * Listen for someone joining the channel.
  17014. */
  17015. }, {
  17016. key: 'joining',
  17017. value: function joining(callback) {
  17018. this.on('pusher:member_added', function (member) {
  17019. callback(member.info);
  17020. });
  17021. return this;
  17022. }
  17023. /**
  17024. * Listen for someone leaving the channel.
  17025. */
  17026. }, {
  17027. key: 'leaving',
  17028. value: function leaving(callback) {
  17029. this.on('pusher:member_removed', function (member) {
  17030. callback(member.info);
  17031. });
  17032. return this;
  17033. }
  17034. /**
  17035. * Trigger client event on the channel.
  17036. */
  17037. }, {
  17038. key: 'whisper',
  17039. value: function whisper(eventName, data) {
  17040. this.pusher.channels.channels[this.name].trigger('client-' + eventName, data);
  17041. return this;
  17042. }
  17043. }]);
  17044. return PusherPresenceChannel;
  17045. }(PusherChannel);
  17046. /**
  17047. * This class represents a Socket.io channel.
  17048. */
  17049. var SocketIoChannel = function (_Channel) {
  17050. inherits(SocketIoChannel, _Channel);
  17051. /**
  17052. * Create a new class instance.
  17053. */
  17054. function SocketIoChannel(socket, name, options) {
  17055. classCallCheck(this, SocketIoChannel);
  17056. /**
  17057. * The event callbacks applied to the channel.
  17058. */
  17059. var _this = possibleConstructorReturn(this, (SocketIoChannel.__proto__ || Object.getPrototypeOf(SocketIoChannel)).call(this));
  17060. _this.events = {};
  17061. _this.name = name;
  17062. _this.socket = socket;
  17063. _this.options = options;
  17064. _this.eventFormatter = new EventFormatter(_this.options.namespace);
  17065. _this.subscribe();
  17066. _this.configureReconnector();
  17067. return _this;
  17068. }
  17069. /**
  17070. * Subscribe to a Socket.io channel.
  17071. */
  17072. createClass(SocketIoChannel, [{
  17073. key: 'subscribe',
  17074. value: function subscribe() {
  17075. this.socket.emit('subscribe', {
  17076. channel: this.name,
  17077. auth: this.options.auth || {}
  17078. });
  17079. }
  17080. /**
  17081. * Unsubscribe from channel and ubind event callbacks.
  17082. */
  17083. }, {
  17084. key: 'unsubscribe',
  17085. value: function unsubscribe() {
  17086. this.unbind();
  17087. this.socket.emit('unsubscribe', {
  17088. channel: this.name,
  17089. auth: this.options.auth || {}
  17090. });
  17091. }
  17092. /**
  17093. * Listen for an event on the channel instance.
  17094. */
  17095. }, {
  17096. key: 'listen',
  17097. value: function listen(event, callback) {
  17098. this.on(this.eventFormatter.format(event), callback);
  17099. return this;
  17100. }
  17101. /**
  17102. * Stop listening for an event on the channel instance.
  17103. */
  17104. }, {
  17105. key: 'stopListening',
  17106. value: function stopListening(event) {
  17107. var name = this.eventFormatter.format(event);
  17108. this.socket.removeListener(name);
  17109. delete this.events[name];
  17110. return this;
  17111. }
  17112. /**
  17113. * Bind the channel's socket to an event and store the callback.
  17114. */
  17115. }, {
  17116. key: 'on',
  17117. value: function on(event, callback) {
  17118. var _this2 = this;
  17119. var listener = function listener(channel, data) {
  17120. if (_this2.name == channel) {
  17121. callback(data);
  17122. }
  17123. };
  17124. this.socket.on(event, listener);
  17125. this.bind(event, listener);
  17126. }
  17127. /**
  17128. * Attach a 'reconnect' listener and bind the event.
  17129. */
  17130. }, {
  17131. key: 'configureReconnector',
  17132. value: function configureReconnector() {
  17133. var _this3 = this;
  17134. var listener = function listener() {
  17135. _this3.subscribe();
  17136. };
  17137. this.socket.on('reconnect', listener);
  17138. this.bind('reconnect', listener);
  17139. }
  17140. /**
  17141. * Bind the channel's socket to an event and store the callback.
  17142. */
  17143. }, {
  17144. key: 'bind',
  17145. value: function bind(event, callback) {
  17146. this.events[event] = this.events[event] || [];
  17147. this.events[event].push(callback);
  17148. }
  17149. /**
  17150. * Unbind the channel's socket from all stored event callbacks.
  17151. */
  17152. }, {
  17153. key: 'unbind',
  17154. value: function unbind() {
  17155. var _this4 = this;
  17156. Object.keys(this.events).forEach(function (event) {
  17157. _this4.events[event].forEach(function (callback) {
  17158. _this4.socket.removeListener(event, callback);
  17159. });
  17160. delete _this4.events[event];
  17161. });
  17162. }
  17163. }]);
  17164. return SocketIoChannel;
  17165. }(Channel);
  17166. /**
  17167. * This class represents a Socket.io presence channel.
  17168. */
  17169. var SocketIoPrivateChannel = function (_SocketIoChannel) {
  17170. inherits(SocketIoPrivateChannel, _SocketIoChannel);
  17171. function SocketIoPrivateChannel() {
  17172. classCallCheck(this, SocketIoPrivateChannel);
  17173. return possibleConstructorReturn(this, (SocketIoPrivateChannel.__proto__ || Object.getPrototypeOf(SocketIoPrivateChannel)).apply(this, arguments));
  17174. }
  17175. createClass(SocketIoPrivateChannel, [{
  17176. key: 'whisper',
  17177. /**
  17178. * Trigger client event on the channel.
  17179. */
  17180. value: function whisper(eventName, data) {
  17181. this.socket.emit('client event', {
  17182. channel: this.name,
  17183. event: 'client-' + eventName,
  17184. data: data
  17185. });
  17186. return this;
  17187. }
  17188. }]);
  17189. return SocketIoPrivateChannel;
  17190. }(SocketIoChannel);
  17191. /**
  17192. * This class represents a Socket.io presence channel.
  17193. */
  17194. var SocketIoPresenceChannel = function (_SocketIoPrivateChann) {
  17195. inherits(SocketIoPresenceChannel, _SocketIoPrivateChann);
  17196. function SocketIoPresenceChannel() {
  17197. classCallCheck(this, SocketIoPresenceChannel);
  17198. return possibleConstructorReturn(this, (SocketIoPresenceChannel.__proto__ || Object.getPrototypeOf(SocketIoPresenceChannel)).apply(this, arguments));
  17199. }
  17200. createClass(SocketIoPresenceChannel, [{
  17201. key: 'here',
  17202. /**
  17203. * Register a callback to be called anytime the member list changes.
  17204. */
  17205. value: function here(callback) {
  17206. this.on('presence:subscribed', function (members) {
  17207. callback(members.map(function (m) {
  17208. return m.user_info;
  17209. }));
  17210. });
  17211. return this;
  17212. }
  17213. /**
  17214. * Listen for someone joining the channel.
  17215. */
  17216. }, {
  17217. key: 'joining',
  17218. value: function joining(callback) {
  17219. this.on('presence:joining', function (member) {
  17220. return callback(member.user_info);
  17221. });
  17222. return this;
  17223. }
  17224. /**
  17225. * Listen for someone leaving the channel.
  17226. */
  17227. }, {
  17228. key: 'leaving',
  17229. value: function leaving(callback) {
  17230. this.on('presence:leaving', function (member) {
  17231. return callback(member.user_info);
  17232. });
  17233. return this;
  17234. }
  17235. }]);
  17236. return SocketIoPresenceChannel;
  17237. }(SocketIoPrivateChannel);
  17238. /**
  17239. * This class represents a null channel.
  17240. */
  17241. var NullChannel = function (_Channel) {
  17242. inherits(NullChannel, _Channel);
  17243. function NullChannel() {
  17244. classCallCheck(this, NullChannel);
  17245. return possibleConstructorReturn(this, (NullChannel.__proto__ || Object.getPrototypeOf(NullChannel)).apply(this, arguments));
  17246. }
  17247. createClass(NullChannel, [{
  17248. key: 'subscribe',
  17249. /**
  17250. * Subscribe to a channel.
  17251. */
  17252. value: function subscribe() {}
  17253. //
  17254. /**
  17255. * Unsubscribe from a channel.
  17256. */
  17257. }, {
  17258. key: 'unsubscribe',
  17259. value: function unsubscribe() {}
  17260. //
  17261. /**
  17262. * Listen for an event on the channel instance.
  17263. */
  17264. }, {
  17265. key: 'listen',
  17266. value: function listen(event, callback) {
  17267. return this;
  17268. }
  17269. /**
  17270. * Stop listening for an event on the channel instance.
  17271. */
  17272. }, {
  17273. key: 'stopListening',
  17274. value: function stopListening(event) {
  17275. return this;
  17276. }
  17277. /**
  17278. * Bind a channel to an event.
  17279. */
  17280. }, {
  17281. key: 'on',
  17282. value: function on(event, callback) {
  17283. return this;
  17284. }
  17285. }]);
  17286. return NullChannel;
  17287. }(Channel);
  17288. /**
  17289. * This class represents a null private channel.
  17290. */
  17291. var NullPrivateChannel = function (_NullChannel) {
  17292. inherits(NullPrivateChannel, _NullChannel);
  17293. function NullPrivateChannel() {
  17294. classCallCheck(this, NullPrivateChannel);
  17295. return possibleConstructorReturn(this, (NullPrivateChannel.__proto__ || Object.getPrototypeOf(NullPrivateChannel)).apply(this, arguments));
  17296. }
  17297. createClass(NullPrivateChannel, [{
  17298. key: 'whisper',
  17299. /**
  17300. * Trigger client event on the channel.
  17301. */
  17302. value: function whisper(eventName, data) {
  17303. return this;
  17304. }
  17305. }]);
  17306. return NullPrivateChannel;
  17307. }(NullChannel);
  17308. /**
  17309. * This class represents a null presence channel.
  17310. */
  17311. var NullPresenceChannel = function (_NullChannel) {
  17312. inherits(NullPresenceChannel, _NullChannel);
  17313. function NullPresenceChannel() {
  17314. classCallCheck(this, NullPresenceChannel);
  17315. return possibleConstructorReturn(this, (NullPresenceChannel.__proto__ || Object.getPrototypeOf(NullPresenceChannel)).apply(this, arguments));
  17316. }
  17317. createClass(NullPresenceChannel, [{
  17318. key: 'here',
  17319. /**
  17320. * Register a callback to be called anytime the member list changes.
  17321. */
  17322. value: function here(callback) {
  17323. return this;
  17324. }
  17325. /**
  17326. * Listen for someone joining the channel.
  17327. */
  17328. }, {
  17329. key: 'joining',
  17330. value: function joining(callback) {
  17331. return this;
  17332. }
  17333. /**
  17334. * Listen for someone leaving the channel.
  17335. */
  17336. }, {
  17337. key: 'leaving',
  17338. value: function leaving(callback) {
  17339. return this;
  17340. }
  17341. /**
  17342. * Trigger client event on the channel.
  17343. */
  17344. }, {
  17345. key: 'whisper',
  17346. value: function whisper(eventName, data) {
  17347. return this;
  17348. }
  17349. }]);
  17350. return NullPresenceChannel;
  17351. }(NullChannel);
  17352. /**
  17353. * This class creates a connector to Pusher.
  17354. */
  17355. var PusherConnector = function (_Connector) {
  17356. inherits(PusherConnector, _Connector);
  17357. function PusherConnector() {
  17358. classCallCheck(this, PusherConnector);
  17359. /**
  17360. * All of the subscribed channel names.
  17361. */
  17362. var _this = possibleConstructorReturn(this, (PusherConnector.__proto__ || Object.getPrototypeOf(PusherConnector)).apply(this, arguments));
  17363. _this.channels = {};
  17364. return _this;
  17365. }
  17366. /**
  17367. * Create a fresh Pusher connection.
  17368. */
  17369. createClass(PusherConnector, [{
  17370. key: 'connect',
  17371. value: function connect() {
  17372. if (typeof this.options.client !== 'undefined') {
  17373. this.pusher = this.options.client;
  17374. } else {
  17375. this.pusher = new Pusher(this.options.key, this.options);
  17376. }
  17377. }
  17378. /**
  17379. * Listen for an event on a channel instance.
  17380. */
  17381. }, {
  17382. key: 'listen',
  17383. value: function listen(name, event, callback) {
  17384. return this.channel(name).listen(event, callback);
  17385. }
  17386. /**
  17387. * Get a channel instance by name.
  17388. */
  17389. }, {
  17390. key: 'channel',
  17391. value: function channel(name) {
  17392. if (!this.channels[name]) {
  17393. this.channels[name] = new PusherChannel(this.pusher, name, this.options);
  17394. }
  17395. return this.channels[name];
  17396. }
  17397. /**
  17398. * Get a private channel instance by name.
  17399. */
  17400. }, {
  17401. key: 'privateChannel',
  17402. value: function privateChannel(name) {
  17403. if (!this.channels['private-' + name]) {
  17404. this.channels['private-' + name] = new PusherPrivateChannel(this.pusher, 'private-' + name, this.options);
  17405. }
  17406. return this.channels['private-' + name];
  17407. }
  17408. /**
  17409. * Get a presence channel instance by name.
  17410. */
  17411. }, {
  17412. key: 'presenceChannel',
  17413. value: function presenceChannel(name) {
  17414. if (!this.channels['presence-' + name]) {
  17415. this.channels['presence-' + name] = new PusherPresenceChannel(this.pusher, 'presence-' + name, this.options);
  17416. }
  17417. return this.channels['presence-' + name];
  17418. }
  17419. /**
  17420. * Leave the given channel, as well as its private and presence variants.
  17421. */
  17422. }, {
  17423. key: 'leave',
  17424. value: function leave(name) {
  17425. var _this2 = this;
  17426. var channels = [name, 'private-' + name, 'presence-' + name];
  17427. channels.forEach(function (name, index) {
  17428. _this2.leaveChannel(name);
  17429. });
  17430. }
  17431. /**
  17432. * Leave the given channel.
  17433. */
  17434. }, {
  17435. key: 'leaveChannel',
  17436. value: function leaveChannel(name) {
  17437. if (this.channels[name]) {
  17438. this.channels[name].unsubscribe();
  17439. delete this.channels[name];
  17440. }
  17441. }
  17442. /**
  17443. * Get the socket ID for the connection.
  17444. */
  17445. }, {
  17446. key: 'socketId',
  17447. value: function socketId() {
  17448. return this.pusher.connection.socket_id;
  17449. }
  17450. /**
  17451. * Disconnect Pusher connection.
  17452. */
  17453. }, {
  17454. key: 'disconnect',
  17455. value: function disconnect() {
  17456. this.pusher.disconnect();
  17457. }
  17458. }]);
  17459. return PusherConnector;
  17460. }(Connector);
  17461. /**
  17462. * This class creates a connnector to a Socket.io server.
  17463. */
  17464. var SocketIoConnector = function (_Connector) {
  17465. inherits(SocketIoConnector, _Connector);
  17466. function SocketIoConnector() {
  17467. classCallCheck(this, SocketIoConnector);
  17468. /**
  17469. * All of the subscribed channel names.
  17470. */
  17471. var _this = possibleConstructorReturn(this, (SocketIoConnector.__proto__ || Object.getPrototypeOf(SocketIoConnector)).apply(this, arguments));
  17472. _this.channels = {};
  17473. return _this;
  17474. }
  17475. /**
  17476. * Create a fresh Socket.io connection.
  17477. */
  17478. createClass(SocketIoConnector, [{
  17479. key: 'connect',
  17480. value: function connect() {
  17481. var io = this.getSocketIO();
  17482. this.socket = io(this.options.host, this.options);
  17483. return this.socket;
  17484. }
  17485. /**
  17486. * Get socket.io module from global scope or options.
  17487. */
  17488. }, {
  17489. key: 'getSocketIO',
  17490. value: function getSocketIO() {
  17491. if (typeof this.options.client !== 'undefined') {
  17492. return this.options.client;
  17493. }
  17494. if (typeof io !== 'undefined') {
  17495. return io;
  17496. }
  17497. throw new Error('Socket.io client not found. Should be globally available or passed via options.client');
  17498. }
  17499. /**
  17500. * Listen for an event on a channel instance.
  17501. */
  17502. }, {
  17503. key: 'listen',
  17504. value: function listen(name, event, callback) {
  17505. return this.channel(name).listen(event, callback);
  17506. }
  17507. /**
  17508. * Get a channel instance by name.
  17509. */
  17510. }, {
  17511. key: 'channel',
  17512. value: function channel(name) {
  17513. if (!this.channels[name]) {
  17514. this.channels[name] = new SocketIoChannel(this.socket, name, this.options);
  17515. }
  17516. return this.channels[name];
  17517. }
  17518. /**
  17519. * Get a private channel instance by name.
  17520. */
  17521. }, {
  17522. key: 'privateChannel',
  17523. value: function privateChannel(name) {
  17524. if (!this.channels['private-' + name]) {
  17525. this.channels['private-' + name] = new SocketIoPrivateChannel(this.socket, 'private-' + name, this.options);
  17526. }
  17527. return this.channels['private-' + name];
  17528. }
  17529. /**
  17530. * Get a presence channel instance by name.
  17531. */
  17532. }, {
  17533. key: 'presenceChannel',
  17534. value: function presenceChannel(name) {
  17535. if (!this.channels['presence-' + name]) {
  17536. this.channels['presence-' + name] = new SocketIoPresenceChannel(this.socket, 'presence-' + name, this.options);
  17537. }
  17538. return this.channels['presence-' + name];
  17539. }
  17540. /**
  17541. * Leave the given channel, as well as its private and presence variants.
  17542. */
  17543. }, {
  17544. key: 'leave',
  17545. value: function leave(name) {
  17546. var _this2 = this;
  17547. var channels = [name, 'private-' + name, 'presence-' + name];
  17548. channels.forEach(function (name) {
  17549. _this2.leaveChannel(name);
  17550. });
  17551. }
  17552. /**
  17553. * Leave the given channel.
  17554. */
  17555. }, {
  17556. key: 'leaveChannel',
  17557. value: function leaveChannel(name) {
  17558. if (this.channels[name]) {
  17559. this.channels[name].unsubscribe();
  17560. delete this.channels[name];
  17561. }
  17562. }
  17563. /**
  17564. * Get the socket ID for the connection.
  17565. */
  17566. }, {
  17567. key: 'socketId',
  17568. value: function socketId() {
  17569. return this.socket.id;
  17570. }
  17571. /**
  17572. * Disconnect Socketio connection.
  17573. */
  17574. }, {
  17575. key: 'disconnect',
  17576. value: function disconnect() {
  17577. this.socket.disconnect();
  17578. }
  17579. }]);
  17580. return SocketIoConnector;
  17581. }(Connector);
  17582. /**
  17583. * This class creates a null connector.
  17584. */
  17585. var NullConnector = function (_Connector) {
  17586. inherits(NullConnector, _Connector);
  17587. function NullConnector() {
  17588. classCallCheck(this, NullConnector);
  17589. /**
  17590. * All of the subscribed channel names.
  17591. */
  17592. var _this = possibleConstructorReturn(this, (NullConnector.__proto__ || Object.getPrototypeOf(NullConnector)).apply(this, arguments));
  17593. _this.channels = {};
  17594. return _this;
  17595. }
  17596. /**
  17597. * Create a fresh connection.
  17598. */
  17599. createClass(NullConnector, [{
  17600. key: 'connect',
  17601. value: function connect() {}
  17602. //
  17603. /**
  17604. * Listen for an event on a channel instance.
  17605. */
  17606. }, {
  17607. key: 'listen',
  17608. value: function listen(name, event, callback) {
  17609. return new NullChannel();
  17610. }
  17611. /**
  17612. * Get a channel instance by name.
  17613. */
  17614. }, {
  17615. key: 'channel',
  17616. value: function channel(name) {
  17617. return new NullChannel();
  17618. }
  17619. /**
  17620. * Get a private channel instance by name.
  17621. */
  17622. }, {
  17623. key: 'privateChannel',
  17624. value: function privateChannel(name) {
  17625. return new NullPrivateChannel();
  17626. }
  17627. /**
  17628. * Get a presence channel instance by name.
  17629. */
  17630. }, {
  17631. key: 'presenceChannel',
  17632. value: function presenceChannel(name) {
  17633. return new NullPresenceChannel();
  17634. }
  17635. /**
  17636. * Leave the given channel, as well as its private and presence variants.
  17637. */
  17638. }, {
  17639. key: 'leave',
  17640. value: function leave(name) {}
  17641. //
  17642. /**
  17643. * Leave the given channel.
  17644. */
  17645. }, {
  17646. key: 'leaveChannel',
  17647. value: function leaveChannel(name) {}
  17648. //
  17649. /**
  17650. * Get the socket ID for the connection.
  17651. */
  17652. }, {
  17653. key: 'socketId',
  17654. value: function socketId() {
  17655. return 'fake-socket-id';
  17656. }
  17657. /**
  17658. * Disconnect the connection.
  17659. */
  17660. }, {
  17661. key: 'disconnect',
  17662. value: function disconnect() {
  17663. //
  17664. }
  17665. }]);
  17666. return NullConnector;
  17667. }(Connector);
  17668. /**
  17669. * This class is the primary API for interacting with broadcasting.
  17670. */
  17671. var Echo = function () {
  17672. /**
  17673. * Create a new class instance.
  17674. */
  17675. function Echo(options) {
  17676. classCallCheck(this, Echo);
  17677. this.options = options;
  17678. this.connect();
  17679. if (!this.options.withoutInterceptors) {
  17680. this.registerInterceptors();
  17681. }
  17682. }
  17683. /**
  17684. * Get a channel instance by name.
  17685. */
  17686. createClass(Echo, [{
  17687. key: 'channel',
  17688. value: function channel(_channel) {
  17689. return this.connector.channel(_channel);
  17690. }
  17691. /**
  17692. * Create a new connection.
  17693. */
  17694. }, {
  17695. key: 'connect',
  17696. value: function connect() {
  17697. if (this.options.broadcaster == 'pusher') {
  17698. this.connector = new PusherConnector(this.options);
  17699. } else if (this.options.broadcaster == 'socket.io') {
  17700. this.connector = new SocketIoConnector(this.options);
  17701. } else if (this.options.broadcaster == 'null') {
  17702. this.connector = new NullConnector(this.options);
  17703. } else if (typeof this.options.broadcaster == 'function') {
  17704. this.connector = new this.options.broadcaster(this.options);
  17705. }
  17706. }
  17707. /**
  17708. * Disconnect from the Echo server.
  17709. */
  17710. }, {
  17711. key: 'disconnect',
  17712. value: function disconnect() {
  17713. this.connector.disconnect();
  17714. }
  17715. /**
  17716. * Get a presence channel instance by name.
  17717. */
  17718. }, {
  17719. key: 'join',
  17720. value: function join(channel) {
  17721. return this.connector.presenceChannel(channel);
  17722. }
  17723. /**
  17724. * Leave the given channel, as well as its private and presence variants.
  17725. */
  17726. }, {
  17727. key: 'leave',
  17728. value: function leave(channel) {
  17729. this.connector.leave(channel);
  17730. }
  17731. /**
  17732. * Leave the given channel.
  17733. */
  17734. }, {
  17735. key: 'leaveChannel',
  17736. value: function leaveChannel(channel) {
  17737. this.connector.leaveChannel(channel);
  17738. }
  17739. /**
  17740. * Listen for an event on a channel instance.
  17741. */
  17742. }, {
  17743. key: 'listen',
  17744. value: function listen(channel, event, callback) {
  17745. return this.connector.listen(channel, event, callback);
  17746. }
  17747. /**
  17748. * Get a private channel instance by name.
  17749. */
  17750. }, {
  17751. key: 'private',
  17752. value: function _private(channel) {
  17753. return this.connector.privateChannel(channel);
  17754. }
  17755. /**
  17756. * Get the Socket ID for the connection.
  17757. */
  17758. }, {
  17759. key: 'socketId',
  17760. value: function socketId() {
  17761. return this.connector.socketId();
  17762. }
  17763. /**
  17764. * Register 3rd party request interceptiors. These are used to automatically
  17765. * send a connections socket id to a Laravel app with a X-Socket-Id header.
  17766. */
  17767. }, {
  17768. key: 'registerInterceptors',
  17769. value: function registerInterceptors() {
  17770. if (typeof Vue === 'function' && Vue.http) {
  17771. this.registerVueRequestInterceptor();
  17772. }
  17773. if (typeof axios === 'function') {
  17774. this.registerAxiosRequestInterceptor();
  17775. }
  17776. if (typeof jQuery === 'function') {
  17777. this.registerjQueryAjaxSetup();
  17778. }
  17779. }
  17780. /**
  17781. * Register a Vue HTTP interceptor to add the X-Socket-ID header.
  17782. */
  17783. }, {
  17784. key: 'registerVueRequestInterceptor',
  17785. value: function registerVueRequestInterceptor() {
  17786. var _this = this;
  17787. Vue.http.interceptors.push(function (request, next) {
  17788. if (_this.socketId()) {
  17789. request.headers.set('X-Socket-ID', _this.socketId());
  17790. }
  17791. next();
  17792. });
  17793. }
  17794. /**
  17795. * Register an Axios HTTP interceptor to add the X-Socket-ID header.
  17796. */
  17797. }, {
  17798. key: 'registerAxiosRequestInterceptor',
  17799. value: function registerAxiosRequestInterceptor() {
  17800. var _this2 = this;
  17801. axios.interceptors.request.use(function (config) {
  17802. if (_this2.socketId()) {
  17803. config.headers['X-Socket-Id'] = _this2.socketId();
  17804. }
  17805. return config;
  17806. });
  17807. }
  17808. /**
  17809. * Register jQuery AjaxPrefilter to add the X-Socket-ID header.
  17810. */
  17811. }, {
  17812. key: 'registerjQueryAjaxSetup',
  17813. value: function registerjQueryAjaxSetup() {
  17814. var _this3 = this;
  17815. if (typeof jQuery.ajax != 'undefined') {
  17816. jQuery.ajaxPrefilter(function (options, originalOptions, xhr) {
  17817. if (_this3.socketId()) {
  17818. xhr.setRequestHeader('X-Socket-Id', _this3.socketId());
  17819. }
  17820. });
  17821. }
  17822. }
  17823. }]);
  17824. return Echo;
  17825. }();
  17826. /* harmony default export */ __webpack_exports__["default"] = (Echo);
  17827. /***/ }),
  17828. /***/ "./node_modules/lodash/lodash.js":
  17829. /*!***************************************!*\
  17830. !*** ./node_modules/lodash/lodash.js ***!
  17831. \***************************************/
  17832. /*! no static exports found */
  17833. /***/ (function(module, exports, __webpack_require__) {
  17834. /* WEBPACK VAR INJECTION */(function(global, module) {var __WEBPACK_AMD_DEFINE_RESULT__;/**
  17835. * @license
  17836. * Lodash <https://lodash.com/>
  17837. * Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
  17838. * Released under MIT license <https://lodash.com/license>
  17839. * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
  17840. * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
  17841. */
  17842. ;(function() {
  17843. /** Used as a safe reference for `undefined` in pre-ES5 environments. */
  17844. var undefined;
  17845. /** Used as the semantic version number. */
  17846. var VERSION = '4.17.15';
  17847. /** Used as the size to enable large array optimizations. */
  17848. var LARGE_ARRAY_SIZE = 200;
  17849. /** Error message constants. */
  17850. var CORE_ERROR_TEXT = 'Unsupported core-js use. Try https://npms.io/search?q=ponyfill.',
  17851. FUNC_ERROR_TEXT = 'Expected a function';
  17852. /** Used to stand-in for `undefined` hash values. */
  17853. var HASH_UNDEFINED = '__lodash_hash_undefined__';
  17854. /** Used as the maximum memoize cache size. */
  17855. var MAX_MEMOIZE_SIZE = 500;
  17856. /** Used as the internal argument placeholder. */
  17857. var PLACEHOLDER = '__lodash_placeholder__';
  17858. /** Used to compose bitmasks for cloning. */
  17859. var CLONE_DEEP_FLAG = 1,
  17860. CLONE_FLAT_FLAG = 2,
  17861. CLONE_SYMBOLS_FLAG = 4;
  17862. /** Used to compose bitmasks for value comparisons. */
  17863. var COMPARE_PARTIAL_FLAG = 1,
  17864. COMPARE_UNORDERED_FLAG = 2;
  17865. /** Used to compose bitmasks for function metadata. */
  17866. var WRAP_BIND_FLAG = 1,
  17867. WRAP_BIND_KEY_FLAG = 2,
  17868. WRAP_CURRY_BOUND_FLAG = 4,
  17869. WRAP_CURRY_FLAG = 8,
  17870. WRAP_CURRY_RIGHT_FLAG = 16,
  17871. WRAP_PARTIAL_FLAG = 32,
  17872. WRAP_PARTIAL_RIGHT_FLAG = 64,
  17873. WRAP_ARY_FLAG = 128,
  17874. WRAP_REARG_FLAG = 256,
  17875. WRAP_FLIP_FLAG = 512;
  17876. /** Used as default options for `_.truncate`. */
  17877. var DEFAULT_TRUNC_LENGTH = 30,
  17878. DEFAULT_TRUNC_OMISSION = '...';
  17879. /** Used to detect hot functions by number of calls within a span of milliseconds. */
  17880. var HOT_COUNT = 800,
  17881. HOT_SPAN = 16;
  17882. /** Used to indicate the type of lazy iteratees. */
  17883. var LAZY_FILTER_FLAG = 1,
  17884. LAZY_MAP_FLAG = 2,
  17885. LAZY_WHILE_FLAG = 3;
  17886. /** Used as references for various `Number` constants. */
  17887. var INFINITY = 1 / 0,
  17888. MAX_SAFE_INTEGER = 9007199254740991,
  17889. MAX_INTEGER = 1.7976931348623157e+308,
  17890. NAN = 0 / 0;
  17891. /** Used as references for the maximum length and index of an array. */
  17892. var MAX_ARRAY_LENGTH = 4294967295,
  17893. MAX_ARRAY_INDEX = MAX_ARRAY_LENGTH - 1,
  17894. HALF_MAX_ARRAY_LENGTH = MAX_ARRAY_LENGTH >>> 1;
  17895. /** Used to associate wrap methods with their bit flags. */
  17896. var wrapFlags = [
  17897. ['ary', WRAP_ARY_FLAG],
  17898. ['bind', WRAP_BIND_FLAG],
  17899. ['bindKey', WRAP_BIND_KEY_FLAG],
  17900. ['curry', WRAP_CURRY_FLAG],
  17901. ['curryRight', WRAP_CURRY_RIGHT_FLAG],
  17902. ['flip', WRAP_FLIP_FLAG],
  17903. ['partial', WRAP_PARTIAL_FLAG],
  17904. ['partialRight', WRAP_PARTIAL_RIGHT_FLAG],
  17905. ['rearg', WRAP_REARG_FLAG]
  17906. ];
  17907. /** `Object#toString` result references. */
  17908. var argsTag = '[object Arguments]',
  17909. arrayTag = '[object Array]',
  17910. asyncTag = '[object AsyncFunction]',
  17911. boolTag = '[object Boolean]',
  17912. dateTag = '[object Date]',
  17913. domExcTag = '[object DOMException]',
  17914. errorTag = '[object Error]',
  17915. funcTag = '[object Function]',
  17916. genTag = '[object GeneratorFunction]',
  17917. mapTag = '[object Map]',
  17918. numberTag = '[object Number]',
  17919. nullTag = '[object Null]',
  17920. objectTag = '[object Object]',
  17921. promiseTag = '[object Promise]',
  17922. proxyTag = '[object Proxy]',
  17923. regexpTag = '[object RegExp]',
  17924. setTag = '[object Set]',
  17925. stringTag = '[object String]',
  17926. symbolTag = '[object Symbol]',
  17927. undefinedTag = '[object Undefined]',
  17928. weakMapTag = '[object WeakMap]',
  17929. weakSetTag = '[object WeakSet]';
  17930. var arrayBufferTag = '[object ArrayBuffer]',
  17931. dataViewTag = '[object DataView]',
  17932. float32Tag = '[object Float32Array]',
  17933. float64Tag = '[object Float64Array]',
  17934. int8Tag = '[object Int8Array]',
  17935. int16Tag = '[object Int16Array]',
  17936. int32Tag = '[object Int32Array]',
  17937. uint8Tag = '[object Uint8Array]',
  17938. uint8ClampedTag = '[object Uint8ClampedArray]',
  17939. uint16Tag = '[object Uint16Array]',
  17940. uint32Tag = '[object Uint32Array]';
  17941. /** Used to match empty string literals in compiled template source. */
  17942. var reEmptyStringLeading = /\b__p \+= '';/g,
  17943. reEmptyStringMiddle = /\b(__p \+=) '' \+/g,
  17944. reEmptyStringTrailing = /(__e\(.*?\)|\b__t\)) \+\n'';/g;
  17945. /** Used to match HTML entities and HTML characters. */
  17946. var reEscapedHtml = /&(?:amp|lt|gt|quot|#39);/g,
  17947. reUnescapedHtml = /[&<>"']/g,
  17948. reHasEscapedHtml = RegExp(reEscapedHtml.source),
  17949. reHasUnescapedHtml = RegExp(reUnescapedHtml.source);
  17950. /** Used to match template delimiters. */
  17951. var reEscape = /<%-([\s\S]+?)%>/g,
  17952. reEvaluate = /<%([\s\S]+?)%>/g,
  17953. reInterpolate = /<%=([\s\S]+?)%>/g;
  17954. /** Used to match property names within property paths. */
  17955. var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,
  17956. reIsPlainProp = /^\w*$/,
  17957. rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;
  17958. /**
  17959. * Used to match `RegExp`
  17960. * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
  17961. */
  17962. var reRegExpChar = /[\\^$.*+?()[\]{}|]/g,
  17963. reHasRegExpChar = RegExp(reRegExpChar.source);
  17964. /** Used to match leading and trailing whitespace. */
  17965. var reTrim = /^\s+|\s+$/g,
  17966. reTrimStart = /^\s+/,
  17967. reTrimEnd = /\s+$/;
  17968. /** Used to match wrap detail comments. */
  17969. var reWrapComment = /\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,
  17970. reWrapDetails = /\{\n\/\* \[wrapped with (.+)\] \*/,
  17971. reSplitDetails = /,? & /;
  17972. /** Used to match words composed of alphanumeric characters. */
  17973. var reAsciiWord = /[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;
  17974. /** Used to match backslashes in property paths. */
  17975. var reEscapeChar = /\\(\\)?/g;
  17976. /**
  17977. * Used to match
  17978. * [ES template delimiters](http://ecma-international.org/ecma-262/7.0/#sec-template-literal-lexical-components).
  17979. */
  17980. var reEsTemplate = /\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g;
  17981. /** Used to match `RegExp` flags from their coerced string values. */
  17982. var reFlags = /\w*$/;
  17983. /** Used to detect bad signed hexadecimal string values. */
  17984. var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
  17985. /** Used to detect binary string values. */
  17986. var reIsBinary = /^0b[01]+$/i;
  17987. /** Used to detect host constructors (Safari). */
  17988. var reIsHostCtor = /^\[object .+?Constructor\]$/;
  17989. /** Used to detect octal string values. */
  17990. var reIsOctal = /^0o[0-7]+$/i;
  17991. /** Used to detect unsigned integer values. */
  17992. var reIsUint = /^(?:0|[1-9]\d*)$/;
  17993. /** Used to match Latin Unicode letters (excluding mathematical operators). */
  17994. var reLatin = /[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g;
  17995. /** Used to ensure capturing order of template delimiters. */
  17996. var reNoMatch = /($^)/;
  17997. /** Used to match unescaped characters in compiled string literals. */
  17998. var reUnescapedString = /['\n\r\u2028\u2029\\]/g;
  17999. /** Used to compose unicode character classes. */
  18000. var rsAstralRange = '\\ud800-\\udfff',
  18001. rsComboMarksRange = '\\u0300-\\u036f',
  18002. reComboHalfMarksRange = '\\ufe20-\\ufe2f',
  18003. rsComboSymbolsRange = '\\u20d0-\\u20ff',
  18004. rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange,
  18005. rsDingbatRange = '\\u2700-\\u27bf',
  18006. rsLowerRange = 'a-z\\xdf-\\xf6\\xf8-\\xff',
  18007. rsMathOpRange = '\\xac\\xb1\\xd7\\xf7',
  18008. rsNonCharRange = '\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf',
  18009. rsPunctuationRange = '\\u2000-\\u206f',
  18010. 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',
  18011. rsUpperRange = 'A-Z\\xc0-\\xd6\\xd8-\\xde',
  18012. rsVarRange = '\\ufe0e\\ufe0f',
  18013. rsBreakRange = rsMathOpRange + rsNonCharRange + rsPunctuationRange + rsSpaceRange;
  18014. /** Used to compose unicode capture groups. */
  18015. var rsApos = "['\u2019]",
  18016. rsAstral = '[' + rsAstralRange + ']',
  18017. rsBreak = '[' + rsBreakRange + ']',
  18018. rsCombo = '[' + rsComboRange + ']',
  18019. rsDigits = '\\d+',
  18020. rsDingbat = '[' + rsDingbatRange + ']',
  18021. rsLower = '[' + rsLowerRange + ']',
  18022. rsMisc = '[^' + rsAstralRange + rsBreakRange + rsDigits + rsDingbatRange + rsLowerRange + rsUpperRange + ']',
  18023. rsFitz = '\\ud83c[\\udffb-\\udfff]',
  18024. rsModifier = '(?:' + rsCombo + '|' + rsFitz + ')',
  18025. rsNonAstral = '[^' + rsAstralRange + ']',
  18026. rsRegional = '(?:\\ud83c[\\udde6-\\uddff]){2}',
  18027. rsSurrPair = '[\\ud800-\\udbff][\\udc00-\\udfff]',
  18028. rsUpper = '[' + rsUpperRange + ']',
  18029. rsZWJ = '\\u200d';
  18030. /** Used to compose unicode regexes. */
  18031. var rsMiscLower = '(?:' + rsLower + '|' + rsMisc + ')',
  18032. rsMiscUpper = '(?:' + rsUpper + '|' + rsMisc + ')',
  18033. rsOptContrLower = '(?:' + rsApos + '(?:d|ll|m|re|s|t|ve))?',
  18034. rsOptContrUpper = '(?:' + rsApos + '(?:D|LL|M|RE|S|T|VE))?',
  18035. reOptMod = rsModifier + '?',
  18036. rsOptVar = '[' + rsVarRange + ']?',
  18037. rsOptJoin = '(?:' + rsZWJ + '(?:' + [rsNonAstral, rsRegional, rsSurrPair].join('|') + ')' + rsOptVar + reOptMod + ')*',
  18038. rsOrdLower = '\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])',
  18039. rsOrdUpper = '\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])',
  18040. rsSeq = rsOptVar + reOptMod + rsOptJoin,
  18041. rsEmoji = '(?:' + [rsDingbat, rsRegional, rsSurrPair].join('|') + ')' + rsSeq,
  18042. rsSymbol = '(?:' + [rsNonAstral + rsCombo + '?', rsCombo, rsRegional, rsSurrPair, rsAstral].join('|') + ')';
  18043. /** Used to match apostrophes. */
  18044. var reApos = RegExp(rsApos, 'g');
  18045. /**
  18046. * Used to match [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks) and
  18047. * [combining diacritical marks for symbols](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks_for_Symbols).
  18048. */
  18049. var reComboMark = RegExp(rsCombo, 'g');
  18050. /** Used to match [string symbols](https://mathiasbynens.be/notes/javascript-unicode). */
  18051. var reUnicode = RegExp(rsFitz + '(?=' + rsFitz + ')|' + rsSymbol + rsSeq, 'g');
  18052. /** Used to match complex or compound words. */
  18053. var reUnicodeWord = RegExp([
  18054. rsUpper + '?' + rsLower + '+' + rsOptContrLower + '(?=' + [rsBreak, rsUpper, '$'].join('|') + ')',
  18055. rsMiscUpper + '+' + rsOptContrUpper + '(?=' + [rsBreak, rsUpper + rsMiscLower, '$'].join('|') + ')',
  18056. rsUpper + '?' + rsMiscLower + '+' + rsOptContrLower,
  18057. rsUpper + '+' + rsOptContrUpper,
  18058. rsOrdUpper,
  18059. rsOrdLower,
  18060. rsDigits,
  18061. rsEmoji
  18062. ].join('|'), 'g');
  18063. /** 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/). */
  18064. var reHasUnicode = RegExp('[' + rsZWJ + rsAstralRange + rsComboRange + rsVarRange + ']');
  18065. /** Used to detect strings that need a more robust regexp to match words. */
  18066. 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 ]/;
  18067. /** Used to assign default `context` object properties. */
  18068. var contextProps = [
  18069. 'Array', 'Buffer', 'DataView', 'Date', 'Error', 'Float32Array', 'Float64Array',
  18070. 'Function', 'Int8Array', 'Int16Array', 'Int32Array', 'Map', 'Math', 'Object',
  18071. 'Promise', 'RegExp', 'Set', 'String', 'Symbol', 'TypeError', 'Uint8Array',
  18072. 'Uint8ClampedArray', 'Uint16Array', 'Uint32Array', 'WeakMap',
  18073. '_', 'clearTimeout', 'isFinite', 'parseInt', 'setTimeout'
  18074. ];
  18075. /** Used to make template sourceURLs easier to identify. */
  18076. var templateCounter = -1;
  18077. /** Used to identify `toStringTag` values of typed arrays. */
  18078. var typedArrayTags = {};
  18079. typedArrayTags[float32Tag] = typedArrayTags[float64Tag] =
  18080. typedArrayTags[int8Tag] = typedArrayTags[int16Tag] =
  18081. typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =
  18082. typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =
  18083. typedArrayTags[uint32Tag] = true;
  18084. typedArrayTags[argsTag] = typedArrayTags[arrayTag] =
  18085. typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] =
  18086. typedArrayTags[dataViewTag] = typedArrayTags[dateTag] =
  18087. typedArrayTags[errorTag] = typedArrayTags[funcTag] =
  18088. typedArrayTags[mapTag] = typedArrayTags[numberTag] =
  18089. typedArrayTags[objectTag] = typedArrayTags[regexpTag] =
  18090. typedArrayTags[setTag] = typedArrayTags[stringTag] =
  18091. typedArrayTags[weakMapTag] = false;
  18092. /** Used to identify `toStringTag` values supported by `_.clone`. */
  18093. var cloneableTags = {};
  18094. cloneableTags[argsTag] = cloneableTags[arrayTag] =
  18095. cloneableTags[arrayBufferTag] = cloneableTags[dataViewTag] =
  18096. cloneableTags[boolTag] = cloneableTags[dateTag] =
  18097. cloneableTags[float32Tag] = cloneableTags[float64Tag] =
  18098. cloneableTags[int8Tag] = cloneableTags[int16Tag] =
  18099. cloneableTags[int32Tag] = cloneableTags[mapTag] =
  18100. cloneableTags[numberTag] = cloneableTags[objectTag] =
  18101. cloneableTags[regexpTag] = cloneableTags[setTag] =
  18102. cloneableTags[stringTag] = cloneableTags[symbolTag] =
  18103. cloneableTags[uint8Tag] = cloneableTags[uint8ClampedTag] =
  18104. cloneableTags[uint16Tag] = cloneableTags[uint32Tag] = true;
  18105. cloneableTags[errorTag] = cloneableTags[funcTag] =
  18106. cloneableTags[weakMapTag] = false;
  18107. /** Used to map Latin Unicode letters to basic Latin letters. */
  18108. var deburredLetters = {
  18109. // Latin-1 Supplement block.
  18110. '\xc0': 'A', '\xc1': 'A', '\xc2': 'A', '\xc3': 'A', '\xc4': 'A', '\xc5': 'A',
  18111. '\xe0': 'a', '\xe1': 'a', '\xe2': 'a', '\xe3': 'a', '\xe4': 'a', '\xe5': 'a',
  18112. '\xc7': 'C', '\xe7': 'c',
  18113. '\xd0': 'D', '\xf0': 'd',
  18114. '\xc8': 'E', '\xc9': 'E', '\xca': 'E', '\xcb': 'E',
  18115. '\xe8': 'e', '\xe9': 'e', '\xea': 'e', '\xeb': 'e',
  18116. '\xcc': 'I', '\xcd': 'I', '\xce': 'I', '\xcf': 'I',
  18117. '\xec': 'i', '\xed': 'i', '\xee': 'i', '\xef': 'i',
  18118. '\xd1': 'N', '\xf1': 'n',
  18119. '\xd2': 'O', '\xd3': 'O', '\xd4': 'O', '\xd5': 'O', '\xd6': 'O', '\xd8': 'O',
  18120. '\xf2': 'o', '\xf3': 'o', '\xf4': 'o', '\xf5': 'o', '\xf6': 'o', '\xf8': 'o',
  18121. '\xd9': 'U', '\xda': 'U', '\xdb': 'U', '\xdc': 'U',
  18122. '\xf9': 'u', '\xfa': 'u', '\xfb': 'u', '\xfc': 'u',
  18123. '\xdd': 'Y', '\xfd': 'y', '\xff': 'y',
  18124. '\xc6': 'Ae', '\xe6': 'ae',
  18125. '\xde': 'Th', '\xfe': 'th',
  18126. '\xdf': 'ss',
  18127. // Latin Extended-A block.
  18128. '\u0100': 'A', '\u0102': 'A', '\u0104': 'A',
  18129. '\u0101': 'a', '\u0103': 'a', '\u0105': 'a',
  18130. '\u0106': 'C', '\u0108': 'C', '\u010a': 'C', '\u010c': 'C',
  18131. '\u0107': 'c', '\u0109': 'c', '\u010b': 'c', '\u010d': 'c',
  18132. '\u010e': 'D', '\u0110': 'D', '\u010f': 'd', '\u0111': 'd',
  18133. '\u0112': 'E', '\u0114': 'E', '\u0116': 'E', '\u0118': 'E', '\u011a': 'E',
  18134. '\u0113': 'e', '\u0115': 'e', '\u0117': 'e', '\u0119': 'e', '\u011b': 'e',
  18135. '\u011c': 'G', '\u011e': 'G', '\u0120': 'G', '\u0122': 'G',
  18136. '\u011d': 'g', '\u011f': 'g', '\u0121': 'g', '\u0123': 'g',
  18137. '\u0124': 'H', '\u0126': 'H', '\u0125': 'h', '\u0127': 'h',
  18138. '\u0128': 'I', '\u012a': 'I', '\u012c': 'I', '\u012e': 'I', '\u0130': 'I',
  18139. '\u0129': 'i', '\u012b': 'i', '\u012d': 'i', '\u012f': 'i', '\u0131': 'i',
  18140. '\u0134': 'J', '\u0135': 'j',
  18141. '\u0136': 'K', '\u0137': 'k', '\u0138': 'k',
  18142. '\u0139': 'L', '\u013b': 'L', '\u013d': 'L', '\u013f': 'L', '\u0141': 'L',
  18143. '\u013a': 'l', '\u013c': 'l', '\u013e': 'l', '\u0140': 'l', '\u0142': 'l',
  18144. '\u0143': 'N', '\u0145': 'N', '\u0147': 'N', '\u014a': 'N',
  18145. '\u0144': 'n', '\u0146': 'n', '\u0148': 'n', '\u014b': 'n',
  18146. '\u014c': 'O', '\u014e': 'O', '\u0150': 'O',
  18147. '\u014d': 'o', '\u014f': 'o', '\u0151': 'o',
  18148. '\u0154': 'R', '\u0156': 'R', '\u0158': 'R',
  18149. '\u0155': 'r', '\u0157': 'r', '\u0159': 'r',
  18150. '\u015a': 'S', '\u015c': 'S', '\u015e': 'S', '\u0160': 'S',
  18151. '\u015b': 's', '\u015d': 's', '\u015f': 's', '\u0161': 's',
  18152. '\u0162': 'T', '\u0164': 'T', '\u0166': 'T',
  18153. '\u0163': 't', '\u0165': 't', '\u0167': 't',
  18154. '\u0168': 'U', '\u016a': 'U', '\u016c': 'U', '\u016e': 'U', '\u0170': 'U', '\u0172': 'U',
  18155. '\u0169': 'u', '\u016b': 'u', '\u016d': 'u', '\u016f': 'u', '\u0171': 'u', '\u0173': 'u',
  18156. '\u0174': 'W', '\u0175': 'w',
  18157. '\u0176': 'Y', '\u0177': 'y', '\u0178': 'Y',
  18158. '\u0179': 'Z', '\u017b': 'Z', '\u017d': 'Z',
  18159. '\u017a': 'z', '\u017c': 'z', '\u017e': 'z',
  18160. '\u0132': 'IJ', '\u0133': 'ij',
  18161. '\u0152': 'Oe', '\u0153': 'oe',
  18162. '\u0149': "'n", '\u017f': 's'
  18163. };
  18164. /** Used to map characters to HTML entities. */
  18165. var htmlEscapes = {
  18166. '&': '&amp;',
  18167. '<': '&lt;',
  18168. '>': '&gt;',
  18169. '"': '&quot;',
  18170. "'": '&#39;'
  18171. };
  18172. /** Used to map HTML entities to characters. */
  18173. var htmlUnescapes = {
  18174. '&amp;': '&',
  18175. '&lt;': '<',
  18176. '&gt;': '>',
  18177. '&quot;': '"',
  18178. '&#39;': "'"
  18179. };
  18180. /** Used to escape characters for inclusion in compiled string literals. */
  18181. var stringEscapes = {
  18182. '\\': '\\',
  18183. "'": "'",
  18184. '\n': 'n',
  18185. '\r': 'r',
  18186. '\u2028': 'u2028',
  18187. '\u2029': 'u2029'
  18188. };
  18189. /** Built-in method references without a dependency on `root`. */
  18190. var freeParseFloat = parseFloat,
  18191. freeParseInt = parseInt;
  18192. /** Detect free variable `global` from Node.js. */
  18193. var freeGlobal = typeof global == 'object' && global && global.Object === Object && global;
  18194. /** Detect free variable `self`. */
  18195. var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
  18196. /** Used as a reference to the global object. */
  18197. var root = freeGlobal || freeSelf || Function('return this')();
  18198. /** Detect free variable `exports`. */
  18199. var freeExports = true && exports && !exports.nodeType && exports;
  18200. /** Detect free variable `module`. */
  18201. var freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module;
  18202. /** Detect the popular CommonJS extension `module.exports`. */
  18203. var moduleExports = freeModule && freeModule.exports === freeExports;
  18204. /** Detect free variable `process` from Node.js. */
  18205. var freeProcess = moduleExports && freeGlobal.process;
  18206. /** Used to access faster Node.js helpers. */
  18207. var nodeUtil = (function() {
  18208. try {
  18209. // Use `util.types` for Node.js 10+.
  18210. var types = freeModule && freeModule.require && freeModule.require('util').types;
  18211. if (types) {
  18212. return types;
  18213. }
  18214. // Legacy `process.binding('util')` for Node.js < 10.
  18215. return freeProcess && freeProcess.binding && freeProcess.binding('util');
  18216. } catch (e) {}
  18217. }());
  18218. /* Node.js helper references. */
  18219. var nodeIsArrayBuffer = nodeUtil && nodeUtil.isArrayBuffer,
  18220. nodeIsDate = nodeUtil && nodeUtil.isDate,
  18221. nodeIsMap = nodeUtil && nodeUtil.isMap,
  18222. nodeIsRegExp = nodeUtil && nodeUtil.isRegExp,
  18223. nodeIsSet = nodeUtil && nodeUtil.isSet,
  18224. nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray;
  18225. /*--------------------------------------------------------------------------*/
  18226. /**
  18227. * A faster alternative to `Function#apply`, this function invokes `func`
  18228. * with the `this` binding of `thisArg` and the arguments of `args`.
  18229. *
  18230. * @private
  18231. * @param {Function} func The function to invoke.
  18232. * @param {*} thisArg The `this` binding of `func`.
  18233. * @param {Array} args The arguments to invoke `func` with.
  18234. * @returns {*} Returns the result of `func`.
  18235. */
  18236. function apply(func, thisArg, args) {
  18237. switch (args.length) {
  18238. case 0: return func.call(thisArg);
  18239. case 1: return func.call(thisArg, args[0]);
  18240. case 2: return func.call(thisArg, args[0], args[1]);
  18241. case 3: return func.call(thisArg, args[0], args[1], args[2]);
  18242. }
  18243. return func.apply(thisArg, args);
  18244. }
  18245. /**
  18246. * A specialized version of `baseAggregator` for arrays.
  18247. *
  18248. * @private
  18249. * @param {Array} [array] The array to iterate over.
  18250. * @param {Function} setter The function to set `accumulator` values.
  18251. * @param {Function} iteratee The iteratee to transform keys.
  18252. * @param {Object} accumulator The initial aggregated object.
  18253. * @returns {Function} Returns `accumulator`.
  18254. */
  18255. function arrayAggregator(array, setter, iteratee, accumulator) {
  18256. var index = -1,
  18257. length = array == null ? 0 : array.length;
  18258. while (++index < length) {
  18259. var value = array[index];
  18260. setter(accumulator, value, iteratee(value), array);
  18261. }
  18262. return accumulator;
  18263. }
  18264. /**
  18265. * A specialized version of `_.forEach` for arrays without support for
  18266. * iteratee shorthands.
  18267. *
  18268. * @private
  18269. * @param {Array} [array] The array to iterate over.
  18270. * @param {Function} iteratee The function invoked per iteration.
  18271. * @returns {Array} Returns `array`.
  18272. */
  18273. function arrayEach(array, iteratee) {
  18274. var index = -1,
  18275. length = array == null ? 0 : array.length;
  18276. while (++index < length) {
  18277. if (iteratee(array[index], index, array) === false) {
  18278. break;
  18279. }
  18280. }
  18281. return array;
  18282. }
  18283. /**
  18284. * A specialized version of `_.forEachRight` for arrays without support for
  18285. * iteratee shorthands.
  18286. *
  18287. * @private
  18288. * @param {Array} [array] The array to iterate over.
  18289. * @param {Function} iteratee The function invoked per iteration.
  18290. * @returns {Array} Returns `array`.
  18291. */
  18292. function arrayEachRight(array, iteratee) {
  18293. var length = array == null ? 0 : array.length;
  18294. while (length--) {
  18295. if (iteratee(array[length], length, array) === false) {
  18296. break;
  18297. }
  18298. }
  18299. return array;
  18300. }
  18301. /**
  18302. * A specialized version of `_.every` for arrays without support for
  18303. * iteratee shorthands.
  18304. *
  18305. * @private
  18306. * @param {Array} [array] The array to iterate over.
  18307. * @param {Function} predicate The function invoked per iteration.
  18308. * @returns {boolean} Returns `true` if all elements pass the predicate check,
  18309. * else `false`.
  18310. */
  18311. function arrayEvery(array, predicate) {
  18312. var index = -1,
  18313. length = array == null ? 0 : array.length;
  18314. while (++index < length) {
  18315. if (!predicate(array[index], index, array)) {
  18316. return false;
  18317. }
  18318. }
  18319. return true;
  18320. }
  18321. /**
  18322. * A specialized version of `_.filter` for arrays without support for
  18323. * iteratee shorthands.
  18324. *
  18325. * @private
  18326. * @param {Array} [array] The array to iterate over.
  18327. * @param {Function} predicate The function invoked per iteration.
  18328. * @returns {Array} Returns the new filtered array.
  18329. */
  18330. function arrayFilter(array, predicate) {
  18331. var index = -1,
  18332. length = array == null ? 0 : array.length,
  18333. resIndex = 0,
  18334. result = [];
  18335. while (++index < length) {
  18336. var value = array[index];
  18337. if (predicate(value, index, array)) {
  18338. result[resIndex++] = value;
  18339. }
  18340. }
  18341. return result;
  18342. }
  18343. /**
  18344. * A specialized version of `_.includes` for arrays without support for
  18345. * specifying an index to search from.
  18346. *
  18347. * @private
  18348. * @param {Array} [array] The array to inspect.
  18349. * @param {*} target The value to search for.
  18350. * @returns {boolean} Returns `true` if `target` is found, else `false`.
  18351. */
  18352. function arrayIncludes(array, value) {
  18353. var length = array == null ? 0 : array.length;
  18354. return !!length && baseIndexOf(array, value, 0) > -1;
  18355. }
  18356. /**
  18357. * This function is like `arrayIncludes` except that it accepts a comparator.
  18358. *
  18359. * @private
  18360. * @param {Array} [array] The array to inspect.
  18361. * @param {*} target The value to search for.
  18362. * @param {Function} comparator The comparator invoked per element.
  18363. * @returns {boolean} Returns `true` if `target` is found, else `false`.
  18364. */
  18365. function arrayIncludesWith(array, value, comparator) {
  18366. var index = -1,
  18367. length = array == null ? 0 : array.length;
  18368. while (++index < length) {
  18369. if (comparator(value, array[index])) {
  18370. return true;
  18371. }
  18372. }
  18373. return false;
  18374. }
  18375. /**
  18376. * A specialized version of `_.map` for arrays without support for iteratee
  18377. * shorthands.
  18378. *
  18379. * @private
  18380. * @param {Array} [array] The array to iterate over.
  18381. * @param {Function} iteratee The function invoked per iteration.
  18382. * @returns {Array} Returns the new mapped array.
  18383. */
  18384. function arrayMap(array, iteratee) {
  18385. var index = -1,
  18386. length = array == null ? 0 : array.length,
  18387. result = Array(length);
  18388. while (++index < length) {
  18389. result[index] = iteratee(array[index], index, array);
  18390. }
  18391. return result;
  18392. }
  18393. /**
  18394. * Appends the elements of `values` to `array`.
  18395. *
  18396. * @private
  18397. * @param {Array} array The array to modify.
  18398. * @param {Array} values The values to append.
  18399. * @returns {Array} Returns `array`.
  18400. */
  18401. function arrayPush(array, values) {
  18402. var index = -1,
  18403. length = values.length,
  18404. offset = array.length;
  18405. while (++index < length) {
  18406. array[offset + index] = values[index];
  18407. }
  18408. return array;
  18409. }
  18410. /**
  18411. * A specialized version of `_.reduce` for arrays without support for
  18412. * iteratee shorthands.
  18413. *
  18414. * @private
  18415. * @param {Array} [array] The array to iterate over.
  18416. * @param {Function} iteratee The function invoked per iteration.
  18417. * @param {*} [accumulator] The initial value.
  18418. * @param {boolean} [initAccum] Specify using the first element of `array` as
  18419. * the initial value.
  18420. * @returns {*} Returns the accumulated value.
  18421. */
  18422. function arrayReduce(array, iteratee, accumulator, initAccum) {
  18423. var index = -1,
  18424. length = array == null ? 0 : array.length;
  18425. if (initAccum && length) {
  18426. accumulator = array[++index];
  18427. }
  18428. while (++index < length) {
  18429. accumulator = iteratee(accumulator, array[index], index, array);
  18430. }
  18431. return accumulator;
  18432. }
  18433. /**
  18434. * A specialized version of `_.reduceRight` for arrays without support for
  18435. * iteratee shorthands.
  18436. *
  18437. * @private
  18438. * @param {Array} [array] The array to iterate over.
  18439. * @param {Function} iteratee The function invoked per iteration.
  18440. * @param {*} [accumulator] The initial value.
  18441. * @param {boolean} [initAccum] Specify using the last element of `array` as
  18442. * the initial value.
  18443. * @returns {*} Returns the accumulated value.
  18444. */
  18445. function arrayReduceRight(array, iteratee, accumulator, initAccum) {
  18446. var length = array == null ? 0 : array.length;
  18447. if (initAccum && length) {
  18448. accumulator = array[--length];
  18449. }
  18450. while (length--) {
  18451. accumulator = iteratee(accumulator, array[length], length, array);
  18452. }
  18453. return accumulator;
  18454. }
  18455. /**
  18456. * A specialized version of `_.some` for arrays without support for iteratee
  18457. * shorthands.
  18458. *
  18459. * @private
  18460. * @param {Array} [array] The array to iterate over.
  18461. * @param {Function} predicate The function invoked per iteration.
  18462. * @returns {boolean} Returns `true` if any element passes the predicate check,
  18463. * else `false`.
  18464. */
  18465. function arraySome(array, predicate) {
  18466. var index = -1,
  18467. length = array == null ? 0 : array.length;
  18468. while (++index < length) {
  18469. if (predicate(array[index], index, array)) {
  18470. return true;
  18471. }
  18472. }
  18473. return false;
  18474. }
  18475. /**
  18476. * Gets the size of an ASCII `string`.
  18477. *
  18478. * @private
  18479. * @param {string} string The string inspect.
  18480. * @returns {number} Returns the string size.
  18481. */
  18482. var asciiSize = baseProperty('length');
  18483. /**
  18484. * Converts an ASCII `string` to an array.
  18485. *
  18486. * @private
  18487. * @param {string} string The string to convert.
  18488. * @returns {Array} Returns the converted array.
  18489. */
  18490. function asciiToArray(string) {
  18491. return string.split('');
  18492. }
  18493. /**
  18494. * Splits an ASCII `string` into an array of its words.
  18495. *
  18496. * @private
  18497. * @param {string} The string to inspect.
  18498. * @returns {Array} Returns the words of `string`.
  18499. */
  18500. function asciiWords(string) {
  18501. return string.match(reAsciiWord) || [];
  18502. }
  18503. /**
  18504. * The base implementation of methods like `_.findKey` and `_.findLastKey`,
  18505. * without support for iteratee shorthands, which iterates over `collection`
  18506. * using `eachFunc`.
  18507. *
  18508. * @private
  18509. * @param {Array|Object} collection The collection to inspect.
  18510. * @param {Function} predicate The function invoked per iteration.
  18511. * @param {Function} eachFunc The function to iterate over `collection`.
  18512. * @returns {*} Returns the found element or its key, else `undefined`.
  18513. */
  18514. function baseFindKey(collection, predicate, eachFunc) {
  18515. var result;
  18516. eachFunc(collection, function(value, key, collection) {
  18517. if (predicate(value, key, collection)) {
  18518. result = key;
  18519. return false;
  18520. }
  18521. });
  18522. return result;
  18523. }
  18524. /**
  18525. * The base implementation of `_.findIndex` and `_.findLastIndex` without
  18526. * support for iteratee shorthands.
  18527. *
  18528. * @private
  18529. * @param {Array} array The array to inspect.
  18530. * @param {Function} predicate The function invoked per iteration.
  18531. * @param {number} fromIndex The index to search from.
  18532. * @param {boolean} [fromRight] Specify iterating from right to left.
  18533. * @returns {number} Returns the index of the matched value, else `-1`.
  18534. */
  18535. function baseFindIndex(array, predicate, fromIndex, fromRight) {
  18536. var length = array.length,
  18537. index = fromIndex + (fromRight ? 1 : -1);
  18538. while ((fromRight ? index-- : ++index < length)) {
  18539. if (predicate(array[index], index, array)) {
  18540. return index;
  18541. }
  18542. }
  18543. return -1;
  18544. }
  18545. /**
  18546. * The base implementation of `_.indexOf` without `fromIndex` bounds checks.
  18547. *
  18548. * @private
  18549. * @param {Array} array The array to inspect.
  18550. * @param {*} value The value to search for.
  18551. * @param {number} fromIndex The index to search from.
  18552. * @returns {number} Returns the index of the matched value, else `-1`.
  18553. */
  18554. function baseIndexOf(array, value, fromIndex) {
  18555. return value === value
  18556. ? strictIndexOf(array, value, fromIndex)
  18557. : baseFindIndex(array, baseIsNaN, fromIndex);
  18558. }
  18559. /**
  18560. * This function is like `baseIndexOf` except that it accepts a comparator.
  18561. *
  18562. * @private
  18563. * @param {Array} array The array to inspect.
  18564. * @param {*} value The value to search for.
  18565. * @param {number} fromIndex The index to search from.
  18566. * @param {Function} comparator The comparator invoked per element.
  18567. * @returns {number} Returns the index of the matched value, else `-1`.
  18568. */
  18569. function baseIndexOfWith(array, value, fromIndex, comparator) {
  18570. var index = fromIndex - 1,
  18571. length = array.length;
  18572. while (++index < length) {
  18573. if (comparator(array[index], value)) {
  18574. return index;
  18575. }
  18576. }
  18577. return -1;
  18578. }
  18579. /**
  18580. * The base implementation of `_.isNaN` without support for number objects.
  18581. *
  18582. * @private
  18583. * @param {*} value The value to check.
  18584. * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`.
  18585. */
  18586. function baseIsNaN(value) {
  18587. return value !== value;
  18588. }
  18589. /**
  18590. * The base implementation of `_.mean` and `_.meanBy` without support for
  18591. * iteratee shorthands.
  18592. *
  18593. * @private
  18594. * @param {Array} array The array to iterate over.
  18595. * @param {Function} iteratee The function invoked per iteration.
  18596. * @returns {number} Returns the mean.
  18597. */
  18598. function baseMean(array, iteratee) {
  18599. var length = array == null ? 0 : array.length;
  18600. return length ? (baseSum(array, iteratee) / length) : NAN;
  18601. }
  18602. /**
  18603. * The base implementation of `_.property` without support for deep paths.
  18604. *
  18605. * @private
  18606. * @param {string} key The key of the property to get.
  18607. * @returns {Function} Returns the new accessor function.
  18608. */
  18609. function baseProperty(key) {
  18610. return function(object) {
  18611. return object == null ? undefined : object[key];
  18612. };
  18613. }
  18614. /**
  18615. * The base implementation of `_.propertyOf` without support for deep paths.
  18616. *
  18617. * @private
  18618. * @param {Object} object The object to query.
  18619. * @returns {Function} Returns the new accessor function.
  18620. */
  18621. function basePropertyOf(object) {
  18622. return function(key) {
  18623. return object == null ? undefined : object[key];
  18624. };
  18625. }
  18626. /**
  18627. * The base implementation of `_.reduce` and `_.reduceRight`, without support
  18628. * for iteratee shorthands, which iterates over `collection` using `eachFunc`.
  18629. *
  18630. * @private
  18631. * @param {Array|Object} collection The collection to iterate over.
  18632. * @param {Function} iteratee The function invoked per iteration.
  18633. * @param {*} accumulator The initial value.
  18634. * @param {boolean} initAccum Specify using the first or last element of
  18635. * `collection` as the initial value.
  18636. * @param {Function} eachFunc The function to iterate over `collection`.
  18637. * @returns {*} Returns the accumulated value.
  18638. */
  18639. function baseReduce(collection, iteratee, accumulator, initAccum, eachFunc) {
  18640. eachFunc(collection, function(value, index, collection) {
  18641. accumulator = initAccum
  18642. ? (initAccum = false, value)
  18643. : iteratee(accumulator, value, index, collection);
  18644. });
  18645. return accumulator;
  18646. }
  18647. /**
  18648. * The base implementation of `_.sortBy` which uses `comparer` to define the
  18649. * sort order of `array` and replaces criteria objects with their corresponding
  18650. * values.
  18651. *
  18652. * @private
  18653. * @param {Array} array The array to sort.
  18654. * @param {Function} comparer The function to define sort order.
  18655. * @returns {Array} Returns `array`.
  18656. */
  18657. function baseSortBy(array, comparer) {
  18658. var length = array.length;
  18659. array.sort(comparer);
  18660. while (length--) {
  18661. array[length] = array[length].value;
  18662. }
  18663. return array;
  18664. }
  18665. /**
  18666. * The base implementation of `_.sum` and `_.sumBy` without support for
  18667. * iteratee shorthands.
  18668. *
  18669. * @private
  18670. * @param {Array} array The array to iterate over.
  18671. * @param {Function} iteratee The function invoked per iteration.
  18672. * @returns {number} Returns the sum.
  18673. */
  18674. function baseSum(array, iteratee) {
  18675. var result,
  18676. index = -1,
  18677. length = array.length;
  18678. while (++index < length) {
  18679. var current = iteratee(array[index]);
  18680. if (current !== undefined) {
  18681. result = result === undefined ? current : (result + current);
  18682. }
  18683. }
  18684. return result;
  18685. }
  18686. /**
  18687. * The base implementation of `_.times` without support for iteratee shorthands
  18688. * or max array length checks.
  18689. *
  18690. * @private
  18691. * @param {number} n The number of times to invoke `iteratee`.
  18692. * @param {Function} iteratee The function invoked per iteration.
  18693. * @returns {Array} Returns the array of results.
  18694. */
  18695. function baseTimes(n, iteratee) {
  18696. var index = -1,
  18697. result = Array(n);
  18698. while (++index < n) {
  18699. result[index] = iteratee(index);
  18700. }
  18701. return result;
  18702. }
  18703. /**
  18704. * The base implementation of `_.toPairs` and `_.toPairsIn` which creates an array
  18705. * of key-value pairs for `object` corresponding to the property names of `props`.
  18706. *
  18707. * @private
  18708. * @param {Object} object The object to query.
  18709. * @param {Array} props The property names to get values for.
  18710. * @returns {Object} Returns the key-value pairs.
  18711. */
  18712. function baseToPairs(object, props) {
  18713. return arrayMap(props, function(key) {
  18714. return [key, object[key]];
  18715. });
  18716. }
  18717. /**
  18718. * The base implementation of `_.unary` without support for storing metadata.
  18719. *
  18720. * @private
  18721. * @param {Function} func The function to cap arguments for.
  18722. * @returns {Function} Returns the new capped function.
  18723. */
  18724. function baseUnary(func) {
  18725. return function(value) {
  18726. return func(value);
  18727. };
  18728. }
  18729. /**
  18730. * The base implementation of `_.values` and `_.valuesIn` which creates an
  18731. * array of `object` property values corresponding to the property names
  18732. * of `props`.
  18733. *
  18734. * @private
  18735. * @param {Object} object The object to query.
  18736. * @param {Array} props The property names to get values for.
  18737. * @returns {Object} Returns the array of property values.
  18738. */
  18739. function baseValues(object, props) {
  18740. return arrayMap(props, function(key) {
  18741. return object[key];
  18742. });
  18743. }
  18744. /**
  18745. * Checks if a `cache` value for `key` exists.
  18746. *
  18747. * @private
  18748. * @param {Object} cache The cache to query.
  18749. * @param {string} key The key of the entry to check.
  18750. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  18751. */
  18752. function cacheHas(cache, key) {
  18753. return cache.has(key);
  18754. }
  18755. /**
  18756. * Used by `_.trim` and `_.trimStart` to get the index of the first string symbol
  18757. * that is not found in the character symbols.
  18758. *
  18759. * @private
  18760. * @param {Array} strSymbols The string symbols to inspect.
  18761. * @param {Array} chrSymbols The character symbols to find.
  18762. * @returns {number} Returns the index of the first unmatched string symbol.
  18763. */
  18764. function charsStartIndex(strSymbols, chrSymbols) {
  18765. var index = -1,
  18766. length = strSymbols.length;
  18767. while (++index < length && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {}
  18768. return index;
  18769. }
  18770. /**
  18771. * Used by `_.trim` and `_.trimEnd` to get the index of the last string symbol
  18772. * that is not found in the character symbols.
  18773. *
  18774. * @private
  18775. * @param {Array} strSymbols The string symbols to inspect.
  18776. * @param {Array} chrSymbols The character symbols to find.
  18777. * @returns {number} Returns the index of the last unmatched string symbol.
  18778. */
  18779. function charsEndIndex(strSymbols, chrSymbols) {
  18780. var index = strSymbols.length;
  18781. while (index-- && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {}
  18782. return index;
  18783. }
  18784. /**
  18785. * Gets the number of `placeholder` occurrences in `array`.
  18786. *
  18787. * @private
  18788. * @param {Array} array The array to inspect.
  18789. * @param {*} placeholder The placeholder to search for.
  18790. * @returns {number} Returns the placeholder count.
  18791. */
  18792. function countHolders(array, placeholder) {
  18793. var length = array.length,
  18794. result = 0;
  18795. while (length--) {
  18796. if (array[length] === placeholder) {
  18797. ++result;
  18798. }
  18799. }
  18800. return result;
  18801. }
  18802. /**
  18803. * Used by `_.deburr` to convert Latin-1 Supplement and Latin Extended-A
  18804. * letters to basic Latin letters.
  18805. *
  18806. * @private
  18807. * @param {string} letter The matched letter to deburr.
  18808. * @returns {string} Returns the deburred letter.
  18809. */
  18810. var deburrLetter = basePropertyOf(deburredLetters);
  18811. /**
  18812. * Used by `_.escape` to convert characters to HTML entities.
  18813. *
  18814. * @private
  18815. * @param {string} chr The matched character to escape.
  18816. * @returns {string} Returns the escaped character.
  18817. */
  18818. var escapeHtmlChar = basePropertyOf(htmlEscapes);
  18819. /**
  18820. * Used by `_.template` to escape characters for inclusion in compiled string literals.
  18821. *
  18822. * @private
  18823. * @param {string} chr The matched character to escape.
  18824. * @returns {string} Returns the escaped character.
  18825. */
  18826. function escapeStringChar(chr) {
  18827. return '\\' + stringEscapes[chr];
  18828. }
  18829. /**
  18830. * Gets the value at `key` of `object`.
  18831. *
  18832. * @private
  18833. * @param {Object} [object] The object to query.
  18834. * @param {string} key The key of the property to get.
  18835. * @returns {*} Returns the property value.
  18836. */
  18837. function getValue(object, key) {
  18838. return object == null ? undefined : object[key];
  18839. }
  18840. /**
  18841. * Checks if `string` contains Unicode symbols.
  18842. *
  18843. * @private
  18844. * @param {string} string The string to inspect.
  18845. * @returns {boolean} Returns `true` if a symbol is found, else `false`.
  18846. */
  18847. function hasUnicode(string) {
  18848. return reHasUnicode.test(string);
  18849. }
  18850. /**
  18851. * Checks if `string` contains a word composed of Unicode symbols.
  18852. *
  18853. * @private
  18854. * @param {string} string The string to inspect.
  18855. * @returns {boolean} Returns `true` if a word is found, else `false`.
  18856. */
  18857. function hasUnicodeWord(string) {
  18858. return reHasUnicodeWord.test(string);
  18859. }
  18860. /**
  18861. * Converts `iterator` to an array.
  18862. *
  18863. * @private
  18864. * @param {Object} iterator The iterator to convert.
  18865. * @returns {Array} Returns the converted array.
  18866. */
  18867. function iteratorToArray(iterator) {
  18868. var data,
  18869. result = [];
  18870. while (!(data = iterator.next()).done) {
  18871. result.push(data.value);
  18872. }
  18873. return result;
  18874. }
  18875. /**
  18876. * Converts `map` to its key-value pairs.
  18877. *
  18878. * @private
  18879. * @param {Object} map The map to convert.
  18880. * @returns {Array} Returns the key-value pairs.
  18881. */
  18882. function mapToArray(map) {
  18883. var index = -1,
  18884. result = Array(map.size);
  18885. map.forEach(function(value, key) {
  18886. result[++index] = [key, value];
  18887. });
  18888. return result;
  18889. }
  18890. /**
  18891. * Creates a unary function that invokes `func` with its argument transformed.
  18892. *
  18893. * @private
  18894. * @param {Function} func The function to wrap.
  18895. * @param {Function} transform The argument transform.
  18896. * @returns {Function} Returns the new function.
  18897. */
  18898. function overArg(func, transform) {
  18899. return function(arg) {
  18900. return func(transform(arg));
  18901. };
  18902. }
  18903. /**
  18904. * Replaces all `placeholder` elements in `array` with an internal placeholder
  18905. * and returns an array of their indexes.
  18906. *
  18907. * @private
  18908. * @param {Array} array The array to modify.
  18909. * @param {*} placeholder The placeholder to replace.
  18910. * @returns {Array} Returns the new array of placeholder indexes.
  18911. */
  18912. function replaceHolders(array, placeholder) {
  18913. var index = -1,
  18914. length = array.length,
  18915. resIndex = 0,
  18916. result = [];
  18917. while (++index < length) {
  18918. var value = array[index];
  18919. if (value === placeholder || value === PLACEHOLDER) {
  18920. array[index] = PLACEHOLDER;
  18921. result[resIndex++] = index;
  18922. }
  18923. }
  18924. return result;
  18925. }
  18926. /**
  18927. * Converts `set` to an array of its values.
  18928. *
  18929. * @private
  18930. * @param {Object} set The set to convert.
  18931. * @returns {Array} Returns the values.
  18932. */
  18933. function setToArray(set) {
  18934. var index = -1,
  18935. result = Array(set.size);
  18936. set.forEach(function(value) {
  18937. result[++index] = value;
  18938. });
  18939. return result;
  18940. }
  18941. /**
  18942. * Converts `set` to its value-value pairs.
  18943. *
  18944. * @private
  18945. * @param {Object} set The set to convert.
  18946. * @returns {Array} Returns the value-value pairs.
  18947. */
  18948. function setToPairs(set) {
  18949. var index = -1,
  18950. result = Array(set.size);
  18951. set.forEach(function(value) {
  18952. result[++index] = [value, value];
  18953. });
  18954. return result;
  18955. }
  18956. /**
  18957. * A specialized version of `_.indexOf` which performs strict equality
  18958. * comparisons of values, i.e. `===`.
  18959. *
  18960. * @private
  18961. * @param {Array} array The array to inspect.
  18962. * @param {*} value The value to search for.
  18963. * @param {number} fromIndex The index to search from.
  18964. * @returns {number} Returns the index of the matched value, else `-1`.
  18965. */
  18966. function strictIndexOf(array, value, fromIndex) {
  18967. var index = fromIndex - 1,
  18968. length = array.length;
  18969. while (++index < length) {
  18970. if (array[index] === value) {
  18971. return index;
  18972. }
  18973. }
  18974. return -1;
  18975. }
  18976. /**
  18977. * A specialized version of `_.lastIndexOf` which performs strict equality
  18978. * comparisons of values, i.e. `===`.
  18979. *
  18980. * @private
  18981. * @param {Array} array The array to inspect.
  18982. * @param {*} value The value to search for.
  18983. * @param {number} fromIndex The index to search from.
  18984. * @returns {number} Returns the index of the matched value, else `-1`.
  18985. */
  18986. function strictLastIndexOf(array, value, fromIndex) {
  18987. var index = fromIndex + 1;
  18988. while (index--) {
  18989. if (array[index] === value) {
  18990. return index;
  18991. }
  18992. }
  18993. return index;
  18994. }
  18995. /**
  18996. * Gets the number of symbols in `string`.
  18997. *
  18998. * @private
  18999. * @param {string} string The string to inspect.
  19000. * @returns {number} Returns the string size.
  19001. */
  19002. function stringSize(string) {
  19003. return hasUnicode(string)
  19004. ? unicodeSize(string)
  19005. : asciiSize(string);
  19006. }
  19007. /**
  19008. * Converts `string` to an array.
  19009. *
  19010. * @private
  19011. * @param {string} string The string to convert.
  19012. * @returns {Array} Returns the converted array.
  19013. */
  19014. function stringToArray(string) {
  19015. return hasUnicode(string)
  19016. ? unicodeToArray(string)
  19017. : asciiToArray(string);
  19018. }
  19019. /**
  19020. * Used by `_.unescape` to convert HTML entities to characters.
  19021. *
  19022. * @private
  19023. * @param {string} chr The matched character to unescape.
  19024. * @returns {string} Returns the unescaped character.
  19025. */
  19026. var unescapeHtmlChar = basePropertyOf(htmlUnescapes);
  19027. /**
  19028. * Gets the size of a Unicode `string`.
  19029. *
  19030. * @private
  19031. * @param {string} string The string inspect.
  19032. * @returns {number} Returns the string size.
  19033. */
  19034. function unicodeSize(string) {
  19035. var result = reUnicode.lastIndex = 0;
  19036. while (reUnicode.test(string)) {
  19037. ++result;
  19038. }
  19039. return result;
  19040. }
  19041. /**
  19042. * Converts a Unicode `string` to an array.
  19043. *
  19044. * @private
  19045. * @param {string} string The string to convert.
  19046. * @returns {Array} Returns the converted array.
  19047. */
  19048. function unicodeToArray(string) {
  19049. return string.match(reUnicode) || [];
  19050. }
  19051. /**
  19052. * Splits a Unicode `string` into an array of its words.
  19053. *
  19054. * @private
  19055. * @param {string} The string to inspect.
  19056. * @returns {Array} Returns the words of `string`.
  19057. */
  19058. function unicodeWords(string) {
  19059. return string.match(reUnicodeWord) || [];
  19060. }
  19061. /*--------------------------------------------------------------------------*/
  19062. /**
  19063. * Create a new pristine `lodash` function using the `context` object.
  19064. *
  19065. * @static
  19066. * @memberOf _
  19067. * @since 1.1.0
  19068. * @category Util
  19069. * @param {Object} [context=root] The context object.
  19070. * @returns {Function} Returns a new `lodash` function.
  19071. * @example
  19072. *
  19073. * _.mixin({ 'foo': _.constant('foo') });
  19074. *
  19075. * var lodash = _.runInContext();
  19076. * lodash.mixin({ 'bar': lodash.constant('bar') });
  19077. *
  19078. * _.isFunction(_.foo);
  19079. * // => true
  19080. * _.isFunction(_.bar);
  19081. * // => false
  19082. *
  19083. * lodash.isFunction(lodash.foo);
  19084. * // => false
  19085. * lodash.isFunction(lodash.bar);
  19086. * // => true
  19087. *
  19088. * // Create a suped-up `defer` in Node.js.
  19089. * var defer = _.runInContext({ 'setTimeout': setImmediate }).defer;
  19090. */
  19091. var runInContext = (function runInContext(context) {
  19092. context = context == null ? root : _.defaults(root.Object(), context, _.pick(root, contextProps));
  19093. /** Built-in constructor references. */
  19094. var Array = context.Array,
  19095. Date = context.Date,
  19096. Error = context.Error,
  19097. Function = context.Function,
  19098. Math = context.Math,
  19099. Object = context.Object,
  19100. RegExp = context.RegExp,
  19101. String = context.String,
  19102. TypeError = context.TypeError;
  19103. /** Used for built-in method references. */
  19104. var arrayProto = Array.prototype,
  19105. funcProto = Function.prototype,
  19106. objectProto = Object.prototype;
  19107. /** Used to detect overreaching core-js shims. */
  19108. var coreJsData = context['__core-js_shared__'];
  19109. /** Used to resolve the decompiled source of functions. */
  19110. var funcToString = funcProto.toString;
  19111. /** Used to check objects for own properties. */
  19112. var hasOwnProperty = objectProto.hasOwnProperty;
  19113. /** Used to generate unique IDs. */
  19114. var idCounter = 0;
  19115. /** Used to detect methods masquerading as native. */
  19116. var maskSrcKey = (function() {
  19117. var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
  19118. return uid ? ('Symbol(src)_1.' + uid) : '';
  19119. }());
  19120. /**
  19121. * Used to resolve the
  19122. * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
  19123. * of values.
  19124. */
  19125. var nativeObjectToString = objectProto.toString;
  19126. /** Used to infer the `Object` constructor. */
  19127. var objectCtorString = funcToString.call(Object);
  19128. /** Used to restore the original `_` reference in `_.noConflict`. */
  19129. var oldDash = root._;
  19130. /** Used to detect if a method is native. */
  19131. var reIsNative = RegExp('^' +
  19132. funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&')
  19133. .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
  19134. );
  19135. /** Built-in value references. */
  19136. var Buffer = moduleExports ? context.Buffer : undefined,
  19137. Symbol = context.Symbol,
  19138. Uint8Array = context.Uint8Array,
  19139. allocUnsafe = Buffer ? Buffer.allocUnsafe : undefined,
  19140. getPrototype = overArg(Object.getPrototypeOf, Object),
  19141. objectCreate = Object.create,
  19142. propertyIsEnumerable = objectProto.propertyIsEnumerable,
  19143. splice = arrayProto.splice,
  19144. spreadableSymbol = Symbol ? Symbol.isConcatSpreadable : undefined,
  19145. symIterator = Symbol ? Symbol.iterator : undefined,
  19146. symToStringTag = Symbol ? Symbol.toStringTag : undefined;
  19147. var defineProperty = (function() {
  19148. try {
  19149. var func = getNative(Object, 'defineProperty');
  19150. func({}, '', {});
  19151. return func;
  19152. } catch (e) {}
  19153. }());
  19154. /** Mocked built-ins. */
  19155. var ctxClearTimeout = context.clearTimeout !== root.clearTimeout && context.clearTimeout,
  19156. ctxNow = Date && Date.now !== root.Date.now && Date.now,
  19157. ctxSetTimeout = context.setTimeout !== root.setTimeout && context.setTimeout;
  19158. /* Built-in method references for those with the same name as other `lodash` methods. */
  19159. var nativeCeil = Math.ceil,
  19160. nativeFloor = Math.floor,
  19161. nativeGetSymbols = Object.getOwnPropertySymbols,
  19162. nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined,
  19163. nativeIsFinite = context.isFinite,
  19164. nativeJoin = arrayProto.join,
  19165. nativeKeys = overArg(Object.keys, Object),
  19166. nativeMax = Math.max,
  19167. nativeMin = Math.min,
  19168. nativeNow = Date.now,
  19169. nativeParseInt = context.parseInt,
  19170. nativeRandom = Math.random,
  19171. nativeReverse = arrayProto.reverse;
  19172. /* Built-in method references that are verified to be native. */
  19173. var DataView = getNative(context, 'DataView'),
  19174. Map = getNative(context, 'Map'),
  19175. Promise = getNative(context, 'Promise'),
  19176. Set = getNative(context, 'Set'),
  19177. WeakMap = getNative(context, 'WeakMap'),
  19178. nativeCreate = getNative(Object, 'create');
  19179. /** Used to store function metadata. */
  19180. var metaMap = WeakMap && new WeakMap;
  19181. /** Used to lookup unminified function names. */
  19182. var realNames = {};
  19183. /** Used to detect maps, sets, and weakmaps. */
  19184. var dataViewCtorString = toSource(DataView),
  19185. mapCtorString = toSource(Map),
  19186. promiseCtorString = toSource(Promise),
  19187. setCtorString = toSource(Set),
  19188. weakMapCtorString = toSource(WeakMap);
  19189. /** Used to convert symbols to primitives and strings. */
  19190. var symbolProto = Symbol ? Symbol.prototype : undefined,
  19191. symbolValueOf = symbolProto ? symbolProto.valueOf : undefined,
  19192. symbolToString = symbolProto ? symbolProto.toString : undefined;
  19193. /*------------------------------------------------------------------------*/
  19194. /**
  19195. * Creates a `lodash` object which wraps `value` to enable implicit method
  19196. * chain sequences. Methods that operate on and return arrays, collections,
  19197. * and functions can be chained together. Methods that retrieve a single value
  19198. * or may return a primitive value will automatically end the chain sequence
  19199. * and return the unwrapped value. Otherwise, the value must be unwrapped
  19200. * with `_#value`.
  19201. *
  19202. * Explicit chain sequences, which must be unwrapped with `_#value`, may be
  19203. * enabled using `_.chain`.
  19204. *
  19205. * The execution of chained methods is lazy, that is, it's deferred until
  19206. * `_#value` is implicitly or explicitly called.
  19207. *
  19208. * Lazy evaluation allows several methods to support shortcut fusion.
  19209. * Shortcut fusion is an optimization to merge iteratee calls; this avoids
  19210. * the creation of intermediate arrays and can greatly reduce the number of
  19211. * iteratee executions. Sections of a chain sequence qualify for shortcut
  19212. * fusion if the section is applied to an array and iteratees accept only
  19213. * one argument. The heuristic for whether a section qualifies for shortcut
  19214. * fusion is subject to change.
  19215. *
  19216. * Chaining is supported in custom builds as long as the `_#value` method is
  19217. * directly or indirectly included in the build.
  19218. *
  19219. * In addition to lodash methods, wrappers have `Array` and `String` methods.
  19220. *
  19221. * The wrapper `Array` methods are:
  19222. * `concat`, `join`, `pop`, `push`, `shift`, `sort`, `splice`, and `unshift`
  19223. *
  19224. * The wrapper `String` methods are:
  19225. * `replace` and `split`
  19226. *
  19227. * The wrapper methods that support shortcut fusion are:
  19228. * `at`, `compact`, `drop`, `dropRight`, `dropWhile`, `filter`, `find`,
  19229. * `findLast`, `head`, `initial`, `last`, `map`, `reject`, `reverse`, `slice`,
  19230. * `tail`, `take`, `takeRight`, `takeRightWhile`, `takeWhile`, and `toArray`
  19231. *
  19232. * The chainable wrapper methods are:
  19233. * `after`, `ary`, `assign`, `assignIn`, `assignInWith`, `assignWith`, `at`,
  19234. * `before`, `bind`, `bindAll`, `bindKey`, `castArray`, `chain`, `chunk`,
  19235. * `commit`, `compact`, `concat`, `conforms`, `constant`, `countBy`, `create`,
  19236. * `curry`, `debounce`, `defaults`, `defaultsDeep`, `defer`, `delay`,
  19237. * `difference`, `differenceBy`, `differenceWith`, `drop`, `dropRight`,
  19238. * `dropRightWhile`, `dropWhile`, `extend`, `extendWith`, `fill`, `filter`,
  19239. * `flatMap`, `flatMapDeep`, `flatMapDepth`, `flatten`, `flattenDeep`,
  19240. * `flattenDepth`, `flip`, `flow`, `flowRight`, `fromPairs`, `functions`,
  19241. * `functionsIn`, `groupBy`, `initial`, `intersection`, `intersectionBy`,
  19242. * `intersectionWith`, `invert`, `invertBy`, `invokeMap`, `iteratee`, `keyBy`,
  19243. * `keys`, `keysIn`, `map`, `mapKeys`, `mapValues`, `matches`, `matchesProperty`,
  19244. * `memoize`, `merge`, `mergeWith`, `method`, `methodOf`, `mixin`, `negate`,
  19245. * `nthArg`, `omit`, `omitBy`, `once`, `orderBy`, `over`, `overArgs`,
  19246. * `overEvery`, `overSome`, `partial`, `partialRight`, `partition`, `pick`,
  19247. * `pickBy`, `plant`, `property`, `propertyOf`, `pull`, `pullAll`, `pullAllBy`,
  19248. * `pullAllWith`, `pullAt`, `push`, `range`, `rangeRight`, `rearg`, `reject`,
  19249. * `remove`, `rest`, `reverse`, `sampleSize`, `set`, `setWith`, `shuffle`,
  19250. * `slice`, `sort`, `sortBy`, `splice`, `spread`, `tail`, `take`, `takeRight`,
  19251. * `takeRightWhile`, `takeWhile`, `tap`, `throttle`, `thru`, `toArray`,
  19252. * `toPairs`, `toPairsIn`, `toPath`, `toPlainObject`, `transform`, `unary`,
  19253. * `union`, `unionBy`, `unionWith`, `uniq`, `uniqBy`, `uniqWith`, `unset`,
  19254. * `unshift`, `unzip`, `unzipWith`, `update`, `updateWith`, `values`,
  19255. * `valuesIn`, `without`, `wrap`, `xor`, `xorBy`, `xorWith`, `zip`,
  19256. * `zipObject`, `zipObjectDeep`, and `zipWith`
  19257. *
  19258. * The wrapper methods that are **not** chainable by default are:
  19259. * `add`, `attempt`, `camelCase`, `capitalize`, `ceil`, `clamp`, `clone`,
  19260. * `cloneDeep`, `cloneDeepWith`, `cloneWith`, `conformsTo`, `deburr`,
  19261. * `defaultTo`, `divide`, `each`, `eachRight`, `endsWith`, `eq`, `escape`,
  19262. * `escapeRegExp`, `every`, `find`, `findIndex`, `findKey`, `findLast`,
  19263. * `findLastIndex`, `findLastKey`, `first`, `floor`, `forEach`, `forEachRight`,
  19264. * `forIn`, `forInRight`, `forOwn`, `forOwnRight`, `get`, `gt`, `gte`, `has`,
  19265. * `hasIn`, `head`, `identity`, `includes`, `indexOf`, `inRange`, `invoke`,
  19266. * `isArguments`, `isArray`, `isArrayBuffer`, `isArrayLike`, `isArrayLikeObject`,
  19267. * `isBoolean`, `isBuffer`, `isDate`, `isElement`, `isEmpty`, `isEqual`,
  19268. * `isEqualWith`, `isError`, `isFinite`, `isFunction`, `isInteger`, `isLength`,
  19269. * `isMap`, `isMatch`, `isMatchWith`, `isNaN`, `isNative`, `isNil`, `isNull`,
  19270. * `isNumber`, `isObject`, `isObjectLike`, `isPlainObject`, `isRegExp`,
  19271. * `isSafeInteger`, `isSet`, `isString`, `isUndefined`, `isTypedArray`,
  19272. * `isWeakMap`, `isWeakSet`, `join`, `kebabCase`, `last`, `lastIndexOf`,
  19273. * `lowerCase`, `lowerFirst`, `lt`, `lte`, `max`, `maxBy`, `mean`, `meanBy`,
  19274. * `min`, `minBy`, `multiply`, `noConflict`, `noop`, `now`, `nth`, `pad`,
  19275. * `padEnd`, `padStart`, `parseInt`, `pop`, `random`, `reduce`, `reduceRight`,
  19276. * `repeat`, `result`, `round`, `runInContext`, `sample`, `shift`, `size`,
  19277. * `snakeCase`, `some`, `sortedIndex`, `sortedIndexBy`, `sortedLastIndex`,
  19278. * `sortedLastIndexBy`, `startCase`, `startsWith`, `stubArray`, `stubFalse`,
  19279. * `stubObject`, `stubString`, `stubTrue`, `subtract`, `sum`, `sumBy`,
  19280. * `template`, `times`, `toFinite`, `toInteger`, `toJSON`, `toLength`,
  19281. * `toLower`, `toNumber`, `toSafeInteger`, `toString`, `toUpper`, `trim`,
  19282. * `trimEnd`, `trimStart`, `truncate`, `unescape`, `uniqueId`, `upperCase`,
  19283. * `upperFirst`, `value`, and `words`
  19284. *
  19285. * @name _
  19286. * @constructor
  19287. * @category Seq
  19288. * @param {*} value The value to wrap in a `lodash` instance.
  19289. * @returns {Object} Returns the new `lodash` wrapper instance.
  19290. * @example
  19291. *
  19292. * function square(n) {
  19293. * return n * n;
  19294. * }
  19295. *
  19296. * var wrapped = _([1, 2, 3]);
  19297. *
  19298. * // Returns an unwrapped value.
  19299. * wrapped.reduce(_.add);
  19300. * // => 6
  19301. *
  19302. * // Returns a wrapped value.
  19303. * var squares = wrapped.map(square);
  19304. *
  19305. * _.isArray(squares);
  19306. * // => false
  19307. *
  19308. * _.isArray(squares.value());
  19309. * // => true
  19310. */
  19311. function lodash(value) {
  19312. if (isObjectLike(value) && !isArray(value) && !(value instanceof LazyWrapper)) {
  19313. if (value instanceof LodashWrapper) {
  19314. return value;
  19315. }
  19316. if (hasOwnProperty.call(value, '__wrapped__')) {
  19317. return wrapperClone(value);
  19318. }
  19319. }
  19320. return new LodashWrapper(value);
  19321. }
  19322. /**
  19323. * The base implementation of `_.create` without support for assigning
  19324. * properties to the created object.
  19325. *
  19326. * @private
  19327. * @param {Object} proto The object to inherit from.
  19328. * @returns {Object} Returns the new object.
  19329. */
  19330. var baseCreate = (function() {
  19331. function object() {}
  19332. return function(proto) {
  19333. if (!isObject(proto)) {
  19334. return {};
  19335. }
  19336. if (objectCreate) {
  19337. return objectCreate(proto);
  19338. }
  19339. object.prototype = proto;
  19340. var result = new object;
  19341. object.prototype = undefined;
  19342. return result;
  19343. };
  19344. }());
  19345. /**
  19346. * The function whose prototype chain sequence wrappers inherit from.
  19347. *
  19348. * @private
  19349. */
  19350. function baseLodash() {
  19351. // No operation performed.
  19352. }
  19353. /**
  19354. * The base constructor for creating `lodash` wrapper objects.
  19355. *
  19356. * @private
  19357. * @param {*} value The value to wrap.
  19358. * @param {boolean} [chainAll] Enable explicit method chain sequences.
  19359. */
  19360. function LodashWrapper(value, chainAll) {
  19361. this.__wrapped__ = value;
  19362. this.__actions__ = [];
  19363. this.__chain__ = !!chainAll;
  19364. this.__index__ = 0;
  19365. this.__values__ = undefined;
  19366. }
  19367. /**
  19368. * By default, the template delimiters used by lodash are like those in
  19369. * embedded Ruby (ERB) as well as ES2015 template strings. Change the
  19370. * following template settings to use alternative delimiters.
  19371. *
  19372. * @static
  19373. * @memberOf _
  19374. * @type {Object}
  19375. */
  19376. lodash.templateSettings = {
  19377. /**
  19378. * Used to detect `data` property values to be HTML-escaped.
  19379. *
  19380. * @memberOf _.templateSettings
  19381. * @type {RegExp}
  19382. */
  19383. 'escape': reEscape,
  19384. /**
  19385. * Used to detect code to be evaluated.
  19386. *
  19387. * @memberOf _.templateSettings
  19388. * @type {RegExp}
  19389. */
  19390. 'evaluate': reEvaluate,
  19391. /**
  19392. * Used to detect `data` property values to inject.
  19393. *
  19394. * @memberOf _.templateSettings
  19395. * @type {RegExp}
  19396. */
  19397. 'interpolate': reInterpolate,
  19398. /**
  19399. * Used to reference the data object in the template text.
  19400. *
  19401. * @memberOf _.templateSettings
  19402. * @type {string}
  19403. */
  19404. 'variable': '',
  19405. /**
  19406. * Used to import variables into the compiled template.
  19407. *
  19408. * @memberOf _.templateSettings
  19409. * @type {Object}
  19410. */
  19411. 'imports': {
  19412. /**
  19413. * A reference to the `lodash` function.
  19414. *
  19415. * @memberOf _.templateSettings.imports
  19416. * @type {Function}
  19417. */
  19418. '_': lodash
  19419. }
  19420. };
  19421. // Ensure wrappers are instances of `baseLodash`.
  19422. lodash.prototype = baseLodash.prototype;
  19423. lodash.prototype.constructor = lodash;
  19424. LodashWrapper.prototype = baseCreate(baseLodash.prototype);
  19425. LodashWrapper.prototype.constructor = LodashWrapper;
  19426. /*------------------------------------------------------------------------*/
  19427. /**
  19428. * Creates a lazy wrapper object which wraps `value` to enable lazy evaluation.
  19429. *
  19430. * @private
  19431. * @constructor
  19432. * @param {*} value The value to wrap.
  19433. */
  19434. function LazyWrapper(value) {
  19435. this.__wrapped__ = value;
  19436. this.__actions__ = [];
  19437. this.__dir__ = 1;
  19438. this.__filtered__ = false;
  19439. this.__iteratees__ = [];
  19440. this.__takeCount__ = MAX_ARRAY_LENGTH;
  19441. this.__views__ = [];
  19442. }
  19443. /**
  19444. * Creates a clone of the lazy wrapper object.
  19445. *
  19446. * @private
  19447. * @name clone
  19448. * @memberOf LazyWrapper
  19449. * @returns {Object} Returns the cloned `LazyWrapper` object.
  19450. */
  19451. function lazyClone() {
  19452. var result = new LazyWrapper(this.__wrapped__);
  19453. result.__actions__ = copyArray(this.__actions__);
  19454. result.__dir__ = this.__dir__;
  19455. result.__filtered__ = this.__filtered__;
  19456. result.__iteratees__ = copyArray(this.__iteratees__);
  19457. result.__takeCount__ = this.__takeCount__;
  19458. result.__views__ = copyArray(this.__views__);
  19459. return result;
  19460. }
  19461. /**
  19462. * Reverses the direction of lazy iteration.
  19463. *
  19464. * @private
  19465. * @name reverse
  19466. * @memberOf LazyWrapper
  19467. * @returns {Object} Returns the new reversed `LazyWrapper` object.
  19468. */
  19469. function lazyReverse() {
  19470. if (this.__filtered__) {
  19471. var result = new LazyWrapper(this);
  19472. result.__dir__ = -1;
  19473. result.__filtered__ = true;
  19474. } else {
  19475. result = this.clone();
  19476. result.__dir__ *= -1;
  19477. }
  19478. return result;
  19479. }
  19480. /**
  19481. * Extracts the unwrapped value from its lazy wrapper.
  19482. *
  19483. * @private
  19484. * @name value
  19485. * @memberOf LazyWrapper
  19486. * @returns {*} Returns the unwrapped value.
  19487. */
  19488. function lazyValue() {
  19489. var array = this.__wrapped__.value(),
  19490. dir = this.__dir__,
  19491. isArr = isArray(array),
  19492. isRight = dir < 0,
  19493. arrLength = isArr ? array.length : 0,
  19494. view = getView(0, arrLength, this.__views__),
  19495. start = view.start,
  19496. end = view.end,
  19497. length = end - start,
  19498. index = isRight ? end : (start - 1),
  19499. iteratees = this.__iteratees__,
  19500. iterLength = iteratees.length,
  19501. resIndex = 0,
  19502. takeCount = nativeMin(length, this.__takeCount__);
  19503. if (!isArr || (!isRight && arrLength == length && takeCount == length)) {
  19504. return baseWrapperValue(array, this.__actions__);
  19505. }
  19506. var result = [];
  19507. outer:
  19508. while (length-- && resIndex < takeCount) {
  19509. index += dir;
  19510. var iterIndex = -1,
  19511. value = array[index];
  19512. while (++iterIndex < iterLength) {
  19513. var data = iteratees[iterIndex],
  19514. iteratee = data.iteratee,
  19515. type = data.type,
  19516. computed = iteratee(value);
  19517. if (type == LAZY_MAP_FLAG) {
  19518. value = computed;
  19519. } else if (!computed) {
  19520. if (type == LAZY_FILTER_FLAG) {
  19521. continue outer;
  19522. } else {
  19523. break outer;
  19524. }
  19525. }
  19526. }
  19527. result[resIndex++] = value;
  19528. }
  19529. return result;
  19530. }
  19531. // Ensure `LazyWrapper` is an instance of `baseLodash`.
  19532. LazyWrapper.prototype = baseCreate(baseLodash.prototype);
  19533. LazyWrapper.prototype.constructor = LazyWrapper;
  19534. /*------------------------------------------------------------------------*/
  19535. /**
  19536. * Creates a hash object.
  19537. *
  19538. * @private
  19539. * @constructor
  19540. * @param {Array} [entries] The key-value pairs to cache.
  19541. */
  19542. function Hash(entries) {
  19543. var index = -1,
  19544. length = entries == null ? 0 : entries.length;
  19545. this.clear();
  19546. while (++index < length) {
  19547. var entry = entries[index];
  19548. this.set(entry[0], entry[1]);
  19549. }
  19550. }
  19551. /**
  19552. * Removes all key-value entries from the hash.
  19553. *
  19554. * @private
  19555. * @name clear
  19556. * @memberOf Hash
  19557. */
  19558. function hashClear() {
  19559. this.__data__ = nativeCreate ? nativeCreate(null) : {};
  19560. this.size = 0;
  19561. }
  19562. /**
  19563. * Removes `key` and its value from the hash.
  19564. *
  19565. * @private
  19566. * @name delete
  19567. * @memberOf Hash
  19568. * @param {Object} hash The hash to modify.
  19569. * @param {string} key The key of the value to remove.
  19570. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  19571. */
  19572. function hashDelete(key) {
  19573. var result = this.has(key) && delete this.__data__[key];
  19574. this.size -= result ? 1 : 0;
  19575. return result;
  19576. }
  19577. /**
  19578. * Gets the hash value for `key`.
  19579. *
  19580. * @private
  19581. * @name get
  19582. * @memberOf Hash
  19583. * @param {string} key The key of the value to get.
  19584. * @returns {*} Returns the entry value.
  19585. */
  19586. function hashGet(key) {
  19587. var data = this.__data__;
  19588. if (nativeCreate) {
  19589. var result = data[key];
  19590. return result === HASH_UNDEFINED ? undefined : result;
  19591. }
  19592. return hasOwnProperty.call(data, key) ? data[key] : undefined;
  19593. }
  19594. /**
  19595. * Checks if a hash value for `key` exists.
  19596. *
  19597. * @private
  19598. * @name has
  19599. * @memberOf Hash
  19600. * @param {string} key The key of the entry to check.
  19601. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  19602. */
  19603. function hashHas(key) {
  19604. var data = this.__data__;
  19605. return nativeCreate ? (data[key] !== undefined) : hasOwnProperty.call(data, key);
  19606. }
  19607. /**
  19608. * Sets the hash `key` to `value`.
  19609. *
  19610. * @private
  19611. * @name set
  19612. * @memberOf Hash
  19613. * @param {string} key The key of the value to set.
  19614. * @param {*} value The value to set.
  19615. * @returns {Object} Returns the hash instance.
  19616. */
  19617. function hashSet(key, value) {
  19618. var data = this.__data__;
  19619. this.size += this.has(key) ? 0 : 1;
  19620. data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value;
  19621. return this;
  19622. }
  19623. // Add methods to `Hash`.
  19624. Hash.prototype.clear = hashClear;
  19625. Hash.prototype['delete'] = hashDelete;
  19626. Hash.prototype.get = hashGet;
  19627. Hash.prototype.has = hashHas;
  19628. Hash.prototype.set = hashSet;
  19629. /*------------------------------------------------------------------------*/
  19630. /**
  19631. * Creates an list cache object.
  19632. *
  19633. * @private
  19634. * @constructor
  19635. * @param {Array} [entries] The key-value pairs to cache.
  19636. */
  19637. function ListCache(entries) {
  19638. var index = -1,
  19639. length = entries == null ? 0 : entries.length;
  19640. this.clear();
  19641. while (++index < length) {
  19642. var entry = entries[index];
  19643. this.set(entry[0], entry[1]);
  19644. }
  19645. }
  19646. /**
  19647. * Removes all key-value entries from the list cache.
  19648. *
  19649. * @private
  19650. * @name clear
  19651. * @memberOf ListCache
  19652. */
  19653. function listCacheClear() {
  19654. this.__data__ = [];
  19655. this.size = 0;
  19656. }
  19657. /**
  19658. * Removes `key` and its value from the list cache.
  19659. *
  19660. * @private
  19661. * @name delete
  19662. * @memberOf ListCache
  19663. * @param {string} key The key of the value to remove.
  19664. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  19665. */
  19666. function listCacheDelete(key) {
  19667. var data = this.__data__,
  19668. index = assocIndexOf(data, key);
  19669. if (index < 0) {
  19670. return false;
  19671. }
  19672. var lastIndex = data.length - 1;
  19673. if (index == lastIndex) {
  19674. data.pop();
  19675. } else {
  19676. splice.call(data, index, 1);
  19677. }
  19678. --this.size;
  19679. return true;
  19680. }
  19681. /**
  19682. * Gets the list cache value for `key`.
  19683. *
  19684. * @private
  19685. * @name get
  19686. * @memberOf ListCache
  19687. * @param {string} key The key of the value to get.
  19688. * @returns {*} Returns the entry value.
  19689. */
  19690. function listCacheGet(key) {
  19691. var data = this.__data__,
  19692. index = assocIndexOf(data, key);
  19693. return index < 0 ? undefined : data[index][1];
  19694. }
  19695. /**
  19696. * Checks if a list cache value for `key` exists.
  19697. *
  19698. * @private
  19699. * @name has
  19700. * @memberOf ListCache
  19701. * @param {string} key The key of the entry to check.
  19702. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  19703. */
  19704. function listCacheHas(key) {
  19705. return assocIndexOf(this.__data__, key) > -1;
  19706. }
  19707. /**
  19708. * Sets the list cache `key` to `value`.
  19709. *
  19710. * @private
  19711. * @name set
  19712. * @memberOf ListCache
  19713. * @param {string} key The key of the value to set.
  19714. * @param {*} value The value to set.
  19715. * @returns {Object} Returns the list cache instance.
  19716. */
  19717. function listCacheSet(key, value) {
  19718. var data = this.__data__,
  19719. index = assocIndexOf(data, key);
  19720. if (index < 0) {
  19721. ++this.size;
  19722. data.push([key, value]);
  19723. } else {
  19724. data[index][1] = value;
  19725. }
  19726. return this;
  19727. }
  19728. // Add methods to `ListCache`.
  19729. ListCache.prototype.clear = listCacheClear;
  19730. ListCache.prototype['delete'] = listCacheDelete;
  19731. ListCache.prototype.get = listCacheGet;
  19732. ListCache.prototype.has = listCacheHas;
  19733. ListCache.prototype.set = listCacheSet;
  19734. /*------------------------------------------------------------------------*/
  19735. /**
  19736. * Creates a map cache object to store key-value pairs.
  19737. *
  19738. * @private
  19739. * @constructor
  19740. * @param {Array} [entries] The key-value pairs to cache.
  19741. */
  19742. function MapCache(entries) {
  19743. var index = -1,
  19744. length = entries == null ? 0 : entries.length;
  19745. this.clear();
  19746. while (++index < length) {
  19747. var entry = entries[index];
  19748. this.set(entry[0], entry[1]);
  19749. }
  19750. }
  19751. /**
  19752. * Removes all key-value entries from the map.
  19753. *
  19754. * @private
  19755. * @name clear
  19756. * @memberOf MapCache
  19757. */
  19758. function mapCacheClear() {
  19759. this.size = 0;
  19760. this.__data__ = {
  19761. 'hash': new Hash,
  19762. 'map': new (Map || ListCache),
  19763. 'string': new Hash
  19764. };
  19765. }
  19766. /**
  19767. * Removes `key` and its value from the map.
  19768. *
  19769. * @private
  19770. * @name delete
  19771. * @memberOf MapCache
  19772. * @param {string} key The key of the value to remove.
  19773. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  19774. */
  19775. function mapCacheDelete(key) {
  19776. var result = getMapData(this, key)['delete'](key);
  19777. this.size -= result ? 1 : 0;
  19778. return result;
  19779. }
  19780. /**
  19781. * Gets the map value for `key`.
  19782. *
  19783. * @private
  19784. * @name get
  19785. * @memberOf MapCache
  19786. * @param {string} key The key of the value to get.
  19787. * @returns {*} Returns the entry value.
  19788. */
  19789. function mapCacheGet(key) {
  19790. return getMapData(this, key).get(key);
  19791. }
  19792. /**
  19793. * Checks if a map value for `key` exists.
  19794. *
  19795. * @private
  19796. * @name has
  19797. * @memberOf MapCache
  19798. * @param {string} key The key of the entry to check.
  19799. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  19800. */
  19801. function mapCacheHas(key) {
  19802. return getMapData(this, key).has(key);
  19803. }
  19804. /**
  19805. * Sets the map `key` to `value`.
  19806. *
  19807. * @private
  19808. * @name set
  19809. * @memberOf MapCache
  19810. * @param {string} key The key of the value to set.
  19811. * @param {*} value The value to set.
  19812. * @returns {Object} Returns the map cache instance.
  19813. */
  19814. function mapCacheSet(key, value) {
  19815. var data = getMapData(this, key),
  19816. size = data.size;
  19817. data.set(key, value);
  19818. this.size += data.size == size ? 0 : 1;
  19819. return this;
  19820. }
  19821. // Add methods to `MapCache`.
  19822. MapCache.prototype.clear = mapCacheClear;
  19823. MapCache.prototype['delete'] = mapCacheDelete;
  19824. MapCache.prototype.get = mapCacheGet;
  19825. MapCache.prototype.has = mapCacheHas;
  19826. MapCache.prototype.set = mapCacheSet;
  19827. /*------------------------------------------------------------------------*/
  19828. /**
  19829. *
  19830. * Creates an array cache object to store unique values.
  19831. *
  19832. * @private
  19833. * @constructor
  19834. * @param {Array} [values] The values to cache.
  19835. */
  19836. function SetCache(values) {
  19837. var index = -1,
  19838. length = values == null ? 0 : values.length;
  19839. this.__data__ = new MapCache;
  19840. while (++index < length) {
  19841. this.add(values[index]);
  19842. }
  19843. }
  19844. /**
  19845. * Adds `value` to the array cache.
  19846. *
  19847. * @private
  19848. * @name add
  19849. * @memberOf SetCache
  19850. * @alias push
  19851. * @param {*} value The value to cache.
  19852. * @returns {Object} Returns the cache instance.
  19853. */
  19854. function setCacheAdd(value) {
  19855. this.__data__.set(value, HASH_UNDEFINED);
  19856. return this;
  19857. }
  19858. /**
  19859. * Checks if `value` is in the array cache.
  19860. *
  19861. * @private
  19862. * @name has
  19863. * @memberOf SetCache
  19864. * @param {*} value The value to search for.
  19865. * @returns {number} Returns `true` if `value` is found, else `false`.
  19866. */
  19867. function setCacheHas(value) {
  19868. return this.__data__.has(value);
  19869. }
  19870. // Add methods to `SetCache`.
  19871. SetCache.prototype.add = SetCache.prototype.push = setCacheAdd;
  19872. SetCache.prototype.has = setCacheHas;
  19873. /*------------------------------------------------------------------------*/
  19874. /**
  19875. * Creates a stack cache object to store key-value pairs.
  19876. *
  19877. * @private
  19878. * @constructor
  19879. * @param {Array} [entries] The key-value pairs to cache.
  19880. */
  19881. function Stack(entries) {
  19882. var data = this.__data__ = new ListCache(entries);
  19883. this.size = data.size;
  19884. }
  19885. /**
  19886. * Removes all key-value entries from the stack.
  19887. *
  19888. * @private
  19889. * @name clear
  19890. * @memberOf Stack
  19891. */
  19892. function stackClear() {
  19893. this.__data__ = new ListCache;
  19894. this.size = 0;
  19895. }
  19896. /**
  19897. * Removes `key` and its value from the stack.
  19898. *
  19899. * @private
  19900. * @name delete
  19901. * @memberOf Stack
  19902. * @param {string} key The key of the value to remove.
  19903. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  19904. */
  19905. function stackDelete(key) {
  19906. var data = this.__data__,
  19907. result = data['delete'](key);
  19908. this.size = data.size;
  19909. return result;
  19910. }
  19911. /**
  19912. * Gets the stack value for `key`.
  19913. *
  19914. * @private
  19915. * @name get
  19916. * @memberOf Stack
  19917. * @param {string} key The key of the value to get.
  19918. * @returns {*} Returns the entry value.
  19919. */
  19920. function stackGet(key) {
  19921. return this.__data__.get(key);
  19922. }
  19923. /**
  19924. * Checks if a stack value for `key` exists.
  19925. *
  19926. * @private
  19927. * @name has
  19928. * @memberOf Stack
  19929. * @param {string} key The key of the entry to check.
  19930. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  19931. */
  19932. function stackHas(key) {
  19933. return this.__data__.has(key);
  19934. }
  19935. /**
  19936. * Sets the stack `key` to `value`.
  19937. *
  19938. * @private
  19939. * @name set
  19940. * @memberOf Stack
  19941. * @param {string} key The key of the value to set.
  19942. * @param {*} value The value to set.
  19943. * @returns {Object} Returns the stack cache instance.
  19944. */
  19945. function stackSet(key, value) {
  19946. var data = this.__data__;
  19947. if (data instanceof ListCache) {
  19948. var pairs = data.__data__;
  19949. if (!Map || (pairs.length < LARGE_ARRAY_SIZE - 1)) {
  19950. pairs.push([key, value]);
  19951. this.size = ++data.size;
  19952. return this;
  19953. }
  19954. data = this.__data__ = new MapCache(pairs);
  19955. }
  19956. data.set(key, value);
  19957. this.size = data.size;
  19958. return this;
  19959. }
  19960. // Add methods to `Stack`.
  19961. Stack.prototype.clear = stackClear;
  19962. Stack.prototype['delete'] = stackDelete;
  19963. Stack.prototype.get = stackGet;
  19964. Stack.prototype.has = stackHas;
  19965. Stack.prototype.set = stackSet;
  19966. /*------------------------------------------------------------------------*/
  19967. /**
  19968. * Creates an array of the enumerable property names of the array-like `value`.
  19969. *
  19970. * @private
  19971. * @param {*} value The value to query.
  19972. * @param {boolean} inherited Specify returning inherited property names.
  19973. * @returns {Array} Returns the array of property names.
  19974. */
  19975. function arrayLikeKeys(value, inherited) {
  19976. var isArr = isArray(value),
  19977. isArg = !isArr && isArguments(value),
  19978. isBuff = !isArr && !isArg && isBuffer(value),
  19979. isType = !isArr && !isArg && !isBuff && isTypedArray(value),
  19980. skipIndexes = isArr || isArg || isBuff || isType,
  19981. result = skipIndexes ? baseTimes(value.length, String) : [],
  19982. length = result.length;
  19983. for (var key in value) {
  19984. if ((inherited || hasOwnProperty.call(value, key)) &&
  19985. !(skipIndexes && (
  19986. // Safari 9 has enumerable `arguments.length` in strict mode.
  19987. key == 'length' ||
  19988. // Node.js 0.10 has enumerable non-index properties on buffers.
  19989. (isBuff && (key == 'offset' || key == 'parent')) ||
  19990. // PhantomJS 2 has enumerable non-index properties on typed arrays.
  19991. (isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) ||
  19992. // Skip index properties.
  19993. isIndex(key, length)
  19994. ))) {
  19995. result.push(key);
  19996. }
  19997. }
  19998. return result;
  19999. }
  20000. /**
  20001. * A specialized version of `_.sample` for arrays.
  20002. *
  20003. * @private
  20004. * @param {Array} array The array to sample.
  20005. * @returns {*} Returns the random element.
  20006. */
  20007. function arraySample(array) {
  20008. var length = array.length;
  20009. return length ? array[baseRandom(0, length - 1)] : undefined;
  20010. }
  20011. /**
  20012. * A specialized version of `_.sampleSize` for arrays.
  20013. *
  20014. * @private
  20015. * @param {Array} array The array to sample.
  20016. * @param {number} n The number of elements to sample.
  20017. * @returns {Array} Returns the random elements.
  20018. */
  20019. function arraySampleSize(array, n) {
  20020. return shuffleSelf(copyArray(array), baseClamp(n, 0, array.length));
  20021. }
  20022. /**
  20023. * A specialized version of `_.shuffle` for arrays.
  20024. *
  20025. * @private
  20026. * @param {Array} array The array to shuffle.
  20027. * @returns {Array} Returns the new shuffled array.
  20028. */
  20029. function arrayShuffle(array) {
  20030. return shuffleSelf(copyArray(array));
  20031. }
  20032. /**
  20033. * This function is like `assignValue` except that it doesn't assign
  20034. * `undefined` values.
  20035. *
  20036. * @private
  20037. * @param {Object} object The object to modify.
  20038. * @param {string} key The key of the property to assign.
  20039. * @param {*} value The value to assign.
  20040. */
  20041. function assignMergeValue(object, key, value) {
  20042. if ((value !== undefined && !eq(object[key], value)) ||
  20043. (value === undefined && !(key in object))) {
  20044. baseAssignValue(object, key, value);
  20045. }
  20046. }
  20047. /**
  20048. * Assigns `value` to `key` of `object` if the existing value is not equivalent
  20049. * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  20050. * for equality comparisons.
  20051. *
  20052. * @private
  20053. * @param {Object} object The object to modify.
  20054. * @param {string} key The key of the property to assign.
  20055. * @param {*} value The value to assign.
  20056. */
  20057. function assignValue(object, key, value) {
  20058. var objValue = object[key];
  20059. if (!(hasOwnProperty.call(object, key) && eq(objValue, value)) ||
  20060. (value === undefined && !(key in object))) {
  20061. baseAssignValue(object, key, value);
  20062. }
  20063. }
  20064. /**
  20065. * Gets the index at which the `key` is found in `array` of key-value pairs.
  20066. *
  20067. * @private
  20068. * @param {Array} array The array to inspect.
  20069. * @param {*} key The key to search for.
  20070. * @returns {number} Returns the index of the matched value, else `-1`.
  20071. */
  20072. function assocIndexOf(array, key) {
  20073. var length = array.length;
  20074. while (length--) {
  20075. if (eq(array[length][0], key)) {
  20076. return length;
  20077. }
  20078. }
  20079. return -1;
  20080. }
  20081. /**
  20082. * Aggregates elements of `collection` on `accumulator` with keys transformed
  20083. * by `iteratee` and values set by `setter`.
  20084. *
  20085. * @private
  20086. * @param {Array|Object} collection The collection to iterate over.
  20087. * @param {Function} setter The function to set `accumulator` values.
  20088. * @param {Function} iteratee The iteratee to transform keys.
  20089. * @param {Object} accumulator The initial aggregated object.
  20090. * @returns {Function} Returns `accumulator`.
  20091. */
  20092. function baseAggregator(collection, setter, iteratee, accumulator) {
  20093. baseEach(collection, function(value, key, collection) {
  20094. setter(accumulator, value, iteratee(value), collection);
  20095. });
  20096. return accumulator;
  20097. }
  20098. /**
  20099. * The base implementation of `_.assign` without support for multiple sources
  20100. * or `customizer` functions.
  20101. *
  20102. * @private
  20103. * @param {Object} object The destination object.
  20104. * @param {Object} source The source object.
  20105. * @returns {Object} Returns `object`.
  20106. */
  20107. function baseAssign(object, source) {
  20108. return object && copyObject(source, keys(source), object);
  20109. }
  20110. /**
  20111. * The base implementation of `_.assignIn` without support for multiple sources
  20112. * or `customizer` functions.
  20113. *
  20114. * @private
  20115. * @param {Object} object The destination object.
  20116. * @param {Object} source The source object.
  20117. * @returns {Object} Returns `object`.
  20118. */
  20119. function baseAssignIn(object, source) {
  20120. return object && copyObject(source, keysIn(source), object);
  20121. }
  20122. /**
  20123. * The base implementation of `assignValue` and `assignMergeValue` without
  20124. * value checks.
  20125. *
  20126. * @private
  20127. * @param {Object} object The object to modify.
  20128. * @param {string} key The key of the property to assign.
  20129. * @param {*} value The value to assign.
  20130. */
  20131. function baseAssignValue(object, key, value) {
  20132. if (key == '__proto__' && defineProperty) {
  20133. defineProperty(object, key, {
  20134. 'configurable': true,
  20135. 'enumerable': true,
  20136. 'value': value,
  20137. 'writable': true
  20138. });
  20139. } else {
  20140. object[key] = value;
  20141. }
  20142. }
  20143. /**
  20144. * The base implementation of `_.at` without support for individual paths.
  20145. *
  20146. * @private
  20147. * @param {Object} object The object to iterate over.
  20148. * @param {string[]} paths The property paths to pick.
  20149. * @returns {Array} Returns the picked elements.
  20150. */
  20151. function baseAt(object, paths) {
  20152. var index = -1,
  20153. length = paths.length,
  20154. result = Array(length),
  20155. skip = object == null;
  20156. while (++index < length) {
  20157. result[index] = skip ? undefined : get(object, paths[index]);
  20158. }
  20159. return result;
  20160. }
  20161. /**
  20162. * The base implementation of `_.clamp` which doesn't coerce arguments.
  20163. *
  20164. * @private
  20165. * @param {number} number The number to clamp.
  20166. * @param {number} [lower] The lower bound.
  20167. * @param {number} upper The upper bound.
  20168. * @returns {number} Returns the clamped number.
  20169. */
  20170. function baseClamp(number, lower, upper) {
  20171. if (number === number) {
  20172. if (upper !== undefined) {
  20173. number = number <= upper ? number : upper;
  20174. }
  20175. if (lower !== undefined) {
  20176. number = number >= lower ? number : lower;
  20177. }
  20178. }
  20179. return number;
  20180. }
  20181. /**
  20182. * The base implementation of `_.clone` and `_.cloneDeep` which tracks
  20183. * traversed objects.
  20184. *
  20185. * @private
  20186. * @param {*} value The value to clone.
  20187. * @param {boolean} bitmask The bitmask flags.
  20188. * 1 - Deep clone
  20189. * 2 - Flatten inherited properties
  20190. * 4 - Clone symbols
  20191. * @param {Function} [customizer] The function to customize cloning.
  20192. * @param {string} [key] The key of `value`.
  20193. * @param {Object} [object] The parent object of `value`.
  20194. * @param {Object} [stack] Tracks traversed objects and their clone counterparts.
  20195. * @returns {*} Returns the cloned value.
  20196. */
  20197. function baseClone(value, bitmask, customizer, key, object, stack) {
  20198. var result,
  20199. isDeep = bitmask & CLONE_DEEP_FLAG,
  20200. isFlat = bitmask & CLONE_FLAT_FLAG,
  20201. isFull = bitmask & CLONE_SYMBOLS_FLAG;
  20202. if (customizer) {
  20203. result = object ? customizer(value, key, object, stack) : customizer(value);
  20204. }
  20205. if (result !== undefined) {
  20206. return result;
  20207. }
  20208. if (!isObject(value)) {
  20209. return value;
  20210. }
  20211. var isArr = isArray(value);
  20212. if (isArr) {
  20213. result = initCloneArray(value);
  20214. if (!isDeep) {
  20215. return copyArray(value, result);
  20216. }
  20217. } else {
  20218. var tag = getTag(value),
  20219. isFunc = tag == funcTag || tag == genTag;
  20220. if (isBuffer(value)) {
  20221. return cloneBuffer(value, isDeep);
  20222. }
  20223. if (tag == objectTag || tag == argsTag || (isFunc && !object)) {
  20224. result = (isFlat || isFunc) ? {} : initCloneObject(value);
  20225. if (!isDeep) {
  20226. return isFlat
  20227. ? copySymbolsIn(value, baseAssignIn(result, value))
  20228. : copySymbols(value, baseAssign(result, value));
  20229. }
  20230. } else {
  20231. if (!cloneableTags[tag]) {
  20232. return object ? value : {};
  20233. }
  20234. result = initCloneByTag(value, tag, isDeep);
  20235. }
  20236. }
  20237. // Check for circular references and return its corresponding clone.
  20238. stack || (stack = new Stack);
  20239. var stacked = stack.get(value);
  20240. if (stacked) {
  20241. return stacked;
  20242. }
  20243. stack.set(value, result);
  20244. if (isSet(value)) {
  20245. value.forEach(function(subValue) {
  20246. result.add(baseClone(subValue, bitmask, customizer, subValue, value, stack));
  20247. });
  20248. } else if (isMap(value)) {
  20249. value.forEach(function(subValue, key) {
  20250. result.set(key, baseClone(subValue, bitmask, customizer, key, value, stack));
  20251. });
  20252. }
  20253. var keysFunc = isFull
  20254. ? (isFlat ? getAllKeysIn : getAllKeys)
  20255. : (isFlat ? keysIn : keys);
  20256. var props = isArr ? undefined : keysFunc(value);
  20257. arrayEach(props || value, function(subValue, key) {
  20258. if (props) {
  20259. key = subValue;
  20260. subValue = value[key];
  20261. }
  20262. // Recursively populate clone (susceptible to call stack limits).
  20263. assignValue(result, key, baseClone(subValue, bitmask, customizer, key, value, stack));
  20264. });
  20265. return result;
  20266. }
  20267. /**
  20268. * The base implementation of `_.conforms` which doesn't clone `source`.
  20269. *
  20270. * @private
  20271. * @param {Object} source The object of property predicates to conform to.
  20272. * @returns {Function} Returns the new spec function.
  20273. */
  20274. function baseConforms(source) {
  20275. var props = keys(source);
  20276. return function(object) {
  20277. return baseConformsTo(object, source, props);
  20278. };
  20279. }
  20280. /**
  20281. * The base implementation of `_.conformsTo` which accepts `props` to check.
  20282. *
  20283. * @private
  20284. * @param {Object} object The object to inspect.
  20285. * @param {Object} source The object of property predicates to conform to.
  20286. * @returns {boolean} Returns `true` if `object` conforms, else `false`.
  20287. */
  20288. function baseConformsTo(object, source, props) {
  20289. var length = props.length;
  20290. if (object == null) {
  20291. return !length;
  20292. }
  20293. object = Object(object);
  20294. while (length--) {
  20295. var key = props[length],
  20296. predicate = source[key],
  20297. value = object[key];
  20298. if ((value === undefined && !(key in object)) || !predicate(value)) {
  20299. return false;
  20300. }
  20301. }
  20302. return true;
  20303. }
  20304. /**
  20305. * The base implementation of `_.delay` and `_.defer` which accepts `args`
  20306. * to provide to `func`.
  20307. *
  20308. * @private
  20309. * @param {Function} func The function to delay.
  20310. * @param {number} wait The number of milliseconds to delay invocation.
  20311. * @param {Array} args The arguments to provide to `func`.
  20312. * @returns {number|Object} Returns the timer id or timeout object.
  20313. */
  20314. function baseDelay(func, wait, args) {
  20315. if (typeof func != 'function') {
  20316. throw new TypeError(FUNC_ERROR_TEXT);
  20317. }
  20318. return setTimeout(function() { func.apply(undefined, args); }, wait);
  20319. }
  20320. /**
  20321. * The base implementation of methods like `_.difference` without support
  20322. * for excluding multiple arrays or iteratee shorthands.
  20323. *
  20324. * @private
  20325. * @param {Array} array The array to inspect.
  20326. * @param {Array} values The values to exclude.
  20327. * @param {Function} [iteratee] The iteratee invoked per element.
  20328. * @param {Function} [comparator] The comparator invoked per element.
  20329. * @returns {Array} Returns the new array of filtered values.
  20330. */
  20331. function baseDifference(array, values, iteratee, comparator) {
  20332. var index = -1,
  20333. includes = arrayIncludes,
  20334. isCommon = true,
  20335. length = array.length,
  20336. result = [],
  20337. valuesLength = values.length;
  20338. if (!length) {
  20339. return result;
  20340. }
  20341. if (iteratee) {
  20342. values = arrayMap(values, baseUnary(iteratee));
  20343. }
  20344. if (comparator) {
  20345. includes = arrayIncludesWith;
  20346. isCommon = false;
  20347. }
  20348. else if (values.length >= LARGE_ARRAY_SIZE) {
  20349. includes = cacheHas;
  20350. isCommon = false;
  20351. values = new SetCache(values);
  20352. }
  20353. outer:
  20354. while (++index < length) {
  20355. var value = array[index],
  20356. computed = iteratee == null ? value : iteratee(value);
  20357. value = (comparator || value !== 0) ? value : 0;
  20358. if (isCommon && computed === computed) {
  20359. var valuesIndex = valuesLength;
  20360. while (valuesIndex--) {
  20361. if (values[valuesIndex] === computed) {
  20362. continue outer;
  20363. }
  20364. }
  20365. result.push(value);
  20366. }
  20367. else if (!includes(values, computed, comparator)) {
  20368. result.push(value);
  20369. }
  20370. }
  20371. return result;
  20372. }
  20373. /**
  20374. * The base implementation of `_.forEach` without support for iteratee shorthands.
  20375. *
  20376. * @private
  20377. * @param {Array|Object} collection The collection to iterate over.
  20378. * @param {Function} iteratee The function invoked per iteration.
  20379. * @returns {Array|Object} Returns `collection`.
  20380. */
  20381. var baseEach = createBaseEach(baseForOwn);
  20382. /**
  20383. * The base implementation of `_.forEachRight` without support for iteratee shorthands.
  20384. *
  20385. * @private
  20386. * @param {Array|Object} collection The collection to iterate over.
  20387. * @param {Function} iteratee The function invoked per iteration.
  20388. * @returns {Array|Object} Returns `collection`.
  20389. */
  20390. var baseEachRight = createBaseEach(baseForOwnRight, true);
  20391. /**
  20392. * The base implementation of `_.every` without support for iteratee shorthands.
  20393. *
  20394. * @private
  20395. * @param {Array|Object} collection The collection to iterate over.
  20396. * @param {Function} predicate The function invoked per iteration.
  20397. * @returns {boolean} Returns `true` if all elements pass the predicate check,
  20398. * else `false`
  20399. */
  20400. function baseEvery(collection, predicate) {
  20401. var result = true;
  20402. baseEach(collection, function(value, index, collection) {
  20403. result = !!predicate(value, index, collection);
  20404. return result;
  20405. });
  20406. return result;
  20407. }
  20408. /**
  20409. * The base implementation of methods like `_.max` and `_.min` which accepts a
  20410. * `comparator` to determine the extremum value.
  20411. *
  20412. * @private
  20413. * @param {Array} array The array to iterate over.
  20414. * @param {Function} iteratee The iteratee invoked per iteration.
  20415. * @param {Function} comparator The comparator used to compare values.
  20416. * @returns {*} Returns the extremum value.
  20417. */
  20418. function baseExtremum(array, iteratee, comparator) {
  20419. var index = -1,
  20420. length = array.length;
  20421. while (++index < length) {
  20422. var value = array[index],
  20423. current = iteratee(value);
  20424. if (current != null && (computed === undefined
  20425. ? (current === current && !isSymbol(current))
  20426. : comparator(current, computed)
  20427. )) {
  20428. var computed = current,
  20429. result = value;
  20430. }
  20431. }
  20432. return result;
  20433. }
  20434. /**
  20435. * The base implementation of `_.fill` without an iteratee call guard.
  20436. *
  20437. * @private
  20438. * @param {Array} array The array to fill.
  20439. * @param {*} value The value to fill `array` with.
  20440. * @param {number} [start=0] The start position.
  20441. * @param {number} [end=array.length] The end position.
  20442. * @returns {Array} Returns `array`.
  20443. */
  20444. function baseFill(array, value, start, end) {
  20445. var length = array.length;
  20446. start = toInteger(start);
  20447. if (start < 0) {
  20448. start = -start > length ? 0 : (length + start);
  20449. }
  20450. end = (end === undefined || end > length) ? length : toInteger(end);
  20451. if (end < 0) {
  20452. end += length;
  20453. }
  20454. end = start > end ? 0 : toLength(end);
  20455. while (start < end) {
  20456. array[start++] = value;
  20457. }
  20458. return array;
  20459. }
  20460. /**
  20461. * The base implementation of `_.filter` without support for iteratee shorthands.
  20462. *
  20463. * @private
  20464. * @param {Array|Object} collection The collection to iterate over.
  20465. * @param {Function} predicate The function invoked per iteration.
  20466. * @returns {Array} Returns the new filtered array.
  20467. */
  20468. function baseFilter(collection, predicate) {
  20469. var result = [];
  20470. baseEach(collection, function(value, index, collection) {
  20471. if (predicate(value, index, collection)) {
  20472. result.push(value);
  20473. }
  20474. });
  20475. return result;
  20476. }
  20477. /**
  20478. * The base implementation of `_.flatten` with support for restricting flattening.
  20479. *
  20480. * @private
  20481. * @param {Array} array The array to flatten.
  20482. * @param {number} depth The maximum recursion depth.
  20483. * @param {boolean} [predicate=isFlattenable] The function invoked per iteration.
  20484. * @param {boolean} [isStrict] Restrict to values that pass `predicate` checks.
  20485. * @param {Array} [result=[]] The initial result value.
  20486. * @returns {Array} Returns the new flattened array.
  20487. */
  20488. function baseFlatten(array, depth, predicate, isStrict, result) {
  20489. var index = -1,
  20490. length = array.length;
  20491. predicate || (predicate = isFlattenable);
  20492. result || (result = []);
  20493. while (++index < length) {
  20494. var value = array[index];
  20495. if (depth > 0 && predicate(value)) {
  20496. if (depth > 1) {
  20497. // Recursively flatten arrays (susceptible to call stack limits).
  20498. baseFlatten(value, depth - 1, predicate, isStrict, result);
  20499. } else {
  20500. arrayPush(result, value);
  20501. }
  20502. } else if (!isStrict) {
  20503. result[result.length] = value;
  20504. }
  20505. }
  20506. return result;
  20507. }
  20508. /**
  20509. * The base implementation of `baseForOwn` which iterates over `object`
  20510. * properties returned by `keysFunc` and invokes `iteratee` for each property.
  20511. * Iteratee functions may exit iteration early by explicitly returning `false`.
  20512. *
  20513. * @private
  20514. * @param {Object} object The object to iterate over.
  20515. * @param {Function} iteratee The function invoked per iteration.
  20516. * @param {Function} keysFunc The function to get the keys of `object`.
  20517. * @returns {Object} Returns `object`.
  20518. */
  20519. var baseFor = createBaseFor();
  20520. /**
  20521. * This function is like `baseFor` except that it iterates over properties
  20522. * in the opposite order.
  20523. *
  20524. * @private
  20525. * @param {Object} object The object to iterate over.
  20526. * @param {Function} iteratee The function invoked per iteration.
  20527. * @param {Function} keysFunc The function to get the keys of `object`.
  20528. * @returns {Object} Returns `object`.
  20529. */
  20530. var baseForRight = createBaseFor(true);
  20531. /**
  20532. * The base implementation of `_.forOwn` without support for iteratee shorthands.
  20533. *
  20534. * @private
  20535. * @param {Object} object The object to iterate over.
  20536. * @param {Function} iteratee The function invoked per iteration.
  20537. * @returns {Object} Returns `object`.
  20538. */
  20539. function baseForOwn(object, iteratee) {
  20540. return object && baseFor(object, iteratee, keys);
  20541. }
  20542. /**
  20543. * The base implementation of `_.forOwnRight` without support for iteratee shorthands.
  20544. *
  20545. * @private
  20546. * @param {Object} object The object to iterate over.
  20547. * @param {Function} iteratee The function invoked per iteration.
  20548. * @returns {Object} Returns `object`.
  20549. */
  20550. function baseForOwnRight(object, iteratee) {
  20551. return object && baseForRight(object, iteratee, keys);
  20552. }
  20553. /**
  20554. * The base implementation of `_.functions` which creates an array of
  20555. * `object` function property names filtered from `props`.
  20556. *
  20557. * @private
  20558. * @param {Object} object The object to inspect.
  20559. * @param {Array} props The property names to filter.
  20560. * @returns {Array} Returns the function names.
  20561. */
  20562. function baseFunctions(object, props) {
  20563. return arrayFilter(props, function(key) {
  20564. return isFunction(object[key]);
  20565. });
  20566. }
  20567. /**
  20568. * The base implementation of `_.get` without support for default values.
  20569. *
  20570. * @private
  20571. * @param {Object} object The object to query.
  20572. * @param {Array|string} path The path of the property to get.
  20573. * @returns {*} Returns the resolved value.
  20574. */
  20575. function baseGet(object, path) {
  20576. path = castPath(path, object);
  20577. var index = 0,
  20578. length = path.length;
  20579. while (object != null && index < length) {
  20580. object = object[toKey(path[index++])];
  20581. }
  20582. return (index && index == length) ? object : undefined;
  20583. }
  20584. /**
  20585. * The base implementation of `getAllKeys` and `getAllKeysIn` which uses
  20586. * `keysFunc` and `symbolsFunc` to get the enumerable property names and
  20587. * symbols of `object`.
  20588. *
  20589. * @private
  20590. * @param {Object} object The object to query.
  20591. * @param {Function} keysFunc The function to get the keys of `object`.
  20592. * @param {Function} symbolsFunc The function to get the symbols of `object`.
  20593. * @returns {Array} Returns the array of property names and symbols.
  20594. */
  20595. function baseGetAllKeys(object, keysFunc, symbolsFunc) {
  20596. var result = keysFunc(object);
  20597. return isArray(object) ? result : arrayPush(result, symbolsFunc(object));
  20598. }
  20599. /**
  20600. * The base implementation of `getTag` without fallbacks for buggy environments.
  20601. *
  20602. * @private
  20603. * @param {*} value The value to query.
  20604. * @returns {string} Returns the `toStringTag`.
  20605. */
  20606. function baseGetTag(value) {
  20607. if (value == null) {
  20608. return value === undefined ? undefinedTag : nullTag;
  20609. }
  20610. return (symToStringTag && symToStringTag in Object(value))
  20611. ? getRawTag(value)
  20612. : objectToString(value);
  20613. }
  20614. /**
  20615. * The base implementation of `_.gt` which doesn't coerce arguments.
  20616. *
  20617. * @private
  20618. * @param {*} value The value to compare.
  20619. * @param {*} other The other value to compare.
  20620. * @returns {boolean} Returns `true` if `value` is greater than `other`,
  20621. * else `false`.
  20622. */
  20623. function baseGt(value, other) {
  20624. return value > other;
  20625. }
  20626. /**
  20627. * The base implementation of `_.has` without support for deep paths.
  20628. *
  20629. * @private
  20630. * @param {Object} [object] The object to query.
  20631. * @param {Array|string} key The key to check.
  20632. * @returns {boolean} Returns `true` if `key` exists, else `false`.
  20633. */
  20634. function baseHas(object, key) {
  20635. return object != null && hasOwnProperty.call(object, key);
  20636. }
  20637. /**
  20638. * The base implementation of `_.hasIn` without support for deep paths.
  20639. *
  20640. * @private
  20641. * @param {Object} [object] The object to query.
  20642. * @param {Array|string} key The key to check.
  20643. * @returns {boolean} Returns `true` if `key` exists, else `false`.
  20644. */
  20645. function baseHasIn(object, key) {
  20646. return object != null && key in Object(object);
  20647. }
  20648. /**
  20649. * The base implementation of `_.inRange` which doesn't coerce arguments.
  20650. *
  20651. * @private
  20652. * @param {number} number The number to check.
  20653. * @param {number} start The start of the range.
  20654. * @param {number} end The end of the range.
  20655. * @returns {boolean} Returns `true` if `number` is in the range, else `false`.
  20656. */
  20657. function baseInRange(number, start, end) {
  20658. return number >= nativeMin(start, end) && number < nativeMax(start, end);
  20659. }
  20660. /**
  20661. * The base implementation of methods like `_.intersection`, without support
  20662. * for iteratee shorthands, that accepts an array of arrays to inspect.
  20663. *
  20664. * @private
  20665. * @param {Array} arrays The arrays to inspect.
  20666. * @param {Function} [iteratee] The iteratee invoked per element.
  20667. * @param {Function} [comparator] The comparator invoked per element.
  20668. * @returns {Array} Returns the new array of shared values.
  20669. */
  20670. function baseIntersection(arrays, iteratee, comparator) {
  20671. var includes = comparator ? arrayIncludesWith : arrayIncludes,
  20672. length = arrays[0].length,
  20673. othLength = arrays.length,
  20674. othIndex = othLength,
  20675. caches = Array(othLength),
  20676. maxLength = Infinity,
  20677. result = [];
  20678. while (othIndex--) {
  20679. var array = arrays[othIndex];
  20680. if (othIndex && iteratee) {
  20681. array = arrayMap(array, baseUnary(iteratee));
  20682. }
  20683. maxLength = nativeMin(array.length, maxLength);
  20684. caches[othIndex] = !comparator && (iteratee || (length >= 120 && array.length >= 120))
  20685. ? new SetCache(othIndex && array)
  20686. : undefined;
  20687. }
  20688. array = arrays[0];
  20689. var index = -1,
  20690. seen = caches[0];
  20691. outer:
  20692. while (++index < length && result.length < maxLength) {
  20693. var value = array[index],
  20694. computed = iteratee ? iteratee(value) : value;
  20695. value = (comparator || value !== 0) ? value : 0;
  20696. if (!(seen
  20697. ? cacheHas(seen, computed)
  20698. : includes(result, computed, comparator)
  20699. )) {
  20700. othIndex = othLength;
  20701. while (--othIndex) {
  20702. var cache = caches[othIndex];
  20703. if (!(cache
  20704. ? cacheHas(cache, computed)
  20705. : includes(arrays[othIndex], computed, comparator))
  20706. ) {
  20707. continue outer;
  20708. }
  20709. }
  20710. if (seen) {
  20711. seen.push(computed);
  20712. }
  20713. result.push(value);
  20714. }
  20715. }
  20716. return result;
  20717. }
  20718. /**
  20719. * The base implementation of `_.invert` and `_.invertBy` which inverts
  20720. * `object` with values transformed by `iteratee` and set by `setter`.
  20721. *
  20722. * @private
  20723. * @param {Object} object The object to iterate over.
  20724. * @param {Function} setter The function to set `accumulator` values.
  20725. * @param {Function} iteratee The iteratee to transform values.
  20726. * @param {Object} accumulator The initial inverted object.
  20727. * @returns {Function} Returns `accumulator`.
  20728. */
  20729. function baseInverter(object, setter, iteratee, accumulator) {
  20730. baseForOwn(object, function(value, key, object) {
  20731. setter(accumulator, iteratee(value), key, object);
  20732. });
  20733. return accumulator;
  20734. }
  20735. /**
  20736. * The base implementation of `_.invoke` without support for individual
  20737. * method arguments.
  20738. *
  20739. * @private
  20740. * @param {Object} object The object to query.
  20741. * @param {Array|string} path The path of the method to invoke.
  20742. * @param {Array} args The arguments to invoke the method with.
  20743. * @returns {*} Returns the result of the invoked method.
  20744. */
  20745. function baseInvoke(object, path, args) {
  20746. path = castPath(path, object);
  20747. object = parent(object, path);
  20748. var func = object == null ? object : object[toKey(last(path))];
  20749. return func == null ? undefined : apply(func, object, args);
  20750. }
  20751. /**
  20752. * The base implementation of `_.isArguments`.
  20753. *
  20754. * @private
  20755. * @param {*} value The value to check.
  20756. * @returns {boolean} Returns `true` if `value` is an `arguments` object,
  20757. */
  20758. function baseIsArguments(value) {
  20759. return isObjectLike(value) && baseGetTag(value) == argsTag;
  20760. }
  20761. /**
  20762. * The base implementation of `_.isArrayBuffer` without Node.js optimizations.
  20763. *
  20764. * @private
  20765. * @param {*} value The value to check.
  20766. * @returns {boolean} Returns `true` if `value` is an array buffer, else `false`.
  20767. */
  20768. function baseIsArrayBuffer(value) {
  20769. return isObjectLike(value) && baseGetTag(value) == arrayBufferTag;
  20770. }
  20771. /**
  20772. * The base implementation of `_.isDate` without Node.js optimizations.
  20773. *
  20774. * @private
  20775. * @param {*} value The value to check.
  20776. * @returns {boolean} Returns `true` if `value` is a date object, else `false`.
  20777. */
  20778. function baseIsDate(value) {
  20779. return isObjectLike(value) && baseGetTag(value) == dateTag;
  20780. }
  20781. /**
  20782. * The base implementation of `_.isEqual` which supports partial comparisons
  20783. * and tracks traversed objects.
  20784. *
  20785. * @private
  20786. * @param {*} value The value to compare.
  20787. * @param {*} other The other value to compare.
  20788. * @param {boolean} bitmask The bitmask flags.
  20789. * 1 - Unordered comparison
  20790. * 2 - Partial comparison
  20791. * @param {Function} [customizer] The function to customize comparisons.
  20792. * @param {Object} [stack] Tracks traversed `value` and `other` objects.
  20793. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  20794. */
  20795. function baseIsEqual(value, other, bitmask, customizer, stack) {
  20796. if (value === other) {
  20797. return true;
  20798. }
  20799. if (value == null || other == null || (!isObjectLike(value) && !isObjectLike(other))) {
  20800. return value !== value && other !== other;
  20801. }
  20802. return baseIsEqualDeep(value, other, bitmask, customizer, baseIsEqual, stack);
  20803. }
  20804. /**
  20805. * A specialized version of `baseIsEqual` for arrays and objects which performs
  20806. * deep comparisons and tracks traversed objects enabling objects with circular
  20807. * references to be compared.
  20808. *
  20809. * @private
  20810. * @param {Object} object The object to compare.
  20811. * @param {Object} other The other object to compare.
  20812. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
  20813. * @param {Function} customizer The function to customize comparisons.
  20814. * @param {Function} equalFunc The function to determine equivalents of values.
  20815. * @param {Object} [stack] Tracks traversed `object` and `other` objects.
  20816. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  20817. */
  20818. function baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) {
  20819. var objIsArr = isArray(object),
  20820. othIsArr = isArray(other),
  20821. objTag = objIsArr ? arrayTag : getTag(object),
  20822. othTag = othIsArr ? arrayTag : getTag(other);
  20823. objTag = objTag == argsTag ? objectTag : objTag;
  20824. othTag = othTag == argsTag ? objectTag : othTag;
  20825. var objIsObj = objTag == objectTag,
  20826. othIsObj = othTag == objectTag,
  20827. isSameTag = objTag == othTag;
  20828. if (isSameTag && isBuffer(object)) {
  20829. if (!isBuffer(other)) {
  20830. return false;
  20831. }
  20832. objIsArr = true;
  20833. objIsObj = false;
  20834. }
  20835. if (isSameTag && !objIsObj) {
  20836. stack || (stack = new Stack);
  20837. return (objIsArr || isTypedArray(object))
  20838. ? equalArrays(object, other, bitmask, customizer, equalFunc, stack)
  20839. : equalByTag(object, other, objTag, bitmask, customizer, equalFunc, stack);
  20840. }
  20841. if (!(bitmask & COMPARE_PARTIAL_FLAG)) {
  20842. var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'),
  20843. othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__');
  20844. if (objIsWrapped || othIsWrapped) {
  20845. var objUnwrapped = objIsWrapped ? object.value() : object,
  20846. othUnwrapped = othIsWrapped ? other.value() : other;
  20847. stack || (stack = new Stack);
  20848. return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack);
  20849. }
  20850. }
  20851. if (!isSameTag) {
  20852. return false;
  20853. }
  20854. stack || (stack = new Stack);
  20855. return equalObjects(object, other, bitmask, customizer, equalFunc, stack);
  20856. }
  20857. /**
  20858. * The base implementation of `_.isMap` without Node.js optimizations.
  20859. *
  20860. * @private
  20861. * @param {*} value The value to check.
  20862. * @returns {boolean} Returns `true` if `value` is a map, else `false`.
  20863. */
  20864. function baseIsMap(value) {
  20865. return isObjectLike(value) && getTag(value) == mapTag;
  20866. }
  20867. /**
  20868. * The base implementation of `_.isMatch` without support for iteratee shorthands.
  20869. *
  20870. * @private
  20871. * @param {Object} object The object to inspect.
  20872. * @param {Object} source The object of property values to match.
  20873. * @param {Array} matchData The property names, values, and compare flags to match.
  20874. * @param {Function} [customizer] The function to customize comparisons.
  20875. * @returns {boolean} Returns `true` if `object` is a match, else `false`.
  20876. */
  20877. function baseIsMatch(object, source, matchData, customizer) {
  20878. var index = matchData.length,
  20879. length = index,
  20880. noCustomizer = !customizer;
  20881. if (object == null) {
  20882. return !length;
  20883. }
  20884. object = Object(object);
  20885. while (index--) {
  20886. var data = matchData[index];
  20887. if ((noCustomizer && data[2])
  20888. ? data[1] !== object[data[0]]
  20889. : !(data[0] in object)
  20890. ) {
  20891. return false;
  20892. }
  20893. }
  20894. while (++index < length) {
  20895. data = matchData[index];
  20896. var key = data[0],
  20897. objValue = object[key],
  20898. srcValue = data[1];
  20899. if (noCustomizer && data[2]) {
  20900. if (objValue === undefined && !(key in object)) {
  20901. return false;
  20902. }
  20903. } else {
  20904. var stack = new Stack;
  20905. if (customizer) {
  20906. var result = customizer(objValue, srcValue, key, object, source, stack);
  20907. }
  20908. if (!(result === undefined
  20909. ? baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG, customizer, stack)
  20910. : result
  20911. )) {
  20912. return false;
  20913. }
  20914. }
  20915. }
  20916. return true;
  20917. }
  20918. /**
  20919. * The base implementation of `_.isNative` without bad shim checks.
  20920. *
  20921. * @private
  20922. * @param {*} value The value to check.
  20923. * @returns {boolean} Returns `true` if `value` is a native function,
  20924. * else `false`.
  20925. */
  20926. function baseIsNative(value) {
  20927. if (!isObject(value) || isMasked(value)) {
  20928. return false;
  20929. }
  20930. var pattern = isFunction(value) ? reIsNative : reIsHostCtor;
  20931. return pattern.test(toSource(value));
  20932. }
  20933. /**
  20934. * The base implementation of `_.isRegExp` without Node.js optimizations.
  20935. *
  20936. * @private
  20937. * @param {*} value The value to check.
  20938. * @returns {boolean} Returns `true` if `value` is a regexp, else `false`.
  20939. */
  20940. function baseIsRegExp(value) {
  20941. return isObjectLike(value) && baseGetTag(value) == regexpTag;
  20942. }
  20943. /**
  20944. * The base implementation of `_.isSet` without Node.js optimizations.
  20945. *
  20946. * @private
  20947. * @param {*} value The value to check.
  20948. * @returns {boolean} Returns `true` if `value` is a set, else `false`.
  20949. */
  20950. function baseIsSet(value) {
  20951. return isObjectLike(value) && getTag(value) == setTag;
  20952. }
  20953. /**
  20954. * The base implementation of `_.isTypedArray` without Node.js optimizations.
  20955. *
  20956. * @private
  20957. * @param {*} value The value to check.
  20958. * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
  20959. */
  20960. function baseIsTypedArray(value) {
  20961. return isObjectLike(value) &&
  20962. isLength(value.length) && !!typedArrayTags[baseGetTag(value)];
  20963. }
  20964. /**
  20965. * The base implementation of `_.iteratee`.
  20966. *
  20967. * @private
  20968. * @param {*} [value=_.identity] The value to convert to an iteratee.
  20969. * @returns {Function} Returns the iteratee.
  20970. */
  20971. function baseIteratee(value) {
  20972. // Don't store the `typeof` result in a variable to avoid a JIT bug in Safari 9.
  20973. // See https://bugs.webkit.org/show_bug.cgi?id=156034 for more details.
  20974. if (typeof value == 'function') {
  20975. return value;
  20976. }
  20977. if (value == null) {
  20978. return identity;
  20979. }
  20980. if (typeof value == 'object') {
  20981. return isArray(value)
  20982. ? baseMatchesProperty(value[0], value[1])
  20983. : baseMatches(value);
  20984. }
  20985. return property(value);
  20986. }
  20987. /**
  20988. * The base implementation of `_.keys` which doesn't treat sparse arrays as dense.
  20989. *
  20990. * @private
  20991. * @param {Object} object The object to query.
  20992. * @returns {Array} Returns the array of property names.
  20993. */
  20994. function baseKeys(object) {
  20995. if (!isPrototype(object)) {
  20996. return nativeKeys(object);
  20997. }
  20998. var result = [];
  20999. for (var key in Object(object)) {
  21000. if (hasOwnProperty.call(object, key) && key != 'constructor') {
  21001. result.push(key);
  21002. }
  21003. }
  21004. return result;
  21005. }
  21006. /**
  21007. * The base implementation of `_.keysIn` which doesn't treat sparse arrays as dense.
  21008. *
  21009. * @private
  21010. * @param {Object} object The object to query.
  21011. * @returns {Array} Returns the array of property names.
  21012. */
  21013. function baseKeysIn(object) {
  21014. if (!isObject(object)) {
  21015. return nativeKeysIn(object);
  21016. }
  21017. var isProto = isPrototype(object),
  21018. result = [];
  21019. for (var key in object) {
  21020. if (!(key == 'constructor' && (isProto || !hasOwnProperty.call(object, key)))) {
  21021. result.push(key);
  21022. }
  21023. }
  21024. return result;
  21025. }
  21026. /**
  21027. * The base implementation of `_.lt` which doesn't coerce arguments.
  21028. *
  21029. * @private
  21030. * @param {*} value The value to compare.
  21031. * @param {*} other The other value to compare.
  21032. * @returns {boolean} Returns `true` if `value` is less than `other`,
  21033. * else `false`.
  21034. */
  21035. function baseLt(value, other) {
  21036. return value < other;
  21037. }
  21038. /**
  21039. * The base implementation of `_.map` without support for iteratee shorthands.
  21040. *
  21041. * @private
  21042. * @param {Array|Object} collection The collection to iterate over.
  21043. * @param {Function} iteratee The function invoked per iteration.
  21044. * @returns {Array} Returns the new mapped array.
  21045. */
  21046. function baseMap(collection, iteratee) {
  21047. var index = -1,
  21048. result = isArrayLike(collection) ? Array(collection.length) : [];
  21049. baseEach(collection, function(value, key, collection) {
  21050. result[++index] = iteratee(value, key, collection);
  21051. });
  21052. return result;
  21053. }
  21054. /**
  21055. * The base implementation of `_.matches` which doesn't clone `source`.
  21056. *
  21057. * @private
  21058. * @param {Object} source The object of property values to match.
  21059. * @returns {Function} Returns the new spec function.
  21060. */
  21061. function baseMatches(source) {
  21062. var matchData = getMatchData(source);
  21063. if (matchData.length == 1 && matchData[0][2]) {
  21064. return matchesStrictComparable(matchData[0][0], matchData[0][1]);
  21065. }
  21066. return function(object) {
  21067. return object === source || baseIsMatch(object, source, matchData);
  21068. };
  21069. }
  21070. /**
  21071. * The base implementation of `_.matchesProperty` which doesn't clone `srcValue`.
  21072. *
  21073. * @private
  21074. * @param {string} path The path of the property to get.
  21075. * @param {*} srcValue The value to match.
  21076. * @returns {Function} Returns the new spec function.
  21077. */
  21078. function baseMatchesProperty(path, srcValue) {
  21079. if (isKey(path) && isStrictComparable(srcValue)) {
  21080. return matchesStrictComparable(toKey(path), srcValue);
  21081. }
  21082. return function(object) {
  21083. var objValue = get(object, path);
  21084. return (objValue === undefined && objValue === srcValue)
  21085. ? hasIn(object, path)
  21086. : baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG);
  21087. };
  21088. }
  21089. /**
  21090. * The base implementation of `_.merge` without support for multiple sources.
  21091. *
  21092. * @private
  21093. * @param {Object} object The destination object.
  21094. * @param {Object} source The source object.
  21095. * @param {number} srcIndex The index of `source`.
  21096. * @param {Function} [customizer] The function to customize merged values.
  21097. * @param {Object} [stack] Tracks traversed source values and their merged
  21098. * counterparts.
  21099. */
  21100. function baseMerge(object, source, srcIndex, customizer, stack) {
  21101. if (object === source) {
  21102. return;
  21103. }
  21104. baseFor(source, function(srcValue, key) {
  21105. stack || (stack = new Stack);
  21106. if (isObject(srcValue)) {
  21107. baseMergeDeep(object, source, key, srcIndex, baseMerge, customizer, stack);
  21108. }
  21109. else {
  21110. var newValue = customizer
  21111. ? customizer(safeGet(object, key), srcValue, (key + ''), object, source, stack)
  21112. : undefined;
  21113. if (newValue === undefined) {
  21114. newValue = srcValue;
  21115. }
  21116. assignMergeValue(object, key, newValue);
  21117. }
  21118. }, keysIn);
  21119. }
  21120. /**
  21121. * A specialized version of `baseMerge` for arrays and objects which performs
  21122. * deep merges and tracks traversed objects enabling objects with circular
  21123. * references to be merged.
  21124. *
  21125. * @private
  21126. * @param {Object} object The destination object.
  21127. * @param {Object} source The source object.
  21128. * @param {string} key The key of the value to merge.
  21129. * @param {number} srcIndex The index of `source`.
  21130. * @param {Function} mergeFunc The function to merge values.
  21131. * @param {Function} [customizer] The function to customize assigned values.
  21132. * @param {Object} [stack] Tracks traversed source values and their merged
  21133. * counterparts.
  21134. */
  21135. function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, stack) {
  21136. var objValue = safeGet(object, key),
  21137. srcValue = safeGet(source, key),
  21138. stacked = stack.get(srcValue);
  21139. if (stacked) {
  21140. assignMergeValue(object, key, stacked);
  21141. return;
  21142. }
  21143. var newValue = customizer
  21144. ? customizer(objValue, srcValue, (key + ''), object, source, stack)
  21145. : undefined;
  21146. var isCommon = newValue === undefined;
  21147. if (isCommon) {
  21148. var isArr = isArray(srcValue),
  21149. isBuff = !isArr && isBuffer(srcValue),
  21150. isTyped = !isArr && !isBuff && isTypedArray(srcValue);
  21151. newValue = srcValue;
  21152. if (isArr || isBuff || isTyped) {
  21153. if (isArray(objValue)) {
  21154. newValue = objValue;
  21155. }
  21156. else if (isArrayLikeObject(objValue)) {
  21157. newValue = copyArray(objValue);
  21158. }
  21159. else if (isBuff) {
  21160. isCommon = false;
  21161. newValue = cloneBuffer(srcValue, true);
  21162. }
  21163. else if (isTyped) {
  21164. isCommon = false;
  21165. newValue = cloneTypedArray(srcValue, true);
  21166. }
  21167. else {
  21168. newValue = [];
  21169. }
  21170. }
  21171. else if (isPlainObject(srcValue) || isArguments(srcValue)) {
  21172. newValue = objValue;
  21173. if (isArguments(objValue)) {
  21174. newValue = toPlainObject(objValue);
  21175. }
  21176. else if (!isObject(objValue) || isFunction(objValue)) {
  21177. newValue = initCloneObject(srcValue);
  21178. }
  21179. }
  21180. else {
  21181. isCommon = false;
  21182. }
  21183. }
  21184. if (isCommon) {
  21185. // Recursively merge objects and arrays (susceptible to call stack limits).
  21186. stack.set(srcValue, newValue);
  21187. mergeFunc(newValue, srcValue, srcIndex, customizer, stack);
  21188. stack['delete'](srcValue);
  21189. }
  21190. assignMergeValue(object, key, newValue);
  21191. }
  21192. /**
  21193. * The base implementation of `_.nth` which doesn't coerce arguments.
  21194. *
  21195. * @private
  21196. * @param {Array} array The array to query.
  21197. * @param {number} n The index of the element to return.
  21198. * @returns {*} Returns the nth element of `array`.
  21199. */
  21200. function baseNth(array, n) {
  21201. var length = array.length;
  21202. if (!length) {
  21203. return;
  21204. }
  21205. n += n < 0 ? length : 0;
  21206. return isIndex(n, length) ? array[n] : undefined;
  21207. }
  21208. /**
  21209. * The base implementation of `_.orderBy` without param guards.
  21210. *
  21211. * @private
  21212. * @param {Array|Object} collection The collection to iterate over.
  21213. * @param {Function[]|Object[]|string[]} iteratees The iteratees to sort by.
  21214. * @param {string[]} orders The sort orders of `iteratees`.
  21215. * @returns {Array} Returns the new sorted array.
  21216. */
  21217. function baseOrderBy(collection, iteratees, orders) {
  21218. var index = -1;
  21219. iteratees = arrayMap(iteratees.length ? iteratees : [identity], baseUnary(getIteratee()));
  21220. var result = baseMap(collection, function(value, key, collection) {
  21221. var criteria = arrayMap(iteratees, function(iteratee) {
  21222. return iteratee(value);
  21223. });
  21224. return { 'criteria': criteria, 'index': ++index, 'value': value };
  21225. });
  21226. return baseSortBy(result, function(object, other) {
  21227. return compareMultiple(object, other, orders);
  21228. });
  21229. }
  21230. /**
  21231. * The base implementation of `_.pick` without support for individual
  21232. * property identifiers.
  21233. *
  21234. * @private
  21235. * @param {Object} object The source object.
  21236. * @param {string[]} paths The property paths to pick.
  21237. * @returns {Object} Returns the new object.
  21238. */
  21239. function basePick(object, paths) {
  21240. return basePickBy(object, paths, function(value, path) {
  21241. return hasIn(object, path);
  21242. });
  21243. }
  21244. /**
  21245. * The base implementation of `_.pickBy` without support for iteratee shorthands.
  21246. *
  21247. * @private
  21248. * @param {Object} object The source object.
  21249. * @param {string[]} paths The property paths to pick.
  21250. * @param {Function} predicate The function invoked per property.
  21251. * @returns {Object} Returns the new object.
  21252. */
  21253. function basePickBy(object, paths, predicate) {
  21254. var index = -1,
  21255. length = paths.length,
  21256. result = {};
  21257. while (++index < length) {
  21258. var path = paths[index],
  21259. value = baseGet(object, path);
  21260. if (predicate(value, path)) {
  21261. baseSet(result, castPath(path, object), value);
  21262. }
  21263. }
  21264. return result;
  21265. }
  21266. /**
  21267. * A specialized version of `baseProperty` which supports deep paths.
  21268. *
  21269. * @private
  21270. * @param {Array|string} path The path of the property to get.
  21271. * @returns {Function} Returns the new accessor function.
  21272. */
  21273. function basePropertyDeep(path) {
  21274. return function(object) {
  21275. return baseGet(object, path);
  21276. };
  21277. }
  21278. /**
  21279. * The base implementation of `_.pullAllBy` without support for iteratee
  21280. * shorthands.
  21281. *
  21282. * @private
  21283. * @param {Array} array The array to modify.
  21284. * @param {Array} values The values to remove.
  21285. * @param {Function} [iteratee] The iteratee invoked per element.
  21286. * @param {Function} [comparator] The comparator invoked per element.
  21287. * @returns {Array} Returns `array`.
  21288. */
  21289. function basePullAll(array, values, iteratee, comparator) {
  21290. var indexOf = comparator ? baseIndexOfWith : baseIndexOf,
  21291. index = -1,
  21292. length = values.length,
  21293. seen = array;
  21294. if (array === values) {
  21295. values = copyArray(values);
  21296. }
  21297. if (iteratee) {
  21298. seen = arrayMap(array, baseUnary(iteratee));
  21299. }
  21300. while (++index < length) {
  21301. var fromIndex = 0,
  21302. value = values[index],
  21303. computed = iteratee ? iteratee(value) : value;
  21304. while ((fromIndex = indexOf(seen, computed, fromIndex, comparator)) > -1) {
  21305. if (seen !== array) {
  21306. splice.call(seen, fromIndex, 1);
  21307. }
  21308. splice.call(array, fromIndex, 1);
  21309. }
  21310. }
  21311. return array;
  21312. }
  21313. /**
  21314. * The base implementation of `_.pullAt` without support for individual
  21315. * indexes or capturing the removed elements.
  21316. *
  21317. * @private
  21318. * @param {Array} array The array to modify.
  21319. * @param {number[]} indexes The indexes of elements to remove.
  21320. * @returns {Array} Returns `array`.
  21321. */
  21322. function basePullAt(array, indexes) {
  21323. var length = array ? indexes.length : 0,
  21324. lastIndex = length - 1;
  21325. while (length--) {
  21326. var index = indexes[length];
  21327. if (length == lastIndex || index !== previous) {
  21328. var previous = index;
  21329. if (isIndex(index)) {
  21330. splice.call(array, index, 1);
  21331. } else {
  21332. baseUnset(array, index);
  21333. }
  21334. }
  21335. }
  21336. return array;
  21337. }
  21338. /**
  21339. * The base implementation of `_.random` without support for returning
  21340. * floating-point numbers.
  21341. *
  21342. * @private
  21343. * @param {number} lower The lower bound.
  21344. * @param {number} upper The upper bound.
  21345. * @returns {number} Returns the random number.
  21346. */
  21347. function baseRandom(lower, upper) {
  21348. return lower + nativeFloor(nativeRandom() * (upper - lower + 1));
  21349. }
  21350. /**
  21351. * The base implementation of `_.range` and `_.rangeRight` which doesn't
  21352. * coerce arguments.
  21353. *
  21354. * @private
  21355. * @param {number} start The start of the range.
  21356. * @param {number} end The end of the range.
  21357. * @param {number} step The value to increment or decrement by.
  21358. * @param {boolean} [fromRight] Specify iterating from right to left.
  21359. * @returns {Array} Returns the range of numbers.
  21360. */
  21361. function baseRange(start, end, step, fromRight) {
  21362. var index = -1,
  21363. length = nativeMax(nativeCeil((end - start) / (step || 1)), 0),
  21364. result = Array(length);
  21365. while (length--) {
  21366. result[fromRight ? length : ++index] = start;
  21367. start += step;
  21368. }
  21369. return result;
  21370. }
  21371. /**
  21372. * The base implementation of `_.repeat` which doesn't coerce arguments.
  21373. *
  21374. * @private
  21375. * @param {string} string The string to repeat.
  21376. * @param {number} n The number of times to repeat the string.
  21377. * @returns {string} Returns the repeated string.
  21378. */
  21379. function baseRepeat(string, n) {
  21380. var result = '';
  21381. if (!string || n < 1 || n > MAX_SAFE_INTEGER) {
  21382. return result;
  21383. }
  21384. // Leverage the exponentiation by squaring algorithm for a faster repeat.
  21385. // See https://en.wikipedia.org/wiki/Exponentiation_by_squaring for more details.
  21386. do {
  21387. if (n % 2) {
  21388. result += string;
  21389. }
  21390. n = nativeFloor(n / 2);
  21391. if (n) {
  21392. string += string;
  21393. }
  21394. } while (n);
  21395. return result;
  21396. }
  21397. /**
  21398. * The base implementation of `_.rest` which doesn't validate or coerce arguments.
  21399. *
  21400. * @private
  21401. * @param {Function} func The function to apply a rest parameter to.
  21402. * @param {number} [start=func.length-1] The start position of the rest parameter.
  21403. * @returns {Function} Returns the new function.
  21404. */
  21405. function baseRest(func, start) {
  21406. return setToString(overRest(func, start, identity), func + '');
  21407. }
  21408. /**
  21409. * The base implementation of `_.sample`.
  21410. *
  21411. * @private
  21412. * @param {Array|Object} collection The collection to sample.
  21413. * @returns {*} Returns the random element.
  21414. */
  21415. function baseSample(collection) {
  21416. return arraySample(values(collection));
  21417. }
  21418. /**
  21419. * The base implementation of `_.sampleSize` without param guards.
  21420. *
  21421. * @private
  21422. * @param {Array|Object} collection The collection to sample.
  21423. * @param {number} n The number of elements to sample.
  21424. * @returns {Array} Returns the random elements.
  21425. */
  21426. function baseSampleSize(collection, n) {
  21427. var array = values(collection);
  21428. return shuffleSelf(array, baseClamp(n, 0, array.length));
  21429. }
  21430. /**
  21431. * The base implementation of `_.set`.
  21432. *
  21433. * @private
  21434. * @param {Object} object The object to modify.
  21435. * @param {Array|string} path The path of the property to set.
  21436. * @param {*} value The value to set.
  21437. * @param {Function} [customizer] The function to customize path creation.
  21438. * @returns {Object} Returns `object`.
  21439. */
  21440. function baseSet(object, path, value, customizer) {
  21441. if (!isObject(object)) {
  21442. return object;
  21443. }
  21444. path = castPath(path, object);
  21445. var index = -1,
  21446. length = path.length,
  21447. lastIndex = length - 1,
  21448. nested = object;
  21449. while (nested != null && ++index < length) {
  21450. var key = toKey(path[index]),
  21451. newValue = value;
  21452. if (index != lastIndex) {
  21453. var objValue = nested[key];
  21454. newValue = customizer ? customizer(objValue, key, nested) : undefined;
  21455. if (newValue === undefined) {
  21456. newValue = isObject(objValue)
  21457. ? objValue
  21458. : (isIndex(path[index + 1]) ? [] : {});
  21459. }
  21460. }
  21461. assignValue(nested, key, newValue);
  21462. nested = nested[key];
  21463. }
  21464. return object;
  21465. }
  21466. /**
  21467. * The base implementation of `setData` without support for hot loop shorting.
  21468. *
  21469. * @private
  21470. * @param {Function} func The function to associate metadata with.
  21471. * @param {*} data The metadata.
  21472. * @returns {Function} Returns `func`.
  21473. */
  21474. var baseSetData = !metaMap ? identity : function(func, data) {
  21475. metaMap.set(func, data);
  21476. return func;
  21477. };
  21478. /**
  21479. * The base implementation of `setToString` without support for hot loop shorting.
  21480. *
  21481. * @private
  21482. * @param {Function} func The function to modify.
  21483. * @param {Function} string The `toString` result.
  21484. * @returns {Function} Returns `func`.
  21485. */
  21486. var baseSetToString = !defineProperty ? identity : function(func, string) {
  21487. return defineProperty(func, 'toString', {
  21488. 'configurable': true,
  21489. 'enumerable': false,
  21490. 'value': constant(string),
  21491. 'writable': true
  21492. });
  21493. };
  21494. /**
  21495. * The base implementation of `_.shuffle`.
  21496. *
  21497. * @private
  21498. * @param {Array|Object} collection The collection to shuffle.
  21499. * @returns {Array} Returns the new shuffled array.
  21500. */
  21501. function baseShuffle(collection) {
  21502. return shuffleSelf(values(collection));
  21503. }
  21504. /**
  21505. * The base implementation of `_.slice` without an iteratee call guard.
  21506. *
  21507. * @private
  21508. * @param {Array} array The array to slice.
  21509. * @param {number} [start=0] The start position.
  21510. * @param {number} [end=array.length] The end position.
  21511. * @returns {Array} Returns the slice of `array`.
  21512. */
  21513. function baseSlice(array, start, end) {
  21514. var index = -1,
  21515. length = array.length;
  21516. if (start < 0) {
  21517. start = -start > length ? 0 : (length + start);
  21518. }
  21519. end = end > length ? length : end;
  21520. if (end < 0) {
  21521. end += length;
  21522. }
  21523. length = start > end ? 0 : ((end - start) >>> 0);
  21524. start >>>= 0;
  21525. var result = Array(length);
  21526. while (++index < length) {
  21527. result[index] = array[index + start];
  21528. }
  21529. return result;
  21530. }
  21531. /**
  21532. * The base implementation of `_.some` without support for iteratee shorthands.
  21533. *
  21534. * @private
  21535. * @param {Array|Object} collection The collection to iterate over.
  21536. * @param {Function} predicate The function invoked per iteration.
  21537. * @returns {boolean} Returns `true` if any element passes the predicate check,
  21538. * else `false`.
  21539. */
  21540. function baseSome(collection, predicate) {
  21541. var result;
  21542. baseEach(collection, function(value, index, collection) {
  21543. result = predicate(value, index, collection);
  21544. return !result;
  21545. });
  21546. return !!result;
  21547. }
  21548. /**
  21549. * The base implementation of `_.sortedIndex` and `_.sortedLastIndex` which
  21550. * performs a binary search of `array` to determine the index at which `value`
  21551. * should be inserted into `array` in order to maintain its sort order.
  21552. *
  21553. * @private
  21554. * @param {Array} array The sorted array to inspect.
  21555. * @param {*} value The value to evaluate.
  21556. * @param {boolean} [retHighest] Specify returning the highest qualified index.
  21557. * @returns {number} Returns the index at which `value` should be inserted
  21558. * into `array`.
  21559. */
  21560. function baseSortedIndex(array, value, retHighest) {
  21561. var low = 0,
  21562. high = array == null ? low : array.length;
  21563. if (typeof value == 'number' && value === value && high <= HALF_MAX_ARRAY_LENGTH) {
  21564. while (low < high) {
  21565. var mid = (low + high) >>> 1,
  21566. computed = array[mid];
  21567. if (computed !== null && !isSymbol(computed) &&
  21568. (retHighest ? (computed <= value) : (computed < value))) {
  21569. low = mid + 1;
  21570. } else {
  21571. high = mid;
  21572. }
  21573. }
  21574. return high;
  21575. }
  21576. return baseSortedIndexBy(array, value, identity, retHighest);
  21577. }
  21578. /**
  21579. * The base implementation of `_.sortedIndexBy` and `_.sortedLastIndexBy`
  21580. * which invokes `iteratee` for `value` and each element of `array` to compute
  21581. * their sort ranking. The iteratee is invoked with one argument; (value).
  21582. *
  21583. * @private
  21584. * @param {Array} array The sorted array to inspect.
  21585. * @param {*} value The value to evaluate.
  21586. * @param {Function} iteratee The iteratee invoked per element.
  21587. * @param {boolean} [retHighest] Specify returning the highest qualified index.
  21588. * @returns {number} Returns the index at which `value` should be inserted
  21589. * into `array`.
  21590. */
  21591. function baseSortedIndexBy(array, value, iteratee, retHighest) {
  21592. value = iteratee(value);
  21593. var low = 0,
  21594. high = array == null ? 0 : array.length,
  21595. valIsNaN = value !== value,
  21596. valIsNull = value === null,
  21597. valIsSymbol = isSymbol(value),
  21598. valIsUndefined = value === undefined;
  21599. while (low < high) {
  21600. var mid = nativeFloor((low + high) / 2),
  21601. computed = iteratee(array[mid]),
  21602. othIsDefined = computed !== undefined,
  21603. othIsNull = computed === null,
  21604. othIsReflexive = computed === computed,
  21605. othIsSymbol = isSymbol(computed);
  21606. if (valIsNaN) {
  21607. var setLow = retHighest || othIsReflexive;
  21608. } else if (valIsUndefined) {
  21609. setLow = othIsReflexive && (retHighest || othIsDefined);
  21610. } else if (valIsNull) {
  21611. setLow = othIsReflexive && othIsDefined && (retHighest || !othIsNull);
  21612. } else if (valIsSymbol) {
  21613. setLow = othIsReflexive && othIsDefined && !othIsNull && (retHighest || !othIsSymbol);
  21614. } else if (othIsNull || othIsSymbol) {
  21615. setLow = false;
  21616. } else {
  21617. setLow = retHighest ? (computed <= value) : (computed < value);
  21618. }
  21619. if (setLow) {
  21620. low = mid + 1;
  21621. } else {
  21622. high = mid;
  21623. }
  21624. }
  21625. return nativeMin(high, MAX_ARRAY_INDEX);
  21626. }
  21627. /**
  21628. * The base implementation of `_.sortedUniq` and `_.sortedUniqBy` without
  21629. * support for iteratee shorthands.
  21630. *
  21631. * @private
  21632. * @param {Array} array The array to inspect.
  21633. * @param {Function} [iteratee] The iteratee invoked per element.
  21634. * @returns {Array} Returns the new duplicate free array.
  21635. */
  21636. function baseSortedUniq(array, iteratee) {
  21637. var index = -1,
  21638. length = array.length,
  21639. resIndex = 0,
  21640. result = [];
  21641. while (++index < length) {
  21642. var value = array[index],
  21643. computed = iteratee ? iteratee(value) : value;
  21644. if (!index || !eq(computed, seen)) {
  21645. var seen = computed;
  21646. result[resIndex++] = value === 0 ? 0 : value;
  21647. }
  21648. }
  21649. return result;
  21650. }
  21651. /**
  21652. * The base implementation of `_.toNumber` which doesn't ensure correct
  21653. * conversions of binary, hexadecimal, or octal string values.
  21654. *
  21655. * @private
  21656. * @param {*} value The value to process.
  21657. * @returns {number} Returns the number.
  21658. */
  21659. function baseToNumber(value) {
  21660. if (typeof value == 'number') {
  21661. return value;
  21662. }
  21663. if (isSymbol(value)) {
  21664. return NAN;
  21665. }
  21666. return +value;
  21667. }
  21668. /**
  21669. * The base implementation of `_.toString` which doesn't convert nullish
  21670. * values to empty strings.
  21671. *
  21672. * @private
  21673. * @param {*} value The value to process.
  21674. * @returns {string} Returns the string.
  21675. */
  21676. function baseToString(value) {
  21677. // Exit early for strings to avoid a performance hit in some environments.
  21678. if (typeof value == 'string') {
  21679. return value;
  21680. }
  21681. if (isArray(value)) {
  21682. // Recursively convert values (susceptible to call stack limits).
  21683. return arrayMap(value, baseToString) + '';
  21684. }
  21685. if (isSymbol(value)) {
  21686. return symbolToString ? symbolToString.call(value) : '';
  21687. }
  21688. var result = (value + '');
  21689. return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
  21690. }
  21691. /**
  21692. * The base implementation of `_.uniqBy` without support for iteratee shorthands.
  21693. *
  21694. * @private
  21695. * @param {Array} array The array to inspect.
  21696. * @param {Function} [iteratee] The iteratee invoked per element.
  21697. * @param {Function} [comparator] The comparator invoked per element.
  21698. * @returns {Array} Returns the new duplicate free array.
  21699. */
  21700. function baseUniq(array, iteratee, comparator) {
  21701. var index = -1,
  21702. includes = arrayIncludes,
  21703. length = array.length,
  21704. isCommon = true,
  21705. result = [],
  21706. seen = result;
  21707. if (comparator) {
  21708. isCommon = false;
  21709. includes = arrayIncludesWith;
  21710. }
  21711. else if (length >= LARGE_ARRAY_SIZE) {
  21712. var set = iteratee ? null : createSet(array);
  21713. if (set) {
  21714. return setToArray(set);
  21715. }
  21716. isCommon = false;
  21717. includes = cacheHas;
  21718. seen = new SetCache;
  21719. }
  21720. else {
  21721. seen = iteratee ? [] : result;
  21722. }
  21723. outer:
  21724. while (++index < length) {
  21725. var value = array[index],
  21726. computed = iteratee ? iteratee(value) : value;
  21727. value = (comparator || value !== 0) ? value : 0;
  21728. if (isCommon && computed === computed) {
  21729. var seenIndex = seen.length;
  21730. while (seenIndex--) {
  21731. if (seen[seenIndex] === computed) {
  21732. continue outer;
  21733. }
  21734. }
  21735. if (iteratee) {
  21736. seen.push(computed);
  21737. }
  21738. result.push(value);
  21739. }
  21740. else if (!includes(seen, computed, comparator)) {
  21741. if (seen !== result) {
  21742. seen.push(computed);
  21743. }
  21744. result.push(value);
  21745. }
  21746. }
  21747. return result;
  21748. }
  21749. /**
  21750. * The base implementation of `_.unset`.
  21751. *
  21752. * @private
  21753. * @param {Object} object The object to modify.
  21754. * @param {Array|string} path The property path to unset.
  21755. * @returns {boolean} Returns `true` if the property is deleted, else `false`.
  21756. */
  21757. function baseUnset(object, path) {
  21758. path = castPath(path, object);
  21759. object = parent(object, path);
  21760. return object == null || delete object[toKey(last(path))];
  21761. }
  21762. /**
  21763. * The base implementation of `_.update`.
  21764. *
  21765. * @private
  21766. * @param {Object} object The object to modify.
  21767. * @param {Array|string} path The path of the property to update.
  21768. * @param {Function} updater The function to produce the updated value.
  21769. * @param {Function} [customizer] The function to customize path creation.
  21770. * @returns {Object} Returns `object`.
  21771. */
  21772. function baseUpdate(object, path, updater, customizer) {
  21773. return baseSet(object, path, updater(baseGet(object, path)), customizer);
  21774. }
  21775. /**
  21776. * The base implementation of methods like `_.dropWhile` and `_.takeWhile`
  21777. * without support for iteratee shorthands.
  21778. *
  21779. * @private
  21780. * @param {Array} array The array to query.
  21781. * @param {Function} predicate The function invoked per iteration.
  21782. * @param {boolean} [isDrop] Specify dropping elements instead of taking them.
  21783. * @param {boolean} [fromRight] Specify iterating from right to left.
  21784. * @returns {Array} Returns the slice of `array`.
  21785. */
  21786. function baseWhile(array, predicate, isDrop, fromRight) {
  21787. var length = array.length,
  21788. index = fromRight ? length : -1;
  21789. while ((fromRight ? index-- : ++index < length) &&
  21790. predicate(array[index], index, array)) {}
  21791. return isDrop
  21792. ? baseSlice(array, (fromRight ? 0 : index), (fromRight ? index + 1 : length))
  21793. : baseSlice(array, (fromRight ? index + 1 : 0), (fromRight ? length : index));
  21794. }
  21795. /**
  21796. * The base implementation of `wrapperValue` which returns the result of
  21797. * performing a sequence of actions on the unwrapped `value`, where each
  21798. * successive action is supplied the return value of the previous.
  21799. *
  21800. * @private
  21801. * @param {*} value The unwrapped value.
  21802. * @param {Array} actions Actions to perform to resolve the unwrapped value.
  21803. * @returns {*} Returns the resolved value.
  21804. */
  21805. function baseWrapperValue(value, actions) {
  21806. var result = value;
  21807. if (result instanceof LazyWrapper) {
  21808. result = result.value();
  21809. }
  21810. return arrayReduce(actions, function(result, action) {
  21811. return action.func.apply(action.thisArg, arrayPush([result], action.args));
  21812. }, result);
  21813. }
  21814. /**
  21815. * The base implementation of methods like `_.xor`, without support for
  21816. * iteratee shorthands, that accepts an array of arrays to inspect.
  21817. *
  21818. * @private
  21819. * @param {Array} arrays The arrays to inspect.
  21820. * @param {Function} [iteratee] The iteratee invoked per element.
  21821. * @param {Function} [comparator] The comparator invoked per element.
  21822. * @returns {Array} Returns the new array of values.
  21823. */
  21824. function baseXor(arrays, iteratee, comparator) {
  21825. var length = arrays.length;
  21826. if (length < 2) {
  21827. return length ? baseUniq(arrays[0]) : [];
  21828. }
  21829. var index = -1,
  21830. result = Array(length);
  21831. while (++index < length) {
  21832. var array = arrays[index],
  21833. othIndex = -1;
  21834. while (++othIndex < length) {
  21835. if (othIndex != index) {
  21836. result[index] = baseDifference(result[index] || array, arrays[othIndex], iteratee, comparator);
  21837. }
  21838. }
  21839. }
  21840. return baseUniq(baseFlatten(result, 1), iteratee, comparator);
  21841. }
  21842. /**
  21843. * This base implementation of `_.zipObject` which assigns values using `assignFunc`.
  21844. *
  21845. * @private
  21846. * @param {Array} props The property identifiers.
  21847. * @param {Array} values The property values.
  21848. * @param {Function} assignFunc The function to assign values.
  21849. * @returns {Object} Returns the new object.
  21850. */
  21851. function baseZipObject(props, values, assignFunc) {
  21852. var index = -1,
  21853. length = props.length,
  21854. valsLength = values.length,
  21855. result = {};
  21856. while (++index < length) {
  21857. var value = index < valsLength ? values[index] : undefined;
  21858. assignFunc(result, props[index], value);
  21859. }
  21860. return result;
  21861. }
  21862. /**
  21863. * Casts `value` to an empty array if it's not an array like object.
  21864. *
  21865. * @private
  21866. * @param {*} value The value to inspect.
  21867. * @returns {Array|Object} Returns the cast array-like object.
  21868. */
  21869. function castArrayLikeObject(value) {
  21870. return isArrayLikeObject(value) ? value : [];
  21871. }
  21872. /**
  21873. * Casts `value` to `identity` if it's not a function.
  21874. *
  21875. * @private
  21876. * @param {*} value The value to inspect.
  21877. * @returns {Function} Returns cast function.
  21878. */
  21879. function castFunction(value) {
  21880. return typeof value == 'function' ? value : identity;
  21881. }
  21882. /**
  21883. * Casts `value` to a path array if it's not one.
  21884. *
  21885. * @private
  21886. * @param {*} value The value to inspect.
  21887. * @param {Object} [object] The object to query keys on.
  21888. * @returns {Array} Returns the cast property path array.
  21889. */
  21890. function castPath(value, object) {
  21891. if (isArray(value)) {
  21892. return value;
  21893. }
  21894. return isKey(value, object) ? [value] : stringToPath(toString(value));
  21895. }
  21896. /**
  21897. * A `baseRest` alias which can be replaced with `identity` by module
  21898. * replacement plugins.
  21899. *
  21900. * @private
  21901. * @type {Function}
  21902. * @param {Function} func The function to apply a rest parameter to.
  21903. * @returns {Function} Returns the new function.
  21904. */
  21905. var castRest = baseRest;
  21906. /**
  21907. * Casts `array` to a slice if it's needed.
  21908. *
  21909. * @private
  21910. * @param {Array} array The array to inspect.
  21911. * @param {number} start The start position.
  21912. * @param {number} [end=array.length] The end position.
  21913. * @returns {Array} Returns the cast slice.
  21914. */
  21915. function castSlice(array, start, end) {
  21916. var length = array.length;
  21917. end = end === undefined ? length : end;
  21918. return (!start && end >= length) ? array : baseSlice(array, start, end);
  21919. }
  21920. /**
  21921. * A simple wrapper around the global [`clearTimeout`](https://mdn.io/clearTimeout).
  21922. *
  21923. * @private
  21924. * @param {number|Object} id The timer id or timeout object of the timer to clear.
  21925. */
  21926. var clearTimeout = ctxClearTimeout || function(id) {
  21927. return root.clearTimeout(id);
  21928. };
  21929. /**
  21930. * Creates a clone of `buffer`.
  21931. *
  21932. * @private
  21933. * @param {Buffer} buffer The buffer to clone.
  21934. * @param {boolean} [isDeep] Specify a deep clone.
  21935. * @returns {Buffer} Returns the cloned buffer.
  21936. */
  21937. function cloneBuffer(buffer, isDeep) {
  21938. if (isDeep) {
  21939. return buffer.slice();
  21940. }
  21941. var length = buffer.length,
  21942. result = allocUnsafe ? allocUnsafe(length) : new buffer.constructor(length);
  21943. buffer.copy(result);
  21944. return result;
  21945. }
  21946. /**
  21947. * Creates a clone of `arrayBuffer`.
  21948. *
  21949. * @private
  21950. * @param {ArrayBuffer} arrayBuffer The array buffer to clone.
  21951. * @returns {ArrayBuffer} Returns the cloned array buffer.
  21952. */
  21953. function cloneArrayBuffer(arrayBuffer) {
  21954. var result = new arrayBuffer.constructor(arrayBuffer.byteLength);
  21955. new Uint8Array(result).set(new Uint8Array(arrayBuffer));
  21956. return result;
  21957. }
  21958. /**
  21959. * Creates a clone of `dataView`.
  21960. *
  21961. * @private
  21962. * @param {Object} dataView The data view to clone.
  21963. * @param {boolean} [isDeep] Specify a deep clone.
  21964. * @returns {Object} Returns the cloned data view.
  21965. */
  21966. function cloneDataView(dataView, isDeep) {
  21967. var buffer = isDeep ? cloneArrayBuffer(dataView.buffer) : dataView.buffer;
  21968. return new dataView.constructor(buffer, dataView.byteOffset, dataView.byteLength);
  21969. }
  21970. /**
  21971. * Creates a clone of `regexp`.
  21972. *
  21973. * @private
  21974. * @param {Object} regexp The regexp to clone.
  21975. * @returns {Object} Returns the cloned regexp.
  21976. */
  21977. function cloneRegExp(regexp) {
  21978. var result = new regexp.constructor(regexp.source, reFlags.exec(regexp));
  21979. result.lastIndex = regexp.lastIndex;
  21980. return result;
  21981. }
  21982. /**
  21983. * Creates a clone of the `symbol` object.
  21984. *
  21985. * @private
  21986. * @param {Object} symbol The symbol object to clone.
  21987. * @returns {Object} Returns the cloned symbol object.
  21988. */
  21989. function cloneSymbol(symbol) {
  21990. return symbolValueOf ? Object(symbolValueOf.call(symbol)) : {};
  21991. }
  21992. /**
  21993. * Creates a clone of `typedArray`.
  21994. *
  21995. * @private
  21996. * @param {Object} typedArray The typed array to clone.
  21997. * @param {boolean} [isDeep] Specify a deep clone.
  21998. * @returns {Object} Returns the cloned typed array.
  21999. */
  22000. function cloneTypedArray(typedArray, isDeep) {
  22001. var buffer = isDeep ? cloneArrayBuffer(typedArray.buffer) : typedArray.buffer;
  22002. return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length);
  22003. }
  22004. /**
  22005. * Compares values to sort them in ascending order.
  22006. *
  22007. * @private
  22008. * @param {*} value The value to compare.
  22009. * @param {*} other The other value to compare.
  22010. * @returns {number} Returns the sort order indicator for `value`.
  22011. */
  22012. function compareAscending(value, other) {
  22013. if (value !== other) {
  22014. var valIsDefined = value !== undefined,
  22015. valIsNull = value === null,
  22016. valIsReflexive = value === value,
  22017. valIsSymbol = isSymbol(value);
  22018. var othIsDefined = other !== undefined,
  22019. othIsNull = other === null,
  22020. othIsReflexive = other === other,
  22021. othIsSymbol = isSymbol(other);
  22022. if ((!othIsNull && !othIsSymbol && !valIsSymbol && value > other) ||
  22023. (valIsSymbol && othIsDefined && othIsReflexive && !othIsNull && !othIsSymbol) ||
  22024. (valIsNull && othIsDefined && othIsReflexive) ||
  22025. (!valIsDefined && othIsReflexive) ||
  22026. !valIsReflexive) {
  22027. return 1;
  22028. }
  22029. if ((!valIsNull && !valIsSymbol && !othIsSymbol && value < other) ||
  22030. (othIsSymbol && valIsDefined && valIsReflexive && !valIsNull && !valIsSymbol) ||
  22031. (othIsNull && valIsDefined && valIsReflexive) ||
  22032. (!othIsDefined && valIsReflexive) ||
  22033. !othIsReflexive) {
  22034. return -1;
  22035. }
  22036. }
  22037. return 0;
  22038. }
  22039. /**
  22040. * Used by `_.orderBy` to compare multiple properties of a value to another
  22041. * and stable sort them.
  22042. *
  22043. * If `orders` is unspecified, all values are sorted in ascending order. Otherwise,
  22044. * specify an order of "desc" for descending or "asc" for ascending sort order
  22045. * of corresponding values.
  22046. *
  22047. * @private
  22048. * @param {Object} object The object to compare.
  22049. * @param {Object} other The other object to compare.
  22050. * @param {boolean[]|string[]} orders The order to sort by for each property.
  22051. * @returns {number} Returns the sort order indicator for `object`.
  22052. */
  22053. function compareMultiple(object, other, orders) {
  22054. var index = -1,
  22055. objCriteria = object.criteria,
  22056. othCriteria = other.criteria,
  22057. length = objCriteria.length,
  22058. ordersLength = orders.length;
  22059. while (++index < length) {
  22060. var result = compareAscending(objCriteria[index], othCriteria[index]);
  22061. if (result) {
  22062. if (index >= ordersLength) {
  22063. return result;
  22064. }
  22065. var order = orders[index];
  22066. return result * (order == 'desc' ? -1 : 1);
  22067. }
  22068. }
  22069. // Fixes an `Array#sort` bug in the JS engine embedded in Adobe applications
  22070. // that causes it, under certain circumstances, to provide the same value for
  22071. // `object` and `other`. See https://github.com/jashkenas/underscore/pull/1247
  22072. // for more details.
  22073. //
  22074. // This also ensures a stable sort in V8 and other engines.
  22075. // See https://bugs.chromium.org/p/v8/issues/detail?id=90 for more details.
  22076. return object.index - other.index;
  22077. }
  22078. /**
  22079. * Creates an array that is the composition of partially applied arguments,
  22080. * placeholders, and provided arguments into a single array of arguments.
  22081. *
  22082. * @private
  22083. * @param {Array} args The provided arguments.
  22084. * @param {Array} partials The arguments to prepend to those provided.
  22085. * @param {Array} holders The `partials` placeholder indexes.
  22086. * @params {boolean} [isCurried] Specify composing for a curried function.
  22087. * @returns {Array} Returns the new array of composed arguments.
  22088. */
  22089. function composeArgs(args, partials, holders, isCurried) {
  22090. var argsIndex = -1,
  22091. argsLength = args.length,
  22092. holdersLength = holders.length,
  22093. leftIndex = -1,
  22094. leftLength = partials.length,
  22095. rangeLength = nativeMax(argsLength - holdersLength, 0),
  22096. result = Array(leftLength + rangeLength),
  22097. isUncurried = !isCurried;
  22098. while (++leftIndex < leftLength) {
  22099. result[leftIndex] = partials[leftIndex];
  22100. }
  22101. while (++argsIndex < holdersLength) {
  22102. if (isUncurried || argsIndex < argsLength) {
  22103. result[holders[argsIndex]] = args[argsIndex];
  22104. }
  22105. }
  22106. while (rangeLength--) {
  22107. result[leftIndex++] = args[argsIndex++];
  22108. }
  22109. return result;
  22110. }
  22111. /**
  22112. * This function is like `composeArgs` except that the arguments composition
  22113. * is tailored for `_.partialRight`.
  22114. *
  22115. * @private
  22116. * @param {Array} args The provided arguments.
  22117. * @param {Array} partials The arguments to append to those provided.
  22118. * @param {Array} holders The `partials` placeholder indexes.
  22119. * @params {boolean} [isCurried] Specify composing for a curried function.
  22120. * @returns {Array} Returns the new array of composed arguments.
  22121. */
  22122. function composeArgsRight(args, partials, holders, isCurried) {
  22123. var argsIndex = -1,
  22124. argsLength = args.length,
  22125. holdersIndex = -1,
  22126. holdersLength = holders.length,
  22127. rightIndex = -1,
  22128. rightLength = partials.length,
  22129. rangeLength = nativeMax(argsLength - holdersLength, 0),
  22130. result = Array(rangeLength + rightLength),
  22131. isUncurried = !isCurried;
  22132. while (++argsIndex < rangeLength) {
  22133. result[argsIndex] = args[argsIndex];
  22134. }
  22135. var offset = argsIndex;
  22136. while (++rightIndex < rightLength) {
  22137. result[offset + rightIndex] = partials[rightIndex];
  22138. }
  22139. while (++holdersIndex < holdersLength) {
  22140. if (isUncurried || argsIndex < argsLength) {
  22141. result[offset + holders[holdersIndex]] = args[argsIndex++];
  22142. }
  22143. }
  22144. return result;
  22145. }
  22146. /**
  22147. * Copies the values of `source` to `array`.
  22148. *
  22149. * @private
  22150. * @param {Array} source The array to copy values from.
  22151. * @param {Array} [array=[]] The array to copy values to.
  22152. * @returns {Array} Returns `array`.
  22153. */
  22154. function copyArray(source, array) {
  22155. var index = -1,
  22156. length = source.length;
  22157. array || (array = Array(length));
  22158. while (++index < length) {
  22159. array[index] = source[index];
  22160. }
  22161. return array;
  22162. }
  22163. /**
  22164. * Copies properties of `source` to `object`.
  22165. *
  22166. * @private
  22167. * @param {Object} source The object to copy properties from.
  22168. * @param {Array} props The property identifiers to copy.
  22169. * @param {Object} [object={}] The object to copy properties to.
  22170. * @param {Function} [customizer] The function to customize copied values.
  22171. * @returns {Object} Returns `object`.
  22172. */
  22173. function copyObject(source, props, object, customizer) {
  22174. var isNew = !object;
  22175. object || (object = {});
  22176. var index = -1,
  22177. length = props.length;
  22178. while (++index < length) {
  22179. var key = props[index];
  22180. var newValue = customizer
  22181. ? customizer(object[key], source[key], key, object, source)
  22182. : undefined;
  22183. if (newValue === undefined) {
  22184. newValue = source[key];
  22185. }
  22186. if (isNew) {
  22187. baseAssignValue(object, key, newValue);
  22188. } else {
  22189. assignValue(object, key, newValue);
  22190. }
  22191. }
  22192. return object;
  22193. }
  22194. /**
  22195. * Copies own symbols of `source` to `object`.
  22196. *
  22197. * @private
  22198. * @param {Object} source The object to copy symbols from.
  22199. * @param {Object} [object={}] The object to copy symbols to.
  22200. * @returns {Object} Returns `object`.
  22201. */
  22202. function copySymbols(source, object) {
  22203. return copyObject(source, getSymbols(source), object);
  22204. }
  22205. /**
  22206. * Copies own and inherited symbols of `source` to `object`.
  22207. *
  22208. * @private
  22209. * @param {Object} source The object to copy symbols from.
  22210. * @param {Object} [object={}] The object to copy symbols to.
  22211. * @returns {Object} Returns `object`.
  22212. */
  22213. function copySymbolsIn(source, object) {
  22214. return copyObject(source, getSymbolsIn(source), object);
  22215. }
  22216. /**
  22217. * Creates a function like `_.groupBy`.
  22218. *
  22219. * @private
  22220. * @param {Function} setter The function to set accumulator values.
  22221. * @param {Function} [initializer] The accumulator object initializer.
  22222. * @returns {Function} Returns the new aggregator function.
  22223. */
  22224. function createAggregator(setter, initializer) {
  22225. return function(collection, iteratee) {
  22226. var func = isArray(collection) ? arrayAggregator : baseAggregator,
  22227. accumulator = initializer ? initializer() : {};
  22228. return func(collection, setter, getIteratee(iteratee, 2), accumulator);
  22229. };
  22230. }
  22231. /**
  22232. * Creates a function like `_.assign`.
  22233. *
  22234. * @private
  22235. * @param {Function} assigner The function to assign values.
  22236. * @returns {Function} Returns the new assigner function.
  22237. */
  22238. function createAssigner(assigner) {
  22239. return baseRest(function(object, sources) {
  22240. var index = -1,
  22241. length = sources.length,
  22242. customizer = length > 1 ? sources[length - 1] : undefined,
  22243. guard = length > 2 ? sources[2] : undefined;
  22244. customizer = (assigner.length > 3 && typeof customizer == 'function')
  22245. ? (length--, customizer)
  22246. : undefined;
  22247. if (guard && isIterateeCall(sources[0], sources[1], guard)) {
  22248. customizer = length < 3 ? undefined : customizer;
  22249. length = 1;
  22250. }
  22251. object = Object(object);
  22252. while (++index < length) {
  22253. var source = sources[index];
  22254. if (source) {
  22255. assigner(object, source, index, customizer);
  22256. }
  22257. }
  22258. return object;
  22259. });
  22260. }
  22261. /**
  22262. * Creates a `baseEach` or `baseEachRight` function.
  22263. *
  22264. * @private
  22265. * @param {Function} eachFunc The function to iterate over a collection.
  22266. * @param {boolean} [fromRight] Specify iterating from right to left.
  22267. * @returns {Function} Returns the new base function.
  22268. */
  22269. function createBaseEach(eachFunc, fromRight) {
  22270. return function(collection, iteratee) {
  22271. if (collection == null) {
  22272. return collection;
  22273. }
  22274. if (!isArrayLike(collection)) {
  22275. return eachFunc(collection, iteratee);
  22276. }
  22277. var length = collection.length,
  22278. index = fromRight ? length : -1,
  22279. iterable = Object(collection);
  22280. while ((fromRight ? index-- : ++index < length)) {
  22281. if (iteratee(iterable[index], index, iterable) === false) {
  22282. break;
  22283. }
  22284. }
  22285. return collection;
  22286. };
  22287. }
  22288. /**
  22289. * Creates a base function for methods like `_.forIn` and `_.forOwn`.
  22290. *
  22291. * @private
  22292. * @param {boolean} [fromRight] Specify iterating from right to left.
  22293. * @returns {Function} Returns the new base function.
  22294. */
  22295. function createBaseFor(fromRight) {
  22296. return function(object, iteratee, keysFunc) {
  22297. var index = -1,
  22298. iterable = Object(object),
  22299. props = keysFunc(object),
  22300. length = props.length;
  22301. while (length--) {
  22302. var key = props[fromRight ? length : ++index];
  22303. if (iteratee(iterable[key], key, iterable) === false) {
  22304. break;
  22305. }
  22306. }
  22307. return object;
  22308. };
  22309. }
  22310. /**
  22311. * Creates a function that wraps `func` to invoke it with the optional `this`
  22312. * binding of `thisArg`.
  22313. *
  22314. * @private
  22315. * @param {Function} func The function to wrap.
  22316. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  22317. * @param {*} [thisArg] The `this` binding of `func`.
  22318. * @returns {Function} Returns the new wrapped function.
  22319. */
  22320. function createBind(func, bitmask, thisArg) {
  22321. var isBind = bitmask & WRAP_BIND_FLAG,
  22322. Ctor = createCtor(func);
  22323. function wrapper() {
  22324. var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;
  22325. return fn.apply(isBind ? thisArg : this, arguments);
  22326. }
  22327. return wrapper;
  22328. }
  22329. /**
  22330. * Creates a function like `_.lowerFirst`.
  22331. *
  22332. * @private
  22333. * @param {string} methodName The name of the `String` case method to use.
  22334. * @returns {Function} Returns the new case function.
  22335. */
  22336. function createCaseFirst(methodName) {
  22337. return function(string) {
  22338. string = toString(string);
  22339. var strSymbols = hasUnicode(string)
  22340. ? stringToArray(string)
  22341. : undefined;
  22342. var chr = strSymbols
  22343. ? strSymbols[0]
  22344. : string.charAt(0);
  22345. var trailing = strSymbols
  22346. ? castSlice(strSymbols, 1).join('')
  22347. : string.slice(1);
  22348. return chr[methodName]() + trailing;
  22349. };
  22350. }
  22351. /**
  22352. * Creates a function like `_.camelCase`.
  22353. *
  22354. * @private
  22355. * @param {Function} callback The function to combine each word.
  22356. * @returns {Function} Returns the new compounder function.
  22357. */
  22358. function createCompounder(callback) {
  22359. return function(string) {
  22360. return arrayReduce(words(deburr(string).replace(reApos, '')), callback, '');
  22361. };
  22362. }
  22363. /**
  22364. * Creates a function that produces an instance of `Ctor` regardless of
  22365. * whether it was invoked as part of a `new` expression or by `call` or `apply`.
  22366. *
  22367. * @private
  22368. * @param {Function} Ctor The constructor to wrap.
  22369. * @returns {Function} Returns the new wrapped function.
  22370. */
  22371. function createCtor(Ctor) {
  22372. return function() {
  22373. // Use a `switch` statement to work with class constructors. See
  22374. // http://ecma-international.org/ecma-262/7.0/#sec-ecmascript-function-objects-call-thisargument-argumentslist
  22375. // for more details.
  22376. var args = arguments;
  22377. switch (args.length) {
  22378. case 0: return new Ctor;
  22379. case 1: return new Ctor(args[0]);
  22380. case 2: return new Ctor(args[0], args[1]);
  22381. case 3: return new Ctor(args[0], args[1], args[2]);
  22382. case 4: return new Ctor(args[0], args[1], args[2], args[3]);
  22383. case 5: return new Ctor(args[0], args[1], args[2], args[3], args[4]);
  22384. case 6: return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5]);
  22385. case 7: return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5], args[6]);
  22386. }
  22387. var thisBinding = baseCreate(Ctor.prototype),
  22388. result = Ctor.apply(thisBinding, args);
  22389. // Mimic the constructor's `return` behavior.
  22390. // See https://es5.github.io/#x13.2.2 for more details.
  22391. return isObject(result) ? result : thisBinding;
  22392. };
  22393. }
  22394. /**
  22395. * Creates a function that wraps `func` to enable currying.
  22396. *
  22397. * @private
  22398. * @param {Function} func The function to wrap.
  22399. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  22400. * @param {number} arity The arity of `func`.
  22401. * @returns {Function} Returns the new wrapped function.
  22402. */
  22403. function createCurry(func, bitmask, arity) {
  22404. var Ctor = createCtor(func);
  22405. function wrapper() {
  22406. var length = arguments.length,
  22407. args = Array(length),
  22408. index = length,
  22409. placeholder = getHolder(wrapper);
  22410. while (index--) {
  22411. args[index] = arguments[index];
  22412. }
  22413. var holders = (length < 3 && args[0] !== placeholder && args[length - 1] !== placeholder)
  22414. ? []
  22415. : replaceHolders(args, placeholder);
  22416. length -= holders.length;
  22417. if (length < arity) {
  22418. return createRecurry(
  22419. func, bitmask, createHybrid, wrapper.placeholder, undefined,
  22420. args, holders, undefined, undefined, arity - length);
  22421. }
  22422. var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;
  22423. return apply(fn, this, args);
  22424. }
  22425. return wrapper;
  22426. }
  22427. /**
  22428. * Creates a `_.find` or `_.findLast` function.
  22429. *
  22430. * @private
  22431. * @param {Function} findIndexFunc The function to find the collection index.
  22432. * @returns {Function} Returns the new find function.
  22433. */
  22434. function createFind(findIndexFunc) {
  22435. return function(collection, predicate, fromIndex) {
  22436. var iterable = Object(collection);
  22437. if (!isArrayLike(collection)) {
  22438. var iteratee = getIteratee(predicate, 3);
  22439. collection = keys(collection);
  22440. predicate = function(key) { return iteratee(iterable[key], key, iterable); };
  22441. }
  22442. var index = findIndexFunc(collection, predicate, fromIndex);
  22443. return index > -1 ? iterable[iteratee ? collection[index] : index] : undefined;
  22444. };
  22445. }
  22446. /**
  22447. * Creates a `_.flow` or `_.flowRight` function.
  22448. *
  22449. * @private
  22450. * @param {boolean} [fromRight] Specify iterating from right to left.
  22451. * @returns {Function} Returns the new flow function.
  22452. */
  22453. function createFlow(fromRight) {
  22454. return flatRest(function(funcs) {
  22455. var length = funcs.length,
  22456. index = length,
  22457. prereq = LodashWrapper.prototype.thru;
  22458. if (fromRight) {
  22459. funcs.reverse();
  22460. }
  22461. while (index--) {
  22462. var func = funcs[index];
  22463. if (typeof func != 'function') {
  22464. throw new TypeError(FUNC_ERROR_TEXT);
  22465. }
  22466. if (prereq && !wrapper && getFuncName(func) == 'wrapper') {
  22467. var wrapper = new LodashWrapper([], true);
  22468. }
  22469. }
  22470. index = wrapper ? index : length;
  22471. while (++index < length) {
  22472. func = funcs[index];
  22473. var funcName = getFuncName(func),
  22474. data = funcName == 'wrapper' ? getData(func) : undefined;
  22475. if (data && isLaziable(data[0]) &&
  22476. data[1] == (WRAP_ARY_FLAG | WRAP_CURRY_FLAG | WRAP_PARTIAL_FLAG | WRAP_REARG_FLAG) &&
  22477. !data[4].length && data[9] == 1
  22478. ) {
  22479. wrapper = wrapper[getFuncName(data[0])].apply(wrapper, data[3]);
  22480. } else {
  22481. wrapper = (func.length == 1 && isLaziable(func))
  22482. ? wrapper[funcName]()
  22483. : wrapper.thru(func);
  22484. }
  22485. }
  22486. return function() {
  22487. var args = arguments,
  22488. value = args[0];
  22489. if (wrapper && args.length == 1 && isArray(value)) {
  22490. return wrapper.plant(value).value();
  22491. }
  22492. var index = 0,
  22493. result = length ? funcs[index].apply(this, args) : value;
  22494. while (++index < length) {
  22495. result = funcs[index].call(this, result);
  22496. }
  22497. return result;
  22498. };
  22499. });
  22500. }
  22501. /**
  22502. * Creates a function that wraps `func` to invoke it with optional `this`
  22503. * binding of `thisArg`, partial application, and currying.
  22504. *
  22505. * @private
  22506. * @param {Function|string} func The function or method name to wrap.
  22507. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  22508. * @param {*} [thisArg] The `this` binding of `func`.
  22509. * @param {Array} [partials] The arguments to prepend to those provided to
  22510. * the new function.
  22511. * @param {Array} [holders] The `partials` placeholder indexes.
  22512. * @param {Array} [partialsRight] The arguments to append to those provided
  22513. * to the new function.
  22514. * @param {Array} [holdersRight] The `partialsRight` placeholder indexes.
  22515. * @param {Array} [argPos] The argument positions of the new function.
  22516. * @param {number} [ary] The arity cap of `func`.
  22517. * @param {number} [arity] The arity of `func`.
  22518. * @returns {Function} Returns the new wrapped function.
  22519. */
  22520. function createHybrid(func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, argPos, ary, arity) {
  22521. var isAry = bitmask & WRAP_ARY_FLAG,
  22522. isBind = bitmask & WRAP_BIND_FLAG,
  22523. isBindKey = bitmask & WRAP_BIND_KEY_FLAG,
  22524. isCurried = bitmask & (WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG),
  22525. isFlip = bitmask & WRAP_FLIP_FLAG,
  22526. Ctor = isBindKey ? undefined : createCtor(func);
  22527. function wrapper() {
  22528. var length = arguments.length,
  22529. args = Array(length),
  22530. index = length;
  22531. while (index--) {
  22532. args[index] = arguments[index];
  22533. }
  22534. if (isCurried) {
  22535. var placeholder = getHolder(wrapper),
  22536. holdersCount = countHolders(args, placeholder);
  22537. }
  22538. if (partials) {
  22539. args = composeArgs(args, partials, holders, isCurried);
  22540. }
  22541. if (partialsRight) {
  22542. args = composeArgsRight(args, partialsRight, holdersRight, isCurried);
  22543. }
  22544. length -= holdersCount;
  22545. if (isCurried && length < arity) {
  22546. var newHolders = replaceHolders(args, placeholder);
  22547. return createRecurry(
  22548. func, bitmask, createHybrid, wrapper.placeholder, thisArg,
  22549. args, newHolders, argPos, ary, arity - length
  22550. );
  22551. }
  22552. var thisBinding = isBind ? thisArg : this,
  22553. fn = isBindKey ? thisBinding[func] : func;
  22554. length = args.length;
  22555. if (argPos) {
  22556. args = reorder(args, argPos);
  22557. } else if (isFlip && length > 1) {
  22558. args.reverse();
  22559. }
  22560. if (isAry && ary < length) {
  22561. args.length = ary;
  22562. }
  22563. if (this && this !== root && this instanceof wrapper) {
  22564. fn = Ctor || createCtor(fn);
  22565. }
  22566. return fn.apply(thisBinding, args);
  22567. }
  22568. return wrapper;
  22569. }
  22570. /**
  22571. * Creates a function like `_.invertBy`.
  22572. *
  22573. * @private
  22574. * @param {Function} setter The function to set accumulator values.
  22575. * @param {Function} toIteratee The function to resolve iteratees.
  22576. * @returns {Function} Returns the new inverter function.
  22577. */
  22578. function createInverter(setter, toIteratee) {
  22579. return function(object, iteratee) {
  22580. return baseInverter(object, setter, toIteratee(iteratee), {});
  22581. };
  22582. }
  22583. /**
  22584. * Creates a function that performs a mathematical operation on two values.
  22585. *
  22586. * @private
  22587. * @param {Function} operator The function to perform the operation.
  22588. * @param {number} [defaultValue] The value used for `undefined` arguments.
  22589. * @returns {Function} Returns the new mathematical operation function.
  22590. */
  22591. function createMathOperation(operator, defaultValue) {
  22592. return function(value, other) {
  22593. var result;
  22594. if (value === undefined && other === undefined) {
  22595. return defaultValue;
  22596. }
  22597. if (value !== undefined) {
  22598. result = value;
  22599. }
  22600. if (other !== undefined) {
  22601. if (result === undefined) {
  22602. return other;
  22603. }
  22604. if (typeof value == 'string' || typeof other == 'string') {
  22605. value = baseToString(value);
  22606. other = baseToString(other);
  22607. } else {
  22608. value = baseToNumber(value);
  22609. other = baseToNumber(other);
  22610. }
  22611. result = operator(value, other);
  22612. }
  22613. return result;
  22614. };
  22615. }
  22616. /**
  22617. * Creates a function like `_.over`.
  22618. *
  22619. * @private
  22620. * @param {Function} arrayFunc The function to iterate over iteratees.
  22621. * @returns {Function} Returns the new over function.
  22622. */
  22623. function createOver(arrayFunc) {
  22624. return flatRest(function(iteratees) {
  22625. iteratees = arrayMap(iteratees, baseUnary(getIteratee()));
  22626. return baseRest(function(args) {
  22627. var thisArg = this;
  22628. return arrayFunc(iteratees, function(iteratee) {
  22629. return apply(iteratee, thisArg, args);
  22630. });
  22631. });
  22632. });
  22633. }
  22634. /**
  22635. * Creates the padding for `string` based on `length`. The `chars` string
  22636. * is truncated if the number of characters exceeds `length`.
  22637. *
  22638. * @private
  22639. * @param {number} length The padding length.
  22640. * @param {string} [chars=' '] The string used as padding.
  22641. * @returns {string} Returns the padding for `string`.
  22642. */
  22643. function createPadding(length, chars) {
  22644. chars = chars === undefined ? ' ' : baseToString(chars);
  22645. var charsLength = chars.length;
  22646. if (charsLength < 2) {
  22647. return charsLength ? baseRepeat(chars, length) : chars;
  22648. }
  22649. var result = baseRepeat(chars, nativeCeil(length / stringSize(chars)));
  22650. return hasUnicode(chars)
  22651. ? castSlice(stringToArray(result), 0, length).join('')
  22652. : result.slice(0, length);
  22653. }
  22654. /**
  22655. * Creates a function that wraps `func` to invoke it with the `this` binding
  22656. * of `thisArg` and `partials` prepended to the arguments it receives.
  22657. *
  22658. * @private
  22659. * @param {Function} func The function to wrap.
  22660. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  22661. * @param {*} thisArg The `this` binding of `func`.
  22662. * @param {Array} partials The arguments to prepend to those provided to
  22663. * the new function.
  22664. * @returns {Function} Returns the new wrapped function.
  22665. */
  22666. function createPartial(func, bitmask, thisArg, partials) {
  22667. var isBind = bitmask & WRAP_BIND_FLAG,
  22668. Ctor = createCtor(func);
  22669. function wrapper() {
  22670. var argsIndex = -1,
  22671. argsLength = arguments.length,
  22672. leftIndex = -1,
  22673. leftLength = partials.length,
  22674. args = Array(leftLength + argsLength),
  22675. fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;
  22676. while (++leftIndex < leftLength) {
  22677. args[leftIndex] = partials[leftIndex];
  22678. }
  22679. while (argsLength--) {
  22680. args[leftIndex++] = arguments[++argsIndex];
  22681. }
  22682. return apply(fn, isBind ? thisArg : this, args);
  22683. }
  22684. return wrapper;
  22685. }
  22686. /**
  22687. * Creates a `_.range` or `_.rangeRight` function.
  22688. *
  22689. * @private
  22690. * @param {boolean} [fromRight] Specify iterating from right to left.
  22691. * @returns {Function} Returns the new range function.
  22692. */
  22693. function createRange(fromRight) {
  22694. return function(start, end, step) {
  22695. if (step && typeof step != 'number' && isIterateeCall(start, end, step)) {
  22696. end = step = undefined;
  22697. }
  22698. // Ensure the sign of `-0` is preserved.
  22699. start = toFinite(start);
  22700. if (end === undefined) {
  22701. end = start;
  22702. start = 0;
  22703. } else {
  22704. end = toFinite(end);
  22705. }
  22706. step = step === undefined ? (start < end ? 1 : -1) : toFinite(step);
  22707. return baseRange(start, end, step, fromRight);
  22708. };
  22709. }
  22710. /**
  22711. * Creates a function that performs a relational operation on two values.
  22712. *
  22713. * @private
  22714. * @param {Function} operator The function to perform the operation.
  22715. * @returns {Function} Returns the new relational operation function.
  22716. */
  22717. function createRelationalOperation(operator) {
  22718. return function(value, other) {
  22719. if (!(typeof value == 'string' && typeof other == 'string')) {
  22720. value = toNumber(value);
  22721. other = toNumber(other);
  22722. }
  22723. return operator(value, other);
  22724. };
  22725. }
  22726. /**
  22727. * Creates a function that wraps `func` to continue currying.
  22728. *
  22729. * @private
  22730. * @param {Function} func The function to wrap.
  22731. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  22732. * @param {Function} wrapFunc The function to create the `func` wrapper.
  22733. * @param {*} placeholder The placeholder value.
  22734. * @param {*} [thisArg] The `this` binding of `func`.
  22735. * @param {Array} [partials] The arguments to prepend to those provided to
  22736. * the new function.
  22737. * @param {Array} [holders] The `partials` placeholder indexes.
  22738. * @param {Array} [argPos] The argument positions of the new function.
  22739. * @param {number} [ary] The arity cap of `func`.
  22740. * @param {number} [arity] The arity of `func`.
  22741. * @returns {Function} Returns the new wrapped function.
  22742. */
  22743. function createRecurry(func, bitmask, wrapFunc, placeholder, thisArg, partials, holders, argPos, ary, arity) {
  22744. var isCurry = bitmask & WRAP_CURRY_FLAG,
  22745. newHolders = isCurry ? holders : undefined,
  22746. newHoldersRight = isCurry ? undefined : holders,
  22747. newPartials = isCurry ? partials : undefined,
  22748. newPartialsRight = isCurry ? undefined : partials;
  22749. bitmask |= (isCurry ? WRAP_PARTIAL_FLAG : WRAP_PARTIAL_RIGHT_FLAG);
  22750. bitmask &= ~(isCurry ? WRAP_PARTIAL_RIGHT_FLAG : WRAP_PARTIAL_FLAG);
  22751. if (!(bitmask & WRAP_CURRY_BOUND_FLAG)) {
  22752. bitmask &= ~(WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG);
  22753. }
  22754. var newData = [
  22755. func, bitmask, thisArg, newPartials, newHolders, newPartialsRight,
  22756. newHoldersRight, argPos, ary, arity
  22757. ];
  22758. var result = wrapFunc.apply(undefined, newData);
  22759. if (isLaziable(func)) {
  22760. setData(result, newData);
  22761. }
  22762. result.placeholder = placeholder;
  22763. return setWrapToString(result, func, bitmask);
  22764. }
  22765. /**
  22766. * Creates a function like `_.round`.
  22767. *
  22768. * @private
  22769. * @param {string} methodName The name of the `Math` method to use when rounding.
  22770. * @returns {Function} Returns the new round function.
  22771. */
  22772. function createRound(methodName) {
  22773. var func = Math[methodName];
  22774. return function(number, precision) {
  22775. number = toNumber(number);
  22776. precision = precision == null ? 0 : nativeMin(toInteger(precision), 292);
  22777. if (precision && nativeIsFinite(number)) {
  22778. // Shift with exponential notation to avoid floating-point issues.
  22779. // See [MDN](https://mdn.io/round#Examples) for more details.
  22780. var pair = (toString(number) + 'e').split('e'),
  22781. value = func(pair[0] + 'e' + (+pair[1] + precision));
  22782. pair = (toString(value) + 'e').split('e');
  22783. return +(pair[0] + 'e' + (+pair[1] - precision));
  22784. }
  22785. return func(number);
  22786. };
  22787. }
  22788. /**
  22789. * Creates a set object of `values`.
  22790. *
  22791. * @private
  22792. * @param {Array} values The values to add to the set.
  22793. * @returns {Object} Returns the new set.
  22794. */
  22795. var createSet = !(Set && (1 / setToArray(new Set([,-0]))[1]) == INFINITY) ? noop : function(values) {
  22796. return new Set(values);
  22797. };
  22798. /**
  22799. * Creates a `_.toPairs` or `_.toPairsIn` function.
  22800. *
  22801. * @private
  22802. * @param {Function} keysFunc The function to get the keys of a given object.
  22803. * @returns {Function} Returns the new pairs function.
  22804. */
  22805. function createToPairs(keysFunc) {
  22806. return function(object) {
  22807. var tag = getTag(object);
  22808. if (tag == mapTag) {
  22809. return mapToArray(object);
  22810. }
  22811. if (tag == setTag) {
  22812. return setToPairs(object);
  22813. }
  22814. return baseToPairs(object, keysFunc(object));
  22815. };
  22816. }
  22817. /**
  22818. * Creates a function that either curries or invokes `func` with optional
  22819. * `this` binding and partially applied arguments.
  22820. *
  22821. * @private
  22822. * @param {Function|string} func The function or method name to wrap.
  22823. * @param {number} bitmask The bitmask flags.
  22824. * 1 - `_.bind`
  22825. * 2 - `_.bindKey`
  22826. * 4 - `_.curry` or `_.curryRight` of a bound function
  22827. * 8 - `_.curry`
  22828. * 16 - `_.curryRight`
  22829. * 32 - `_.partial`
  22830. * 64 - `_.partialRight`
  22831. * 128 - `_.rearg`
  22832. * 256 - `_.ary`
  22833. * 512 - `_.flip`
  22834. * @param {*} [thisArg] The `this` binding of `func`.
  22835. * @param {Array} [partials] The arguments to be partially applied.
  22836. * @param {Array} [holders] The `partials` placeholder indexes.
  22837. * @param {Array} [argPos] The argument positions of the new function.
  22838. * @param {number} [ary] The arity cap of `func`.
  22839. * @param {number} [arity] The arity of `func`.
  22840. * @returns {Function} Returns the new wrapped function.
  22841. */
  22842. function createWrap(func, bitmask, thisArg, partials, holders, argPos, ary, arity) {
  22843. var isBindKey = bitmask & WRAP_BIND_KEY_FLAG;
  22844. if (!isBindKey && typeof func != 'function') {
  22845. throw new TypeError(FUNC_ERROR_TEXT);
  22846. }
  22847. var length = partials ? partials.length : 0;
  22848. if (!length) {
  22849. bitmask &= ~(WRAP_PARTIAL_FLAG | WRAP_PARTIAL_RIGHT_FLAG);
  22850. partials = holders = undefined;
  22851. }
  22852. ary = ary === undefined ? ary : nativeMax(toInteger(ary), 0);
  22853. arity = arity === undefined ? arity : toInteger(arity);
  22854. length -= holders ? holders.length : 0;
  22855. if (bitmask & WRAP_PARTIAL_RIGHT_FLAG) {
  22856. var partialsRight = partials,
  22857. holdersRight = holders;
  22858. partials = holders = undefined;
  22859. }
  22860. var data = isBindKey ? undefined : getData(func);
  22861. var newData = [
  22862. func, bitmask, thisArg, partials, holders, partialsRight, holdersRight,
  22863. argPos, ary, arity
  22864. ];
  22865. if (data) {
  22866. mergeData(newData, data);
  22867. }
  22868. func = newData[0];
  22869. bitmask = newData[1];
  22870. thisArg = newData[2];
  22871. partials = newData[3];
  22872. holders = newData[4];
  22873. arity = newData[9] = newData[9] === undefined
  22874. ? (isBindKey ? 0 : func.length)
  22875. : nativeMax(newData[9] - length, 0);
  22876. if (!arity && bitmask & (WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG)) {
  22877. bitmask &= ~(WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG);
  22878. }
  22879. if (!bitmask || bitmask == WRAP_BIND_FLAG) {
  22880. var result = createBind(func, bitmask, thisArg);
  22881. } else if (bitmask == WRAP_CURRY_FLAG || bitmask == WRAP_CURRY_RIGHT_FLAG) {
  22882. result = createCurry(func, bitmask, arity);
  22883. } else if ((bitmask == WRAP_PARTIAL_FLAG || bitmask == (WRAP_BIND_FLAG | WRAP_PARTIAL_FLAG)) && !holders.length) {
  22884. result = createPartial(func, bitmask, thisArg, partials);
  22885. } else {
  22886. result = createHybrid.apply(undefined, newData);
  22887. }
  22888. var setter = data ? baseSetData : setData;
  22889. return setWrapToString(setter(result, newData), func, bitmask);
  22890. }
  22891. /**
  22892. * Used by `_.defaults` to customize its `_.assignIn` use to assign properties
  22893. * of source objects to the destination object for all destination properties
  22894. * that resolve to `undefined`.
  22895. *
  22896. * @private
  22897. * @param {*} objValue The destination value.
  22898. * @param {*} srcValue The source value.
  22899. * @param {string} key The key of the property to assign.
  22900. * @param {Object} object The parent object of `objValue`.
  22901. * @returns {*} Returns the value to assign.
  22902. */
  22903. function customDefaultsAssignIn(objValue, srcValue, key, object) {
  22904. if (objValue === undefined ||
  22905. (eq(objValue, objectProto[key]) && !hasOwnProperty.call(object, key))) {
  22906. return srcValue;
  22907. }
  22908. return objValue;
  22909. }
  22910. /**
  22911. * Used by `_.defaultsDeep` to customize its `_.merge` use to merge source
  22912. * objects into destination objects that are passed thru.
  22913. *
  22914. * @private
  22915. * @param {*} objValue The destination value.
  22916. * @param {*} srcValue The source value.
  22917. * @param {string} key The key of the property to merge.
  22918. * @param {Object} object The parent object of `objValue`.
  22919. * @param {Object} source The parent object of `srcValue`.
  22920. * @param {Object} [stack] Tracks traversed source values and their merged
  22921. * counterparts.
  22922. * @returns {*} Returns the value to assign.
  22923. */
  22924. function customDefaultsMerge(objValue, srcValue, key, object, source, stack) {
  22925. if (isObject(objValue) && isObject(srcValue)) {
  22926. // Recursively merge objects and arrays (susceptible to call stack limits).
  22927. stack.set(srcValue, objValue);
  22928. baseMerge(objValue, srcValue, undefined, customDefaultsMerge, stack);
  22929. stack['delete'](srcValue);
  22930. }
  22931. return objValue;
  22932. }
  22933. /**
  22934. * Used by `_.omit` to customize its `_.cloneDeep` use to only clone plain
  22935. * objects.
  22936. *
  22937. * @private
  22938. * @param {*} value The value to inspect.
  22939. * @param {string} key The key of the property to inspect.
  22940. * @returns {*} Returns the uncloned value or `undefined` to defer cloning to `_.cloneDeep`.
  22941. */
  22942. function customOmitClone(value) {
  22943. return isPlainObject(value) ? undefined : value;
  22944. }
  22945. /**
  22946. * A specialized version of `baseIsEqualDeep` for arrays with support for
  22947. * partial deep comparisons.
  22948. *
  22949. * @private
  22950. * @param {Array} array The array to compare.
  22951. * @param {Array} other The other array to compare.
  22952. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
  22953. * @param {Function} customizer The function to customize comparisons.
  22954. * @param {Function} equalFunc The function to determine equivalents of values.
  22955. * @param {Object} stack Tracks traversed `array` and `other` objects.
  22956. * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`.
  22957. */
  22958. function equalArrays(array, other, bitmask, customizer, equalFunc, stack) {
  22959. var isPartial = bitmask & COMPARE_PARTIAL_FLAG,
  22960. arrLength = array.length,
  22961. othLength = other.length;
  22962. if (arrLength != othLength && !(isPartial && othLength > arrLength)) {
  22963. return false;
  22964. }
  22965. // Assume cyclic values are equal.
  22966. var stacked = stack.get(array);
  22967. if (stacked && stack.get(other)) {
  22968. return stacked == other;
  22969. }
  22970. var index = -1,
  22971. result = true,
  22972. seen = (bitmask & COMPARE_UNORDERED_FLAG) ? new SetCache : undefined;
  22973. stack.set(array, other);
  22974. stack.set(other, array);
  22975. // Ignore non-index properties.
  22976. while (++index < arrLength) {
  22977. var arrValue = array[index],
  22978. othValue = other[index];
  22979. if (customizer) {
  22980. var compared = isPartial
  22981. ? customizer(othValue, arrValue, index, other, array, stack)
  22982. : customizer(arrValue, othValue, index, array, other, stack);
  22983. }
  22984. if (compared !== undefined) {
  22985. if (compared) {
  22986. continue;
  22987. }
  22988. result = false;
  22989. break;
  22990. }
  22991. // Recursively compare arrays (susceptible to call stack limits).
  22992. if (seen) {
  22993. if (!arraySome(other, function(othValue, othIndex) {
  22994. if (!cacheHas(seen, othIndex) &&
  22995. (arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) {
  22996. return seen.push(othIndex);
  22997. }
  22998. })) {
  22999. result = false;
  23000. break;
  23001. }
  23002. } else if (!(
  23003. arrValue === othValue ||
  23004. equalFunc(arrValue, othValue, bitmask, customizer, stack)
  23005. )) {
  23006. result = false;
  23007. break;
  23008. }
  23009. }
  23010. stack['delete'](array);
  23011. stack['delete'](other);
  23012. return result;
  23013. }
  23014. /**
  23015. * A specialized version of `baseIsEqualDeep` for comparing objects of
  23016. * the same `toStringTag`.
  23017. *
  23018. * **Note:** This function only supports comparing values with tags of
  23019. * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`.
  23020. *
  23021. * @private
  23022. * @param {Object} object The object to compare.
  23023. * @param {Object} other The other object to compare.
  23024. * @param {string} tag The `toStringTag` of the objects to compare.
  23025. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
  23026. * @param {Function} customizer The function to customize comparisons.
  23027. * @param {Function} equalFunc The function to determine equivalents of values.
  23028. * @param {Object} stack Tracks traversed `object` and `other` objects.
  23029. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  23030. */
  23031. function equalByTag(object, other, tag, bitmask, customizer, equalFunc, stack) {
  23032. switch (tag) {
  23033. case dataViewTag:
  23034. if ((object.byteLength != other.byteLength) ||
  23035. (object.byteOffset != other.byteOffset)) {
  23036. return false;
  23037. }
  23038. object = object.buffer;
  23039. other = other.buffer;
  23040. case arrayBufferTag:
  23041. if ((object.byteLength != other.byteLength) ||
  23042. !equalFunc(new Uint8Array(object), new Uint8Array(other))) {
  23043. return false;
  23044. }
  23045. return true;
  23046. case boolTag:
  23047. case dateTag:
  23048. case numberTag:
  23049. // Coerce booleans to `1` or `0` and dates to milliseconds.
  23050. // Invalid dates are coerced to `NaN`.
  23051. return eq(+object, +other);
  23052. case errorTag:
  23053. return object.name == other.name && object.message == other.message;
  23054. case regexpTag:
  23055. case stringTag:
  23056. // Coerce regexes to strings and treat strings, primitives and objects,
  23057. // as equal. See http://www.ecma-international.org/ecma-262/7.0/#sec-regexp.prototype.tostring
  23058. // for more details.
  23059. return object == (other + '');
  23060. case mapTag:
  23061. var convert = mapToArray;
  23062. case setTag:
  23063. var isPartial = bitmask & COMPARE_PARTIAL_FLAG;
  23064. convert || (convert = setToArray);
  23065. if (object.size != other.size && !isPartial) {
  23066. return false;
  23067. }
  23068. // Assume cyclic values are equal.
  23069. var stacked = stack.get(object);
  23070. if (stacked) {
  23071. return stacked == other;
  23072. }
  23073. bitmask |= COMPARE_UNORDERED_FLAG;
  23074. // Recursively compare objects (susceptible to call stack limits).
  23075. stack.set(object, other);
  23076. var result = equalArrays(convert(object), convert(other), bitmask, customizer, equalFunc, stack);
  23077. stack['delete'](object);
  23078. return result;
  23079. case symbolTag:
  23080. if (symbolValueOf) {
  23081. return symbolValueOf.call(object) == symbolValueOf.call(other);
  23082. }
  23083. }
  23084. return false;
  23085. }
  23086. /**
  23087. * A specialized version of `baseIsEqualDeep` for objects with support for
  23088. * partial deep comparisons.
  23089. *
  23090. * @private
  23091. * @param {Object} object The object to compare.
  23092. * @param {Object} other The other object to compare.
  23093. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
  23094. * @param {Function} customizer The function to customize comparisons.
  23095. * @param {Function} equalFunc The function to determine equivalents of values.
  23096. * @param {Object} stack Tracks traversed `object` and `other` objects.
  23097. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  23098. */
  23099. function equalObjects(object, other, bitmask, customizer, equalFunc, stack) {
  23100. var isPartial = bitmask & COMPARE_PARTIAL_FLAG,
  23101. objProps = getAllKeys(object),
  23102. objLength = objProps.length,
  23103. othProps = getAllKeys(other),
  23104. othLength = othProps.length;
  23105. if (objLength != othLength && !isPartial) {
  23106. return false;
  23107. }
  23108. var index = objLength;
  23109. while (index--) {
  23110. var key = objProps[index];
  23111. if (!(isPartial ? key in other : hasOwnProperty.call(other, key))) {
  23112. return false;
  23113. }
  23114. }
  23115. // Assume cyclic values are equal.
  23116. var stacked = stack.get(object);
  23117. if (stacked && stack.get(other)) {
  23118. return stacked == other;
  23119. }
  23120. var result = true;
  23121. stack.set(object, other);
  23122. stack.set(other, object);
  23123. var skipCtor = isPartial;
  23124. while (++index < objLength) {
  23125. key = objProps[index];
  23126. var objValue = object[key],
  23127. othValue = other[key];
  23128. if (customizer) {
  23129. var compared = isPartial
  23130. ? customizer(othValue, objValue, key, other, object, stack)
  23131. : customizer(objValue, othValue, key, object, other, stack);
  23132. }
  23133. // Recursively compare objects (susceptible to call stack limits).
  23134. if (!(compared === undefined
  23135. ? (objValue === othValue || equalFunc(objValue, othValue, bitmask, customizer, stack))
  23136. : compared
  23137. )) {
  23138. result = false;
  23139. break;
  23140. }
  23141. skipCtor || (skipCtor = key == 'constructor');
  23142. }
  23143. if (result && !skipCtor) {
  23144. var objCtor = object.constructor,
  23145. othCtor = other.constructor;
  23146. // Non `Object` object instances with different constructors are not equal.
  23147. if (objCtor != othCtor &&
  23148. ('constructor' in object && 'constructor' in other) &&
  23149. !(typeof objCtor == 'function' && objCtor instanceof objCtor &&
  23150. typeof othCtor == 'function' && othCtor instanceof othCtor)) {
  23151. result = false;
  23152. }
  23153. }
  23154. stack['delete'](object);
  23155. stack['delete'](other);
  23156. return result;
  23157. }
  23158. /**
  23159. * A specialized version of `baseRest` which flattens the rest array.
  23160. *
  23161. * @private
  23162. * @param {Function} func The function to apply a rest parameter to.
  23163. * @returns {Function} Returns the new function.
  23164. */
  23165. function flatRest(func) {
  23166. return setToString(overRest(func, undefined, flatten), func + '');
  23167. }
  23168. /**
  23169. * Creates an array of own enumerable property names and symbols of `object`.
  23170. *
  23171. * @private
  23172. * @param {Object} object The object to query.
  23173. * @returns {Array} Returns the array of property names and symbols.
  23174. */
  23175. function getAllKeys(object) {
  23176. return baseGetAllKeys(object, keys, getSymbols);
  23177. }
  23178. /**
  23179. * Creates an array of own and inherited enumerable property names and
  23180. * symbols of `object`.
  23181. *
  23182. * @private
  23183. * @param {Object} object The object to query.
  23184. * @returns {Array} Returns the array of property names and symbols.
  23185. */
  23186. function getAllKeysIn(object) {
  23187. return baseGetAllKeys(object, keysIn, getSymbolsIn);
  23188. }
  23189. /**
  23190. * Gets metadata for `func`.
  23191. *
  23192. * @private
  23193. * @param {Function} func The function to query.
  23194. * @returns {*} Returns the metadata for `func`.
  23195. */
  23196. var getData = !metaMap ? noop : function(func) {
  23197. return metaMap.get(func);
  23198. };
  23199. /**
  23200. * Gets the name of `func`.
  23201. *
  23202. * @private
  23203. * @param {Function} func The function to query.
  23204. * @returns {string} Returns the function name.
  23205. */
  23206. function getFuncName(func) {
  23207. var result = (func.name + ''),
  23208. array = realNames[result],
  23209. length = hasOwnProperty.call(realNames, result) ? array.length : 0;
  23210. while (length--) {
  23211. var data = array[length],
  23212. otherFunc = data.func;
  23213. if (otherFunc == null || otherFunc == func) {
  23214. return data.name;
  23215. }
  23216. }
  23217. return result;
  23218. }
  23219. /**
  23220. * Gets the argument placeholder value for `func`.
  23221. *
  23222. * @private
  23223. * @param {Function} func The function to inspect.
  23224. * @returns {*} Returns the placeholder value.
  23225. */
  23226. function getHolder(func) {
  23227. var object = hasOwnProperty.call(lodash, 'placeholder') ? lodash : func;
  23228. return object.placeholder;
  23229. }
  23230. /**
  23231. * Gets the appropriate "iteratee" function. If `_.iteratee` is customized,
  23232. * this function returns the custom method, otherwise it returns `baseIteratee`.
  23233. * If arguments are provided, the chosen function is invoked with them and
  23234. * its result is returned.
  23235. *
  23236. * @private
  23237. * @param {*} [value] The value to convert to an iteratee.
  23238. * @param {number} [arity] The arity of the created iteratee.
  23239. * @returns {Function} Returns the chosen function or its result.
  23240. */
  23241. function getIteratee() {
  23242. var result = lodash.iteratee || iteratee;
  23243. result = result === iteratee ? baseIteratee : result;
  23244. return arguments.length ? result(arguments[0], arguments[1]) : result;
  23245. }
  23246. /**
  23247. * Gets the data for `map`.
  23248. *
  23249. * @private
  23250. * @param {Object} map The map to query.
  23251. * @param {string} key The reference key.
  23252. * @returns {*} Returns the map data.
  23253. */
  23254. function getMapData(map, key) {
  23255. var data = map.__data__;
  23256. return isKeyable(key)
  23257. ? data[typeof key == 'string' ? 'string' : 'hash']
  23258. : data.map;
  23259. }
  23260. /**
  23261. * Gets the property names, values, and compare flags of `object`.
  23262. *
  23263. * @private
  23264. * @param {Object} object The object to query.
  23265. * @returns {Array} Returns the match data of `object`.
  23266. */
  23267. function getMatchData(object) {
  23268. var result = keys(object),
  23269. length = result.length;
  23270. while (length--) {
  23271. var key = result[length],
  23272. value = object[key];
  23273. result[length] = [key, value, isStrictComparable(value)];
  23274. }
  23275. return result;
  23276. }
  23277. /**
  23278. * Gets the native function at `key` of `object`.
  23279. *
  23280. * @private
  23281. * @param {Object} object The object to query.
  23282. * @param {string} key The key of the method to get.
  23283. * @returns {*} Returns the function if it's native, else `undefined`.
  23284. */
  23285. function getNative(object, key) {
  23286. var value = getValue(object, key);
  23287. return baseIsNative(value) ? value : undefined;
  23288. }
  23289. /**
  23290. * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
  23291. *
  23292. * @private
  23293. * @param {*} value The value to query.
  23294. * @returns {string} Returns the raw `toStringTag`.
  23295. */
  23296. function getRawTag(value) {
  23297. var isOwn = hasOwnProperty.call(value, symToStringTag),
  23298. tag = value[symToStringTag];
  23299. try {
  23300. value[symToStringTag] = undefined;
  23301. var unmasked = true;
  23302. } catch (e) {}
  23303. var result = nativeObjectToString.call(value);
  23304. if (unmasked) {
  23305. if (isOwn) {
  23306. value[symToStringTag] = tag;
  23307. } else {
  23308. delete value[symToStringTag];
  23309. }
  23310. }
  23311. return result;
  23312. }
  23313. /**
  23314. * Creates an array of the own enumerable symbols of `object`.
  23315. *
  23316. * @private
  23317. * @param {Object} object The object to query.
  23318. * @returns {Array} Returns the array of symbols.
  23319. */
  23320. var getSymbols = !nativeGetSymbols ? stubArray : function(object) {
  23321. if (object == null) {
  23322. return [];
  23323. }
  23324. object = Object(object);
  23325. return arrayFilter(nativeGetSymbols(object), function(symbol) {
  23326. return propertyIsEnumerable.call(object, symbol);
  23327. });
  23328. };
  23329. /**
  23330. * Creates an array of the own and inherited enumerable symbols of `object`.
  23331. *
  23332. * @private
  23333. * @param {Object} object The object to query.
  23334. * @returns {Array} Returns the array of symbols.
  23335. */
  23336. var getSymbolsIn = !nativeGetSymbols ? stubArray : function(object) {
  23337. var result = [];
  23338. while (object) {
  23339. arrayPush(result, getSymbols(object));
  23340. object = getPrototype(object);
  23341. }
  23342. return result;
  23343. };
  23344. /**
  23345. * Gets the `toStringTag` of `value`.
  23346. *
  23347. * @private
  23348. * @param {*} value The value to query.
  23349. * @returns {string} Returns the `toStringTag`.
  23350. */
  23351. var getTag = baseGetTag;
  23352. // Fallback for data views, maps, sets, and weak maps in IE 11 and promises in Node.js < 6.
  23353. if ((DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag) ||
  23354. (Map && getTag(new Map) != mapTag) ||
  23355. (Promise && getTag(Promise.resolve()) != promiseTag) ||
  23356. (Set && getTag(new Set) != setTag) ||
  23357. (WeakMap && getTag(new WeakMap) != weakMapTag)) {
  23358. getTag = function(value) {
  23359. var result = baseGetTag(value),
  23360. Ctor = result == objectTag ? value.constructor : undefined,
  23361. ctorString = Ctor ? toSource(Ctor) : '';
  23362. if (ctorString) {
  23363. switch (ctorString) {
  23364. case dataViewCtorString: return dataViewTag;
  23365. case mapCtorString: return mapTag;
  23366. case promiseCtorString: return promiseTag;
  23367. case setCtorString: return setTag;
  23368. case weakMapCtorString: return weakMapTag;
  23369. }
  23370. }
  23371. return result;
  23372. };
  23373. }
  23374. /**
  23375. * Gets the view, applying any `transforms` to the `start` and `end` positions.
  23376. *
  23377. * @private
  23378. * @param {number} start The start of the view.
  23379. * @param {number} end The end of the view.
  23380. * @param {Array} transforms The transformations to apply to the view.
  23381. * @returns {Object} Returns an object containing the `start` and `end`
  23382. * positions of the view.
  23383. */
  23384. function getView(start, end, transforms) {
  23385. var index = -1,
  23386. length = transforms.length;
  23387. while (++index < length) {
  23388. var data = transforms[index],
  23389. size = data.size;
  23390. switch (data.type) {
  23391. case 'drop': start += size; break;
  23392. case 'dropRight': end -= size; break;
  23393. case 'take': end = nativeMin(end, start + size); break;
  23394. case 'takeRight': start = nativeMax(start, end - size); break;
  23395. }
  23396. }
  23397. return { 'start': start, 'end': end };
  23398. }
  23399. /**
  23400. * Extracts wrapper details from the `source` body comment.
  23401. *
  23402. * @private
  23403. * @param {string} source The source to inspect.
  23404. * @returns {Array} Returns the wrapper details.
  23405. */
  23406. function getWrapDetails(source) {
  23407. var match = source.match(reWrapDetails);
  23408. return match ? match[1].split(reSplitDetails) : [];
  23409. }
  23410. /**
  23411. * Checks if `path` exists on `object`.
  23412. *
  23413. * @private
  23414. * @param {Object} object The object to query.
  23415. * @param {Array|string} path The path to check.
  23416. * @param {Function} hasFunc The function to check properties.
  23417. * @returns {boolean} Returns `true` if `path` exists, else `false`.
  23418. */
  23419. function hasPath(object, path, hasFunc) {
  23420. path = castPath(path, object);
  23421. var index = -1,
  23422. length = path.length,
  23423. result = false;
  23424. while (++index < length) {
  23425. var key = toKey(path[index]);
  23426. if (!(result = object != null && hasFunc(object, key))) {
  23427. break;
  23428. }
  23429. object = object[key];
  23430. }
  23431. if (result || ++index != length) {
  23432. return result;
  23433. }
  23434. length = object == null ? 0 : object.length;
  23435. return !!length && isLength(length) && isIndex(key, length) &&
  23436. (isArray(object) || isArguments(object));
  23437. }
  23438. /**
  23439. * Initializes an array clone.
  23440. *
  23441. * @private
  23442. * @param {Array} array The array to clone.
  23443. * @returns {Array} Returns the initialized clone.
  23444. */
  23445. function initCloneArray(array) {
  23446. var length = array.length,
  23447. result = new array.constructor(length);
  23448. // Add properties assigned by `RegExp#exec`.
  23449. if (length && typeof array[0] == 'string' && hasOwnProperty.call(array, 'index')) {
  23450. result.index = array.index;
  23451. result.input = array.input;
  23452. }
  23453. return result;
  23454. }
  23455. /**
  23456. * Initializes an object clone.
  23457. *
  23458. * @private
  23459. * @param {Object} object The object to clone.
  23460. * @returns {Object} Returns the initialized clone.
  23461. */
  23462. function initCloneObject(object) {
  23463. return (typeof object.constructor == 'function' && !isPrototype(object))
  23464. ? baseCreate(getPrototype(object))
  23465. : {};
  23466. }
  23467. /**
  23468. * Initializes an object clone based on its `toStringTag`.
  23469. *
  23470. * **Note:** This function only supports cloning values with tags of
  23471. * `Boolean`, `Date`, `Error`, `Map`, `Number`, `RegExp`, `Set`, or `String`.
  23472. *
  23473. * @private
  23474. * @param {Object} object The object to clone.
  23475. * @param {string} tag The `toStringTag` of the object to clone.
  23476. * @param {boolean} [isDeep] Specify a deep clone.
  23477. * @returns {Object} Returns the initialized clone.
  23478. */
  23479. function initCloneByTag(object, tag, isDeep) {
  23480. var Ctor = object.constructor;
  23481. switch (tag) {
  23482. case arrayBufferTag:
  23483. return cloneArrayBuffer(object);
  23484. case boolTag:
  23485. case dateTag:
  23486. return new Ctor(+object);
  23487. case dataViewTag:
  23488. return cloneDataView(object, isDeep);
  23489. case float32Tag: case float64Tag:
  23490. case int8Tag: case int16Tag: case int32Tag:
  23491. case uint8Tag: case uint8ClampedTag: case uint16Tag: case uint32Tag:
  23492. return cloneTypedArray(object, isDeep);
  23493. case mapTag:
  23494. return new Ctor;
  23495. case numberTag:
  23496. case stringTag:
  23497. return new Ctor(object);
  23498. case regexpTag:
  23499. return cloneRegExp(object);
  23500. case setTag:
  23501. return new Ctor;
  23502. case symbolTag:
  23503. return cloneSymbol(object);
  23504. }
  23505. }
  23506. /**
  23507. * Inserts wrapper `details` in a comment at the top of the `source` body.
  23508. *
  23509. * @private
  23510. * @param {string} source The source to modify.
  23511. * @returns {Array} details The details to insert.
  23512. * @returns {string} Returns the modified source.
  23513. */
  23514. function insertWrapDetails(source, details) {
  23515. var length = details.length;
  23516. if (!length) {
  23517. return source;
  23518. }
  23519. var lastIndex = length - 1;
  23520. details[lastIndex] = (length > 1 ? '& ' : '') + details[lastIndex];
  23521. details = details.join(length > 2 ? ', ' : ' ');
  23522. return source.replace(reWrapComment, '{\n/* [wrapped with ' + details + '] */\n');
  23523. }
  23524. /**
  23525. * Checks if `value` is a flattenable `arguments` object or array.
  23526. *
  23527. * @private
  23528. * @param {*} value The value to check.
  23529. * @returns {boolean} Returns `true` if `value` is flattenable, else `false`.
  23530. */
  23531. function isFlattenable(value) {
  23532. return isArray(value) || isArguments(value) ||
  23533. !!(spreadableSymbol && value && value[spreadableSymbol]);
  23534. }
  23535. /**
  23536. * Checks if `value` is a valid array-like index.
  23537. *
  23538. * @private
  23539. * @param {*} value The value to check.
  23540. * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
  23541. * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
  23542. */
  23543. function isIndex(value, length) {
  23544. var type = typeof value;
  23545. length = length == null ? MAX_SAFE_INTEGER : length;
  23546. return !!length &&
  23547. (type == 'number' ||
  23548. (type != 'symbol' && reIsUint.test(value))) &&
  23549. (value > -1 && value % 1 == 0 && value < length);
  23550. }
  23551. /**
  23552. * Checks if the given arguments are from an iteratee call.
  23553. *
  23554. * @private
  23555. * @param {*} value The potential iteratee value argument.
  23556. * @param {*} index The potential iteratee index or key argument.
  23557. * @param {*} object The potential iteratee object argument.
  23558. * @returns {boolean} Returns `true` if the arguments are from an iteratee call,
  23559. * else `false`.
  23560. */
  23561. function isIterateeCall(value, index, object) {
  23562. if (!isObject(object)) {
  23563. return false;
  23564. }
  23565. var type = typeof index;
  23566. if (type == 'number'
  23567. ? (isArrayLike(object) && isIndex(index, object.length))
  23568. : (type == 'string' && index in object)
  23569. ) {
  23570. return eq(object[index], value);
  23571. }
  23572. return false;
  23573. }
  23574. /**
  23575. * Checks if `value` is a property name and not a property path.
  23576. *
  23577. * @private
  23578. * @param {*} value The value to check.
  23579. * @param {Object} [object] The object to query keys on.
  23580. * @returns {boolean} Returns `true` if `value` is a property name, else `false`.
  23581. */
  23582. function isKey(value, object) {
  23583. if (isArray(value)) {
  23584. return false;
  23585. }
  23586. var type = typeof value;
  23587. if (type == 'number' || type == 'symbol' || type == 'boolean' ||
  23588. value == null || isSymbol(value)) {
  23589. return true;
  23590. }
  23591. return reIsPlainProp.test(value) || !reIsDeepProp.test(value) ||
  23592. (object != null && value in Object(object));
  23593. }
  23594. /**
  23595. * Checks if `value` is suitable for use as unique object key.
  23596. *
  23597. * @private
  23598. * @param {*} value The value to check.
  23599. * @returns {boolean} Returns `true` if `value` is suitable, else `false`.
  23600. */
  23601. function isKeyable(value) {
  23602. var type = typeof value;
  23603. return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')
  23604. ? (value !== '__proto__')
  23605. : (value === null);
  23606. }
  23607. /**
  23608. * Checks if `func` has a lazy counterpart.
  23609. *
  23610. * @private
  23611. * @param {Function} func The function to check.
  23612. * @returns {boolean} Returns `true` if `func` has a lazy counterpart,
  23613. * else `false`.
  23614. */
  23615. function isLaziable(func) {
  23616. var funcName = getFuncName(func),
  23617. other = lodash[funcName];
  23618. if (typeof other != 'function' || !(funcName in LazyWrapper.prototype)) {
  23619. return false;
  23620. }
  23621. if (func === other) {
  23622. return true;
  23623. }
  23624. var data = getData(other);
  23625. return !!data && func === data[0];
  23626. }
  23627. /**
  23628. * Checks if `func` has its source masked.
  23629. *
  23630. * @private
  23631. * @param {Function} func The function to check.
  23632. * @returns {boolean} Returns `true` if `func` is masked, else `false`.
  23633. */
  23634. function isMasked(func) {
  23635. return !!maskSrcKey && (maskSrcKey in func);
  23636. }
  23637. /**
  23638. * Checks if `func` is capable of being masked.
  23639. *
  23640. * @private
  23641. * @param {*} value The value to check.
  23642. * @returns {boolean} Returns `true` if `func` is maskable, else `false`.
  23643. */
  23644. var isMaskable = coreJsData ? isFunction : stubFalse;
  23645. /**
  23646. * Checks if `value` is likely a prototype object.
  23647. *
  23648. * @private
  23649. * @param {*} value The value to check.
  23650. * @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
  23651. */
  23652. function isPrototype(value) {
  23653. var Ctor = value && value.constructor,
  23654. proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto;
  23655. return value === proto;
  23656. }
  23657. /**
  23658. * Checks if `value` is suitable for strict equality comparisons, i.e. `===`.
  23659. *
  23660. * @private
  23661. * @param {*} value The value to check.
  23662. * @returns {boolean} Returns `true` if `value` if suitable for strict
  23663. * equality comparisons, else `false`.
  23664. */
  23665. function isStrictComparable(value) {
  23666. return value === value && !isObject(value);
  23667. }
  23668. /**
  23669. * A specialized version of `matchesProperty` for source values suitable
  23670. * for strict equality comparisons, i.e. `===`.
  23671. *
  23672. * @private
  23673. * @param {string} key The key of the property to get.
  23674. * @param {*} srcValue The value to match.
  23675. * @returns {Function} Returns the new spec function.
  23676. */
  23677. function matchesStrictComparable(key, srcValue) {
  23678. return function(object) {
  23679. if (object == null) {
  23680. return false;
  23681. }
  23682. return object[key] === srcValue &&
  23683. (srcValue !== undefined || (key in Object(object)));
  23684. };
  23685. }
  23686. /**
  23687. * A specialized version of `_.memoize` which clears the memoized function's
  23688. * cache when it exceeds `MAX_MEMOIZE_SIZE`.
  23689. *
  23690. * @private
  23691. * @param {Function} func The function to have its output memoized.
  23692. * @returns {Function} Returns the new memoized function.
  23693. */
  23694. function memoizeCapped(func) {
  23695. var result = memoize(func, function(key) {
  23696. if (cache.size === MAX_MEMOIZE_SIZE) {
  23697. cache.clear();
  23698. }
  23699. return key;
  23700. });
  23701. var cache = result.cache;
  23702. return result;
  23703. }
  23704. /**
  23705. * Merges the function metadata of `source` into `data`.
  23706. *
  23707. * Merging metadata reduces the number of wrappers used to invoke a function.
  23708. * This is possible because methods like `_.bind`, `_.curry`, and `_.partial`
  23709. * may be applied regardless of execution order. Methods like `_.ary` and
  23710. * `_.rearg` modify function arguments, making the order in which they are
  23711. * executed important, preventing the merging of metadata. However, we make
  23712. * an exception for a safe combined case where curried functions have `_.ary`
  23713. * and or `_.rearg` applied.
  23714. *
  23715. * @private
  23716. * @param {Array} data The destination metadata.
  23717. * @param {Array} source The source metadata.
  23718. * @returns {Array} Returns `data`.
  23719. */
  23720. function mergeData(data, source) {
  23721. var bitmask = data[1],
  23722. srcBitmask = source[1],
  23723. newBitmask = bitmask | srcBitmask,
  23724. isCommon = newBitmask < (WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG | WRAP_ARY_FLAG);
  23725. var isCombo =
  23726. ((srcBitmask == WRAP_ARY_FLAG) && (bitmask == WRAP_CURRY_FLAG)) ||
  23727. ((srcBitmask == WRAP_ARY_FLAG) && (bitmask == WRAP_REARG_FLAG) && (data[7].length <= source[8])) ||
  23728. ((srcBitmask == (WRAP_ARY_FLAG | WRAP_REARG_FLAG)) && (source[7].length <= source[8]) && (bitmask == WRAP_CURRY_FLAG));
  23729. // Exit early if metadata can't be merged.
  23730. if (!(isCommon || isCombo)) {
  23731. return data;
  23732. }
  23733. // Use source `thisArg` if available.
  23734. if (srcBitmask & WRAP_BIND_FLAG) {
  23735. data[2] = source[2];
  23736. // Set when currying a bound function.
  23737. newBitmask |= bitmask & WRAP_BIND_FLAG ? 0 : WRAP_CURRY_BOUND_FLAG;
  23738. }
  23739. // Compose partial arguments.
  23740. var value = source[3];
  23741. if (value) {
  23742. var partials = data[3];
  23743. data[3] = partials ? composeArgs(partials, value, source[4]) : value;
  23744. data[4] = partials ? replaceHolders(data[3], PLACEHOLDER) : source[4];
  23745. }
  23746. // Compose partial right arguments.
  23747. value = source[5];
  23748. if (value) {
  23749. partials = data[5];
  23750. data[5] = partials ? composeArgsRight(partials, value, source[6]) : value;
  23751. data[6] = partials ? replaceHolders(data[5], PLACEHOLDER) : source[6];
  23752. }
  23753. // Use source `argPos` if available.
  23754. value = source[7];
  23755. if (value) {
  23756. data[7] = value;
  23757. }
  23758. // Use source `ary` if it's smaller.
  23759. if (srcBitmask & WRAP_ARY_FLAG) {
  23760. data[8] = data[8] == null ? source[8] : nativeMin(data[8], source[8]);
  23761. }
  23762. // Use source `arity` if one is not provided.
  23763. if (data[9] == null) {
  23764. data[9] = source[9];
  23765. }
  23766. // Use source `func` and merge bitmasks.
  23767. data[0] = source[0];
  23768. data[1] = newBitmask;
  23769. return data;
  23770. }
  23771. /**
  23772. * This function is like
  23773. * [`Object.keys`](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
  23774. * except that it includes inherited enumerable properties.
  23775. *
  23776. * @private
  23777. * @param {Object} object The object to query.
  23778. * @returns {Array} Returns the array of property names.
  23779. */
  23780. function nativeKeysIn(object) {
  23781. var result = [];
  23782. if (object != null) {
  23783. for (var key in Object(object)) {
  23784. result.push(key);
  23785. }
  23786. }
  23787. return result;
  23788. }
  23789. /**
  23790. * Converts `value` to a string using `Object.prototype.toString`.
  23791. *
  23792. * @private
  23793. * @param {*} value The value to convert.
  23794. * @returns {string} Returns the converted string.
  23795. */
  23796. function objectToString(value) {
  23797. return nativeObjectToString.call(value);
  23798. }
  23799. /**
  23800. * A specialized version of `baseRest` which transforms the rest array.
  23801. *
  23802. * @private
  23803. * @param {Function} func The function to apply a rest parameter to.
  23804. * @param {number} [start=func.length-1] The start position of the rest parameter.
  23805. * @param {Function} transform The rest array transform.
  23806. * @returns {Function} Returns the new function.
  23807. */
  23808. function overRest(func, start, transform) {
  23809. start = nativeMax(start === undefined ? (func.length - 1) : start, 0);
  23810. return function() {
  23811. var args = arguments,
  23812. index = -1,
  23813. length = nativeMax(args.length - start, 0),
  23814. array = Array(length);
  23815. while (++index < length) {
  23816. array[index] = args[start + index];
  23817. }
  23818. index = -1;
  23819. var otherArgs = Array(start + 1);
  23820. while (++index < start) {
  23821. otherArgs[index] = args[index];
  23822. }
  23823. otherArgs[start] = transform(array);
  23824. return apply(func, this, otherArgs);
  23825. };
  23826. }
  23827. /**
  23828. * Gets the parent value at `path` of `object`.
  23829. *
  23830. * @private
  23831. * @param {Object} object The object to query.
  23832. * @param {Array} path The path to get the parent value of.
  23833. * @returns {*} Returns the parent value.
  23834. */
  23835. function parent(object, path) {
  23836. return path.length < 2 ? object : baseGet(object, baseSlice(path, 0, -1));
  23837. }
  23838. /**
  23839. * Reorder `array` according to the specified indexes where the element at
  23840. * the first index is assigned as the first element, the element at
  23841. * the second index is assigned as the second element, and so on.
  23842. *
  23843. * @private
  23844. * @param {Array} array The array to reorder.
  23845. * @param {Array} indexes The arranged array indexes.
  23846. * @returns {Array} Returns `array`.
  23847. */
  23848. function reorder(array, indexes) {
  23849. var arrLength = array.length,
  23850. length = nativeMin(indexes.length, arrLength),
  23851. oldArray = copyArray(array);
  23852. while (length--) {
  23853. var index = indexes[length];
  23854. array[length] = isIndex(index, arrLength) ? oldArray[index] : undefined;
  23855. }
  23856. return array;
  23857. }
  23858. /**
  23859. * Gets the value at `key`, unless `key` is "__proto__" or "constructor".
  23860. *
  23861. * @private
  23862. * @param {Object} object The object to query.
  23863. * @param {string} key The key of the property to get.
  23864. * @returns {*} Returns the property value.
  23865. */
  23866. function safeGet(object, key) {
  23867. if (key === 'constructor' && typeof object[key] === 'function') {
  23868. return;
  23869. }
  23870. if (key == '__proto__') {
  23871. return;
  23872. }
  23873. return object[key];
  23874. }
  23875. /**
  23876. * Sets metadata for `func`.
  23877. *
  23878. * **Note:** If this function becomes hot, i.e. is invoked a lot in a short
  23879. * period of time, it will trip its breaker and transition to an identity
  23880. * function to avoid garbage collection pauses in V8. See
  23881. * [V8 issue 2070](https://bugs.chromium.org/p/v8/issues/detail?id=2070)
  23882. * for more details.
  23883. *
  23884. * @private
  23885. * @param {Function} func The function to associate metadata with.
  23886. * @param {*} data The metadata.
  23887. * @returns {Function} Returns `func`.
  23888. */
  23889. var setData = shortOut(baseSetData);
  23890. /**
  23891. * A simple wrapper around the global [`setTimeout`](https://mdn.io/setTimeout).
  23892. *
  23893. * @private
  23894. * @param {Function} func The function to delay.
  23895. * @param {number} wait The number of milliseconds to delay invocation.
  23896. * @returns {number|Object} Returns the timer id or timeout object.
  23897. */
  23898. var setTimeout = ctxSetTimeout || function(func, wait) {
  23899. return root.setTimeout(func, wait);
  23900. };
  23901. /**
  23902. * Sets the `toString` method of `func` to return `string`.
  23903. *
  23904. * @private
  23905. * @param {Function} func The function to modify.
  23906. * @param {Function} string The `toString` result.
  23907. * @returns {Function} Returns `func`.
  23908. */
  23909. var setToString = shortOut(baseSetToString);
  23910. /**
  23911. * Sets the `toString` method of `wrapper` to mimic the source of `reference`
  23912. * with wrapper details in a comment at the top of the source body.
  23913. *
  23914. * @private
  23915. * @param {Function} wrapper The function to modify.
  23916. * @param {Function} reference The reference function.
  23917. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  23918. * @returns {Function} Returns `wrapper`.
  23919. */
  23920. function setWrapToString(wrapper, reference, bitmask) {
  23921. var source = (reference + '');
  23922. return setToString(wrapper, insertWrapDetails(source, updateWrapDetails(getWrapDetails(source), bitmask)));
  23923. }
  23924. /**
  23925. * Creates a function that'll short out and invoke `identity` instead
  23926. * of `func` when it's called `HOT_COUNT` or more times in `HOT_SPAN`
  23927. * milliseconds.
  23928. *
  23929. * @private
  23930. * @param {Function} func The function to restrict.
  23931. * @returns {Function} Returns the new shortable function.
  23932. */
  23933. function shortOut(func) {
  23934. var count = 0,
  23935. lastCalled = 0;
  23936. return function() {
  23937. var stamp = nativeNow(),
  23938. remaining = HOT_SPAN - (stamp - lastCalled);
  23939. lastCalled = stamp;
  23940. if (remaining > 0) {
  23941. if (++count >= HOT_COUNT) {
  23942. return arguments[0];
  23943. }
  23944. } else {
  23945. count = 0;
  23946. }
  23947. return func.apply(undefined, arguments);
  23948. };
  23949. }
  23950. /**
  23951. * A specialized version of `_.shuffle` which mutates and sets the size of `array`.
  23952. *
  23953. * @private
  23954. * @param {Array} array The array to shuffle.
  23955. * @param {number} [size=array.length] The size of `array`.
  23956. * @returns {Array} Returns `array`.
  23957. */
  23958. function shuffleSelf(array, size) {
  23959. var index = -1,
  23960. length = array.length,
  23961. lastIndex = length - 1;
  23962. size = size === undefined ? length : size;
  23963. while (++index < size) {
  23964. var rand = baseRandom(index, lastIndex),
  23965. value = array[rand];
  23966. array[rand] = array[index];
  23967. array[index] = value;
  23968. }
  23969. array.length = size;
  23970. return array;
  23971. }
  23972. /**
  23973. * Converts `string` to a property path array.
  23974. *
  23975. * @private
  23976. * @param {string} string The string to convert.
  23977. * @returns {Array} Returns the property path array.
  23978. */
  23979. var stringToPath = memoizeCapped(function(string) {
  23980. var result = [];
  23981. if (string.charCodeAt(0) === 46 /* . */) {
  23982. result.push('');
  23983. }
  23984. string.replace(rePropName, function(match, number, quote, subString) {
  23985. result.push(quote ? subString.replace(reEscapeChar, '$1') : (number || match));
  23986. });
  23987. return result;
  23988. });
  23989. /**
  23990. * Converts `value` to a string key if it's not a string or symbol.
  23991. *
  23992. * @private
  23993. * @param {*} value The value to inspect.
  23994. * @returns {string|symbol} Returns the key.
  23995. */
  23996. function toKey(value) {
  23997. if (typeof value == 'string' || isSymbol(value)) {
  23998. return value;
  23999. }
  24000. var result = (value + '');
  24001. return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
  24002. }
  24003. /**
  24004. * Converts `func` to its source code.
  24005. *
  24006. * @private
  24007. * @param {Function} func The function to convert.
  24008. * @returns {string} Returns the source code.
  24009. */
  24010. function toSource(func) {
  24011. if (func != null) {
  24012. try {
  24013. return funcToString.call(func);
  24014. } catch (e) {}
  24015. try {
  24016. return (func + '');
  24017. } catch (e) {}
  24018. }
  24019. return '';
  24020. }
  24021. /**
  24022. * Updates wrapper `details` based on `bitmask` flags.
  24023. *
  24024. * @private
  24025. * @returns {Array} details The details to modify.
  24026. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  24027. * @returns {Array} Returns `details`.
  24028. */
  24029. function updateWrapDetails(details, bitmask) {
  24030. arrayEach(wrapFlags, function(pair) {
  24031. var value = '_.' + pair[0];
  24032. if ((bitmask & pair[1]) && !arrayIncludes(details, value)) {
  24033. details.push(value);
  24034. }
  24035. });
  24036. return details.sort();
  24037. }
  24038. /**
  24039. * Creates a clone of `wrapper`.
  24040. *
  24041. * @private
  24042. * @param {Object} wrapper The wrapper to clone.
  24043. * @returns {Object} Returns the cloned wrapper.
  24044. */
  24045. function wrapperClone(wrapper) {
  24046. if (wrapper instanceof LazyWrapper) {
  24047. return wrapper.clone();
  24048. }
  24049. var result = new LodashWrapper(wrapper.__wrapped__, wrapper.__chain__);
  24050. result.__actions__ = copyArray(wrapper.__actions__);
  24051. result.__index__ = wrapper.__index__;
  24052. result.__values__ = wrapper.__values__;
  24053. return result;
  24054. }
  24055. /*------------------------------------------------------------------------*/
  24056. /**
  24057. * Creates an array of elements split into groups the length of `size`.
  24058. * If `array` can't be split evenly, the final chunk will be the remaining
  24059. * elements.
  24060. *
  24061. * @static
  24062. * @memberOf _
  24063. * @since 3.0.0
  24064. * @category Array
  24065. * @param {Array} array The array to process.
  24066. * @param {number} [size=1] The length of each chunk
  24067. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  24068. * @returns {Array} Returns the new array of chunks.
  24069. * @example
  24070. *
  24071. * _.chunk(['a', 'b', 'c', 'd'], 2);
  24072. * // => [['a', 'b'], ['c', 'd']]
  24073. *
  24074. * _.chunk(['a', 'b', 'c', 'd'], 3);
  24075. * // => [['a', 'b', 'c'], ['d']]
  24076. */
  24077. function chunk(array, size, guard) {
  24078. if ((guard ? isIterateeCall(array, size, guard) : size === undefined)) {
  24079. size = 1;
  24080. } else {
  24081. size = nativeMax(toInteger(size), 0);
  24082. }
  24083. var length = array == null ? 0 : array.length;
  24084. if (!length || size < 1) {
  24085. return [];
  24086. }
  24087. var index = 0,
  24088. resIndex = 0,
  24089. result = Array(nativeCeil(length / size));
  24090. while (index < length) {
  24091. result[resIndex++] = baseSlice(array, index, (index += size));
  24092. }
  24093. return result;
  24094. }
  24095. /**
  24096. * Creates an array with all falsey values removed. The values `false`, `null`,
  24097. * `0`, `""`, `undefined`, and `NaN` are falsey.
  24098. *
  24099. * @static
  24100. * @memberOf _
  24101. * @since 0.1.0
  24102. * @category Array
  24103. * @param {Array} array The array to compact.
  24104. * @returns {Array} Returns the new array of filtered values.
  24105. * @example
  24106. *
  24107. * _.compact([0, 1, false, 2, '', 3]);
  24108. * // => [1, 2, 3]
  24109. */
  24110. function compact(array) {
  24111. var index = -1,
  24112. length = array == null ? 0 : array.length,
  24113. resIndex = 0,
  24114. result = [];
  24115. while (++index < length) {
  24116. var value = array[index];
  24117. if (value) {
  24118. result[resIndex++] = value;
  24119. }
  24120. }
  24121. return result;
  24122. }
  24123. /**
  24124. * Creates a new array concatenating `array` with any additional arrays
  24125. * and/or values.
  24126. *
  24127. * @static
  24128. * @memberOf _
  24129. * @since 4.0.0
  24130. * @category Array
  24131. * @param {Array} array The array to concatenate.
  24132. * @param {...*} [values] The values to concatenate.
  24133. * @returns {Array} Returns the new concatenated array.
  24134. * @example
  24135. *
  24136. * var array = [1];
  24137. * var other = _.concat(array, 2, [3], [[4]]);
  24138. *
  24139. * console.log(other);
  24140. * // => [1, 2, 3, [4]]
  24141. *
  24142. * console.log(array);
  24143. * // => [1]
  24144. */
  24145. function concat() {
  24146. var length = arguments.length;
  24147. if (!length) {
  24148. return [];
  24149. }
  24150. var args = Array(length - 1),
  24151. array = arguments[0],
  24152. index = length;
  24153. while (index--) {
  24154. args[index - 1] = arguments[index];
  24155. }
  24156. return arrayPush(isArray(array) ? copyArray(array) : [array], baseFlatten(args, 1));
  24157. }
  24158. /**
  24159. * Creates an array of `array` values not included in the other given arrays
  24160. * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  24161. * for equality comparisons. The order and references of result values are
  24162. * determined by the first array.
  24163. *
  24164. * **Note:** Unlike `_.pullAll`, this method returns a new array.
  24165. *
  24166. * @static
  24167. * @memberOf _
  24168. * @since 0.1.0
  24169. * @category Array
  24170. * @param {Array} array The array to inspect.
  24171. * @param {...Array} [values] The values to exclude.
  24172. * @returns {Array} Returns the new array of filtered values.
  24173. * @see _.without, _.xor
  24174. * @example
  24175. *
  24176. * _.difference([2, 1], [2, 3]);
  24177. * // => [1]
  24178. */
  24179. var difference = baseRest(function(array, values) {
  24180. return isArrayLikeObject(array)
  24181. ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true))
  24182. : [];
  24183. });
  24184. /**
  24185. * This method is like `_.difference` except that it accepts `iteratee` which
  24186. * is invoked for each element of `array` and `values` to generate the criterion
  24187. * by which they're compared. The order and references of result values are
  24188. * determined by the first array. The iteratee is invoked with one argument:
  24189. * (value).
  24190. *
  24191. * **Note:** Unlike `_.pullAllBy`, this method returns a new array.
  24192. *
  24193. * @static
  24194. * @memberOf _
  24195. * @since 4.0.0
  24196. * @category Array
  24197. * @param {Array} array The array to inspect.
  24198. * @param {...Array} [values] The values to exclude.
  24199. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  24200. * @returns {Array} Returns the new array of filtered values.
  24201. * @example
  24202. *
  24203. * _.differenceBy([2.1, 1.2], [2.3, 3.4], Math.floor);
  24204. * // => [1.2]
  24205. *
  24206. * // The `_.property` iteratee shorthand.
  24207. * _.differenceBy([{ 'x': 2 }, { 'x': 1 }], [{ 'x': 1 }], 'x');
  24208. * // => [{ 'x': 2 }]
  24209. */
  24210. var differenceBy = baseRest(function(array, values) {
  24211. var iteratee = last(values);
  24212. if (isArrayLikeObject(iteratee)) {
  24213. iteratee = undefined;
  24214. }
  24215. return isArrayLikeObject(array)
  24216. ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true), getIteratee(iteratee, 2))
  24217. : [];
  24218. });
  24219. /**
  24220. * This method is like `_.difference` except that it accepts `comparator`
  24221. * which is invoked to compare elements of `array` to `values`. The order and
  24222. * references of result values are determined by the first array. The comparator
  24223. * is invoked with two arguments: (arrVal, othVal).
  24224. *
  24225. * **Note:** Unlike `_.pullAllWith`, this method returns a new array.
  24226. *
  24227. * @static
  24228. * @memberOf _
  24229. * @since 4.0.0
  24230. * @category Array
  24231. * @param {Array} array The array to inspect.
  24232. * @param {...Array} [values] The values to exclude.
  24233. * @param {Function} [comparator] The comparator invoked per element.
  24234. * @returns {Array} Returns the new array of filtered values.
  24235. * @example
  24236. *
  24237. * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
  24238. *
  24239. * _.differenceWith(objects, [{ 'x': 1, 'y': 2 }], _.isEqual);
  24240. * // => [{ 'x': 2, 'y': 1 }]
  24241. */
  24242. var differenceWith = baseRest(function(array, values) {
  24243. var comparator = last(values);
  24244. if (isArrayLikeObject(comparator)) {
  24245. comparator = undefined;
  24246. }
  24247. return isArrayLikeObject(array)
  24248. ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true), undefined, comparator)
  24249. : [];
  24250. });
  24251. /**
  24252. * Creates a slice of `array` with `n` elements dropped from the beginning.
  24253. *
  24254. * @static
  24255. * @memberOf _
  24256. * @since 0.5.0
  24257. * @category Array
  24258. * @param {Array} array The array to query.
  24259. * @param {number} [n=1] The number of elements to drop.
  24260. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  24261. * @returns {Array} Returns the slice of `array`.
  24262. * @example
  24263. *
  24264. * _.drop([1, 2, 3]);
  24265. * // => [2, 3]
  24266. *
  24267. * _.drop([1, 2, 3], 2);
  24268. * // => [3]
  24269. *
  24270. * _.drop([1, 2, 3], 5);
  24271. * // => []
  24272. *
  24273. * _.drop([1, 2, 3], 0);
  24274. * // => [1, 2, 3]
  24275. */
  24276. function drop(array, n, guard) {
  24277. var length = array == null ? 0 : array.length;
  24278. if (!length) {
  24279. return [];
  24280. }
  24281. n = (guard || n === undefined) ? 1 : toInteger(n);
  24282. return baseSlice(array, n < 0 ? 0 : n, length);
  24283. }
  24284. /**
  24285. * Creates a slice of `array` with `n` elements dropped from the end.
  24286. *
  24287. * @static
  24288. * @memberOf _
  24289. * @since 3.0.0
  24290. * @category Array
  24291. * @param {Array} array The array to query.
  24292. * @param {number} [n=1] The number of elements to drop.
  24293. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  24294. * @returns {Array} Returns the slice of `array`.
  24295. * @example
  24296. *
  24297. * _.dropRight([1, 2, 3]);
  24298. * // => [1, 2]
  24299. *
  24300. * _.dropRight([1, 2, 3], 2);
  24301. * // => [1]
  24302. *
  24303. * _.dropRight([1, 2, 3], 5);
  24304. * // => []
  24305. *
  24306. * _.dropRight([1, 2, 3], 0);
  24307. * // => [1, 2, 3]
  24308. */
  24309. function dropRight(array, n, guard) {
  24310. var length = array == null ? 0 : array.length;
  24311. if (!length) {
  24312. return [];
  24313. }
  24314. n = (guard || n === undefined) ? 1 : toInteger(n);
  24315. n = length - n;
  24316. return baseSlice(array, 0, n < 0 ? 0 : n);
  24317. }
  24318. /**
  24319. * Creates a slice of `array` excluding elements dropped from the end.
  24320. * Elements are dropped until `predicate` returns falsey. The predicate is
  24321. * invoked with three arguments: (value, index, array).
  24322. *
  24323. * @static
  24324. * @memberOf _
  24325. * @since 3.0.0
  24326. * @category Array
  24327. * @param {Array} array The array to query.
  24328. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  24329. * @returns {Array} Returns the slice of `array`.
  24330. * @example
  24331. *
  24332. * var users = [
  24333. * { 'user': 'barney', 'active': true },
  24334. * { 'user': 'fred', 'active': false },
  24335. * { 'user': 'pebbles', 'active': false }
  24336. * ];
  24337. *
  24338. * _.dropRightWhile(users, function(o) { return !o.active; });
  24339. * // => objects for ['barney']
  24340. *
  24341. * // The `_.matches` iteratee shorthand.
  24342. * _.dropRightWhile(users, { 'user': 'pebbles', 'active': false });
  24343. * // => objects for ['barney', 'fred']
  24344. *
  24345. * // The `_.matchesProperty` iteratee shorthand.
  24346. * _.dropRightWhile(users, ['active', false]);
  24347. * // => objects for ['barney']
  24348. *
  24349. * // The `_.property` iteratee shorthand.
  24350. * _.dropRightWhile(users, 'active');
  24351. * // => objects for ['barney', 'fred', 'pebbles']
  24352. */
  24353. function dropRightWhile(array, predicate) {
  24354. return (array && array.length)
  24355. ? baseWhile(array, getIteratee(predicate, 3), true, true)
  24356. : [];
  24357. }
  24358. /**
  24359. * Creates a slice of `array` excluding elements dropped from the beginning.
  24360. * Elements are dropped until `predicate` returns falsey. The predicate is
  24361. * invoked with three arguments: (value, index, array).
  24362. *
  24363. * @static
  24364. * @memberOf _
  24365. * @since 3.0.0
  24366. * @category Array
  24367. * @param {Array} array The array to query.
  24368. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  24369. * @returns {Array} Returns the slice of `array`.
  24370. * @example
  24371. *
  24372. * var users = [
  24373. * { 'user': 'barney', 'active': false },
  24374. * { 'user': 'fred', 'active': false },
  24375. * { 'user': 'pebbles', 'active': true }
  24376. * ];
  24377. *
  24378. * _.dropWhile(users, function(o) { return !o.active; });
  24379. * // => objects for ['pebbles']
  24380. *
  24381. * // The `_.matches` iteratee shorthand.
  24382. * _.dropWhile(users, { 'user': 'barney', 'active': false });
  24383. * // => objects for ['fred', 'pebbles']
  24384. *
  24385. * // The `_.matchesProperty` iteratee shorthand.
  24386. * _.dropWhile(users, ['active', false]);
  24387. * // => objects for ['pebbles']
  24388. *
  24389. * // The `_.property` iteratee shorthand.
  24390. * _.dropWhile(users, 'active');
  24391. * // => objects for ['barney', 'fred', 'pebbles']
  24392. */
  24393. function dropWhile(array, predicate) {
  24394. return (array && array.length)
  24395. ? baseWhile(array, getIteratee(predicate, 3), true)
  24396. : [];
  24397. }
  24398. /**
  24399. * Fills elements of `array` with `value` from `start` up to, but not
  24400. * including, `end`.
  24401. *
  24402. * **Note:** This method mutates `array`.
  24403. *
  24404. * @static
  24405. * @memberOf _
  24406. * @since 3.2.0
  24407. * @category Array
  24408. * @param {Array} array The array to fill.
  24409. * @param {*} value The value to fill `array` with.
  24410. * @param {number} [start=0] The start position.
  24411. * @param {number} [end=array.length] The end position.
  24412. * @returns {Array} Returns `array`.
  24413. * @example
  24414. *
  24415. * var array = [1, 2, 3];
  24416. *
  24417. * _.fill(array, 'a');
  24418. * console.log(array);
  24419. * // => ['a', 'a', 'a']
  24420. *
  24421. * _.fill(Array(3), 2);
  24422. * // => [2, 2, 2]
  24423. *
  24424. * _.fill([4, 6, 8, 10], '*', 1, 3);
  24425. * // => [4, '*', '*', 10]
  24426. */
  24427. function fill(array, value, start, end) {
  24428. var length = array == null ? 0 : array.length;
  24429. if (!length) {
  24430. return [];
  24431. }
  24432. if (start && typeof start != 'number' && isIterateeCall(array, value, start)) {
  24433. start = 0;
  24434. end = length;
  24435. }
  24436. return baseFill(array, value, start, end);
  24437. }
  24438. /**
  24439. * This method is like `_.find` except that it returns the index of the first
  24440. * element `predicate` returns truthy for instead of the element itself.
  24441. *
  24442. * @static
  24443. * @memberOf _
  24444. * @since 1.1.0
  24445. * @category Array
  24446. * @param {Array} array The array to inspect.
  24447. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  24448. * @param {number} [fromIndex=0] The index to search from.
  24449. * @returns {number} Returns the index of the found element, else `-1`.
  24450. * @example
  24451. *
  24452. * var users = [
  24453. * { 'user': 'barney', 'active': false },
  24454. * { 'user': 'fred', 'active': false },
  24455. * { 'user': 'pebbles', 'active': true }
  24456. * ];
  24457. *
  24458. * _.findIndex(users, function(o) { return o.user == 'barney'; });
  24459. * // => 0
  24460. *
  24461. * // The `_.matches` iteratee shorthand.
  24462. * _.findIndex(users, { 'user': 'fred', 'active': false });
  24463. * // => 1
  24464. *
  24465. * // The `_.matchesProperty` iteratee shorthand.
  24466. * _.findIndex(users, ['active', false]);
  24467. * // => 0
  24468. *
  24469. * // The `_.property` iteratee shorthand.
  24470. * _.findIndex(users, 'active');
  24471. * // => 2
  24472. */
  24473. function findIndex(array, predicate, fromIndex) {
  24474. var length = array == null ? 0 : array.length;
  24475. if (!length) {
  24476. return -1;
  24477. }
  24478. var index = fromIndex == null ? 0 : toInteger(fromIndex);
  24479. if (index < 0) {
  24480. index = nativeMax(length + index, 0);
  24481. }
  24482. return baseFindIndex(array, getIteratee(predicate, 3), index);
  24483. }
  24484. /**
  24485. * This method is like `_.findIndex` except that it iterates over elements
  24486. * of `collection` from right to left.
  24487. *
  24488. * @static
  24489. * @memberOf _
  24490. * @since 2.0.0
  24491. * @category Array
  24492. * @param {Array} array The array to inspect.
  24493. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  24494. * @param {number} [fromIndex=array.length-1] The index to search from.
  24495. * @returns {number} Returns the index of the found element, else `-1`.
  24496. * @example
  24497. *
  24498. * var users = [
  24499. * { 'user': 'barney', 'active': true },
  24500. * { 'user': 'fred', 'active': false },
  24501. * { 'user': 'pebbles', 'active': false }
  24502. * ];
  24503. *
  24504. * _.findLastIndex(users, function(o) { return o.user == 'pebbles'; });
  24505. * // => 2
  24506. *
  24507. * // The `_.matches` iteratee shorthand.
  24508. * _.findLastIndex(users, { 'user': 'barney', 'active': true });
  24509. * // => 0
  24510. *
  24511. * // The `_.matchesProperty` iteratee shorthand.
  24512. * _.findLastIndex(users, ['active', false]);
  24513. * // => 2
  24514. *
  24515. * // The `_.property` iteratee shorthand.
  24516. * _.findLastIndex(users, 'active');
  24517. * // => 0
  24518. */
  24519. function findLastIndex(array, predicate, fromIndex) {
  24520. var length = array == null ? 0 : array.length;
  24521. if (!length) {
  24522. return -1;
  24523. }
  24524. var index = length - 1;
  24525. if (fromIndex !== undefined) {
  24526. index = toInteger(fromIndex);
  24527. index = fromIndex < 0
  24528. ? nativeMax(length + index, 0)
  24529. : nativeMin(index, length - 1);
  24530. }
  24531. return baseFindIndex(array, getIteratee(predicate, 3), index, true);
  24532. }
  24533. /**
  24534. * Flattens `array` a single level deep.
  24535. *
  24536. * @static
  24537. * @memberOf _
  24538. * @since 0.1.0
  24539. * @category Array
  24540. * @param {Array} array The array to flatten.
  24541. * @returns {Array} Returns the new flattened array.
  24542. * @example
  24543. *
  24544. * _.flatten([1, [2, [3, [4]], 5]]);
  24545. * // => [1, 2, [3, [4]], 5]
  24546. */
  24547. function flatten(array) {
  24548. var length = array == null ? 0 : array.length;
  24549. return length ? baseFlatten(array, 1) : [];
  24550. }
  24551. /**
  24552. * Recursively flattens `array`.
  24553. *
  24554. * @static
  24555. * @memberOf _
  24556. * @since 3.0.0
  24557. * @category Array
  24558. * @param {Array} array The array to flatten.
  24559. * @returns {Array} Returns the new flattened array.
  24560. * @example
  24561. *
  24562. * _.flattenDeep([1, [2, [3, [4]], 5]]);
  24563. * // => [1, 2, 3, 4, 5]
  24564. */
  24565. function flattenDeep(array) {
  24566. var length = array == null ? 0 : array.length;
  24567. return length ? baseFlatten(array, INFINITY) : [];
  24568. }
  24569. /**
  24570. * Recursively flatten `array` up to `depth` times.
  24571. *
  24572. * @static
  24573. * @memberOf _
  24574. * @since 4.4.0
  24575. * @category Array
  24576. * @param {Array} array The array to flatten.
  24577. * @param {number} [depth=1] The maximum recursion depth.
  24578. * @returns {Array} Returns the new flattened array.
  24579. * @example
  24580. *
  24581. * var array = [1, [2, [3, [4]], 5]];
  24582. *
  24583. * _.flattenDepth(array, 1);
  24584. * // => [1, 2, [3, [4]], 5]
  24585. *
  24586. * _.flattenDepth(array, 2);
  24587. * // => [1, 2, 3, [4], 5]
  24588. */
  24589. function flattenDepth(array, depth) {
  24590. var length = array == null ? 0 : array.length;
  24591. if (!length) {
  24592. return [];
  24593. }
  24594. depth = depth === undefined ? 1 : toInteger(depth);
  24595. return baseFlatten(array, depth);
  24596. }
  24597. /**
  24598. * The inverse of `_.toPairs`; this method returns an object composed
  24599. * from key-value `pairs`.
  24600. *
  24601. * @static
  24602. * @memberOf _
  24603. * @since 4.0.0
  24604. * @category Array
  24605. * @param {Array} pairs The key-value pairs.
  24606. * @returns {Object} Returns the new object.
  24607. * @example
  24608. *
  24609. * _.fromPairs([['a', 1], ['b', 2]]);
  24610. * // => { 'a': 1, 'b': 2 }
  24611. */
  24612. function fromPairs(pairs) {
  24613. var index = -1,
  24614. length = pairs == null ? 0 : pairs.length,
  24615. result = {};
  24616. while (++index < length) {
  24617. var pair = pairs[index];
  24618. result[pair[0]] = pair[1];
  24619. }
  24620. return result;
  24621. }
  24622. /**
  24623. * Gets the first element of `array`.
  24624. *
  24625. * @static
  24626. * @memberOf _
  24627. * @since 0.1.0
  24628. * @alias first
  24629. * @category Array
  24630. * @param {Array} array The array to query.
  24631. * @returns {*} Returns the first element of `array`.
  24632. * @example
  24633. *
  24634. * _.head([1, 2, 3]);
  24635. * // => 1
  24636. *
  24637. * _.head([]);
  24638. * // => undefined
  24639. */
  24640. function head(array) {
  24641. return (array && array.length) ? array[0] : undefined;
  24642. }
  24643. /**
  24644. * Gets the index at which the first occurrence of `value` is found in `array`
  24645. * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  24646. * for equality comparisons. If `fromIndex` is negative, it's used as the
  24647. * offset from the end of `array`.
  24648. *
  24649. * @static
  24650. * @memberOf _
  24651. * @since 0.1.0
  24652. * @category Array
  24653. * @param {Array} array The array to inspect.
  24654. * @param {*} value The value to search for.
  24655. * @param {number} [fromIndex=0] The index to search from.
  24656. * @returns {number} Returns the index of the matched value, else `-1`.
  24657. * @example
  24658. *
  24659. * _.indexOf([1, 2, 1, 2], 2);
  24660. * // => 1
  24661. *
  24662. * // Search from the `fromIndex`.
  24663. * _.indexOf([1, 2, 1, 2], 2, 2);
  24664. * // => 3
  24665. */
  24666. function indexOf(array, value, fromIndex) {
  24667. var length = array == null ? 0 : array.length;
  24668. if (!length) {
  24669. return -1;
  24670. }
  24671. var index = fromIndex == null ? 0 : toInteger(fromIndex);
  24672. if (index < 0) {
  24673. index = nativeMax(length + index, 0);
  24674. }
  24675. return baseIndexOf(array, value, index);
  24676. }
  24677. /**
  24678. * Gets all but the last element of `array`.
  24679. *
  24680. * @static
  24681. * @memberOf _
  24682. * @since 0.1.0
  24683. * @category Array
  24684. * @param {Array} array The array to query.
  24685. * @returns {Array} Returns the slice of `array`.
  24686. * @example
  24687. *
  24688. * _.initial([1, 2, 3]);
  24689. * // => [1, 2]
  24690. */
  24691. function initial(array) {
  24692. var length = array == null ? 0 : array.length;
  24693. return length ? baseSlice(array, 0, -1) : [];
  24694. }
  24695. /**
  24696. * Creates an array of unique values that are included in all given arrays
  24697. * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  24698. * for equality comparisons. The order and references of result values are
  24699. * determined by the first array.
  24700. *
  24701. * @static
  24702. * @memberOf _
  24703. * @since 0.1.0
  24704. * @category Array
  24705. * @param {...Array} [arrays] The arrays to inspect.
  24706. * @returns {Array} Returns the new array of intersecting values.
  24707. * @example
  24708. *
  24709. * _.intersection([2, 1], [2, 3]);
  24710. * // => [2]
  24711. */
  24712. var intersection = baseRest(function(arrays) {
  24713. var mapped = arrayMap(arrays, castArrayLikeObject);
  24714. return (mapped.length && mapped[0] === arrays[0])
  24715. ? baseIntersection(mapped)
  24716. : [];
  24717. });
  24718. /**
  24719. * This method is like `_.intersection` except that it accepts `iteratee`
  24720. * which is invoked for each element of each `arrays` to generate the criterion
  24721. * by which they're compared. The order and references of result values are
  24722. * determined by the first array. The iteratee is invoked with one argument:
  24723. * (value).
  24724. *
  24725. * @static
  24726. * @memberOf _
  24727. * @since 4.0.0
  24728. * @category Array
  24729. * @param {...Array} [arrays] The arrays to inspect.
  24730. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  24731. * @returns {Array} Returns the new array of intersecting values.
  24732. * @example
  24733. *
  24734. * _.intersectionBy([2.1, 1.2], [2.3, 3.4], Math.floor);
  24735. * // => [2.1]
  24736. *
  24737. * // The `_.property` iteratee shorthand.
  24738. * _.intersectionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
  24739. * // => [{ 'x': 1 }]
  24740. */
  24741. var intersectionBy = baseRest(function(arrays) {
  24742. var iteratee = last(arrays),
  24743. mapped = arrayMap(arrays, castArrayLikeObject);
  24744. if (iteratee === last(mapped)) {
  24745. iteratee = undefined;
  24746. } else {
  24747. mapped.pop();
  24748. }
  24749. return (mapped.length && mapped[0] === arrays[0])
  24750. ? baseIntersection(mapped, getIteratee(iteratee, 2))
  24751. : [];
  24752. });
  24753. /**
  24754. * This method is like `_.intersection` except that it accepts `comparator`
  24755. * which is invoked to compare elements of `arrays`. The order and references
  24756. * of result values are determined by the first array. The comparator is
  24757. * invoked with two arguments: (arrVal, othVal).
  24758. *
  24759. * @static
  24760. * @memberOf _
  24761. * @since 4.0.0
  24762. * @category Array
  24763. * @param {...Array} [arrays] The arrays to inspect.
  24764. * @param {Function} [comparator] The comparator invoked per element.
  24765. * @returns {Array} Returns the new array of intersecting values.
  24766. * @example
  24767. *
  24768. * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
  24769. * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }];
  24770. *
  24771. * _.intersectionWith(objects, others, _.isEqual);
  24772. * // => [{ 'x': 1, 'y': 2 }]
  24773. */
  24774. var intersectionWith = baseRest(function(arrays) {
  24775. var comparator = last(arrays),
  24776. mapped = arrayMap(arrays, castArrayLikeObject);
  24777. comparator = typeof comparator == 'function' ? comparator : undefined;
  24778. if (comparator) {
  24779. mapped.pop();
  24780. }
  24781. return (mapped.length && mapped[0] === arrays[0])
  24782. ? baseIntersection(mapped, undefined, comparator)
  24783. : [];
  24784. });
  24785. /**
  24786. * Converts all elements in `array` into a string separated by `separator`.
  24787. *
  24788. * @static
  24789. * @memberOf _
  24790. * @since 4.0.0
  24791. * @category Array
  24792. * @param {Array} array The array to convert.
  24793. * @param {string} [separator=','] The element separator.
  24794. * @returns {string} Returns the joined string.
  24795. * @example
  24796. *
  24797. * _.join(['a', 'b', 'c'], '~');
  24798. * // => 'a~b~c'
  24799. */
  24800. function join(array, separator) {
  24801. return array == null ? '' : nativeJoin.call(array, separator);
  24802. }
  24803. /**
  24804. * Gets the last element of `array`.
  24805. *
  24806. * @static
  24807. * @memberOf _
  24808. * @since 0.1.0
  24809. * @category Array
  24810. * @param {Array} array The array to query.
  24811. * @returns {*} Returns the last element of `array`.
  24812. * @example
  24813. *
  24814. * _.last([1, 2, 3]);
  24815. * // => 3
  24816. */
  24817. function last(array) {
  24818. var length = array == null ? 0 : array.length;
  24819. return length ? array[length - 1] : undefined;
  24820. }
  24821. /**
  24822. * This method is like `_.indexOf` except that it iterates over elements of
  24823. * `array` from right to left.
  24824. *
  24825. * @static
  24826. * @memberOf _
  24827. * @since 0.1.0
  24828. * @category Array
  24829. * @param {Array} array The array to inspect.
  24830. * @param {*} value The value to search for.
  24831. * @param {number} [fromIndex=array.length-1] The index to search from.
  24832. * @returns {number} Returns the index of the matched value, else `-1`.
  24833. * @example
  24834. *
  24835. * _.lastIndexOf([1, 2, 1, 2], 2);
  24836. * // => 3
  24837. *
  24838. * // Search from the `fromIndex`.
  24839. * _.lastIndexOf([1, 2, 1, 2], 2, 2);
  24840. * // => 1
  24841. */
  24842. function lastIndexOf(array, value, fromIndex) {
  24843. var length = array == null ? 0 : array.length;
  24844. if (!length) {
  24845. return -1;
  24846. }
  24847. var index = length;
  24848. if (fromIndex !== undefined) {
  24849. index = toInteger(fromIndex);
  24850. index = index < 0 ? nativeMax(length + index, 0) : nativeMin(index, length - 1);
  24851. }
  24852. return value === value
  24853. ? strictLastIndexOf(array, value, index)
  24854. : baseFindIndex(array, baseIsNaN, index, true);
  24855. }
  24856. /**
  24857. * Gets the element at index `n` of `array`. If `n` is negative, the nth
  24858. * element from the end is returned.
  24859. *
  24860. * @static
  24861. * @memberOf _
  24862. * @since 4.11.0
  24863. * @category Array
  24864. * @param {Array} array The array to query.
  24865. * @param {number} [n=0] The index of the element to return.
  24866. * @returns {*} Returns the nth element of `array`.
  24867. * @example
  24868. *
  24869. * var array = ['a', 'b', 'c', 'd'];
  24870. *
  24871. * _.nth(array, 1);
  24872. * // => 'b'
  24873. *
  24874. * _.nth(array, -2);
  24875. * // => 'c';
  24876. */
  24877. function nth(array, n) {
  24878. return (array && array.length) ? baseNth(array, toInteger(n)) : undefined;
  24879. }
  24880. /**
  24881. * Removes all given values from `array` using
  24882. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  24883. * for equality comparisons.
  24884. *
  24885. * **Note:** Unlike `_.without`, this method mutates `array`. Use `_.remove`
  24886. * to remove elements from an array by predicate.
  24887. *
  24888. * @static
  24889. * @memberOf _
  24890. * @since 2.0.0
  24891. * @category Array
  24892. * @param {Array} array The array to modify.
  24893. * @param {...*} [values] The values to remove.
  24894. * @returns {Array} Returns `array`.
  24895. * @example
  24896. *
  24897. * var array = ['a', 'b', 'c', 'a', 'b', 'c'];
  24898. *
  24899. * _.pull(array, 'a', 'c');
  24900. * console.log(array);
  24901. * // => ['b', 'b']
  24902. */
  24903. var pull = baseRest(pullAll);
  24904. /**
  24905. * This method is like `_.pull` except that it accepts an array of values to remove.
  24906. *
  24907. * **Note:** Unlike `_.difference`, this method mutates `array`.
  24908. *
  24909. * @static
  24910. * @memberOf _
  24911. * @since 4.0.0
  24912. * @category Array
  24913. * @param {Array} array The array to modify.
  24914. * @param {Array} values The values to remove.
  24915. * @returns {Array} Returns `array`.
  24916. * @example
  24917. *
  24918. * var array = ['a', 'b', 'c', 'a', 'b', 'c'];
  24919. *
  24920. * _.pullAll(array, ['a', 'c']);
  24921. * console.log(array);
  24922. * // => ['b', 'b']
  24923. */
  24924. function pullAll(array, values) {
  24925. return (array && array.length && values && values.length)
  24926. ? basePullAll(array, values)
  24927. : array;
  24928. }
  24929. /**
  24930. * This method is like `_.pullAll` except that it accepts `iteratee` which is
  24931. * invoked for each element of `array` and `values` to generate the criterion
  24932. * by which they're compared. The iteratee is invoked with one argument: (value).
  24933. *
  24934. * **Note:** Unlike `_.differenceBy`, this method mutates `array`.
  24935. *
  24936. * @static
  24937. * @memberOf _
  24938. * @since 4.0.0
  24939. * @category Array
  24940. * @param {Array} array The array to modify.
  24941. * @param {Array} values The values to remove.
  24942. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  24943. * @returns {Array} Returns `array`.
  24944. * @example
  24945. *
  24946. * var array = [{ 'x': 1 }, { 'x': 2 }, { 'x': 3 }, { 'x': 1 }];
  24947. *
  24948. * _.pullAllBy(array, [{ 'x': 1 }, { 'x': 3 }], 'x');
  24949. * console.log(array);
  24950. * // => [{ 'x': 2 }]
  24951. */
  24952. function pullAllBy(array, values, iteratee) {
  24953. return (array && array.length && values && values.length)
  24954. ? basePullAll(array, values, getIteratee(iteratee, 2))
  24955. : array;
  24956. }
  24957. /**
  24958. * This method is like `_.pullAll` except that it accepts `comparator` which
  24959. * is invoked to compare elements of `array` to `values`. The comparator is
  24960. * invoked with two arguments: (arrVal, othVal).
  24961. *
  24962. * **Note:** Unlike `_.differenceWith`, this method mutates `array`.
  24963. *
  24964. * @static
  24965. * @memberOf _
  24966. * @since 4.6.0
  24967. * @category Array
  24968. * @param {Array} array The array to modify.
  24969. * @param {Array} values The values to remove.
  24970. * @param {Function} [comparator] The comparator invoked per element.
  24971. * @returns {Array} Returns `array`.
  24972. * @example
  24973. *
  24974. * var array = [{ 'x': 1, 'y': 2 }, { 'x': 3, 'y': 4 }, { 'x': 5, 'y': 6 }];
  24975. *
  24976. * _.pullAllWith(array, [{ 'x': 3, 'y': 4 }], _.isEqual);
  24977. * console.log(array);
  24978. * // => [{ 'x': 1, 'y': 2 }, { 'x': 5, 'y': 6 }]
  24979. */
  24980. function pullAllWith(array, values, comparator) {
  24981. return (array && array.length && values && values.length)
  24982. ? basePullAll(array, values, undefined, comparator)
  24983. : array;
  24984. }
  24985. /**
  24986. * Removes elements from `array` corresponding to `indexes` and returns an
  24987. * array of removed elements.
  24988. *
  24989. * **Note:** Unlike `_.at`, this method mutates `array`.
  24990. *
  24991. * @static
  24992. * @memberOf _
  24993. * @since 3.0.0
  24994. * @category Array
  24995. * @param {Array} array The array to modify.
  24996. * @param {...(number|number[])} [indexes] The indexes of elements to remove.
  24997. * @returns {Array} Returns the new array of removed elements.
  24998. * @example
  24999. *
  25000. * var array = ['a', 'b', 'c', 'd'];
  25001. * var pulled = _.pullAt(array, [1, 3]);
  25002. *
  25003. * console.log(array);
  25004. * // => ['a', 'c']
  25005. *
  25006. * console.log(pulled);
  25007. * // => ['b', 'd']
  25008. */
  25009. var pullAt = flatRest(function(array, indexes) {
  25010. var length = array == null ? 0 : array.length,
  25011. result = baseAt(array, indexes);
  25012. basePullAt(array, arrayMap(indexes, function(index) {
  25013. return isIndex(index, length) ? +index : index;
  25014. }).sort(compareAscending));
  25015. return result;
  25016. });
  25017. /**
  25018. * Removes all elements from `array` that `predicate` returns truthy for
  25019. * and returns an array of the removed elements. The predicate is invoked
  25020. * with three arguments: (value, index, array).
  25021. *
  25022. * **Note:** Unlike `_.filter`, this method mutates `array`. Use `_.pull`
  25023. * to pull elements from an array by value.
  25024. *
  25025. * @static
  25026. * @memberOf _
  25027. * @since 2.0.0
  25028. * @category Array
  25029. * @param {Array} array The array to modify.
  25030. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  25031. * @returns {Array} Returns the new array of removed elements.
  25032. * @example
  25033. *
  25034. * var array = [1, 2, 3, 4];
  25035. * var evens = _.remove(array, function(n) {
  25036. * return n % 2 == 0;
  25037. * });
  25038. *
  25039. * console.log(array);
  25040. * // => [1, 3]
  25041. *
  25042. * console.log(evens);
  25043. * // => [2, 4]
  25044. */
  25045. function remove(array, predicate) {
  25046. var result = [];
  25047. if (!(array && array.length)) {
  25048. return result;
  25049. }
  25050. var index = -1,
  25051. indexes = [],
  25052. length = array.length;
  25053. predicate = getIteratee(predicate, 3);
  25054. while (++index < length) {
  25055. var value = array[index];
  25056. if (predicate(value, index, array)) {
  25057. result.push(value);
  25058. indexes.push(index);
  25059. }
  25060. }
  25061. basePullAt(array, indexes);
  25062. return result;
  25063. }
  25064. /**
  25065. * Reverses `array` so that the first element becomes the last, the second
  25066. * element becomes the second to last, and so on.
  25067. *
  25068. * **Note:** This method mutates `array` and is based on
  25069. * [`Array#reverse`](https://mdn.io/Array/reverse).
  25070. *
  25071. * @static
  25072. * @memberOf _
  25073. * @since 4.0.0
  25074. * @category Array
  25075. * @param {Array} array The array to modify.
  25076. * @returns {Array} Returns `array`.
  25077. * @example
  25078. *
  25079. * var array = [1, 2, 3];
  25080. *
  25081. * _.reverse(array);
  25082. * // => [3, 2, 1]
  25083. *
  25084. * console.log(array);
  25085. * // => [3, 2, 1]
  25086. */
  25087. function reverse(array) {
  25088. return array == null ? array : nativeReverse.call(array);
  25089. }
  25090. /**
  25091. * Creates a slice of `array` from `start` up to, but not including, `end`.
  25092. *
  25093. * **Note:** This method is used instead of
  25094. * [`Array#slice`](https://mdn.io/Array/slice) to ensure dense arrays are
  25095. * returned.
  25096. *
  25097. * @static
  25098. * @memberOf _
  25099. * @since 3.0.0
  25100. * @category Array
  25101. * @param {Array} array The array to slice.
  25102. * @param {number} [start=0] The start position.
  25103. * @param {number} [end=array.length] The end position.
  25104. * @returns {Array} Returns the slice of `array`.
  25105. */
  25106. function slice(array, start, end) {
  25107. var length = array == null ? 0 : array.length;
  25108. if (!length) {
  25109. return [];
  25110. }
  25111. if (end && typeof end != 'number' && isIterateeCall(array, start, end)) {
  25112. start = 0;
  25113. end = length;
  25114. }
  25115. else {
  25116. start = start == null ? 0 : toInteger(start);
  25117. end = end === undefined ? length : toInteger(end);
  25118. }
  25119. return baseSlice(array, start, end);
  25120. }
  25121. /**
  25122. * Uses a binary search to determine the lowest index at which `value`
  25123. * should be inserted into `array` in order to maintain its sort order.
  25124. *
  25125. * @static
  25126. * @memberOf _
  25127. * @since 0.1.0
  25128. * @category Array
  25129. * @param {Array} array The sorted array to inspect.
  25130. * @param {*} value The value to evaluate.
  25131. * @returns {number} Returns the index at which `value` should be inserted
  25132. * into `array`.
  25133. * @example
  25134. *
  25135. * _.sortedIndex([30, 50], 40);
  25136. * // => 1
  25137. */
  25138. function sortedIndex(array, value) {
  25139. return baseSortedIndex(array, value);
  25140. }
  25141. /**
  25142. * This method is like `_.sortedIndex` except that it accepts `iteratee`
  25143. * which is invoked for `value` and each element of `array` to compute their
  25144. * sort ranking. The iteratee is invoked with one argument: (value).
  25145. *
  25146. * @static
  25147. * @memberOf _
  25148. * @since 4.0.0
  25149. * @category Array
  25150. * @param {Array} array The sorted array to inspect.
  25151. * @param {*} value The value to evaluate.
  25152. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  25153. * @returns {number} Returns the index at which `value` should be inserted
  25154. * into `array`.
  25155. * @example
  25156. *
  25157. * var objects = [{ 'x': 4 }, { 'x': 5 }];
  25158. *
  25159. * _.sortedIndexBy(objects, { 'x': 4 }, function(o) { return o.x; });
  25160. * // => 0
  25161. *
  25162. * // The `_.property` iteratee shorthand.
  25163. * _.sortedIndexBy(objects, { 'x': 4 }, 'x');
  25164. * // => 0
  25165. */
  25166. function sortedIndexBy(array, value, iteratee) {
  25167. return baseSortedIndexBy(array, value, getIteratee(iteratee, 2));
  25168. }
  25169. /**
  25170. * This method is like `_.indexOf` except that it performs a binary
  25171. * search on a sorted `array`.
  25172. *
  25173. * @static
  25174. * @memberOf _
  25175. * @since 4.0.0
  25176. * @category Array
  25177. * @param {Array} array The array to inspect.
  25178. * @param {*} value The value to search for.
  25179. * @returns {number} Returns the index of the matched value, else `-1`.
  25180. * @example
  25181. *
  25182. * _.sortedIndexOf([4, 5, 5, 5, 6], 5);
  25183. * // => 1
  25184. */
  25185. function sortedIndexOf(array, value) {
  25186. var length = array == null ? 0 : array.length;
  25187. if (length) {
  25188. var index = baseSortedIndex(array, value);
  25189. if (index < length && eq(array[index], value)) {
  25190. return index;
  25191. }
  25192. }
  25193. return -1;
  25194. }
  25195. /**
  25196. * This method is like `_.sortedIndex` except that it returns the highest
  25197. * index at which `value` should be inserted into `array` in order to
  25198. * maintain its sort order.
  25199. *
  25200. * @static
  25201. * @memberOf _
  25202. * @since 3.0.0
  25203. * @category Array
  25204. * @param {Array} array The sorted array to inspect.
  25205. * @param {*} value The value to evaluate.
  25206. * @returns {number} Returns the index at which `value` should be inserted
  25207. * into `array`.
  25208. * @example
  25209. *
  25210. * _.sortedLastIndex([4, 5, 5, 5, 6], 5);
  25211. * // => 4
  25212. */
  25213. function sortedLastIndex(array, value) {
  25214. return baseSortedIndex(array, value, true);
  25215. }
  25216. /**
  25217. * This method is like `_.sortedLastIndex` except that it accepts `iteratee`
  25218. * which is invoked for `value` and each element of `array` to compute their
  25219. * sort ranking. The iteratee is invoked with one argument: (value).
  25220. *
  25221. * @static
  25222. * @memberOf _
  25223. * @since 4.0.0
  25224. * @category Array
  25225. * @param {Array} array The sorted array to inspect.
  25226. * @param {*} value The value to evaluate.
  25227. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  25228. * @returns {number} Returns the index at which `value` should be inserted
  25229. * into `array`.
  25230. * @example
  25231. *
  25232. * var objects = [{ 'x': 4 }, { 'x': 5 }];
  25233. *
  25234. * _.sortedLastIndexBy(objects, { 'x': 4 }, function(o) { return o.x; });
  25235. * // => 1
  25236. *
  25237. * // The `_.property` iteratee shorthand.
  25238. * _.sortedLastIndexBy(objects, { 'x': 4 }, 'x');
  25239. * // => 1
  25240. */
  25241. function sortedLastIndexBy(array, value, iteratee) {
  25242. return baseSortedIndexBy(array, value, getIteratee(iteratee, 2), true);
  25243. }
  25244. /**
  25245. * This method is like `_.lastIndexOf` except that it performs a binary
  25246. * search on a sorted `array`.
  25247. *
  25248. * @static
  25249. * @memberOf _
  25250. * @since 4.0.0
  25251. * @category Array
  25252. * @param {Array} array The array to inspect.
  25253. * @param {*} value The value to search for.
  25254. * @returns {number} Returns the index of the matched value, else `-1`.
  25255. * @example
  25256. *
  25257. * _.sortedLastIndexOf([4, 5, 5, 5, 6], 5);
  25258. * // => 3
  25259. */
  25260. function sortedLastIndexOf(array, value) {
  25261. var length = array == null ? 0 : array.length;
  25262. if (length) {
  25263. var index = baseSortedIndex(array, value, true) - 1;
  25264. if (eq(array[index], value)) {
  25265. return index;
  25266. }
  25267. }
  25268. return -1;
  25269. }
  25270. /**
  25271. * This method is like `_.uniq` except that it's designed and optimized
  25272. * for sorted arrays.
  25273. *
  25274. * @static
  25275. * @memberOf _
  25276. * @since 4.0.0
  25277. * @category Array
  25278. * @param {Array} array The array to inspect.
  25279. * @returns {Array} Returns the new duplicate free array.
  25280. * @example
  25281. *
  25282. * _.sortedUniq([1, 1, 2]);
  25283. * // => [1, 2]
  25284. */
  25285. function sortedUniq(array) {
  25286. return (array && array.length)
  25287. ? baseSortedUniq(array)
  25288. : [];
  25289. }
  25290. /**
  25291. * This method is like `_.uniqBy` except that it's designed and optimized
  25292. * for sorted arrays.
  25293. *
  25294. * @static
  25295. * @memberOf _
  25296. * @since 4.0.0
  25297. * @category Array
  25298. * @param {Array} array The array to inspect.
  25299. * @param {Function} [iteratee] The iteratee invoked per element.
  25300. * @returns {Array} Returns the new duplicate free array.
  25301. * @example
  25302. *
  25303. * _.sortedUniqBy([1.1, 1.2, 2.3, 2.4], Math.floor);
  25304. * // => [1.1, 2.3]
  25305. */
  25306. function sortedUniqBy(array, iteratee) {
  25307. return (array && array.length)
  25308. ? baseSortedUniq(array, getIteratee(iteratee, 2))
  25309. : [];
  25310. }
  25311. /**
  25312. * Gets all but the first element of `array`.
  25313. *
  25314. * @static
  25315. * @memberOf _
  25316. * @since 4.0.0
  25317. * @category Array
  25318. * @param {Array} array The array to query.
  25319. * @returns {Array} Returns the slice of `array`.
  25320. * @example
  25321. *
  25322. * _.tail([1, 2, 3]);
  25323. * // => [2, 3]
  25324. */
  25325. function tail(array) {
  25326. var length = array == null ? 0 : array.length;
  25327. return length ? baseSlice(array, 1, length) : [];
  25328. }
  25329. /**
  25330. * Creates a slice of `array` with `n` elements taken from the beginning.
  25331. *
  25332. * @static
  25333. * @memberOf _
  25334. * @since 0.1.0
  25335. * @category Array
  25336. * @param {Array} array The array to query.
  25337. * @param {number} [n=1] The number of elements to take.
  25338. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  25339. * @returns {Array} Returns the slice of `array`.
  25340. * @example
  25341. *
  25342. * _.take([1, 2, 3]);
  25343. * // => [1]
  25344. *
  25345. * _.take([1, 2, 3], 2);
  25346. * // => [1, 2]
  25347. *
  25348. * _.take([1, 2, 3], 5);
  25349. * // => [1, 2, 3]
  25350. *
  25351. * _.take([1, 2, 3], 0);
  25352. * // => []
  25353. */
  25354. function take(array, n, guard) {
  25355. if (!(array && array.length)) {
  25356. return [];
  25357. }
  25358. n = (guard || n === undefined) ? 1 : toInteger(n);
  25359. return baseSlice(array, 0, n < 0 ? 0 : n);
  25360. }
  25361. /**
  25362. * Creates a slice of `array` with `n` elements taken from the end.
  25363. *
  25364. * @static
  25365. * @memberOf _
  25366. * @since 3.0.0
  25367. * @category Array
  25368. * @param {Array} array The array to query.
  25369. * @param {number} [n=1] The number of elements to take.
  25370. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  25371. * @returns {Array} Returns the slice of `array`.
  25372. * @example
  25373. *
  25374. * _.takeRight([1, 2, 3]);
  25375. * // => [3]
  25376. *
  25377. * _.takeRight([1, 2, 3], 2);
  25378. * // => [2, 3]
  25379. *
  25380. * _.takeRight([1, 2, 3], 5);
  25381. * // => [1, 2, 3]
  25382. *
  25383. * _.takeRight([1, 2, 3], 0);
  25384. * // => []
  25385. */
  25386. function takeRight(array, n, guard) {
  25387. var length = array == null ? 0 : array.length;
  25388. if (!length) {
  25389. return [];
  25390. }
  25391. n = (guard || n === undefined) ? 1 : toInteger(n);
  25392. n = length - n;
  25393. return baseSlice(array, n < 0 ? 0 : n, length);
  25394. }
  25395. /**
  25396. * Creates a slice of `array` with elements taken from the end. Elements are
  25397. * taken until `predicate` returns falsey. The predicate is invoked with
  25398. * three arguments: (value, index, array).
  25399. *
  25400. * @static
  25401. * @memberOf _
  25402. * @since 3.0.0
  25403. * @category Array
  25404. * @param {Array} array The array to query.
  25405. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  25406. * @returns {Array} Returns the slice of `array`.
  25407. * @example
  25408. *
  25409. * var users = [
  25410. * { 'user': 'barney', 'active': true },
  25411. * { 'user': 'fred', 'active': false },
  25412. * { 'user': 'pebbles', 'active': false }
  25413. * ];
  25414. *
  25415. * _.takeRightWhile(users, function(o) { return !o.active; });
  25416. * // => objects for ['fred', 'pebbles']
  25417. *
  25418. * // The `_.matches` iteratee shorthand.
  25419. * _.takeRightWhile(users, { 'user': 'pebbles', 'active': false });
  25420. * // => objects for ['pebbles']
  25421. *
  25422. * // The `_.matchesProperty` iteratee shorthand.
  25423. * _.takeRightWhile(users, ['active', false]);
  25424. * // => objects for ['fred', 'pebbles']
  25425. *
  25426. * // The `_.property` iteratee shorthand.
  25427. * _.takeRightWhile(users, 'active');
  25428. * // => []
  25429. */
  25430. function takeRightWhile(array, predicate) {
  25431. return (array && array.length)
  25432. ? baseWhile(array, getIteratee(predicate, 3), false, true)
  25433. : [];
  25434. }
  25435. /**
  25436. * Creates a slice of `array` with elements taken from the beginning. Elements
  25437. * are taken until `predicate` returns falsey. The predicate is invoked with
  25438. * three arguments: (value, index, array).
  25439. *
  25440. * @static
  25441. * @memberOf _
  25442. * @since 3.0.0
  25443. * @category Array
  25444. * @param {Array} array The array to query.
  25445. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  25446. * @returns {Array} Returns the slice of `array`.
  25447. * @example
  25448. *
  25449. * var users = [
  25450. * { 'user': 'barney', 'active': false },
  25451. * { 'user': 'fred', 'active': false },
  25452. * { 'user': 'pebbles', 'active': true }
  25453. * ];
  25454. *
  25455. * _.takeWhile(users, function(o) { return !o.active; });
  25456. * // => objects for ['barney', 'fred']
  25457. *
  25458. * // The `_.matches` iteratee shorthand.
  25459. * _.takeWhile(users, { 'user': 'barney', 'active': false });
  25460. * // => objects for ['barney']
  25461. *
  25462. * // The `_.matchesProperty` iteratee shorthand.
  25463. * _.takeWhile(users, ['active', false]);
  25464. * // => objects for ['barney', 'fred']
  25465. *
  25466. * // The `_.property` iteratee shorthand.
  25467. * _.takeWhile(users, 'active');
  25468. * // => []
  25469. */
  25470. function takeWhile(array, predicate) {
  25471. return (array && array.length)
  25472. ? baseWhile(array, getIteratee(predicate, 3))
  25473. : [];
  25474. }
  25475. /**
  25476. * Creates an array of unique values, in order, from all given arrays using
  25477. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  25478. * for equality comparisons.
  25479. *
  25480. * @static
  25481. * @memberOf _
  25482. * @since 0.1.0
  25483. * @category Array
  25484. * @param {...Array} [arrays] The arrays to inspect.
  25485. * @returns {Array} Returns the new array of combined values.
  25486. * @example
  25487. *
  25488. * _.union([2], [1, 2]);
  25489. * // => [2, 1]
  25490. */
  25491. var union = baseRest(function(arrays) {
  25492. return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true));
  25493. });
  25494. /**
  25495. * This method is like `_.union` except that it accepts `iteratee` which is
  25496. * invoked for each element of each `arrays` to generate the criterion by
  25497. * which uniqueness is computed. Result values are chosen from the first
  25498. * array in which the value occurs. The iteratee is invoked with one argument:
  25499. * (value).
  25500. *
  25501. * @static
  25502. * @memberOf _
  25503. * @since 4.0.0
  25504. * @category Array
  25505. * @param {...Array} [arrays] The arrays to inspect.
  25506. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  25507. * @returns {Array} Returns the new array of combined values.
  25508. * @example
  25509. *
  25510. * _.unionBy([2.1], [1.2, 2.3], Math.floor);
  25511. * // => [2.1, 1.2]
  25512. *
  25513. * // The `_.property` iteratee shorthand.
  25514. * _.unionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
  25515. * // => [{ 'x': 1 }, { 'x': 2 }]
  25516. */
  25517. var unionBy = baseRest(function(arrays) {
  25518. var iteratee = last(arrays);
  25519. if (isArrayLikeObject(iteratee)) {
  25520. iteratee = undefined;
  25521. }
  25522. return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true), getIteratee(iteratee, 2));
  25523. });
  25524. /**
  25525. * This method is like `_.union` except that it accepts `comparator` which
  25526. * is invoked to compare elements of `arrays`. Result values are chosen from
  25527. * the first array in which the value occurs. The comparator is invoked
  25528. * with two arguments: (arrVal, othVal).
  25529. *
  25530. * @static
  25531. * @memberOf _
  25532. * @since 4.0.0
  25533. * @category Array
  25534. * @param {...Array} [arrays] The arrays to inspect.
  25535. * @param {Function} [comparator] The comparator invoked per element.
  25536. * @returns {Array} Returns the new array of combined values.
  25537. * @example
  25538. *
  25539. * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
  25540. * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }];
  25541. *
  25542. * _.unionWith(objects, others, _.isEqual);
  25543. * // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 1 }]
  25544. */
  25545. var unionWith = baseRest(function(arrays) {
  25546. var comparator = last(arrays);
  25547. comparator = typeof comparator == 'function' ? comparator : undefined;
  25548. return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true), undefined, comparator);
  25549. });
  25550. /**
  25551. * Creates a duplicate-free version of an array, using
  25552. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  25553. * for equality comparisons, in which only the first occurrence of each element
  25554. * is kept. The order of result values is determined by the order they occur
  25555. * in the array.
  25556. *
  25557. * @static
  25558. * @memberOf _
  25559. * @since 0.1.0
  25560. * @category Array
  25561. * @param {Array} array The array to inspect.
  25562. * @returns {Array} Returns the new duplicate free array.
  25563. * @example
  25564. *
  25565. * _.uniq([2, 1, 2]);
  25566. * // => [2, 1]
  25567. */
  25568. function uniq(array) {
  25569. return (array && array.length) ? baseUniq(array) : [];
  25570. }
  25571. /**
  25572. * This method is like `_.uniq` except that it accepts `iteratee` which is
  25573. * invoked for each element in `array` to generate the criterion by which
  25574. * uniqueness is computed. The order of result values is determined by the
  25575. * order they occur in the array. The iteratee is invoked with one argument:
  25576. * (value).
  25577. *
  25578. * @static
  25579. * @memberOf _
  25580. * @since 4.0.0
  25581. * @category Array
  25582. * @param {Array} array The array to inspect.
  25583. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  25584. * @returns {Array} Returns the new duplicate free array.
  25585. * @example
  25586. *
  25587. * _.uniqBy([2.1, 1.2, 2.3], Math.floor);
  25588. * // => [2.1, 1.2]
  25589. *
  25590. * // The `_.property` iteratee shorthand.
  25591. * _.uniqBy([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x');
  25592. * // => [{ 'x': 1 }, { 'x': 2 }]
  25593. */
  25594. function uniqBy(array, iteratee) {
  25595. return (array && array.length) ? baseUniq(array, getIteratee(iteratee, 2)) : [];
  25596. }
  25597. /**
  25598. * This method is like `_.uniq` except that it accepts `comparator` which
  25599. * is invoked to compare elements of `array`. The order of result values is
  25600. * determined by the order they occur in the array.The comparator is invoked
  25601. * with two arguments: (arrVal, othVal).
  25602. *
  25603. * @static
  25604. * @memberOf _
  25605. * @since 4.0.0
  25606. * @category Array
  25607. * @param {Array} array The array to inspect.
  25608. * @param {Function} [comparator] The comparator invoked per element.
  25609. * @returns {Array} Returns the new duplicate free array.
  25610. * @example
  25611. *
  25612. * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 2 }];
  25613. *
  25614. * _.uniqWith(objects, _.isEqual);
  25615. * // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]
  25616. */
  25617. function uniqWith(array, comparator) {
  25618. comparator = typeof comparator == 'function' ? comparator : undefined;
  25619. return (array && array.length) ? baseUniq(array, undefined, comparator) : [];
  25620. }
  25621. /**
  25622. * This method is like `_.zip` except that it accepts an array of grouped
  25623. * elements and creates an array regrouping the elements to their pre-zip
  25624. * configuration.
  25625. *
  25626. * @static
  25627. * @memberOf _
  25628. * @since 1.2.0
  25629. * @category Array
  25630. * @param {Array} array The array of grouped elements to process.
  25631. * @returns {Array} Returns the new array of regrouped elements.
  25632. * @example
  25633. *
  25634. * var zipped = _.zip(['a', 'b'], [1, 2], [true, false]);
  25635. * // => [['a', 1, true], ['b', 2, false]]
  25636. *
  25637. * _.unzip(zipped);
  25638. * // => [['a', 'b'], [1, 2], [true, false]]
  25639. */
  25640. function unzip(array) {
  25641. if (!(array && array.length)) {
  25642. return [];
  25643. }
  25644. var length = 0;
  25645. array = arrayFilter(array, function(group) {
  25646. if (isArrayLikeObject(group)) {
  25647. length = nativeMax(group.length, length);
  25648. return true;
  25649. }
  25650. });
  25651. return baseTimes(length, function(index) {
  25652. return arrayMap(array, baseProperty(index));
  25653. });
  25654. }
  25655. /**
  25656. * This method is like `_.unzip` except that it accepts `iteratee` to specify
  25657. * how regrouped values should be combined. The iteratee is invoked with the
  25658. * elements of each group: (...group).
  25659. *
  25660. * @static
  25661. * @memberOf _
  25662. * @since 3.8.0
  25663. * @category Array
  25664. * @param {Array} array The array of grouped elements to process.
  25665. * @param {Function} [iteratee=_.identity] The function to combine
  25666. * regrouped values.
  25667. * @returns {Array} Returns the new array of regrouped elements.
  25668. * @example
  25669. *
  25670. * var zipped = _.zip([1, 2], [10, 20], [100, 200]);
  25671. * // => [[1, 10, 100], [2, 20, 200]]
  25672. *
  25673. * _.unzipWith(zipped, _.add);
  25674. * // => [3, 30, 300]
  25675. */
  25676. function unzipWith(array, iteratee) {
  25677. if (!(array && array.length)) {
  25678. return [];
  25679. }
  25680. var result = unzip(array);
  25681. if (iteratee == null) {
  25682. return result;
  25683. }
  25684. return arrayMap(result, function(group) {
  25685. return apply(iteratee, undefined, group);
  25686. });
  25687. }
  25688. /**
  25689. * Creates an array excluding all given values using
  25690. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  25691. * for equality comparisons.
  25692. *
  25693. * **Note:** Unlike `_.pull`, this method returns a new array.
  25694. *
  25695. * @static
  25696. * @memberOf _
  25697. * @since 0.1.0
  25698. * @category Array
  25699. * @param {Array} array The array to inspect.
  25700. * @param {...*} [values] The values to exclude.
  25701. * @returns {Array} Returns the new array of filtered values.
  25702. * @see _.difference, _.xor
  25703. * @example
  25704. *
  25705. * _.without([2, 1, 2, 3], 1, 2);
  25706. * // => [3]
  25707. */
  25708. var without = baseRest(function(array, values) {
  25709. return isArrayLikeObject(array)
  25710. ? baseDifference(array, values)
  25711. : [];
  25712. });
  25713. /**
  25714. * Creates an array of unique values that is the
  25715. * [symmetric difference](https://en.wikipedia.org/wiki/Symmetric_difference)
  25716. * of the given arrays. The order of result values is determined by the order
  25717. * they occur in the arrays.
  25718. *
  25719. * @static
  25720. * @memberOf _
  25721. * @since 2.4.0
  25722. * @category Array
  25723. * @param {...Array} [arrays] The arrays to inspect.
  25724. * @returns {Array} Returns the new array of filtered values.
  25725. * @see _.difference, _.without
  25726. * @example
  25727. *
  25728. * _.xor([2, 1], [2, 3]);
  25729. * // => [1, 3]
  25730. */
  25731. var xor = baseRest(function(arrays) {
  25732. return baseXor(arrayFilter(arrays, isArrayLikeObject));
  25733. });
  25734. /**
  25735. * This method is like `_.xor` except that it accepts `iteratee` which is
  25736. * invoked for each element of each `arrays` to generate the criterion by
  25737. * which by which they're compared. The order of result values is determined
  25738. * by the order they occur in the arrays. The iteratee is invoked with one
  25739. * argument: (value).
  25740. *
  25741. * @static
  25742. * @memberOf _
  25743. * @since 4.0.0
  25744. * @category Array
  25745. * @param {...Array} [arrays] The arrays to inspect.
  25746. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  25747. * @returns {Array} Returns the new array of filtered values.
  25748. * @example
  25749. *
  25750. * _.xorBy([2.1, 1.2], [2.3, 3.4], Math.floor);
  25751. * // => [1.2, 3.4]
  25752. *
  25753. * // The `_.property` iteratee shorthand.
  25754. * _.xorBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
  25755. * // => [{ 'x': 2 }]
  25756. */
  25757. var xorBy = baseRest(function(arrays) {
  25758. var iteratee = last(arrays);
  25759. if (isArrayLikeObject(iteratee)) {
  25760. iteratee = undefined;
  25761. }
  25762. return baseXor(arrayFilter(arrays, isArrayLikeObject), getIteratee(iteratee, 2));
  25763. });
  25764. /**
  25765. * This method is like `_.xor` except that it accepts `comparator` which is
  25766. * invoked to compare elements of `arrays`. The order of result values is
  25767. * determined by the order they occur in the arrays. The comparator is invoked
  25768. * with two arguments: (arrVal, othVal).
  25769. *
  25770. * @static
  25771. * @memberOf _
  25772. * @since 4.0.0
  25773. * @category Array
  25774. * @param {...Array} [arrays] The arrays to inspect.
  25775. * @param {Function} [comparator] The comparator invoked per element.
  25776. * @returns {Array} Returns the new array of filtered values.
  25777. * @example
  25778. *
  25779. * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
  25780. * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }];
  25781. *
  25782. * _.xorWith(objects, others, _.isEqual);
  25783. * // => [{ 'x': 2, 'y': 1 }, { 'x': 1, 'y': 1 }]
  25784. */
  25785. var xorWith = baseRest(function(arrays) {
  25786. var comparator = last(arrays);
  25787. comparator = typeof comparator == 'function' ? comparator : undefined;
  25788. return baseXor(arrayFilter(arrays, isArrayLikeObject), undefined, comparator);
  25789. });
  25790. /**
  25791. * Creates an array of grouped elements, the first of which contains the
  25792. * first elements of the given arrays, the second of which contains the
  25793. * second elements of the given arrays, and so on.
  25794. *
  25795. * @static
  25796. * @memberOf _
  25797. * @since 0.1.0
  25798. * @category Array
  25799. * @param {...Array} [arrays] The arrays to process.
  25800. * @returns {Array} Returns the new array of grouped elements.
  25801. * @example
  25802. *
  25803. * _.zip(['a', 'b'], [1, 2], [true, false]);
  25804. * // => [['a', 1, true], ['b', 2, false]]
  25805. */
  25806. var zip = baseRest(unzip);
  25807. /**
  25808. * This method is like `_.fromPairs` except that it accepts two arrays,
  25809. * one of property identifiers and one of corresponding values.
  25810. *
  25811. * @static
  25812. * @memberOf _
  25813. * @since 0.4.0
  25814. * @category Array
  25815. * @param {Array} [props=[]] The property identifiers.
  25816. * @param {Array} [values=[]] The property values.
  25817. * @returns {Object} Returns the new object.
  25818. * @example
  25819. *
  25820. * _.zipObject(['a', 'b'], [1, 2]);
  25821. * // => { 'a': 1, 'b': 2 }
  25822. */
  25823. function zipObject(props, values) {
  25824. return baseZipObject(props || [], values || [], assignValue);
  25825. }
  25826. /**
  25827. * This method is like `_.zipObject` except that it supports property paths.
  25828. *
  25829. * @static
  25830. * @memberOf _
  25831. * @since 4.1.0
  25832. * @category Array
  25833. * @param {Array} [props=[]] The property identifiers.
  25834. * @param {Array} [values=[]] The property values.
  25835. * @returns {Object} Returns the new object.
  25836. * @example
  25837. *
  25838. * _.zipObjectDeep(['a.b[0].c', 'a.b[1].d'], [1, 2]);
  25839. * // => { 'a': { 'b': [{ 'c': 1 }, { 'd': 2 }] } }
  25840. */
  25841. function zipObjectDeep(props, values) {
  25842. return baseZipObject(props || [], values || [], baseSet);
  25843. }
  25844. /**
  25845. * This method is like `_.zip` except that it accepts `iteratee` to specify
  25846. * how grouped values should be combined. The iteratee is invoked with the
  25847. * elements of each group: (...group).
  25848. *
  25849. * @static
  25850. * @memberOf _
  25851. * @since 3.8.0
  25852. * @category Array
  25853. * @param {...Array} [arrays] The arrays to process.
  25854. * @param {Function} [iteratee=_.identity] The function to combine
  25855. * grouped values.
  25856. * @returns {Array} Returns the new array of grouped elements.
  25857. * @example
  25858. *
  25859. * _.zipWith([1, 2], [10, 20], [100, 200], function(a, b, c) {
  25860. * return a + b + c;
  25861. * });
  25862. * // => [111, 222]
  25863. */
  25864. var zipWith = baseRest(function(arrays) {
  25865. var length = arrays.length,
  25866. iteratee = length > 1 ? arrays[length - 1] : undefined;
  25867. iteratee = typeof iteratee == 'function' ? (arrays.pop(), iteratee) : undefined;
  25868. return unzipWith(arrays, iteratee);
  25869. });
  25870. /*------------------------------------------------------------------------*/
  25871. /**
  25872. * Creates a `lodash` wrapper instance that wraps `value` with explicit method
  25873. * chain sequences enabled. The result of such sequences must be unwrapped
  25874. * with `_#value`.
  25875. *
  25876. * @static
  25877. * @memberOf _
  25878. * @since 1.3.0
  25879. * @category Seq
  25880. * @param {*} value The value to wrap.
  25881. * @returns {Object} Returns the new `lodash` wrapper instance.
  25882. * @example
  25883. *
  25884. * var users = [
  25885. * { 'user': 'barney', 'age': 36 },
  25886. * { 'user': 'fred', 'age': 40 },
  25887. * { 'user': 'pebbles', 'age': 1 }
  25888. * ];
  25889. *
  25890. * var youngest = _
  25891. * .chain(users)
  25892. * .sortBy('age')
  25893. * .map(function(o) {
  25894. * return o.user + ' is ' + o.age;
  25895. * })
  25896. * .head()
  25897. * .value();
  25898. * // => 'pebbles is 1'
  25899. */
  25900. function chain(value) {
  25901. var result = lodash(value);
  25902. result.__chain__ = true;
  25903. return result;
  25904. }
  25905. /**
  25906. * This method invokes `interceptor` and returns `value`. The interceptor
  25907. * is invoked with one argument; (value). The purpose of this method is to
  25908. * "tap into" a method chain sequence in order to modify intermediate results.
  25909. *
  25910. * @static
  25911. * @memberOf _
  25912. * @since 0.1.0
  25913. * @category Seq
  25914. * @param {*} value The value to provide to `interceptor`.
  25915. * @param {Function} interceptor The function to invoke.
  25916. * @returns {*} Returns `value`.
  25917. * @example
  25918. *
  25919. * _([1, 2, 3])
  25920. * .tap(function(array) {
  25921. * // Mutate input array.
  25922. * array.pop();
  25923. * })
  25924. * .reverse()
  25925. * .value();
  25926. * // => [2, 1]
  25927. */
  25928. function tap(value, interceptor) {
  25929. interceptor(value);
  25930. return value;
  25931. }
  25932. /**
  25933. * This method is like `_.tap` except that it returns the result of `interceptor`.
  25934. * The purpose of this method is to "pass thru" values replacing intermediate
  25935. * results in a method chain sequence.
  25936. *
  25937. * @static
  25938. * @memberOf _
  25939. * @since 3.0.0
  25940. * @category Seq
  25941. * @param {*} value The value to provide to `interceptor`.
  25942. * @param {Function} interceptor The function to invoke.
  25943. * @returns {*} Returns the result of `interceptor`.
  25944. * @example
  25945. *
  25946. * _(' abc ')
  25947. * .chain()
  25948. * .trim()
  25949. * .thru(function(value) {
  25950. * return [value];
  25951. * })
  25952. * .value();
  25953. * // => ['abc']
  25954. */
  25955. function thru(value, interceptor) {
  25956. return interceptor(value);
  25957. }
  25958. /**
  25959. * This method is the wrapper version of `_.at`.
  25960. *
  25961. * @name at
  25962. * @memberOf _
  25963. * @since 1.0.0
  25964. * @category Seq
  25965. * @param {...(string|string[])} [paths] The property paths to pick.
  25966. * @returns {Object} Returns the new `lodash` wrapper instance.
  25967. * @example
  25968. *
  25969. * var object = { 'a': [{ 'b': { 'c': 3 } }, 4] };
  25970. *
  25971. * _(object).at(['a[0].b.c', 'a[1]']).value();
  25972. * // => [3, 4]
  25973. */
  25974. var wrapperAt = flatRest(function(paths) {
  25975. var length = paths.length,
  25976. start = length ? paths[0] : 0,
  25977. value = this.__wrapped__,
  25978. interceptor = function(object) { return baseAt(object, paths); };
  25979. if (length > 1 || this.__actions__.length ||
  25980. !(value instanceof LazyWrapper) || !isIndex(start)) {
  25981. return this.thru(interceptor);
  25982. }
  25983. value = value.slice(start, +start + (length ? 1 : 0));
  25984. value.__actions__.push({
  25985. 'func': thru,
  25986. 'args': [interceptor],
  25987. 'thisArg': undefined
  25988. });
  25989. return new LodashWrapper(value, this.__chain__).thru(function(array) {
  25990. if (length && !array.length) {
  25991. array.push(undefined);
  25992. }
  25993. return array;
  25994. });
  25995. });
  25996. /**
  25997. * Creates a `lodash` wrapper instance with explicit method chain sequences enabled.
  25998. *
  25999. * @name chain
  26000. * @memberOf _
  26001. * @since 0.1.0
  26002. * @category Seq
  26003. * @returns {Object} Returns the new `lodash` wrapper instance.
  26004. * @example
  26005. *
  26006. * var users = [
  26007. * { 'user': 'barney', 'age': 36 },
  26008. * { 'user': 'fred', 'age': 40 }
  26009. * ];
  26010. *
  26011. * // A sequence without explicit chaining.
  26012. * _(users).head();
  26013. * // => { 'user': 'barney', 'age': 36 }
  26014. *
  26015. * // A sequence with explicit chaining.
  26016. * _(users)
  26017. * .chain()
  26018. * .head()
  26019. * .pick('user')
  26020. * .value();
  26021. * // => { 'user': 'barney' }
  26022. */
  26023. function wrapperChain() {
  26024. return chain(this);
  26025. }
  26026. /**
  26027. * Executes the chain sequence and returns the wrapped result.
  26028. *
  26029. * @name commit
  26030. * @memberOf _
  26031. * @since 3.2.0
  26032. * @category Seq
  26033. * @returns {Object} Returns the new `lodash` wrapper instance.
  26034. * @example
  26035. *
  26036. * var array = [1, 2];
  26037. * var wrapped = _(array).push(3);
  26038. *
  26039. * console.log(array);
  26040. * // => [1, 2]
  26041. *
  26042. * wrapped = wrapped.commit();
  26043. * console.log(array);
  26044. * // => [1, 2, 3]
  26045. *
  26046. * wrapped.last();
  26047. * // => 3
  26048. *
  26049. * console.log(array);
  26050. * // => [1, 2, 3]
  26051. */
  26052. function wrapperCommit() {
  26053. return new LodashWrapper(this.value(), this.__chain__);
  26054. }
  26055. /**
  26056. * Gets the next value on a wrapped object following the
  26057. * [iterator protocol](https://mdn.io/iteration_protocols#iterator).
  26058. *
  26059. * @name next
  26060. * @memberOf _
  26061. * @since 4.0.0
  26062. * @category Seq
  26063. * @returns {Object} Returns the next iterator value.
  26064. * @example
  26065. *
  26066. * var wrapped = _([1, 2]);
  26067. *
  26068. * wrapped.next();
  26069. * // => { 'done': false, 'value': 1 }
  26070. *
  26071. * wrapped.next();
  26072. * // => { 'done': false, 'value': 2 }
  26073. *
  26074. * wrapped.next();
  26075. * // => { 'done': true, 'value': undefined }
  26076. */
  26077. function wrapperNext() {
  26078. if (this.__values__ === undefined) {
  26079. this.__values__ = toArray(this.value());
  26080. }
  26081. var done = this.__index__ >= this.__values__.length,
  26082. value = done ? undefined : this.__values__[this.__index__++];
  26083. return { 'done': done, 'value': value };
  26084. }
  26085. /**
  26086. * Enables the wrapper to be iterable.
  26087. *
  26088. * @name Symbol.iterator
  26089. * @memberOf _
  26090. * @since 4.0.0
  26091. * @category Seq
  26092. * @returns {Object} Returns the wrapper object.
  26093. * @example
  26094. *
  26095. * var wrapped = _([1, 2]);
  26096. *
  26097. * wrapped[Symbol.iterator]() === wrapped;
  26098. * // => true
  26099. *
  26100. * Array.from(wrapped);
  26101. * // => [1, 2]
  26102. */
  26103. function wrapperToIterator() {
  26104. return this;
  26105. }
  26106. /**
  26107. * Creates a clone of the chain sequence planting `value` as the wrapped value.
  26108. *
  26109. * @name plant
  26110. * @memberOf _
  26111. * @since 3.2.0
  26112. * @category Seq
  26113. * @param {*} value The value to plant.
  26114. * @returns {Object} Returns the new `lodash` wrapper instance.
  26115. * @example
  26116. *
  26117. * function square(n) {
  26118. * return n * n;
  26119. * }
  26120. *
  26121. * var wrapped = _([1, 2]).map(square);
  26122. * var other = wrapped.plant([3, 4]);
  26123. *
  26124. * other.value();
  26125. * // => [9, 16]
  26126. *
  26127. * wrapped.value();
  26128. * // => [1, 4]
  26129. */
  26130. function wrapperPlant(value) {
  26131. var result,
  26132. parent = this;
  26133. while (parent instanceof baseLodash) {
  26134. var clone = wrapperClone(parent);
  26135. clone.__index__ = 0;
  26136. clone.__values__ = undefined;
  26137. if (result) {
  26138. previous.__wrapped__ = clone;
  26139. } else {
  26140. result = clone;
  26141. }
  26142. var previous = clone;
  26143. parent = parent.__wrapped__;
  26144. }
  26145. previous.__wrapped__ = value;
  26146. return result;
  26147. }
  26148. /**
  26149. * This method is the wrapper version of `_.reverse`.
  26150. *
  26151. * **Note:** This method mutates the wrapped array.
  26152. *
  26153. * @name reverse
  26154. * @memberOf _
  26155. * @since 0.1.0
  26156. * @category Seq
  26157. * @returns {Object} Returns the new `lodash` wrapper instance.
  26158. * @example
  26159. *
  26160. * var array = [1, 2, 3];
  26161. *
  26162. * _(array).reverse().value()
  26163. * // => [3, 2, 1]
  26164. *
  26165. * console.log(array);
  26166. * // => [3, 2, 1]
  26167. */
  26168. function wrapperReverse() {
  26169. var value = this.__wrapped__;
  26170. if (value instanceof LazyWrapper) {
  26171. var wrapped = value;
  26172. if (this.__actions__.length) {
  26173. wrapped = new LazyWrapper(this);
  26174. }
  26175. wrapped = wrapped.reverse();
  26176. wrapped.__actions__.push({
  26177. 'func': thru,
  26178. 'args': [reverse],
  26179. 'thisArg': undefined
  26180. });
  26181. return new LodashWrapper(wrapped, this.__chain__);
  26182. }
  26183. return this.thru(reverse);
  26184. }
  26185. /**
  26186. * Executes the chain sequence to resolve the unwrapped value.
  26187. *
  26188. * @name value
  26189. * @memberOf _
  26190. * @since 0.1.0
  26191. * @alias toJSON, valueOf
  26192. * @category Seq
  26193. * @returns {*} Returns the resolved unwrapped value.
  26194. * @example
  26195. *
  26196. * _([1, 2, 3]).value();
  26197. * // => [1, 2, 3]
  26198. */
  26199. function wrapperValue() {
  26200. return baseWrapperValue(this.__wrapped__, this.__actions__);
  26201. }
  26202. /*------------------------------------------------------------------------*/
  26203. /**
  26204. * Creates an object composed of keys generated from the results of running
  26205. * each element of `collection` thru `iteratee`. The corresponding value of
  26206. * each key is the number of times the key was returned by `iteratee`. The
  26207. * iteratee is invoked with one argument: (value).
  26208. *
  26209. * @static
  26210. * @memberOf _
  26211. * @since 0.5.0
  26212. * @category Collection
  26213. * @param {Array|Object} collection The collection to iterate over.
  26214. * @param {Function} [iteratee=_.identity] The iteratee to transform keys.
  26215. * @returns {Object} Returns the composed aggregate object.
  26216. * @example
  26217. *
  26218. * _.countBy([6.1, 4.2, 6.3], Math.floor);
  26219. * // => { '4': 1, '6': 2 }
  26220. *
  26221. * // The `_.property` iteratee shorthand.
  26222. * _.countBy(['one', 'two', 'three'], 'length');
  26223. * // => { '3': 2, '5': 1 }
  26224. */
  26225. var countBy = createAggregator(function(result, value, key) {
  26226. if (hasOwnProperty.call(result, key)) {
  26227. ++result[key];
  26228. } else {
  26229. baseAssignValue(result, key, 1);
  26230. }
  26231. });
  26232. /**
  26233. * Checks if `predicate` returns truthy for **all** elements of `collection`.
  26234. * Iteration is stopped once `predicate` returns falsey. The predicate is
  26235. * invoked with three arguments: (value, index|key, collection).
  26236. *
  26237. * **Note:** This method returns `true` for
  26238. * [empty collections](https://en.wikipedia.org/wiki/Empty_set) because
  26239. * [everything is true](https://en.wikipedia.org/wiki/Vacuous_truth) of
  26240. * elements of empty collections.
  26241. *
  26242. * @static
  26243. * @memberOf _
  26244. * @since 0.1.0
  26245. * @category Collection
  26246. * @param {Array|Object} collection The collection to iterate over.
  26247. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  26248. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  26249. * @returns {boolean} Returns `true` if all elements pass the predicate check,
  26250. * else `false`.
  26251. * @example
  26252. *
  26253. * _.every([true, 1, null, 'yes'], Boolean);
  26254. * // => false
  26255. *
  26256. * var users = [
  26257. * { 'user': 'barney', 'age': 36, 'active': false },
  26258. * { 'user': 'fred', 'age': 40, 'active': false }
  26259. * ];
  26260. *
  26261. * // The `_.matches` iteratee shorthand.
  26262. * _.every(users, { 'user': 'barney', 'active': false });
  26263. * // => false
  26264. *
  26265. * // The `_.matchesProperty` iteratee shorthand.
  26266. * _.every(users, ['active', false]);
  26267. * // => true
  26268. *
  26269. * // The `_.property` iteratee shorthand.
  26270. * _.every(users, 'active');
  26271. * // => false
  26272. */
  26273. function every(collection, predicate, guard) {
  26274. var func = isArray(collection) ? arrayEvery : baseEvery;
  26275. if (guard && isIterateeCall(collection, predicate, guard)) {
  26276. predicate = undefined;
  26277. }
  26278. return func(collection, getIteratee(predicate, 3));
  26279. }
  26280. /**
  26281. * Iterates over elements of `collection`, returning an array of all elements
  26282. * `predicate` returns truthy for. The predicate is invoked with three
  26283. * arguments: (value, index|key, collection).
  26284. *
  26285. * **Note:** Unlike `_.remove`, this method returns a new array.
  26286. *
  26287. * @static
  26288. * @memberOf _
  26289. * @since 0.1.0
  26290. * @category Collection
  26291. * @param {Array|Object} collection The collection to iterate over.
  26292. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  26293. * @returns {Array} Returns the new filtered array.
  26294. * @see _.reject
  26295. * @example
  26296. *
  26297. * var users = [
  26298. * { 'user': 'barney', 'age': 36, 'active': true },
  26299. * { 'user': 'fred', 'age': 40, 'active': false }
  26300. * ];
  26301. *
  26302. * _.filter(users, function(o) { return !o.active; });
  26303. * // => objects for ['fred']
  26304. *
  26305. * // The `_.matches` iteratee shorthand.
  26306. * _.filter(users, { 'age': 36, 'active': true });
  26307. * // => objects for ['barney']
  26308. *
  26309. * // The `_.matchesProperty` iteratee shorthand.
  26310. * _.filter(users, ['active', false]);
  26311. * // => objects for ['fred']
  26312. *
  26313. * // The `_.property` iteratee shorthand.
  26314. * _.filter(users, 'active');
  26315. * // => objects for ['barney']
  26316. */
  26317. function filter(collection, predicate) {
  26318. var func = isArray(collection) ? arrayFilter : baseFilter;
  26319. return func(collection, getIteratee(predicate, 3));
  26320. }
  26321. /**
  26322. * Iterates over elements of `collection`, returning the first element
  26323. * `predicate` returns truthy for. The predicate is invoked with three
  26324. * arguments: (value, index|key, collection).
  26325. *
  26326. * @static
  26327. * @memberOf _
  26328. * @since 0.1.0
  26329. * @category Collection
  26330. * @param {Array|Object} collection The collection to inspect.
  26331. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  26332. * @param {number} [fromIndex=0] The index to search from.
  26333. * @returns {*} Returns the matched element, else `undefined`.
  26334. * @example
  26335. *
  26336. * var users = [
  26337. * { 'user': 'barney', 'age': 36, 'active': true },
  26338. * { 'user': 'fred', 'age': 40, 'active': false },
  26339. * { 'user': 'pebbles', 'age': 1, 'active': true }
  26340. * ];
  26341. *
  26342. * _.find(users, function(o) { return o.age < 40; });
  26343. * // => object for 'barney'
  26344. *
  26345. * // The `_.matches` iteratee shorthand.
  26346. * _.find(users, { 'age': 1, 'active': true });
  26347. * // => object for 'pebbles'
  26348. *
  26349. * // The `_.matchesProperty` iteratee shorthand.
  26350. * _.find(users, ['active', false]);
  26351. * // => object for 'fred'
  26352. *
  26353. * // The `_.property` iteratee shorthand.
  26354. * _.find(users, 'active');
  26355. * // => object for 'barney'
  26356. */
  26357. var find = createFind(findIndex);
  26358. /**
  26359. * This method is like `_.find` except that it iterates over elements of
  26360. * `collection` from right to left.
  26361. *
  26362. * @static
  26363. * @memberOf _
  26364. * @since 2.0.0
  26365. * @category Collection
  26366. * @param {Array|Object} collection The collection to inspect.
  26367. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  26368. * @param {number} [fromIndex=collection.length-1] The index to search from.
  26369. * @returns {*} Returns the matched element, else `undefined`.
  26370. * @example
  26371. *
  26372. * _.findLast([1, 2, 3, 4], function(n) {
  26373. * return n % 2 == 1;
  26374. * });
  26375. * // => 3
  26376. */
  26377. var findLast = createFind(findLastIndex);
  26378. /**
  26379. * Creates a flattened array of values by running each element in `collection`
  26380. * thru `iteratee` and flattening the mapped results. The iteratee is invoked
  26381. * with three arguments: (value, index|key, collection).
  26382. *
  26383. * @static
  26384. * @memberOf _
  26385. * @since 4.0.0
  26386. * @category Collection
  26387. * @param {Array|Object} collection The collection to iterate over.
  26388. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  26389. * @returns {Array} Returns the new flattened array.
  26390. * @example
  26391. *
  26392. * function duplicate(n) {
  26393. * return [n, n];
  26394. * }
  26395. *
  26396. * _.flatMap([1, 2], duplicate);
  26397. * // => [1, 1, 2, 2]
  26398. */
  26399. function flatMap(collection, iteratee) {
  26400. return baseFlatten(map(collection, iteratee), 1);
  26401. }
  26402. /**
  26403. * This method is like `_.flatMap` except that it recursively flattens the
  26404. * mapped results.
  26405. *
  26406. * @static
  26407. * @memberOf _
  26408. * @since 4.7.0
  26409. * @category Collection
  26410. * @param {Array|Object} collection The collection to iterate over.
  26411. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  26412. * @returns {Array} Returns the new flattened array.
  26413. * @example
  26414. *
  26415. * function duplicate(n) {
  26416. * return [[[n, n]]];
  26417. * }
  26418. *
  26419. * _.flatMapDeep([1, 2], duplicate);
  26420. * // => [1, 1, 2, 2]
  26421. */
  26422. function flatMapDeep(collection, iteratee) {
  26423. return baseFlatten(map(collection, iteratee), INFINITY);
  26424. }
  26425. /**
  26426. * This method is like `_.flatMap` except that it recursively flattens the
  26427. * mapped results up to `depth` times.
  26428. *
  26429. * @static
  26430. * @memberOf _
  26431. * @since 4.7.0
  26432. * @category Collection
  26433. * @param {Array|Object} collection The collection to iterate over.
  26434. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  26435. * @param {number} [depth=1] The maximum recursion depth.
  26436. * @returns {Array} Returns the new flattened array.
  26437. * @example
  26438. *
  26439. * function duplicate(n) {
  26440. * return [[[n, n]]];
  26441. * }
  26442. *
  26443. * _.flatMapDepth([1, 2], duplicate, 2);
  26444. * // => [[1, 1], [2, 2]]
  26445. */
  26446. function flatMapDepth(collection, iteratee, depth) {
  26447. depth = depth === undefined ? 1 : toInteger(depth);
  26448. return baseFlatten(map(collection, iteratee), depth);
  26449. }
  26450. /**
  26451. * Iterates over elements of `collection` and invokes `iteratee` for each element.
  26452. * The iteratee is invoked with three arguments: (value, index|key, collection).
  26453. * Iteratee functions may exit iteration early by explicitly returning `false`.
  26454. *
  26455. * **Note:** As with other "Collections" methods, objects with a "length"
  26456. * property are iterated like arrays. To avoid this behavior use `_.forIn`
  26457. * or `_.forOwn` for object iteration.
  26458. *
  26459. * @static
  26460. * @memberOf _
  26461. * @since 0.1.0
  26462. * @alias each
  26463. * @category Collection
  26464. * @param {Array|Object} collection The collection to iterate over.
  26465. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  26466. * @returns {Array|Object} Returns `collection`.
  26467. * @see _.forEachRight
  26468. * @example
  26469. *
  26470. * _.forEach([1, 2], function(value) {
  26471. * console.log(value);
  26472. * });
  26473. * // => Logs `1` then `2`.
  26474. *
  26475. * _.forEach({ 'a': 1, 'b': 2 }, function(value, key) {
  26476. * console.log(key);
  26477. * });
  26478. * // => Logs 'a' then 'b' (iteration order is not guaranteed).
  26479. */
  26480. function forEach(collection, iteratee) {
  26481. var func = isArray(collection) ? arrayEach : baseEach;
  26482. return func(collection, getIteratee(iteratee, 3));
  26483. }
  26484. /**
  26485. * This method is like `_.forEach` except that it iterates over elements of
  26486. * `collection` from right to left.
  26487. *
  26488. * @static
  26489. * @memberOf _
  26490. * @since 2.0.0
  26491. * @alias eachRight
  26492. * @category Collection
  26493. * @param {Array|Object} collection The collection to iterate over.
  26494. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  26495. * @returns {Array|Object} Returns `collection`.
  26496. * @see _.forEach
  26497. * @example
  26498. *
  26499. * _.forEachRight([1, 2], function(value) {
  26500. * console.log(value);
  26501. * });
  26502. * // => Logs `2` then `1`.
  26503. */
  26504. function forEachRight(collection, iteratee) {
  26505. var func = isArray(collection) ? arrayEachRight : baseEachRight;
  26506. return func(collection, getIteratee(iteratee, 3));
  26507. }
  26508. /**
  26509. * Creates an object composed of keys generated from the results of running
  26510. * each element of `collection` thru `iteratee`. The order of grouped values
  26511. * is determined by the order they occur in `collection`. The corresponding
  26512. * value of each key is an array of elements responsible for generating the
  26513. * key. The iteratee is invoked with one argument: (value).
  26514. *
  26515. * @static
  26516. * @memberOf _
  26517. * @since 0.1.0
  26518. * @category Collection
  26519. * @param {Array|Object} collection The collection to iterate over.
  26520. * @param {Function} [iteratee=_.identity] The iteratee to transform keys.
  26521. * @returns {Object} Returns the composed aggregate object.
  26522. * @example
  26523. *
  26524. * _.groupBy([6.1, 4.2, 6.3], Math.floor);
  26525. * // => { '4': [4.2], '6': [6.1, 6.3] }
  26526. *
  26527. * // The `_.property` iteratee shorthand.
  26528. * _.groupBy(['one', 'two', 'three'], 'length');
  26529. * // => { '3': ['one', 'two'], '5': ['three'] }
  26530. */
  26531. var groupBy = createAggregator(function(result, value, key) {
  26532. if (hasOwnProperty.call(result, key)) {
  26533. result[key].push(value);
  26534. } else {
  26535. baseAssignValue(result, key, [value]);
  26536. }
  26537. });
  26538. /**
  26539. * Checks if `value` is in `collection`. If `collection` is a string, it's
  26540. * checked for a substring of `value`, otherwise
  26541. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  26542. * is used for equality comparisons. If `fromIndex` is negative, it's used as
  26543. * the offset from the end of `collection`.
  26544. *
  26545. * @static
  26546. * @memberOf _
  26547. * @since 0.1.0
  26548. * @category Collection
  26549. * @param {Array|Object|string} collection The collection to inspect.
  26550. * @param {*} value The value to search for.
  26551. * @param {number} [fromIndex=0] The index to search from.
  26552. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.reduce`.
  26553. * @returns {boolean} Returns `true` if `value` is found, else `false`.
  26554. * @example
  26555. *
  26556. * _.includes([1, 2, 3], 1);
  26557. * // => true
  26558. *
  26559. * _.includes([1, 2, 3], 1, 2);
  26560. * // => false
  26561. *
  26562. * _.includes({ 'a': 1, 'b': 2 }, 1);
  26563. * // => true
  26564. *
  26565. * _.includes('abcd', 'bc');
  26566. * // => true
  26567. */
  26568. function includes(collection, value, fromIndex, guard) {
  26569. collection = isArrayLike(collection) ? collection : values(collection);
  26570. fromIndex = (fromIndex && !guard) ? toInteger(fromIndex) : 0;
  26571. var length = collection.length;
  26572. if (fromIndex < 0) {
  26573. fromIndex = nativeMax(length + fromIndex, 0);
  26574. }
  26575. return isString(collection)
  26576. ? (fromIndex <= length && collection.indexOf(value, fromIndex) > -1)
  26577. : (!!length && baseIndexOf(collection, value, fromIndex) > -1);
  26578. }
  26579. /**
  26580. * Invokes the method at `path` of each element in `collection`, returning
  26581. * an array of the results of each invoked method. Any additional arguments
  26582. * are provided to each invoked method. If `path` is a function, it's invoked
  26583. * for, and `this` bound to, each element in `collection`.
  26584. *
  26585. * @static
  26586. * @memberOf _
  26587. * @since 4.0.0
  26588. * @category Collection
  26589. * @param {Array|Object} collection The collection to iterate over.
  26590. * @param {Array|Function|string} path The path of the method to invoke or
  26591. * the function invoked per iteration.
  26592. * @param {...*} [args] The arguments to invoke each method with.
  26593. * @returns {Array} Returns the array of results.
  26594. * @example
  26595. *
  26596. * _.invokeMap([[5, 1, 7], [3, 2, 1]], 'sort');
  26597. * // => [[1, 5, 7], [1, 2, 3]]
  26598. *
  26599. * _.invokeMap([123, 456], String.prototype.split, '');
  26600. * // => [['1', '2', '3'], ['4', '5', '6']]
  26601. */
  26602. var invokeMap = baseRest(function(collection, path, args) {
  26603. var index = -1,
  26604. isFunc = typeof path == 'function',
  26605. result = isArrayLike(collection) ? Array(collection.length) : [];
  26606. baseEach(collection, function(value) {
  26607. result[++index] = isFunc ? apply(path, value, args) : baseInvoke(value, path, args);
  26608. });
  26609. return result;
  26610. });
  26611. /**
  26612. * Creates an object composed of keys generated from the results of running
  26613. * each element of `collection` thru `iteratee`. The corresponding value of
  26614. * each key is the last element responsible for generating the key. The
  26615. * iteratee is invoked with one argument: (value).
  26616. *
  26617. * @static
  26618. * @memberOf _
  26619. * @since 4.0.0
  26620. * @category Collection
  26621. * @param {Array|Object} collection The collection to iterate over.
  26622. * @param {Function} [iteratee=_.identity] The iteratee to transform keys.
  26623. * @returns {Object} Returns the composed aggregate object.
  26624. * @example
  26625. *
  26626. * var array = [
  26627. * { 'dir': 'left', 'code': 97 },
  26628. * { 'dir': 'right', 'code': 100 }
  26629. * ];
  26630. *
  26631. * _.keyBy(array, function(o) {
  26632. * return String.fromCharCode(o.code);
  26633. * });
  26634. * // => { 'a': { 'dir': 'left', 'code': 97 }, 'd': { 'dir': 'right', 'code': 100 } }
  26635. *
  26636. * _.keyBy(array, 'dir');
  26637. * // => { 'left': { 'dir': 'left', 'code': 97 }, 'right': { 'dir': 'right', 'code': 100 } }
  26638. */
  26639. var keyBy = createAggregator(function(result, value, key) {
  26640. baseAssignValue(result, key, value);
  26641. });
  26642. /**
  26643. * Creates an array of values by running each element in `collection` thru
  26644. * `iteratee`. The iteratee is invoked with three arguments:
  26645. * (value, index|key, collection).
  26646. *
  26647. * Many lodash methods are guarded to work as iteratees for methods like
  26648. * `_.every`, `_.filter`, `_.map`, `_.mapValues`, `_.reject`, and `_.some`.
  26649. *
  26650. * The guarded methods are:
  26651. * `ary`, `chunk`, `curry`, `curryRight`, `drop`, `dropRight`, `every`,
  26652. * `fill`, `invert`, `parseInt`, `random`, `range`, `rangeRight`, `repeat`,
  26653. * `sampleSize`, `slice`, `some`, `sortBy`, `split`, `take`, `takeRight`,
  26654. * `template`, `trim`, `trimEnd`, `trimStart`, and `words`
  26655. *
  26656. * @static
  26657. * @memberOf _
  26658. * @since 0.1.0
  26659. * @category Collection
  26660. * @param {Array|Object} collection The collection to iterate over.
  26661. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  26662. * @returns {Array} Returns the new mapped array.
  26663. * @example
  26664. *
  26665. * function square(n) {
  26666. * return n * n;
  26667. * }
  26668. *
  26669. * _.map([4, 8], square);
  26670. * // => [16, 64]
  26671. *
  26672. * _.map({ 'a': 4, 'b': 8 }, square);
  26673. * // => [16, 64] (iteration order is not guaranteed)
  26674. *
  26675. * var users = [
  26676. * { 'user': 'barney' },
  26677. * { 'user': 'fred' }
  26678. * ];
  26679. *
  26680. * // The `_.property` iteratee shorthand.
  26681. * _.map(users, 'user');
  26682. * // => ['barney', 'fred']
  26683. */
  26684. function map(collection, iteratee) {
  26685. var func = isArray(collection) ? arrayMap : baseMap;
  26686. return func(collection, getIteratee(iteratee, 3));
  26687. }
  26688. /**
  26689. * This method is like `_.sortBy` except that it allows specifying the sort
  26690. * orders of the iteratees to sort by. If `orders` is unspecified, all values
  26691. * are sorted in ascending order. Otherwise, specify an order of "desc" for
  26692. * descending or "asc" for ascending sort order of corresponding values.
  26693. *
  26694. * @static
  26695. * @memberOf _
  26696. * @since 4.0.0
  26697. * @category Collection
  26698. * @param {Array|Object} collection The collection to iterate over.
  26699. * @param {Array[]|Function[]|Object[]|string[]} [iteratees=[_.identity]]
  26700. * The iteratees to sort by.
  26701. * @param {string[]} [orders] The sort orders of `iteratees`.
  26702. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.reduce`.
  26703. * @returns {Array} Returns the new sorted array.
  26704. * @example
  26705. *
  26706. * var users = [
  26707. * { 'user': 'fred', 'age': 48 },
  26708. * { 'user': 'barney', 'age': 34 },
  26709. * { 'user': 'fred', 'age': 40 },
  26710. * { 'user': 'barney', 'age': 36 }
  26711. * ];
  26712. *
  26713. * // Sort by `user` in ascending order and by `age` in descending order.
  26714. * _.orderBy(users, ['user', 'age'], ['asc', 'desc']);
  26715. * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 40]]
  26716. */
  26717. function orderBy(collection, iteratees, orders, guard) {
  26718. if (collection == null) {
  26719. return [];
  26720. }
  26721. if (!isArray(iteratees)) {
  26722. iteratees = iteratees == null ? [] : [iteratees];
  26723. }
  26724. orders = guard ? undefined : orders;
  26725. if (!isArray(orders)) {
  26726. orders = orders == null ? [] : [orders];
  26727. }
  26728. return baseOrderBy(collection, iteratees, orders);
  26729. }
  26730. /**
  26731. * Creates an array of elements split into two groups, the first of which
  26732. * contains elements `predicate` returns truthy for, the second of which
  26733. * contains elements `predicate` returns falsey for. The predicate is
  26734. * invoked with one argument: (value).
  26735. *
  26736. * @static
  26737. * @memberOf _
  26738. * @since 3.0.0
  26739. * @category Collection
  26740. * @param {Array|Object} collection The collection to iterate over.
  26741. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  26742. * @returns {Array} Returns the array of grouped elements.
  26743. * @example
  26744. *
  26745. * var users = [
  26746. * { 'user': 'barney', 'age': 36, 'active': false },
  26747. * { 'user': 'fred', 'age': 40, 'active': true },
  26748. * { 'user': 'pebbles', 'age': 1, 'active': false }
  26749. * ];
  26750. *
  26751. * _.partition(users, function(o) { return o.active; });
  26752. * // => objects for [['fred'], ['barney', 'pebbles']]
  26753. *
  26754. * // The `_.matches` iteratee shorthand.
  26755. * _.partition(users, { 'age': 1, 'active': false });
  26756. * // => objects for [['pebbles'], ['barney', 'fred']]
  26757. *
  26758. * // The `_.matchesProperty` iteratee shorthand.
  26759. * _.partition(users, ['active', false]);
  26760. * // => objects for [['barney', 'pebbles'], ['fred']]
  26761. *
  26762. * // The `_.property` iteratee shorthand.
  26763. * _.partition(users, 'active');
  26764. * // => objects for [['fred'], ['barney', 'pebbles']]
  26765. */
  26766. var partition = createAggregator(function(result, value, key) {
  26767. result[key ? 0 : 1].push(value);
  26768. }, function() { return [[], []]; });
  26769. /**
  26770. * Reduces `collection` to a value which is the accumulated result of running
  26771. * each element in `collection` thru `iteratee`, where each successive
  26772. * invocation is supplied the return value of the previous. If `accumulator`
  26773. * is not given, the first element of `collection` is used as the initial
  26774. * value. The iteratee is invoked with four arguments:
  26775. * (accumulator, value, index|key, collection).
  26776. *
  26777. * Many lodash methods are guarded to work as iteratees for methods like
  26778. * `_.reduce`, `_.reduceRight`, and `_.transform`.
  26779. *
  26780. * The guarded methods are:
  26781. * `assign`, `defaults`, `defaultsDeep`, `includes`, `merge`, `orderBy`,
  26782. * and `sortBy`
  26783. *
  26784. * @static
  26785. * @memberOf _
  26786. * @since 0.1.0
  26787. * @category Collection
  26788. * @param {Array|Object} collection The collection to iterate over.
  26789. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  26790. * @param {*} [accumulator] The initial value.
  26791. * @returns {*} Returns the accumulated value.
  26792. * @see _.reduceRight
  26793. * @example
  26794. *
  26795. * _.reduce([1, 2], function(sum, n) {
  26796. * return sum + n;
  26797. * }, 0);
  26798. * // => 3
  26799. *
  26800. * _.reduce({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) {
  26801. * (result[value] || (result[value] = [])).push(key);
  26802. * return result;
  26803. * }, {});
  26804. * // => { '1': ['a', 'c'], '2': ['b'] } (iteration order is not guaranteed)
  26805. */
  26806. function reduce(collection, iteratee, accumulator) {
  26807. var func = isArray(collection) ? arrayReduce : baseReduce,
  26808. initAccum = arguments.length < 3;
  26809. return func(collection, getIteratee(iteratee, 4), accumulator, initAccum, baseEach);
  26810. }
  26811. /**
  26812. * This method is like `_.reduce` except that it iterates over elements of
  26813. * `collection` from right to left.
  26814. *
  26815. * @static
  26816. * @memberOf _
  26817. * @since 0.1.0
  26818. * @category Collection
  26819. * @param {Array|Object} collection The collection to iterate over.
  26820. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  26821. * @param {*} [accumulator] The initial value.
  26822. * @returns {*} Returns the accumulated value.
  26823. * @see _.reduce
  26824. * @example
  26825. *
  26826. * var array = [[0, 1], [2, 3], [4, 5]];
  26827. *
  26828. * _.reduceRight(array, function(flattened, other) {
  26829. * return flattened.concat(other);
  26830. * }, []);
  26831. * // => [4, 5, 2, 3, 0, 1]
  26832. */
  26833. function reduceRight(collection, iteratee, accumulator) {
  26834. var func = isArray(collection) ? arrayReduceRight : baseReduce,
  26835. initAccum = arguments.length < 3;
  26836. return func(collection, getIteratee(iteratee, 4), accumulator, initAccum, baseEachRight);
  26837. }
  26838. /**
  26839. * The opposite of `_.filter`; this method returns the elements of `collection`
  26840. * that `predicate` does **not** return truthy for.
  26841. *
  26842. * @static
  26843. * @memberOf _
  26844. * @since 0.1.0
  26845. * @category Collection
  26846. * @param {Array|Object} collection The collection to iterate over.
  26847. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  26848. * @returns {Array} Returns the new filtered array.
  26849. * @see _.filter
  26850. * @example
  26851. *
  26852. * var users = [
  26853. * { 'user': 'barney', 'age': 36, 'active': false },
  26854. * { 'user': 'fred', 'age': 40, 'active': true }
  26855. * ];
  26856. *
  26857. * _.reject(users, function(o) { return !o.active; });
  26858. * // => objects for ['fred']
  26859. *
  26860. * // The `_.matches` iteratee shorthand.
  26861. * _.reject(users, { 'age': 40, 'active': true });
  26862. * // => objects for ['barney']
  26863. *
  26864. * // The `_.matchesProperty` iteratee shorthand.
  26865. * _.reject(users, ['active', false]);
  26866. * // => objects for ['fred']
  26867. *
  26868. * // The `_.property` iteratee shorthand.
  26869. * _.reject(users, 'active');
  26870. * // => objects for ['barney']
  26871. */
  26872. function reject(collection, predicate) {
  26873. var func = isArray(collection) ? arrayFilter : baseFilter;
  26874. return func(collection, negate(getIteratee(predicate, 3)));
  26875. }
  26876. /**
  26877. * Gets a random element from `collection`.
  26878. *
  26879. * @static
  26880. * @memberOf _
  26881. * @since 2.0.0
  26882. * @category Collection
  26883. * @param {Array|Object} collection The collection to sample.
  26884. * @returns {*} Returns the random element.
  26885. * @example
  26886. *
  26887. * _.sample([1, 2, 3, 4]);
  26888. * // => 2
  26889. */
  26890. function sample(collection) {
  26891. var func = isArray(collection) ? arraySample : baseSample;
  26892. return func(collection);
  26893. }
  26894. /**
  26895. * Gets `n` random elements at unique keys from `collection` up to the
  26896. * size of `collection`.
  26897. *
  26898. * @static
  26899. * @memberOf _
  26900. * @since 4.0.0
  26901. * @category Collection
  26902. * @param {Array|Object} collection The collection to sample.
  26903. * @param {number} [n=1] The number of elements to sample.
  26904. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  26905. * @returns {Array} Returns the random elements.
  26906. * @example
  26907. *
  26908. * _.sampleSize([1, 2, 3], 2);
  26909. * // => [3, 1]
  26910. *
  26911. * _.sampleSize([1, 2, 3], 4);
  26912. * // => [2, 3, 1]
  26913. */
  26914. function sampleSize(collection, n, guard) {
  26915. if ((guard ? isIterateeCall(collection, n, guard) : n === undefined)) {
  26916. n = 1;
  26917. } else {
  26918. n = toInteger(n);
  26919. }
  26920. var func = isArray(collection) ? arraySampleSize : baseSampleSize;
  26921. return func(collection, n);
  26922. }
  26923. /**
  26924. * Creates an array of shuffled values, using a version of the
  26925. * [Fisher-Yates shuffle](https://en.wikipedia.org/wiki/Fisher-Yates_shuffle).
  26926. *
  26927. * @static
  26928. * @memberOf _
  26929. * @since 0.1.0
  26930. * @category Collection
  26931. * @param {Array|Object} collection The collection to shuffle.
  26932. * @returns {Array} Returns the new shuffled array.
  26933. * @example
  26934. *
  26935. * _.shuffle([1, 2, 3, 4]);
  26936. * // => [4, 1, 3, 2]
  26937. */
  26938. function shuffle(collection) {
  26939. var func = isArray(collection) ? arrayShuffle : baseShuffle;
  26940. return func(collection);
  26941. }
  26942. /**
  26943. * Gets the size of `collection` by returning its length for array-like
  26944. * values or the number of own enumerable string keyed properties for objects.
  26945. *
  26946. * @static
  26947. * @memberOf _
  26948. * @since 0.1.0
  26949. * @category Collection
  26950. * @param {Array|Object|string} collection The collection to inspect.
  26951. * @returns {number} Returns the collection size.
  26952. * @example
  26953. *
  26954. * _.size([1, 2, 3]);
  26955. * // => 3
  26956. *
  26957. * _.size({ 'a': 1, 'b': 2 });
  26958. * // => 2
  26959. *
  26960. * _.size('pebbles');
  26961. * // => 7
  26962. */
  26963. function size(collection) {
  26964. if (collection == null) {
  26965. return 0;
  26966. }
  26967. if (isArrayLike(collection)) {
  26968. return isString(collection) ? stringSize(collection) : collection.length;
  26969. }
  26970. var tag = getTag(collection);
  26971. if (tag == mapTag || tag == setTag) {
  26972. return collection.size;
  26973. }
  26974. return baseKeys(collection).length;
  26975. }
  26976. /**
  26977. * Checks if `predicate` returns truthy for **any** element of `collection`.
  26978. * Iteration is stopped once `predicate` returns truthy. The predicate is
  26979. * invoked with three arguments: (value, index|key, collection).
  26980. *
  26981. * @static
  26982. * @memberOf _
  26983. * @since 0.1.0
  26984. * @category Collection
  26985. * @param {Array|Object} collection The collection to iterate over.
  26986. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  26987. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  26988. * @returns {boolean} Returns `true` if any element passes the predicate check,
  26989. * else `false`.
  26990. * @example
  26991. *
  26992. * _.some([null, 0, 'yes', false], Boolean);
  26993. * // => true
  26994. *
  26995. * var users = [
  26996. * { 'user': 'barney', 'active': true },
  26997. * { 'user': 'fred', 'active': false }
  26998. * ];
  26999. *
  27000. * // The `_.matches` iteratee shorthand.
  27001. * _.some(users, { 'user': 'barney', 'active': false });
  27002. * // => false
  27003. *
  27004. * // The `_.matchesProperty` iteratee shorthand.
  27005. * _.some(users, ['active', false]);
  27006. * // => true
  27007. *
  27008. * // The `_.property` iteratee shorthand.
  27009. * _.some(users, 'active');
  27010. * // => true
  27011. */
  27012. function some(collection, predicate, guard) {
  27013. var func = isArray(collection) ? arraySome : baseSome;
  27014. if (guard && isIterateeCall(collection, predicate, guard)) {
  27015. predicate = undefined;
  27016. }
  27017. return func(collection, getIteratee(predicate, 3));
  27018. }
  27019. /**
  27020. * Creates an array of elements, sorted in ascending order by the results of
  27021. * running each element in a collection thru each iteratee. This method
  27022. * performs a stable sort, that is, it preserves the original sort order of
  27023. * equal elements. The iteratees are invoked with one argument: (value).
  27024. *
  27025. * @static
  27026. * @memberOf _
  27027. * @since 0.1.0
  27028. * @category Collection
  27029. * @param {Array|Object} collection The collection to iterate over.
  27030. * @param {...(Function|Function[])} [iteratees=[_.identity]]
  27031. * The iteratees to sort by.
  27032. * @returns {Array} Returns the new sorted array.
  27033. * @example
  27034. *
  27035. * var users = [
  27036. * { 'user': 'fred', 'age': 48 },
  27037. * { 'user': 'barney', 'age': 36 },
  27038. * { 'user': 'fred', 'age': 40 },
  27039. * { 'user': 'barney', 'age': 34 }
  27040. * ];
  27041. *
  27042. * _.sortBy(users, [function(o) { return o.user; }]);
  27043. * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 40]]
  27044. *
  27045. * _.sortBy(users, ['user', 'age']);
  27046. * // => objects for [['barney', 34], ['barney', 36], ['fred', 40], ['fred', 48]]
  27047. */
  27048. var sortBy = baseRest(function(collection, iteratees) {
  27049. if (collection == null) {
  27050. return [];
  27051. }
  27052. var length = iteratees.length;
  27053. if (length > 1 && isIterateeCall(collection, iteratees[0], iteratees[1])) {
  27054. iteratees = [];
  27055. } else if (length > 2 && isIterateeCall(iteratees[0], iteratees[1], iteratees[2])) {
  27056. iteratees = [iteratees[0]];
  27057. }
  27058. return baseOrderBy(collection, baseFlatten(iteratees, 1), []);
  27059. });
  27060. /*------------------------------------------------------------------------*/
  27061. /**
  27062. * Gets the timestamp of the number of milliseconds that have elapsed since
  27063. * the Unix epoch (1 January 1970 00:00:00 UTC).
  27064. *
  27065. * @static
  27066. * @memberOf _
  27067. * @since 2.4.0
  27068. * @category Date
  27069. * @returns {number} Returns the timestamp.
  27070. * @example
  27071. *
  27072. * _.defer(function(stamp) {
  27073. * console.log(_.now() - stamp);
  27074. * }, _.now());
  27075. * // => Logs the number of milliseconds it took for the deferred invocation.
  27076. */
  27077. var now = ctxNow || function() {
  27078. return root.Date.now();
  27079. };
  27080. /*------------------------------------------------------------------------*/
  27081. /**
  27082. * The opposite of `_.before`; this method creates a function that invokes
  27083. * `func` once it's called `n` or more times.
  27084. *
  27085. * @static
  27086. * @memberOf _
  27087. * @since 0.1.0
  27088. * @category Function
  27089. * @param {number} n The number of calls before `func` is invoked.
  27090. * @param {Function} func The function to restrict.
  27091. * @returns {Function} Returns the new restricted function.
  27092. * @example
  27093. *
  27094. * var saves = ['profile', 'settings'];
  27095. *
  27096. * var done = _.after(saves.length, function() {
  27097. * console.log('done saving!');
  27098. * });
  27099. *
  27100. * _.forEach(saves, function(type) {
  27101. * asyncSave({ 'type': type, 'complete': done });
  27102. * });
  27103. * // => Logs 'done saving!' after the two async saves have completed.
  27104. */
  27105. function after(n, func) {
  27106. if (typeof func != 'function') {
  27107. throw new TypeError(FUNC_ERROR_TEXT);
  27108. }
  27109. n = toInteger(n);
  27110. return function() {
  27111. if (--n < 1) {
  27112. return func.apply(this, arguments);
  27113. }
  27114. };
  27115. }
  27116. /**
  27117. * Creates a function that invokes `func`, with up to `n` arguments,
  27118. * ignoring any additional arguments.
  27119. *
  27120. * @static
  27121. * @memberOf _
  27122. * @since 3.0.0
  27123. * @category Function
  27124. * @param {Function} func The function to cap arguments for.
  27125. * @param {number} [n=func.length] The arity cap.
  27126. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  27127. * @returns {Function} Returns the new capped function.
  27128. * @example
  27129. *
  27130. * _.map(['6', '8', '10'], _.ary(parseInt, 1));
  27131. * // => [6, 8, 10]
  27132. */
  27133. function ary(func, n, guard) {
  27134. n = guard ? undefined : n;
  27135. n = (func && n == null) ? func.length : n;
  27136. return createWrap(func, WRAP_ARY_FLAG, undefined, undefined, undefined, undefined, n);
  27137. }
  27138. /**
  27139. * Creates a function that invokes `func`, with the `this` binding and arguments
  27140. * of the created function, while it's called less than `n` times. Subsequent
  27141. * calls to the created function return the result of the last `func` invocation.
  27142. *
  27143. * @static
  27144. * @memberOf _
  27145. * @since 3.0.0
  27146. * @category Function
  27147. * @param {number} n The number of calls at which `func` is no longer invoked.
  27148. * @param {Function} func The function to restrict.
  27149. * @returns {Function} Returns the new restricted function.
  27150. * @example
  27151. *
  27152. * jQuery(element).on('click', _.before(5, addContactToList));
  27153. * // => Allows adding up to 4 contacts to the list.
  27154. */
  27155. function before(n, func) {
  27156. var result;
  27157. if (typeof func != 'function') {
  27158. throw new TypeError(FUNC_ERROR_TEXT);
  27159. }
  27160. n = toInteger(n);
  27161. return function() {
  27162. if (--n > 0) {
  27163. result = func.apply(this, arguments);
  27164. }
  27165. if (n <= 1) {
  27166. func = undefined;
  27167. }
  27168. return result;
  27169. };
  27170. }
  27171. /**
  27172. * Creates a function that invokes `func` with the `this` binding of `thisArg`
  27173. * and `partials` prepended to the arguments it receives.
  27174. *
  27175. * The `_.bind.placeholder` value, which defaults to `_` in monolithic builds,
  27176. * may be used as a placeholder for partially applied arguments.
  27177. *
  27178. * **Note:** Unlike native `Function#bind`, this method doesn't set the "length"
  27179. * property of bound functions.
  27180. *
  27181. * @static
  27182. * @memberOf _
  27183. * @since 0.1.0
  27184. * @category Function
  27185. * @param {Function} func The function to bind.
  27186. * @param {*} thisArg The `this` binding of `func`.
  27187. * @param {...*} [partials] The arguments to be partially applied.
  27188. * @returns {Function} Returns the new bound function.
  27189. * @example
  27190. *
  27191. * function greet(greeting, punctuation) {
  27192. * return greeting + ' ' + this.user + punctuation;
  27193. * }
  27194. *
  27195. * var object = { 'user': 'fred' };
  27196. *
  27197. * var bound = _.bind(greet, object, 'hi');
  27198. * bound('!');
  27199. * // => 'hi fred!'
  27200. *
  27201. * // Bound with placeholders.
  27202. * var bound = _.bind(greet, object, _, '!');
  27203. * bound('hi');
  27204. * // => 'hi fred!'
  27205. */
  27206. var bind = baseRest(function(func, thisArg, partials) {
  27207. var bitmask = WRAP_BIND_FLAG;
  27208. if (partials.length) {
  27209. var holders = replaceHolders(partials, getHolder(bind));
  27210. bitmask |= WRAP_PARTIAL_FLAG;
  27211. }
  27212. return createWrap(func, bitmask, thisArg, partials, holders);
  27213. });
  27214. /**
  27215. * Creates a function that invokes the method at `object[key]` with `partials`
  27216. * prepended to the arguments it receives.
  27217. *
  27218. * This method differs from `_.bind` by allowing bound functions to reference
  27219. * methods that may be redefined or don't yet exist. See
  27220. * [Peter Michaux's article](http://peter.michaux.ca/articles/lazy-function-definition-pattern)
  27221. * for more details.
  27222. *
  27223. * The `_.bindKey.placeholder` value, which defaults to `_` in monolithic
  27224. * builds, may be used as a placeholder for partially applied arguments.
  27225. *
  27226. * @static
  27227. * @memberOf _
  27228. * @since 0.10.0
  27229. * @category Function
  27230. * @param {Object} object The object to invoke the method on.
  27231. * @param {string} key The key of the method.
  27232. * @param {...*} [partials] The arguments to be partially applied.
  27233. * @returns {Function} Returns the new bound function.
  27234. * @example
  27235. *
  27236. * var object = {
  27237. * 'user': 'fred',
  27238. * 'greet': function(greeting, punctuation) {
  27239. * return greeting + ' ' + this.user + punctuation;
  27240. * }
  27241. * };
  27242. *
  27243. * var bound = _.bindKey(object, 'greet', 'hi');
  27244. * bound('!');
  27245. * // => 'hi fred!'
  27246. *
  27247. * object.greet = function(greeting, punctuation) {
  27248. * return greeting + 'ya ' + this.user + punctuation;
  27249. * };
  27250. *
  27251. * bound('!');
  27252. * // => 'hiya fred!'
  27253. *
  27254. * // Bound with placeholders.
  27255. * var bound = _.bindKey(object, 'greet', _, '!');
  27256. * bound('hi');
  27257. * // => 'hiya fred!'
  27258. */
  27259. var bindKey = baseRest(function(object, key, partials) {
  27260. var bitmask = WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG;
  27261. if (partials.length) {
  27262. var holders = replaceHolders(partials, getHolder(bindKey));
  27263. bitmask |= WRAP_PARTIAL_FLAG;
  27264. }
  27265. return createWrap(key, bitmask, object, partials, holders);
  27266. });
  27267. /**
  27268. * Creates a function that accepts arguments of `func` and either invokes
  27269. * `func` returning its result, if at least `arity` number of arguments have
  27270. * been provided, or returns a function that accepts the remaining `func`
  27271. * arguments, and so on. The arity of `func` may be specified if `func.length`
  27272. * is not sufficient.
  27273. *
  27274. * The `_.curry.placeholder` value, which defaults to `_` in monolithic builds,
  27275. * may be used as a placeholder for provided arguments.
  27276. *
  27277. * **Note:** This method doesn't set the "length" property of curried functions.
  27278. *
  27279. * @static
  27280. * @memberOf _
  27281. * @since 2.0.0
  27282. * @category Function
  27283. * @param {Function} func The function to curry.
  27284. * @param {number} [arity=func.length] The arity of `func`.
  27285. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  27286. * @returns {Function} Returns the new curried function.
  27287. * @example
  27288. *
  27289. * var abc = function(a, b, c) {
  27290. * return [a, b, c];
  27291. * };
  27292. *
  27293. * var curried = _.curry(abc);
  27294. *
  27295. * curried(1)(2)(3);
  27296. * // => [1, 2, 3]
  27297. *
  27298. * curried(1, 2)(3);
  27299. * // => [1, 2, 3]
  27300. *
  27301. * curried(1, 2, 3);
  27302. * // => [1, 2, 3]
  27303. *
  27304. * // Curried with placeholders.
  27305. * curried(1)(_, 3)(2);
  27306. * // => [1, 2, 3]
  27307. */
  27308. function curry(func, arity, guard) {
  27309. arity = guard ? undefined : arity;
  27310. var result = createWrap(func, WRAP_CURRY_FLAG, undefined, undefined, undefined, undefined, undefined, arity);
  27311. result.placeholder = curry.placeholder;
  27312. return result;
  27313. }
  27314. /**
  27315. * This method is like `_.curry` except that arguments are applied to `func`
  27316. * in the manner of `_.partialRight` instead of `_.partial`.
  27317. *
  27318. * The `_.curryRight.placeholder` value, which defaults to `_` in monolithic
  27319. * builds, may be used as a placeholder for provided arguments.
  27320. *
  27321. * **Note:** This method doesn't set the "length" property of curried functions.
  27322. *
  27323. * @static
  27324. * @memberOf _
  27325. * @since 3.0.0
  27326. * @category Function
  27327. * @param {Function} func The function to curry.
  27328. * @param {number} [arity=func.length] The arity of `func`.
  27329. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  27330. * @returns {Function} Returns the new curried function.
  27331. * @example
  27332. *
  27333. * var abc = function(a, b, c) {
  27334. * return [a, b, c];
  27335. * };
  27336. *
  27337. * var curried = _.curryRight(abc);
  27338. *
  27339. * curried(3)(2)(1);
  27340. * // => [1, 2, 3]
  27341. *
  27342. * curried(2, 3)(1);
  27343. * // => [1, 2, 3]
  27344. *
  27345. * curried(1, 2, 3);
  27346. * // => [1, 2, 3]
  27347. *
  27348. * // Curried with placeholders.
  27349. * curried(3)(1, _)(2);
  27350. * // => [1, 2, 3]
  27351. */
  27352. function curryRight(func, arity, guard) {
  27353. arity = guard ? undefined : arity;
  27354. var result = createWrap(func, WRAP_CURRY_RIGHT_FLAG, undefined, undefined, undefined, undefined, undefined, arity);
  27355. result.placeholder = curryRight.placeholder;
  27356. return result;
  27357. }
  27358. /**
  27359. * Creates a debounced function that delays invoking `func` until after `wait`
  27360. * milliseconds have elapsed since the last time the debounced function was
  27361. * invoked. The debounced function comes with a `cancel` method to cancel
  27362. * delayed `func` invocations and a `flush` method to immediately invoke them.
  27363. * Provide `options` to indicate whether `func` should be invoked on the
  27364. * leading and/or trailing edge of the `wait` timeout. The `func` is invoked
  27365. * with the last arguments provided to the debounced function. Subsequent
  27366. * calls to the debounced function return the result of the last `func`
  27367. * invocation.
  27368. *
  27369. * **Note:** If `leading` and `trailing` options are `true`, `func` is
  27370. * invoked on the trailing edge of the timeout only if the debounced function
  27371. * is invoked more than once during the `wait` timeout.
  27372. *
  27373. * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
  27374. * until to the next tick, similar to `setTimeout` with a timeout of `0`.
  27375. *
  27376. * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
  27377. * for details over the differences between `_.debounce` and `_.throttle`.
  27378. *
  27379. * @static
  27380. * @memberOf _
  27381. * @since 0.1.0
  27382. * @category Function
  27383. * @param {Function} func The function to debounce.
  27384. * @param {number} [wait=0] The number of milliseconds to delay.
  27385. * @param {Object} [options={}] The options object.
  27386. * @param {boolean} [options.leading=false]
  27387. * Specify invoking on the leading edge of the timeout.
  27388. * @param {number} [options.maxWait]
  27389. * The maximum time `func` is allowed to be delayed before it's invoked.
  27390. * @param {boolean} [options.trailing=true]
  27391. * Specify invoking on the trailing edge of the timeout.
  27392. * @returns {Function} Returns the new debounced function.
  27393. * @example
  27394. *
  27395. * // Avoid costly calculations while the window size is in flux.
  27396. * jQuery(window).on('resize', _.debounce(calculateLayout, 150));
  27397. *
  27398. * // Invoke `sendMail` when clicked, debouncing subsequent calls.
  27399. * jQuery(element).on('click', _.debounce(sendMail, 300, {
  27400. * 'leading': true,
  27401. * 'trailing': false
  27402. * }));
  27403. *
  27404. * // Ensure `batchLog` is invoked once after 1 second of debounced calls.
  27405. * var debounced = _.debounce(batchLog, 250, { 'maxWait': 1000 });
  27406. * var source = new EventSource('/stream');
  27407. * jQuery(source).on('message', debounced);
  27408. *
  27409. * // Cancel the trailing debounced invocation.
  27410. * jQuery(window).on('popstate', debounced.cancel);
  27411. */
  27412. function debounce(func, wait, options) {
  27413. var lastArgs,
  27414. lastThis,
  27415. maxWait,
  27416. result,
  27417. timerId,
  27418. lastCallTime,
  27419. lastInvokeTime = 0,
  27420. leading = false,
  27421. maxing = false,
  27422. trailing = true;
  27423. if (typeof func != 'function') {
  27424. throw new TypeError(FUNC_ERROR_TEXT);
  27425. }
  27426. wait = toNumber(wait) || 0;
  27427. if (isObject(options)) {
  27428. leading = !!options.leading;
  27429. maxing = 'maxWait' in options;
  27430. maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait;
  27431. trailing = 'trailing' in options ? !!options.trailing : trailing;
  27432. }
  27433. function invokeFunc(time) {
  27434. var args = lastArgs,
  27435. thisArg = lastThis;
  27436. lastArgs = lastThis = undefined;
  27437. lastInvokeTime = time;
  27438. result = func.apply(thisArg, args);
  27439. return result;
  27440. }
  27441. function leadingEdge(time) {
  27442. // Reset any `maxWait` timer.
  27443. lastInvokeTime = time;
  27444. // Start the timer for the trailing edge.
  27445. timerId = setTimeout(timerExpired, wait);
  27446. // Invoke the leading edge.
  27447. return leading ? invokeFunc(time) : result;
  27448. }
  27449. function remainingWait(time) {
  27450. var timeSinceLastCall = time - lastCallTime,
  27451. timeSinceLastInvoke = time - lastInvokeTime,
  27452. timeWaiting = wait - timeSinceLastCall;
  27453. return maxing
  27454. ? nativeMin(timeWaiting, maxWait - timeSinceLastInvoke)
  27455. : timeWaiting;
  27456. }
  27457. function shouldInvoke(time) {
  27458. var timeSinceLastCall = time - lastCallTime,
  27459. timeSinceLastInvoke = time - lastInvokeTime;
  27460. // Either this is the first call, activity has stopped and we're at the
  27461. // trailing edge, the system time has gone backwards and we're treating
  27462. // it as the trailing edge, or we've hit the `maxWait` limit.
  27463. return (lastCallTime === undefined || (timeSinceLastCall >= wait) ||
  27464. (timeSinceLastCall < 0) || (maxing && timeSinceLastInvoke >= maxWait));
  27465. }
  27466. function timerExpired() {
  27467. var time = now();
  27468. if (shouldInvoke(time)) {
  27469. return trailingEdge(time);
  27470. }
  27471. // Restart the timer.
  27472. timerId = setTimeout(timerExpired, remainingWait(time));
  27473. }
  27474. function trailingEdge(time) {
  27475. timerId = undefined;
  27476. // Only invoke if we have `lastArgs` which means `func` has been
  27477. // debounced at least once.
  27478. if (trailing && lastArgs) {
  27479. return invokeFunc(time);
  27480. }
  27481. lastArgs = lastThis = undefined;
  27482. return result;
  27483. }
  27484. function cancel() {
  27485. if (timerId !== undefined) {
  27486. clearTimeout(timerId);
  27487. }
  27488. lastInvokeTime = 0;
  27489. lastArgs = lastCallTime = lastThis = timerId = undefined;
  27490. }
  27491. function flush() {
  27492. return timerId === undefined ? result : trailingEdge(now());
  27493. }
  27494. function debounced() {
  27495. var time = now(),
  27496. isInvoking = shouldInvoke(time);
  27497. lastArgs = arguments;
  27498. lastThis = this;
  27499. lastCallTime = time;
  27500. if (isInvoking) {
  27501. if (timerId === undefined) {
  27502. return leadingEdge(lastCallTime);
  27503. }
  27504. if (maxing) {
  27505. // Handle invocations in a tight loop.
  27506. clearTimeout(timerId);
  27507. timerId = setTimeout(timerExpired, wait);
  27508. return invokeFunc(lastCallTime);
  27509. }
  27510. }
  27511. if (timerId === undefined) {
  27512. timerId = setTimeout(timerExpired, wait);
  27513. }
  27514. return result;
  27515. }
  27516. debounced.cancel = cancel;
  27517. debounced.flush = flush;
  27518. return debounced;
  27519. }
  27520. /**
  27521. * Defers invoking the `func` until the current call stack has cleared. Any
  27522. * additional arguments are provided to `func` when it's invoked.
  27523. *
  27524. * @static
  27525. * @memberOf _
  27526. * @since 0.1.0
  27527. * @category Function
  27528. * @param {Function} func The function to defer.
  27529. * @param {...*} [args] The arguments to invoke `func` with.
  27530. * @returns {number} Returns the timer id.
  27531. * @example
  27532. *
  27533. * _.defer(function(text) {
  27534. * console.log(text);
  27535. * }, 'deferred');
  27536. * // => Logs 'deferred' after one millisecond.
  27537. */
  27538. var defer = baseRest(function(func, args) {
  27539. return baseDelay(func, 1, args);
  27540. });
  27541. /**
  27542. * Invokes `func` after `wait` milliseconds. Any additional arguments are
  27543. * provided to `func` when it's invoked.
  27544. *
  27545. * @static
  27546. * @memberOf _
  27547. * @since 0.1.0
  27548. * @category Function
  27549. * @param {Function} func The function to delay.
  27550. * @param {number} wait The number of milliseconds to delay invocation.
  27551. * @param {...*} [args] The arguments to invoke `func` with.
  27552. * @returns {number} Returns the timer id.
  27553. * @example
  27554. *
  27555. * _.delay(function(text) {
  27556. * console.log(text);
  27557. * }, 1000, 'later');
  27558. * // => Logs 'later' after one second.
  27559. */
  27560. var delay = baseRest(function(func, wait, args) {
  27561. return baseDelay(func, toNumber(wait) || 0, args);
  27562. });
  27563. /**
  27564. * Creates a function that invokes `func` with arguments reversed.
  27565. *
  27566. * @static
  27567. * @memberOf _
  27568. * @since 4.0.0
  27569. * @category Function
  27570. * @param {Function} func The function to flip arguments for.
  27571. * @returns {Function} Returns the new flipped function.
  27572. * @example
  27573. *
  27574. * var flipped = _.flip(function() {
  27575. * return _.toArray(arguments);
  27576. * });
  27577. *
  27578. * flipped('a', 'b', 'c', 'd');
  27579. * // => ['d', 'c', 'b', 'a']
  27580. */
  27581. function flip(func) {
  27582. return createWrap(func, WRAP_FLIP_FLAG);
  27583. }
  27584. /**
  27585. * Creates a function that memoizes the result of `func`. If `resolver` is
  27586. * provided, it determines the cache key for storing the result based on the
  27587. * arguments provided to the memoized function. By default, the first argument
  27588. * provided to the memoized function is used as the map cache key. The `func`
  27589. * is invoked with the `this` binding of the memoized function.
  27590. *
  27591. * **Note:** The cache is exposed as the `cache` property on the memoized
  27592. * function. Its creation may be customized by replacing the `_.memoize.Cache`
  27593. * constructor with one whose instances implement the
  27594. * [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object)
  27595. * method interface of `clear`, `delete`, `get`, `has`, and `set`.
  27596. *
  27597. * @static
  27598. * @memberOf _
  27599. * @since 0.1.0
  27600. * @category Function
  27601. * @param {Function} func The function to have its output memoized.
  27602. * @param {Function} [resolver] The function to resolve the cache key.
  27603. * @returns {Function} Returns the new memoized function.
  27604. * @example
  27605. *
  27606. * var object = { 'a': 1, 'b': 2 };
  27607. * var other = { 'c': 3, 'd': 4 };
  27608. *
  27609. * var values = _.memoize(_.values);
  27610. * values(object);
  27611. * // => [1, 2]
  27612. *
  27613. * values(other);
  27614. * // => [3, 4]
  27615. *
  27616. * object.a = 2;
  27617. * values(object);
  27618. * // => [1, 2]
  27619. *
  27620. * // Modify the result cache.
  27621. * values.cache.set(object, ['a', 'b']);
  27622. * values(object);
  27623. * // => ['a', 'b']
  27624. *
  27625. * // Replace `_.memoize.Cache`.
  27626. * _.memoize.Cache = WeakMap;
  27627. */
  27628. function memoize(func, resolver) {
  27629. if (typeof func != 'function' || (resolver != null && typeof resolver != 'function')) {
  27630. throw new TypeError(FUNC_ERROR_TEXT);
  27631. }
  27632. var memoized = function() {
  27633. var args = arguments,
  27634. key = resolver ? resolver.apply(this, args) : args[0],
  27635. cache = memoized.cache;
  27636. if (cache.has(key)) {
  27637. return cache.get(key);
  27638. }
  27639. var result = func.apply(this, args);
  27640. memoized.cache = cache.set(key, result) || cache;
  27641. return result;
  27642. };
  27643. memoized.cache = new (memoize.Cache || MapCache);
  27644. return memoized;
  27645. }
  27646. // Expose `MapCache`.
  27647. memoize.Cache = MapCache;
  27648. /**
  27649. * Creates a function that negates the result of the predicate `func`. The
  27650. * `func` predicate is invoked with the `this` binding and arguments of the
  27651. * created function.
  27652. *
  27653. * @static
  27654. * @memberOf _
  27655. * @since 3.0.0
  27656. * @category Function
  27657. * @param {Function} predicate The predicate to negate.
  27658. * @returns {Function} Returns the new negated function.
  27659. * @example
  27660. *
  27661. * function isEven(n) {
  27662. * return n % 2 == 0;
  27663. * }
  27664. *
  27665. * _.filter([1, 2, 3, 4, 5, 6], _.negate(isEven));
  27666. * // => [1, 3, 5]
  27667. */
  27668. function negate(predicate) {
  27669. if (typeof predicate != 'function') {
  27670. throw new TypeError(FUNC_ERROR_TEXT);
  27671. }
  27672. return function() {
  27673. var args = arguments;
  27674. switch (args.length) {
  27675. case 0: return !predicate.call(this);
  27676. case 1: return !predicate.call(this, args[0]);
  27677. case 2: return !predicate.call(this, args[0], args[1]);
  27678. case 3: return !predicate.call(this, args[0], args[1], args[2]);
  27679. }
  27680. return !predicate.apply(this, args);
  27681. };
  27682. }
  27683. /**
  27684. * Creates a function that is restricted to invoking `func` once. Repeat calls
  27685. * to the function return the value of the first invocation. The `func` is
  27686. * invoked with the `this` binding and arguments of the created function.
  27687. *
  27688. * @static
  27689. * @memberOf _
  27690. * @since 0.1.0
  27691. * @category Function
  27692. * @param {Function} func The function to restrict.
  27693. * @returns {Function} Returns the new restricted function.
  27694. * @example
  27695. *
  27696. * var initialize = _.once(createApplication);
  27697. * initialize();
  27698. * initialize();
  27699. * // => `createApplication` is invoked once
  27700. */
  27701. function once(func) {
  27702. return before(2, func);
  27703. }
  27704. /**
  27705. * Creates a function that invokes `func` with its arguments transformed.
  27706. *
  27707. * @static
  27708. * @since 4.0.0
  27709. * @memberOf _
  27710. * @category Function
  27711. * @param {Function} func The function to wrap.
  27712. * @param {...(Function|Function[])} [transforms=[_.identity]]
  27713. * The argument transforms.
  27714. * @returns {Function} Returns the new function.
  27715. * @example
  27716. *
  27717. * function doubled(n) {
  27718. * return n * 2;
  27719. * }
  27720. *
  27721. * function square(n) {
  27722. * return n * n;
  27723. * }
  27724. *
  27725. * var func = _.overArgs(function(x, y) {
  27726. * return [x, y];
  27727. * }, [square, doubled]);
  27728. *
  27729. * func(9, 3);
  27730. * // => [81, 6]
  27731. *
  27732. * func(10, 5);
  27733. * // => [100, 10]
  27734. */
  27735. var overArgs = castRest(function(func, transforms) {
  27736. transforms = (transforms.length == 1 && isArray(transforms[0]))
  27737. ? arrayMap(transforms[0], baseUnary(getIteratee()))
  27738. : arrayMap(baseFlatten(transforms, 1), baseUnary(getIteratee()));
  27739. var funcsLength = transforms.length;
  27740. return baseRest(function(args) {
  27741. var index = -1,
  27742. length = nativeMin(args.length, funcsLength);
  27743. while (++index < length) {
  27744. args[index] = transforms[index].call(this, args[index]);
  27745. }
  27746. return apply(func, this, args);
  27747. });
  27748. });
  27749. /**
  27750. * Creates a function that invokes `func` with `partials` prepended to the
  27751. * arguments it receives. This method is like `_.bind` except it does **not**
  27752. * alter the `this` binding.
  27753. *
  27754. * The `_.partial.placeholder` value, which defaults to `_` in monolithic
  27755. * builds, may be used as a placeholder for partially applied arguments.
  27756. *
  27757. * **Note:** This method doesn't set the "length" property of partially
  27758. * applied functions.
  27759. *
  27760. * @static
  27761. * @memberOf _
  27762. * @since 0.2.0
  27763. * @category Function
  27764. * @param {Function} func The function to partially apply arguments to.
  27765. * @param {...*} [partials] The arguments to be partially applied.
  27766. * @returns {Function} Returns the new partially applied function.
  27767. * @example
  27768. *
  27769. * function greet(greeting, name) {
  27770. * return greeting + ' ' + name;
  27771. * }
  27772. *
  27773. * var sayHelloTo = _.partial(greet, 'hello');
  27774. * sayHelloTo('fred');
  27775. * // => 'hello fred'
  27776. *
  27777. * // Partially applied with placeholders.
  27778. * var greetFred = _.partial(greet, _, 'fred');
  27779. * greetFred('hi');
  27780. * // => 'hi fred'
  27781. */
  27782. var partial = baseRest(function(func, partials) {
  27783. var holders = replaceHolders(partials, getHolder(partial));
  27784. return createWrap(func, WRAP_PARTIAL_FLAG, undefined, partials, holders);
  27785. });
  27786. /**
  27787. * This method is like `_.partial` except that partially applied arguments
  27788. * are appended to the arguments it receives.
  27789. *
  27790. * The `_.partialRight.placeholder` value, which defaults to `_` in monolithic
  27791. * builds, may be used as a placeholder for partially applied arguments.
  27792. *
  27793. * **Note:** This method doesn't set the "length" property of partially
  27794. * applied functions.
  27795. *
  27796. * @static
  27797. * @memberOf _
  27798. * @since 1.0.0
  27799. * @category Function
  27800. * @param {Function} func The function to partially apply arguments to.
  27801. * @param {...*} [partials] The arguments to be partially applied.
  27802. * @returns {Function} Returns the new partially applied function.
  27803. * @example
  27804. *
  27805. * function greet(greeting, name) {
  27806. * return greeting + ' ' + name;
  27807. * }
  27808. *
  27809. * var greetFred = _.partialRight(greet, 'fred');
  27810. * greetFred('hi');
  27811. * // => 'hi fred'
  27812. *
  27813. * // Partially applied with placeholders.
  27814. * var sayHelloTo = _.partialRight(greet, 'hello', _);
  27815. * sayHelloTo('fred');
  27816. * // => 'hello fred'
  27817. */
  27818. var partialRight = baseRest(function(func, partials) {
  27819. var holders = replaceHolders(partials, getHolder(partialRight));
  27820. return createWrap(func, WRAP_PARTIAL_RIGHT_FLAG, undefined, partials, holders);
  27821. });
  27822. /**
  27823. * Creates a function that invokes `func` with arguments arranged according
  27824. * to the specified `indexes` where the argument value at the first index is
  27825. * provided as the first argument, the argument value at the second index is
  27826. * provided as the second argument, and so on.
  27827. *
  27828. * @static
  27829. * @memberOf _
  27830. * @since 3.0.0
  27831. * @category Function
  27832. * @param {Function} func The function to rearrange arguments for.
  27833. * @param {...(number|number[])} indexes The arranged argument indexes.
  27834. * @returns {Function} Returns the new function.
  27835. * @example
  27836. *
  27837. * var rearged = _.rearg(function(a, b, c) {
  27838. * return [a, b, c];
  27839. * }, [2, 0, 1]);
  27840. *
  27841. * rearged('b', 'c', 'a')
  27842. * // => ['a', 'b', 'c']
  27843. */
  27844. var rearg = flatRest(function(func, indexes) {
  27845. return createWrap(func, WRAP_REARG_FLAG, undefined, undefined, undefined, indexes);
  27846. });
  27847. /**
  27848. * Creates a function that invokes `func` with the `this` binding of the
  27849. * created function and arguments from `start` and beyond provided as
  27850. * an array.
  27851. *
  27852. * **Note:** This method is based on the
  27853. * [rest parameter](https://mdn.io/rest_parameters).
  27854. *
  27855. * @static
  27856. * @memberOf _
  27857. * @since 4.0.0
  27858. * @category Function
  27859. * @param {Function} func The function to apply a rest parameter to.
  27860. * @param {number} [start=func.length-1] The start position of the rest parameter.
  27861. * @returns {Function} Returns the new function.
  27862. * @example
  27863. *
  27864. * var say = _.rest(function(what, names) {
  27865. * return what + ' ' + _.initial(names).join(', ') +
  27866. * (_.size(names) > 1 ? ', & ' : '') + _.last(names);
  27867. * });
  27868. *
  27869. * say('hello', 'fred', 'barney', 'pebbles');
  27870. * // => 'hello fred, barney, & pebbles'
  27871. */
  27872. function rest(func, start) {
  27873. if (typeof func != 'function') {
  27874. throw new TypeError(FUNC_ERROR_TEXT);
  27875. }
  27876. start = start === undefined ? start : toInteger(start);
  27877. return baseRest(func, start);
  27878. }
  27879. /**
  27880. * Creates a function that invokes `func` with the `this` binding of the
  27881. * create function and an array of arguments much like
  27882. * [`Function#apply`](http://www.ecma-international.org/ecma-262/7.0/#sec-function.prototype.apply).
  27883. *
  27884. * **Note:** This method is based on the
  27885. * [spread operator](https://mdn.io/spread_operator).
  27886. *
  27887. * @static
  27888. * @memberOf _
  27889. * @since 3.2.0
  27890. * @category Function
  27891. * @param {Function} func The function to spread arguments over.
  27892. * @param {number} [start=0] The start position of the spread.
  27893. * @returns {Function} Returns the new function.
  27894. * @example
  27895. *
  27896. * var say = _.spread(function(who, what) {
  27897. * return who + ' says ' + what;
  27898. * });
  27899. *
  27900. * say(['fred', 'hello']);
  27901. * // => 'fred says hello'
  27902. *
  27903. * var numbers = Promise.all([
  27904. * Promise.resolve(40),
  27905. * Promise.resolve(36)
  27906. * ]);
  27907. *
  27908. * numbers.then(_.spread(function(x, y) {
  27909. * return x + y;
  27910. * }));
  27911. * // => a Promise of 76
  27912. */
  27913. function spread(func, start) {
  27914. if (typeof func != 'function') {
  27915. throw new TypeError(FUNC_ERROR_TEXT);
  27916. }
  27917. start = start == null ? 0 : nativeMax(toInteger(start), 0);
  27918. return baseRest(function(args) {
  27919. var array = args[start],
  27920. otherArgs = castSlice(args, 0, start);
  27921. if (array) {
  27922. arrayPush(otherArgs, array);
  27923. }
  27924. return apply(func, this, otherArgs);
  27925. });
  27926. }
  27927. /**
  27928. * Creates a throttled function that only invokes `func` at most once per
  27929. * every `wait` milliseconds. The throttled function comes with a `cancel`
  27930. * method to cancel delayed `func` invocations and a `flush` method to
  27931. * immediately invoke them. Provide `options` to indicate whether `func`
  27932. * should be invoked on the leading and/or trailing edge of the `wait`
  27933. * timeout. The `func` is invoked with the last arguments provided to the
  27934. * throttled function. Subsequent calls to the throttled function return the
  27935. * result of the last `func` invocation.
  27936. *
  27937. * **Note:** If `leading` and `trailing` options are `true`, `func` is
  27938. * invoked on the trailing edge of the timeout only if the throttled function
  27939. * is invoked more than once during the `wait` timeout.
  27940. *
  27941. * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
  27942. * until to the next tick, similar to `setTimeout` with a timeout of `0`.
  27943. *
  27944. * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
  27945. * for details over the differences between `_.throttle` and `_.debounce`.
  27946. *
  27947. * @static
  27948. * @memberOf _
  27949. * @since 0.1.0
  27950. * @category Function
  27951. * @param {Function} func The function to throttle.
  27952. * @param {number} [wait=0] The number of milliseconds to throttle invocations to.
  27953. * @param {Object} [options={}] The options object.
  27954. * @param {boolean} [options.leading=true]
  27955. * Specify invoking on the leading edge of the timeout.
  27956. * @param {boolean} [options.trailing=true]
  27957. * Specify invoking on the trailing edge of the timeout.
  27958. * @returns {Function} Returns the new throttled function.
  27959. * @example
  27960. *
  27961. * // Avoid excessively updating the position while scrolling.
  27962. * jQuery(window).on('scroll', _.throttle(updatePosition, 100));
  27963. *
  27964. * // Invoke `renewToken` when the click event is fired, but not more than once every 5 minutes.
  27965. * var throttled = _.throttle(renewToken, 300000, { 'trailing': false });
  27966. * jQuery(element).on('click', throttled);
  27967. *
  27968. * // Cancel the trailing throttled invocation.
  27969. * jQuery(window).on('popstate', throttled.cancel);
  27970. */
  27971. function throttle(func, wait, options) {
  27972. var leading = true,
  27973. trailing = true;
  27974. if (typeof func != 'function') {
  27975. throw new TypeError(FUNC_ERROR_TEXT);
  27976. }
  27977. if (isObject(options)) {
  27978. leading = 'leading' in options ? !!options.leading : leading;
  27979. trailing = 'trailing' in options ? !!options.trailing : trailing;
  27980. }
  27981. return debounce(func, wait, {
  27982. 'leading': leading,
  27983. 'maxWait': wait,
  27984. 'trailing': trailing
  27985. });
  27986. }
  27987. /**
  27988. * Creates a function that accepts up to one argument, ignoring any
  27989. * additional arguments.
  27990. *
  27991. * @static
  27992. * @memberOf _
  27993. * @since 4.0.0
  27994. * @category Function
  27995. * @param {Function} func The function to cap arguments for.
  27996. * @returns {Function} Returns the new capped function.
  27997. * @example
  27998. *
  27999. * _.map(['6', '8', '10'], _.unary(parseInt));
  28000. * // => [6, 8, 10]
  28001. */
  28002. function unary(func) {
  28003. return ary(func, 1);
  28004. }
  28005. /**
  28006. * Creates a function that provides `value` to `wrapper` as its first
  28007. * argument. Any additional arguments provided to the function are appended
  28008. * to those provided to the `wrapper`. The wrapper is invoked with the `this`
  28009. * binding of the created function.
  28010. *
  28011. * @static
  28012. * @memberOf _
  28013. * @since 0.1.0
  28014. * @category Function
  28015. * @param {*} value The value to wrap.
  28016. * @param {Function} [wrapper=identity] The wrapper function.
  28017. * @returns {Function} Returns the new function.
  28018. * @example
  28019. *
  28020. * var p = _.wrap(_.escape, function(func, text) {
  28021. * return '<p>' + func(text) + '</p>';
  28022. * });
  28023. *
  28024. * p('fred, barney, & pebbles');
  28025. * // => '<p>fred, barney, &amp; pebbles</p>'
  28026. */
  28027. function wrap(value, wrapper) {
  28028. return partial(castFunction(wrapper), value);
  28029. }
  28030. /*------------------------------------------------------------------------*/
  28031. /**
  28032. * Casts `value` as an array if it's not one.
  28033. *
  28034. * @static
  28035. * @memberOf _
  28036. * @since 4.4.0
  28037. * @category Lang
  28038. * @param {*} value The value to inspect.
  28039. * @returns {Array} Returns the cast array.
  28040. * @example
  28041. *
  28042. * _.castArray(1);
  28043. * // => [1]
  28044. *
  28045. * _.castArray({ 'a': 1 });
  28046. * // => [{ 'a': 1 }]
  28047. *
  28048. * _.castArray('abc');
  28049. * // => ['abc']
  28050. *
  28051. * _.castArray(null);
  28052. * // => [null]
  28053. *
  28054. * _.castArray(undefined);
  28055. * // => [undefined]
  28056. *
  28057. * _.castArray();
  28058. * // => []
  28059. *
  28060. * var array = [1, 2, 3];
  28061. * console.log(_.castArray(array) === array);
  28062. * // => true
  28063. */
  28064. function castArray() {
  28065. if (!arguments.length) {
  28066. return [];
  28067. }
  28068. var value = arguments[0];
  28069. return isArray(value) ? value : [value];
  28070. }
  28071. /**
  28072. * Creates a shallow clone of `value`.
  28073. *
  28074. * **Note:** This method is loosely based on the
  28075. * [structured clone algorithm](https://mdn.io/Structured_clone_algorithm)
  28076. * and supports cloning arrays, array buffers, booleans, date objects, maps,
  28077. * numbers, `Object` objects, regexes, sets, strings, symbols, and typed
  28078. * arrays. The own enumerable properties of `arguments` objects are cloned
  28079. * as plain objects. An empty object is returned for uncloneable values such
  28080. * as error objects, functions, DOM nodes, and WeakMaps.
  28081. *
  28082. * @static
  28083. * @memberOf _
  28084. * @since 0.1.0
  28085. * @category Lang
  28086. * @param {*} value The value to clone.
  28087. * @returns {*} Returns the cloned value.
  28088. * @see _.cloneDeep
  28089. * @example
  28090. *
  28091. * var objects = [{ 'a': 1 }, { 'b': 2 }];
  28092. *
  28093. * var shallow = _.clone(objects);
  28094. * console.log(shallow[0] === objects[0]);
  28095. * // => true
  28096. */
  28097. function clone(value) {
  28098. return baseClone(value, CLONE_SYMBOLS_FLAG);
  28099. }
  28100. /**
  28101. * This method is like `_.clone` except that it accepts `customizer` which
  28102. * is invoked to produce the cloned value. If `customizer` returns `undefined`,
  28103. * cloning is handled by the method instead. The `customizer` is invoked with
  28104. * up to four arguments; (value [, index|key, object, stack]).
  28105. *
  28106. * @static
  28107. * @memberOf _
  28108. * @since 4.0.0
  28109. * @category Lang
  28110. * @param {*} value The value to clone.
  28111. * @param {Function} [customizer] The function to customize cloning.
  28112. * @returns {*} Returns the cloned value.
  28113. * @see _.cloneDeepWith
  28114. * @example
  28115. *
  28116. * function customizer(value) {
  28117. * if (_.isElement(value)) {
  28118. * return value.cloneNode(false);
  28119. * }
  28120. * }
  28121. *
  28122. * var el = _.cloneWith(document.body, customizer);
  28123. *
  28124. * console.log(el === document.body);
  28125. * // => false
  28126. * console.log(el.nodeName);
  28127. * // => 'BODY'
  28128. * console.log(el.childNodes.length);
  28129. * // => 0
  28130. */
  28131. function cloneWith(value, customizer) {
  28132. customizer = typeof customizer == 'function' ? customizer : undefined;
  28133. return baseClone(value, CLONE_SYMBOLS_FLAG, customizer);
  28134. }
  28135. /**
  28136. * This method is like `_.clone` except that it recursively clones `value`.
  28137. *
  28138. * @static
  28139. * @memberOf _
  28140. * @since 1.0.0
  28141. * @category Lang
  28142. * @param {*} value The value to recursively clone.
  28143. * @returns {*} Returns the deep cloned value.
  28144. * @see _.clone
  28145. * @example
  28146. *
  28147. * var objects = [{ 'a': 1 }, { 'b': 2 }];
  28148. *
  28149. * var deep = _.cloneDeep(objects);
  28150. * console.log(deep[0] === objects[0]);
  28151. * // => false
  28152. */
  28153. function cloneDeep(value) {
  28154. return baseClone(value, CLONE_DEEP_FLAG | CLONE_SYMBOLS_FLAG);
  28155. }
  28156. /**
  28157. * This method is like `_.cloneWith` except that it recursively clones `value`.
  28158. *
  28159. * @static
  28160. * @memberOf _
  28161. * @since 4.0.0
  28162. * @category Lang
  28163. * @param {*} value The value to recursively clone.
  28164. * @param {Function} [customizer] The function to customize cloning.
  28165. * @returns {*} Returns the deep cloned value.
  28166. * @see _.cloneWith
  28167. * @example
  28168. *
  28169. * function customizer(value) {
  28170. * if (_.isElement(value)) {
  28171. * return value.cloneNode(true);
  28172. * }
  28173. * }
  28174. *
  28175. * var el = _.cloneDeepWith(document.body, customizer);
  28176. *
  28177. * console.log(el === document.body);
  28178. * // => false
  28179. * console.log(el.nodeName);
  28180. * // => 'BODY'
  28181. * console.log(el.childNodes.length);
  28182. * // => 20
  28183. */
  28184. function cloneDeepWith(value, customizer) {
  28185. customizer = typeof customizer == 'function' ? customizer : undefined;
  28186. return baseClone(value, CLONE_DEEP_FLAG | CLONE_SYMBOLS_FLAG, customizer);
  28187. }
  28188. /**
  28189. * Checks if `object` conforms to `source` by invoking the predicate
  28190. * properties of `source` with the corresponding property values of `object`.
  28191. *
  28192. * **Note:** This method is equivalent to `_.conforms` when `source` is
  28193. * partially applied.
  28194. *
  28195. * @static
  28196. * @memberOf _
  28197. * @since 4.14.0
  28198. * @category Lang
  28199. * @param {Object} object The object to inspect.
  28200. * @param {Object} source The object of property predicates to conform to.
  28201. * @returns {boolean} Returns `true` if `object` conforms, else `false`.
  28202. * @example
  28203. *
  28204. * var object = { 'a': 1, 'b': 2 };
  28205. *
  28206. * _.conformsTo(object, { 'b': function(n) { return n > 1; } });
  28207. * // => true
  28208. *
  28209. * _.conformsTo(object, { 'b': function(n) { return n > 2; } });
  28210. * // => false
  28211. */
  28212. function conformsTo(object, source) {
  28213. return source == null || baseConformsTo(object, source, keys(source));
  28214. }
  28215. /**
  28216. * Performs a
  28217. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  28218. * comparison between two values to determine if they are equivalent.
  28219. *
  28220. * @static
  28221. * @memberOf _
  28222. * @since 4.0.0
  28223. * @category Lang
  28224. * @param {*} value The value to compare.
  28225. * @param {*} other The other value to compare.
  28226. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  28227. * @example
  28228. *
  28229. * var object = { 'a': 1 };
  28230. * var other = { 'a': 1 };
  28231. *
  28232. * _.eq(object, object);
  28233. * // => true
  28234. *
  28235. * _.eq(object, other);
  28236. * // => false
  28237. *
  28238. * _.eq('a', 'a');
  28239. * // => true
  28240. *
  28241. * _.eq('a', Object('a'));
  28242. * // => false
  28243. *
  28244. * _.eq(NaN, NaN);
  28245. * // => true
  28246. */
  28247. function eq(value, other) {
  28248. return value === other || (value !== value && other !== other);
  28249. }
  28250. /**
  28251. * Checks if `value` is greater than `other`.
  28252. *
  28253. * @static
  28254. * @memberOf _
  28255. * @since 3.9.0
  28256. * @category Lang
  28257. * @param {*} value The value to compare.
  28258. * @param {*} other The other value to compare.
  28259. * @returns {boolean} Returns `true` if `value` is greater than `other`,
  28260. * else `false`.
  28261. * @see _.lt
  28262. * @example
  28263. *
  28264. * _.gt(3, 1);
  28265. * // => true
  28266. *
  28267. * _.gt(3, 3);
  28268. * // => false
  28269. *
  28270. * _.gt(1, 3);
  28271. * // => false
  28272. */
  28273. var gt = createRelationalOperation(baseGt);
  28274. /**
  28275. * Checks if `value` is greater than or equal to `other`.
  28276. *
  28277. * @static
  28278. * @memberOf _
  28279. * @since 3.9.0
  28280. * @category Lang
  28281. * @param {*} value The value to compare.
  28282. * @param {*} other The other value to compare.
  28283. * @returns {boolean} Returns `true` if `value` is greater than or equal to
  28284. * `other`, else `false`.
  28285. * @see _.lte
  28286. * @example
  28287. *
  28288. * _.gte(3, 1);
  28289. * // => true
  28290. *
  28291. * _.gte(3, 3);
  28292. * // => true
  28293. *
  28294. * _.gte(1, 3);
  28295. * // => false
  28296. */
  28297. var gte = createRelationalOperation(function(value, other) {
  28298. return value >= other;
  28299. });
  28300. /**
  28301. * Checks if `value` is likely an `arguments` object.
  28302. *
  28303. * @static
  28304. * @memberOf _
  28305. * @since 0.1.0
  28306. * @category Lang
  28307. * @param {*} value The value to check.
  28308. * @returns {boolean} Returns `true` if `value` is an `arguments` object,
  28309. * else `false`.
  28310. * @example
  28311. *
  28312. * _.isArguments(function() { return arguments; }());
  28313. * // => true
  28314. *
  28315. * _.isArguments([1, 2, 3]);
  28316. * // => false
  28317. */
  28318. var isArguments = baseIsArguments(function() { return arguments; }()) ? baseIsArguments : function(value) {
  28319. return isObjectLike(value) && hasOwnProperty.call(value, 'callee') &&
  28320. !propertyIsEnumerable.call(value, 'callee');
  28321. };
  28322. /**
  28323. * Checks if `value` is classified as an `Array` object.
  28324. *
  28325. * @static
  28326. * @memberOf _
  28327. * @since 0.1.0
  28328. * @category Lang
  28329. * @param {*} value The value to check.
  28330. * @returns {boolean} Returns `true` if `value` is an array, else `false`.
  28331. * @example
  28332. *
  28333. * _.isArray([1, 2, 3]);
  28334. * // => true
  28335. *
  28336. * _.isArray(document.body.children);
  28337. * // => false
  28338. *
  28339. * _.isArray('abc');
  28340. * // => false
  28341. *
  28342. * _.isArray(_.noop);
  28343. * // => false
  28344. */
  28345. var isArray = Array.isArray;
  28346. /**
  28347. * Checks if `value` is classified as an `ArrayBuffer` object.
  28348. *
  28349. * @static
  28350. * @memberOf _
  28351. * @since 4.3.0
  28352. * @category Lang
  28353. * @param {*} value The value to check.
  28354. * @returns {boolean} Returns `true` if `value` is an array buffer, else `false`.
  28355. * @example
  28356. *
  28357. * _.isArrayBuffer(new ArrayBuffer(2));
  28358. * // => true
  28359. *
  28360. * _.isArrayBuffer(new Array(2));
  28361. * // => false
  28362. */
  28363. var isArrayBuffer = nodeIsArrayBuffer ? baseUnary(nodeIsArrayBuffer) : baseIsArrayBuffer;
  28364. /**
  28365. * Checks if `value` is array-like. A value is considered array-like if it's
  28366. * not a function and has a `value.length` that's an integer greater than or
  28367. * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
  28368. *
  28369. * @static
  28370. * @memberOf _
  28371. * @since 4.0.0
  28372. * @category Lang
  28373. * @param {*} value The value to check.
  28374. * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
  28375. * @example
  28376. *
  28377. * _.isArrayLike([1, 2, 3]);
  28378. * // => true
  28379. *
  28380. * _.isArrayLike(document.body.children);
  28381. * // => true
  28382. *
  28383. * _.isArrayLike('abc');
  28384. * // => true
  28385. *
  28386. * _.isArrayLike(_.noop);
  28387. * // => false
  28388. */
  28389. function isArrayLike(value) {
  28390. return value != null && isLength(value.length) && !isFunction(value);
  28391. }
  28392. /**
  28393. * This method is like `_.isArrayLike` except that it also checks if `value`
  28394. * is an object.
  28395. *
  28396. * @static
  28397. * @memberOf _
  28398. * @since 4.0.0
  28399. * @category Lang
  28400. * @param {*} value The value to check.
  28401. * @returns {boolean} Returns `true` if `value` is an array-like object,
  28402. * else `false`.
  28403. * @example
  28404. *
  28405. * _.isArrayLikeObject([1, 2, 3]);
  28406. * // => true
  28407. *
  28408. * _.isArrayLikeObject(document.body.children);
  28409. * // => true
  28410. *
  28411. * _.isArrayLikeObject('abc');
  28412. * // => false
  28413. *
  28414. * _.isArrayLikeObject(_.noop);
  28415. * // => false
  28416. */
  28417. function isArrayLikeObject(value) {
  28418. return isObjectLike(value) && isArrayLike(value);
  28419. }
  28420. /**
  28421. * Checks if `value` is classified as a boolean primitive or object.
  28422. *
  28423. * @static
  28424. * @memberOf _
  28425. * @since 0.1.0
  28426. * @category Lang
  28427. * @param {*} value The value to check.
  28428. * @returns {boolean} Returns `true` if `value` is a boolean, else `false`.
  28429. * @example
  28430. *
  28431. * _.isBoolean(false);
  28432. * // => true
  28433. *
  28434. * _.isBoolean(null);
  28435. * // => false
  28436. */
  28437. function isBoolean(value) {
  28438. return value === true || value === false ||
  28439. (isObjectLike(value) && baseGetTag(value) == boolTag);
  28440. }
  28441. /**
  28442. * Checks if `value` is a buffer.
  28443. *
  28444. * @static
  28445. * @memberOf _
  28446. * @since 4.3.0
  28447. * @category Lang
  28448. * @param {*} value The value to check.
  28449. * @returns {boolean} Returns `true` if `value` is a buffer, else `false`.
  28450. * @example
  28451. *
  28452. * _.isBuffer(new Buffer(2));
  28453. * // => true
  28454. *
  28455. * _.isBuffer(new Uint8Array(2));
  28456. * // => false
  28457. */
  28458. var isBuffer = nativeIsBuffer || stubFalse;
  28459. /**
  28460. * Checks if `value` is classified as a `Date` object.
  28461. *
  28462. * @static
  28463. * @memberOf _
  28464. * @since 0.1.0
  28465. * @category Lang
  28466. * @param {*} value The value to check.
  28467. * @returns {boolean} Returns `true` if `value` is a date object, else `false`.
  28468. * @example
  28469. *
  28470. * _.isDate(new Date);
  28471. * // => true
  28472. *
  28473. * _.isDate('Mon April 23 2012');
  28474. * // => false
  28475. */
  28476. var isDate = nodeIsDate ? baseUnary(nodeIsDate) : baseIsDate;
  28477. /**
  28478. * Checks if `value` is likely a DOM element.
  28479. *
  28480. * @static
  28481. * @memberOf _
  28482. * @since 0.1.0
  28483. * @category Lang
  28484. * @param {*} value The value to check.
  28485. * @returns {boolean} Returns `true` if `value` is a DOM element, else `false`.
  28486. * @example
  28487. *
  28488. * _.isElement(document.body);
  28489. * // => true
  28490. *
  28491. * _.isElement('<body>');
  28492. * // => false
  28493. */
  28494. function isElement(value) {
  28495. return isObjectLike(value) && value.nodeType === 1 && !isPlainObject(value);
  28496. }
  28497. /**
  28498. * Checks if `value` is an empty object, collection, map, or set.
  28499. *
  28500. * Objects are considered empty if they have no own enumerable string keyed
  28501. * properties.
  28502. *
  28503. * Array-like values such as `arguments` objects, arrays, buffers, strings, or
  28504. * jQuery-like collections are considered empty if they have a `length` of `0`.
  28505. * Similarly, maps and sets are considered empty if they have a `size` of `0`.
  28506. *
  28507. * @static
  28508. * @memberOf _
  28509. * @since 0.1.0
  28510. * @category Lang
  28511. * @param {*} value The value to check.
  28512. * @returns {boolean} Returns `true` if `value` is empty, else `false`.
  28513. * @example
  28514. *
  28515. * _.isEmpty(null);
  28516. * // => true
  28517. *
  28518. * _.isEmpty(true);
  28519. * // => true
  28520. *
  28521. * _.isEmpty(1);
  28522. * // => true
  28523. *
  28524. * _.isEmpty([1, 2, 3]);
  28525. * // => false
  28526. *
  28527. * _.isEmpty({ 'a': 1 });
  28528. * // => false
  28529. */
  28530. function isEmpty(value) {
  28531. if (value == null) {
  28532. return true;
  28533. }
  28534. if (isArrayLike(value) &&
  28535. (isArray(value) || typeof value == 'string' || typeof value.splice == 'function' ||
  28536. isBuffer(value) || isTypedArray(value) || isArguments(value))) {
  28537. return !value.length;
  28538. }
  28539. var tag = getTag(value);
  28540. if (tag == mapTag || tag == setTag) {
  28541. return !value.size;
  28542. }
  28543. if (isPrototype(value)) {
  28544. return !baseKeys(value).length;
  28545. }
  28546. for (var key in value) {
  28547. if (hasOwnProperty.call(value, key)) {
  28548. return false;
  28549. }
  28550. }
  28551. return true;
  28552. }
  28553. /**
  28554. * Performs a deep comparison between two values to determine if they are
  28555. * equivalent.
  28556. *
  28557. * **Note:** This method supports comparing arrays, array buffers, booleans,
  28558. * date objects, error objects, maps, numbers, `Object` objects, regexes,
  28559. * sets, strings, symbols, and typed arrays. `Object` objects are compared
  28560. * by their own, not inherited, enumerable properties. Functions and DOM
  28561. * nodes are compared by strict equality, i.e. `===`.
  28562. *
  28563. * @static
  28564. * @memberOf _
  28565. * @since 0.1.0
  28566. * @category Lang
  28567. * @param {*} value The value to compare.
  28568. * @param {*} other The other value to compare.
  28569. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  28570. * @example
  28571. *
  28572. * var object = { 'a': 1 };
  28573. * var other = { 'a': 1 };
  28574. *
  28575. * _.isEqual(object, other);
  28576. * // => true
  28577. *
  28578. * object === other;
  28579. * // => false
  28580. */
  28581. function isEqual(value, other) {
  28582. return baseIsEqual(value, other);
  28583. }
  28584. /**
  28585. * This method is like `_.isEqual` except that it accepts `customizer` which
  28586. * is invoked to compare values. If `customizer` returns `undefined`, comparisons
  28587. * are handled by the method instead. The `customizer` is invoked with up to
  28588. * six arguments: (objValue, othValue [, index|key, object, other, stack]).
  28589. *
  28590. * @static
  28591. * @memberOf _
  28592. * @since 4.0.0
  28593. * @category Lang
  28594. * @param {*} value The value to compare.
  28595. * @param {*} other The other value to compare.
  28596. * @param {Function} [customizer] The function to customize comparisons.
  28597. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  28598. * @example
  28599. *
  28600. * function isGreeting(value) {
  28601. * return /^h(?:i|ello)$/.test(value);
  28602. * }
  28603. *
  28604. * function customizer(objValue, othValue) {
  28605. * if (isGreeting(objValue) && isGreeting(othValue)) {
  28606. * return true;
  28607. * }
  28608. * }
  28609. *
  28610. * var array = ['hello', 'goodbye'];
  28611. * var other = ['hi', 'goodbye'];
  28612. *
  28613. * _.isEqualWith(array, other, customizer);
  28614. * // => true
  28615. */
  28616. function isEqualWith(value, other, customizer) {
  28617. customizer = typeof customizer == 'function' ? customizer : undefined;
  28618. var result = customizer ? customizer(value, other) : undefined;
  28619. return result === undefined ? baseIsEqual(value, other, undefined, customizer) : !!result;
  28620. }
  28621. /**
  28622. * Checks if `value` is an `Error`, `EvalError`, `RangeError`, `ReferenceError`,
  28623. * `SyntaxError`, `TypeError`, or `URIError` object.
  28624. *
  28625. * @static
  28626. * @memberOf _
  28627. * @since 3.0.0
  28628. * @category Lang
  28629. * @param {*} value The value to check.
  28630. * @returns {boolean} Returns `true` if `value` is an error object, else `false`.
  28631. * @example
  28632. *
  28633. * _.isError(new Error);
  28634. * // => true
  28635. *
  28636. * _.isError(Error);
  28637. * // => false
  28638. */
  28639. function isError(value) {
  28640. if (!isObjectLike(value)) {
  28641. return false;
  28642. }
  28643. var tag = baseGetTag(value);
  28644. return tag == errorTag || tag == domExcTag ||
  28645. (typeof value.message == 'string' && typeof value.name == 'string' && !isPlainObject(value));
  28646. }
  28647. /**
  28648. * Checks if `value` is a finite primitive number.
  28649. *
  28650. * **Note:** This method is based on
  28651. * [`Number.isFinite`](https://mdn.io/Number/isFinite).
  28652. *
  28653. * @static
  28654. * @memberOf _
  28655. * @since 0.1.0
  28656. * @category Lang
  28657. * @param {*} value The value to check.
  28658. * @returns {boolean} Returns `true` if `value` is a finite number, else `false`.
  28659. * @example
  28660. *
  28661. * _.isFinite(3);
  28662. * // => true
  28663. *
  28664. * _.isFinite(Number.MIN_VALUE);
  28665. * // => true
  28666. *
  28667. * _.isFinite(Infinity);
  28668. * // => false
  28669. *
  28670. * _.isFinite('3');
  28671. * // => false
  28672. */
  28673. function isFinite(value) {
  28674. return typeof value == 'number' && nativeIsFinite(value);
  28675. }
  28676. /**
  28677. * Checks if `value` is classified as a `Function` object.
  28678. *
  28679. * @static
  28680. * @memberOf _
  28681. * @since 0.1.0
  28682. * @category Lang
  28683. * @param {*} value The value to check.
  28684. * @returns {boolean} Returns `true` if `value` is a function, else `false`.
  28685. * @example
  28686. *
  28687. * _.isFunction(_);
  28688. * // => true
  28689. *
  28690. * _.isFunction(/abc/);
  28691. * // => false
  28692. */
  28693. function isFunction(value) {
  28694. if (!isObject(value)) {
  28695. return false;
  28696. }
  28697. // The use of `Object#toString` avoids issues with the `typeof` operator
  28698. // in Safari 9 which returns 'object' for typed arrays and other constructors.
  28699. var tag = baseGetTag(value);
  28700. return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag;
  28701. }
  28702. /**
  28703. * Checks if `value` is an integer.
  28704. *
  28705. * **Note:** This method is based on
  28706. * [`Number.isInteger`](https://mdn.io/Number/isInteger).
  28707. *
  28708. * @static
  28709. * @memberOf _
  28710. * @since 4.0.0
  28711. * @category Lang
  28712. * @param {*} value The value to check.
  28713. * @returns {boolean} Returns `true` if `value` is an integer, else `false`.
  28714. * @example
  28715. *
  28716. * _.isInteger(3);
  28717. * // => true
  28718. *
  28719. * _.isInteger(Number.MIN_VALUE);
  28720. * // => false
  28721. *
  28722. * _.isInteger(Infinity);
  28723. * // => false
  28724. *
  28725. * _.isInteger('3');
  28726. * // => false
  28727. */
  28728. function isInteger(value) {
  28729. return typeof value == 'number' && value == toInteger(value);
  28730. }
  28731. /**
  28732. * Checks if `value` is a valid array-like length.
  28733. *
  28734. * **Note:** This method is loosely based on
  28735. * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
  28736. *
  28737. * @static
  28738. * @memberOf _
  28739. * @since 4.0.0
  28740. * @category Lang
  28741. * @param {*} value The value to check.
  28742. * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
  28743. * @example
  28744. *
  28745. * _.isLength(3);
  28746. * // => true
  28747. *
  28748. * _.isLength(Number.MIN_VALUE);
  28749. * // => false
  28750. *
  28751. * _.isLength(Infinity);
  28752. * // => false
  28753. *
  28754. * _.isLength('3');
  28755. * // => false
  28756. */
  28757. function isLength(value) {
  28758. return typeof value == 'number' &&
  28759. value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
  28760. }
  28761. /**
  28762. * Checks if `value` is the
  28763. * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
  28764. * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
  28765. *
  28766. * @static
  28767. * @memberOf _
  28768. * @since 0.1.0
  28769. * @category Lang
  28770. * @param {*} value The value to check.
  28771. * @returns {boolean} Returns `true` if `value` is an object, else `false`.
  28772. * @example
  28773. *
  28774. * _.isObject({});
  28775. * // => true
  28776. *
  28777. * _.isObject([1, 2, 3]);
  28778. * // => true
  28779. *
  28780. * _.isObject(_.noop);
  28781. * // => true
  28782. *
  28783. * _.isObject(null);
  28784. * // => false
  28785. */
  28786. function isObject(value) {
  28787. var type = typeof value;
  28788. return value != null && (type == 'object' || type == 'function');
  28789. }
  28790. /**
  28791. * Checks if `value` is object-like. A value is object-like if it's not `null`
  28792. * and has a `typeof` result of "object".
  28793. *
  28794. * @static
  28795. * @memberOf _
  28796. * @since 4.0.0
  28797. * @category Lang
  28798. * @param {*} value The value to check.
  28799. * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
  28800. * @example
  28801. *
  28802. * _.isObjectLike({});
  28803. * // => true
  28804. *
  28805. * _.isObjectLike([1, 2, 3]);
  28806. * // => true
  28807. *
  28808. * _.isObjectLike(_.noop);
  28809. * // => false
  28810. *
  28811. * _.isObjectLike(null);
  28812. * // => false
  28813. */
  28814. function isObjectLike(value) {
  28815. return value != null && typeof value == 'object';
  28816. }
  28817. /**
  28818. * Checks if `value` is classified as a `Map` object.
  28819. *
  28820. * @static
  28821. * @memberOf _
  28822. * @since 4.3.0
  28823. * @category Lang
  28824. * @param {*} value The value to check.
  28825. * @returns {boolean} Returns `true` if `value` is a map, else `false`.
  28826. * @example
  28827. *
  28828. * _.isMap(new Map);
  28829. * // => true
  28830. *
  28831. * _.isMap(new WeakMap);
  28832. * // => false
  28833. */
  28834. var isMap = nodeIsMap ? baseUnary(nodeIsMap) : baseIsMap;
  28835. /**
  28836. * Performs a partial deep comparison between `object` and `source` to
  28837. * determine if `object` contains equivalent property values.
  28838. *
  28839. * **Note:** This method is equivalent to `_.matches` when `source` is
  28840. * partially applied.
  28841. *
  28842. * Partial comparisons will match empty array and empty object `source`
  28843. * values against any array or object value, respectively. See `_.isEqual`
  28844. * for a list of supported value comparisons.
  28845. *
  28846. * @static
  28847. * @memberOf _
  28848. * @since 3.0.0
  28849. * @category Lang
  28850. * @param {Object} object The object to inspect.
  28851. * @param {Object} source The object of property values to match.
  28852. * @returns {boolean} Returns `true` if `object` is a match, else `false`.
  28853. * @example
  28854. *
  28855. * var object = { 'a': 1, 'b': 2 };
  28856. *
  28857. * _.isMatch(object, { 'b': 2 });
  28858. * // => true
  28859. *
  28860. * _.isMatch(object, { 'b': 1 });
  28861. * // => false
  28862. */
  28863. function isMatch(object, source) {
  28864. return object === source || baseIsMatch(object, source, getMatchData(source));
  28865. }
  28866. /**
  28867. * This method is like `_.isMatch` except that it accepts `customizer` which
  28868. * is invoked to compare values. If `customizer` returns `undefined`, comparisons
  28869. * are handled by the method instead. The `customizer` is invoked with five
  28870. * arguments: (objValue, srcValue, index|key, object, source).
  28871. *
  28872. * @static
  28873. * @memberOf _
  28874. * @since 4.0.0
  28875. * @category Lang
  28876. * @param {Object} object The object to inspect.
  28877. * @param {Object} source The object of property values to match.
  28878. * @param {Function} [customizer] The function to customize comparisons.
  28879. * @returns {boolean} Returns `true` if `object` is a match, else `false`.
  28880. * @example
  28881. *
  28882. * function isGreeting(value) {
  28883. * return /^h(?:i|ello)$/.test(value);
  28884. * }
  28885. *
  28886. * function customizer(objValue, srcValue) {
  28887. * if (isGreeting(objValue) && isGreeting(srcValue)) {
  28888. * return true;
  28889. * }
  28890. * }
  28891. *
  28892. * var object = { 'greeting': 'hello' };
  28893. * var source = { 'greeting': 'hi' };
  28894. *
  28895. * _.isMatchWith(object, source, customizer);
  28896. * // => true
  28897. */
  28898. function isMatchWith(object, source, customizer) {
  28899. customizer = typeof customizer == 'function' ? customizer : undefined;
  28900. return baseIsMatch(object, source, getMatchData(source), customizer);
  28901. }
  28902. /**
  28903. * Checks if `value` is `NaN`.
  28904. *
  28905. * **Note:** This method is based on
  28906. * [`Number.isNaN`](https://mdn.io/Number/isNaN) and is not the same as
  28907. * global [`isNaN`](https://mdn.io/isNaN) which returns `true` for
  28908. * `undefined` and other non-number values.
  28909. *
  28910. * @static
  28911. * @memberOf _
  28912. * @since 0.1.0
  28913. * @category Lang
  28914. * @param {*} value The value to check.
  28915. * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`.
  28916. * @example
  28917. *
  28918. * _.isNaN(NaN);
  28919. * // => true
  28920. *
  28921. * _.isNaN(new Number(NaN));
  28922. * // => true
  28923. *
  28924. * isNaN(undefined);
  28925. * // => true
  28926. *
  28927. * _.isNaN(undefined);
  28928. * // => false
  28929. */
  28930. function isNaN(value) {
  28931. // An `NaN` primitive is the only value that is not equal to itself.
  28932. // Perform the `toStringTag` check first to avoid errors with some
  28933. // ActiveX objects in IE.
  28934. return isNumber(value) && value != +value;
  28935. }
  28936. /**
  28937. * Checks if `value` is a pristine native function.
  28938. *
  28939. * **Note:** This method can't reliably detect native functions in the presence
  28940. * of the core-js package because core-js circumvents this kind of detection.
  28941. * Despite multiple requests, the core-js maintainer has made it clear: any
  28942. * attempt to fix the detection will be obstructed. As a result, we're left
  28943. * with little choice but to throw an error. Unfortunately, this also affects
  28944. * packages, like [babel-polyfill](https://www.npmjs.com/package/babel-polyfill),
  28945. * which rely on core-js.
  28946. *
  28947. * @static
  28948. * @memberOf _
  28949. * @since 3.0.0
  28950. * @category Lang
  28951. * @param {*} value The value to check.
  28952. * @returns {boolean} Returns `true` if `value` is a native function,
  28953. * else `false`.
  28954. * @example
  28955. *
  28956. * _.isNative(Array.prototype.push);
  28957. * // => true
  28958. *
  28959. * _.isNative(_);
  28960. * // => false
  28961. */
  28962. function isNative(value) {
  28963. if (isMaskable(value)) {
  28964. throw new Error(CORE_ERROR_TEXT);
  28965. }
  28966. return baseIsNative(value);
  28967. }
  28968. /**
  28969. * Checks if `value` is `null`.
  28970. *
  28971. * @static
  28972. * @memberOf _
  28973. * @since 0.1.0
  28974. * @category Lang
  28975. * @param {*} value The value to check.
  28976. * @returns {boolean} Returns `true` if `value` is `null`, else `false`.
  28977. * @example
  28978. *
  28979. * _.isNull(null);
  28980. * // => true
  28981. *
  28982. * _.isNull(void 0);
  28983. * // => false
  28984. */
  28985. function isNull(value) {
  28986. return value === null;
  28987. }
  28988. /**
  28989. * Checks if `value` is `null` or `undefined`.
  28990. *
  28991. * @static
  28992. * @memberOf _
  28993. * @since 4.0.0
  28994. * @category Lang
  28995. * @param {*} value The value to check.
  28996. * @returns {boolean} Returns `true` if `value` is nullish, else `false`.
  28997. * @example
  28998. *
  28999. * _.isNil(null);
  29000. * // => true
  29001. *
  29002. * _.isNil(void 0);
  29003. * // => true
  29004. *
  29005. * _.isNil(NaN);
  29006. * // => false
  29007. */
  29008. function isNil(value) {
  29009. return value == null;
  29010. }
  29011. /**
  29012. * Checks if `value` is classified as a `Number` primitive or object.
  29013. *
  29014. * **Note:** To exclude `Infinity`, `-Infinity`, and `NaN`, which are
  29015. * classified as numbers, use the `_.isFinite` method.
  29016. *
  29017. * @static
  29018. * @memberOf _
  29019. * @since 0.1.0
  29020. * @category Lang
  29021. * @param {*} value The value to check.
  29022. * @returns {boolean} Returns `true` if `value` is a number, else `false`.
  29023. * @example
  29024. *
  29025. * _.isNumber(3);
  29026. * // => true
  29027. *
  29028. * _.isNumber(Number.MIN_VALUE);
  29029. * // => true
  29030. *
  29031. * _.isNumber(Infinity);
  29032. * // => true
  29033. *
  29034. * _.isNumber('3');
  29035. * // => false
  29036. */
  29037. function isNumber(value) {
  29038. return typeof value == 'number' ||
  29039. (isObjectLike(value) && baseGetTag(value) == numberTag);
  29040. }
  29041. /**
  29042. * Checks if `value` is a plain object, that is, an object created by the
  29043. * `Object` constructor or one with a `[[Prototype]]` of `null`.
  29044. *
  29045. * @static
  29046. * @memberOf _
  29047. * @since 0.8.0
  29048. * @category Lang
  29049. * @param {*} value The value to check.
  29050. * @returns {boolean} Returns `true` if `value` is a plain object, else `false`.
  29051. * @example
  29052. *
  29053. * function Foo() {
  29054. * this.a = 1;
  29055. * }
  29056. *
  29057. * _.isPlainObject(new Foo);
  29058. * // => false
  29059. *
  29060. * _.isPlainObject([1, 2, 3]);
  29061. * // => false
  29062. *
  29063. * _.isPlainObject({ 'x': 0, 'y': 0 });
  29064. * // => true
  29065. *
  29066. * _.isPlainObject(Object.create(null));
  29067. * // => true
  29068. */
  29069. function isPlainObject(value) {
  29070. if (!isObjectLike(value) || baseGetTag(value) != objectTag) {
  29071. return false;
  29072. }
  29073. var proto = getPrototype(value);
  29074. if (proto === null) {
  29075. return true;
  29076. }
  29077. var Ctor = hasOwnProperty.call(proto, 'constructor') && proto.constructor;
  29078. return typeof Ctor == 'function' && Ctor instanceof Ctor &&
  29079. funcToString.call(Ctor) == objectCtorString;
  29080. }
  29081. /**
  29082. * Checks if `value` is classified as a `RegExp` object.
  29083. *
  29084. * @static
  29085. * @memberOf _
  29086. * @since 0.1.0
  29087. * @category Lang
  29088. * @param {*} value The value to check.
  29089. * @returns {boolean} Returns `true` if `value` is a regexp, else `false`.
  29090. * @example
  29091. *
  29092. * _.isRegExp(/abc/);
  29093. * // => true
  29094. *
  29095. * _.isRegExp('/abc/');
  29096. * // => false
  29097. */
  29098. var isRegExp = nodeIsRegExp ? baseUnary(nodeIsRegExp) : baseIsRegExp;
  29099. /**
  29100. * Checks if `value` is a safe integer. An integer is safe if it's an IEEE-754
  29101. * double precision number which isn't the result of a rounded unsafe integer.
  29102. *
  29103. * **Note:** This method is based on
  29104. * [`Number.isSafeInteger`](https://mdn.io/Number/isSafeInteger).
  29105. *
  29106. * @static
  29107. * @memberOf _
  29108. * @since 4.0.0
  29109. * @category Lang
  29110. * @param {*} value The value to check.
  29111. * @returns {boolean} Returns `true` if `value` is a safe integer, else `false`.
  29112. * @example
  29113. *
  29114. * _.isSafeInteger(3);
  29115. * // => true
  29116. *
  29117. * _.isSafeInteger(Number.MIN_VALUE);
  29118. * // => false
  29119. *
  29120. * _.isSafeInteger(Infinity);
  29121. * // => false
  29122. *
  29123. * _.isSafeInteger('3');
  29124. * // => false
  29125. */
  29126. function isSafeInteger(value) {
  29127. return isInteger(value) && value >= -MAX_SAFE_INTEGER && value <= MAX_SAFE_INTEGER;
  29128. }
  29129. /**
  29130. * Checks if `value` is classified as a `Set` object.
  29131. *
  29132. * @static
  29133. * @memberOf _
  29134. * @since 4.3.0
  29135. * @category Lang
  29136. * @param {*} value The value to check.
  29137. * @returns {boolean} Returns `true` if `value` is a set, else `false`.
  29138. * @example
  29139. *
  29140. * _.isSet(new Set);
  29141. * // => true
  29142. *
  29143. * _.isSet(new WeakSet);
  29144. * // => false
  29145. */
  29146. var isSet = nodeIsSet ? baseUnary(nodeIsSet) : baseIsSet;
  29147. /**
  29148. * Checks if `value` is classified as a `String` primitive or object.
  29149. *
  29150. * @static
  29151. * @since 0.1.0
  29152. * @memberOf _
  29153. * @category Lang
  29154. * @param {*} value The value to check.
  29155. * @returns {boolean} Returns `true` if `value` is a string, else `false`.
  29156. * @example
  29157. *
  29158. * _.isString('abc');
  29159. * // => true
  29160. *
  29161. * _.isString(1);
  29162. * // => false
  29163. */
  29164. function isString(value) {
  29165. return typeof value == 'string' ||
  29166. (!isArray(value) && isObjectLike(value) && baseGetTag(value) == stringTag);
  29167. }
  29168. /**
  29169. * Checks if `value` is classified as a `Symbol` primitive or object.
  29170. *
  29171. * @static
  29172. * @memberOf _
  29173. * @since 4.0.0
  29174. * @category Lang
  29175. * @param {*} value The value to check.
  29176. * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
  29177. * @example
  29178. *
  29179. * _.isSymbol(Symbol.iterator);
  29180. * // => true
  29181. *
  29182. * _.isSymbol('abc');
  29183. * // => false
  29184. */
  29185. function isSymbol(value) {
  29186. return typeof value == 'symbol' ||
  29187. (isObjectLike(value) && baseGetTag(value) == symbolTag);
  29188. }
  29189. /**
  29190. * Checks if `value` is classified as a typed array.
  29191. *
  29192. * @static
  29193. * @memberOf _
  29194. * @since 3.0.0
  29195. * @category Lang
  29196. * @param {*} value The value to check.
  29197. * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
  29198. * @example
  29199. *
  29200. * _.isTypedArray(new Uint8Array);
  29201. * // => true
  29202. *
  29203. * _.isTypedArray([]);
  29204. * // => false
  29205. */
  29206. var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray;
  29207. /**
  29208. * Checks if `value` is `undefined`.
  29209. *
  29210. * @static
  29211. * @since 0.1.0
  29212. * @memberOf _
  29213. * @category Lang
  29214. * @param {*} value The value to check.
  29215. * @returns {boolean} Returns `true` if `value` is `undefined`, else `false`.
  29216. * @example
  29217. *
  29218. * _.isUndefined(void 0);
  29219. * // => true
  29220. *
  29221. * _.isUndefined(null);
  29222. * // => false
  29223. */
  29224. function isUndefined(value) {
  29225. return value === undefined;
  29226. }
  29227. /**
  29228. * Checks if `value` is classified as a `WeakMap` object.
  29229. *
  29230. * @static
  29231. * @memberOf _
  29232. * @since 4.3.0
  29233. * @category Lang
  29234. * @param {*} value The value to check.
  29235. * @returns {boolean} Returns `true` if `value` is a weak map, else `false`.
  29236. * @example
  29237. *
  29238. * _.isWeakMap(new WeakMap);
  29239. * // => true
  29240. *
  29241. * _.isWeakMap(new Map);
  29242. * // => false
  29243. */
  29244. function isWeakMap(value) {
  29245. return isObjectLike(value) && getTag(value) == weakMapTag;
  29246. }
  29247. /**
  29248. * Checks if `value` is classified as a `WeakSet` object.
  29249. *
  29250. * @static
  29251. * @memberOf _
  29252. * @since 4.3.0
  29253. * @category Lang
  29254. * @param {*} value The value to check.
  29255. * @returns {boolean} Returns `true` if `value` is a weak set, else `false`.
  29256. * @example
  29257. *
  29258. * _.isWeakSet(new WeakSet);
  29259. * // => true
  29260. *
  29261. * _.isWeakSet(new Set);
  29262. * // => false
  29263. */
  29264. function isWeakSet(value) {
  29265. return isObjectLike(value) && baseGetTag(value) == weakSetTag;
  29266. }
  29267. /**
  29268. * Checks if `value` is less than `other`.
  29269. *
  29270. * @static
  29271. * @memberOf _
  29272. * @since 3.9.0
  29273. * @category Lang
  29274. * @param {*} value The value to compare.
  29275. * @param {*} other The other value to compare.
  29276. * @returns {boolean} Returns `true` if `value` is less than `other`,
  29277. * else `false`.
  29278. * @see _.gt
  29279. * @example
  29280. *
  29281. * _.lt(1, 3);
  29282. * // => true
  29283. *
  29284. * _.lt(3, 3);
  29285. * // => false
  29286. *
  29287. * _.lt(3, 1);
  29288. * // => false
  29289. */
  29290. var lt = createRelationalOperation(baseLt);
  29291. /**
  29292. * Checks if `value` is less than or equal to `other`.
  29293. *
  29294. * @static
  29295. * @memberOf _
  29296. * @since 3.9.0
  29297. * @category Lang
  29298. * @param {*} value The value to compare.
  29299. * @param {*} other The other value to compare.
  29300. * @returns {boolean} Returns `true` if `value` is less than or equal to
  29301. * `other`, else `false`.
  29302. * @see _.gte
  29303. * @example
  29304. *
  29305. * _.lte(1, 3);
  29306. * // => true
  29307. *
  29308. * _.lte(3, 3);
  29309. * // => true
  29310. *
  29311. * _.lte(3, 1);
  29312. * // => false
  29313. */
  29314. var lte = createRelationalOperation(function(value, other) {
  29315. return value <= other;
  29316. });
  29317. /**
  29318. * Converts `value` to an array.
  29319. *
  29320. * @static
  29321. * @since 0.1.0
  29322. * @memberOf _
  29323. * @category Lang
  29324. * @param {*} value The value to convert.
  29325. * @returns {Array} Returns the converted array.
  29326. * @example
  29327. *
  29328. * _.toArray({ 'a': 1, 'b': 2 });
  29329. * // => [1, 2]
  29330. *
  29331. * _.toArray('abc');
  29332. * // => ['a', 'b', 'c']
  29333. *
  29334. * _.toArray(1);
  29335. * // => []
  29336. *
  29337. * _.toArray(null);
  29338. * // => []
  29339. */
  29340. function toArray(value) {
  29341. if (!value) {
  29342. return [];
  29343. }
  29344. if (isArrayLike(value)) {
  29345. return isString(value) ? stringToArray(value) : copyArray(value);
  29346. }
  29347. if (symIterator && value[symIterator]) {
  29348. return iteratorToArray(value[symIterator]());
  29349. }
  29350. var tag = getTag(value),
  29351. func = tag == mapTag ? mapToArray : (tag == setTag ? setToArray : values);
  29352. return func(value);
  29353. }
  29354. /**
  29355. * Converts `value` to a finite number.
  29356. *
  29357. * @static
  29358. * @memberOf _
  29359. * @since 4.12.0
  29360. * @category Lang
  29361. * @param {*} value The value to convert.
  29362. * @returns {number} Returns the converted number.
  29363. * @example
  29364. *
  29365. * _.toFinite(3.2);
  29366. * // => 3.2
  29367. *
  29368. * _.toFinite(Number.MIN_VALUE);
  29369. * // => 5e-324
  29370. *
  29371. * _.toFinite(Infinity);
  29372. * // => 1.7976931348623157e+308
  29373. *
  29374. * _.toFinite('3.2');
  29375. * // => 3.2
  29376. */
  29377. function toFinite(value) {
  29378. if (!value) {
  29379. return value === 0 ? value : 0;
  29380. }
  29381. value = toNumber(value);
  29382. if (value === INFINITY || value === -INFINITY) {
  29383. var sign = (value < 0 ? -1 : 1);
  29384. return sign * MAX_INTEGER;
  29385. }
  29386. return value === value ? value : 0;
  29387. }
  29388. /**
  29389. * Converts `value` to an integer.
  29390. *
  29391. * **Note:** This method is loosely based on
  29392. * [`ToInteger`](http://www.ecma-international.org/ecma-262/7.0/#sec-tointeger).
  29393. *
  29394. * @static
  29395. * @memberOf _
  29396. * @since 4.0.0
  29397. * @category Lang
  29398. * @param {*} value The value to convert.
  29399. * @returns {number} Returns the converted integer.
  29400. * @example
  29401. *
  29402. * _.toInteger(3.2);
  29403. * // => 3
  29404. *
  29405. * _.toInteger(Number.MIN_VALUE);
  29406. * // => 0
  29407. *
  29408. * _.toInteger(Infinity);
  29409. * // => 1.7976931348623157e+308
  29410. *
  29411. * _.toInteger('3.2');
  29412. * // => 3
  29413. */
  29414. function toInteger(value) {
  29415. var result = toFinite(value),
  29416. remainder = result % 1;
  29417. return result === result ? (remainder ? result - remainder : result) : 0;
  29418. }
  29419. /**
  29420. * Converts `value` to an integer suitable for use as the length of an
  29421. * array-like object.
  29422. *
  29423. * **Note:** This method is based on
  29424. * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
  29425. *
  29426. * @static
  29427. * @memberOf _
  29428. * @since 4.0.0
  29429. * @category Lang
  29430. * @param {*} value The value to convert.
  29431. * @returns {number} Returns the converted integer.
  29432. * @example
  29433. *
  29434. * _.toLength(3.2);
  29435. * // => 3
  29436. *
  29437. * _.toLength(Number.MIN_VALUE);
  29438. * // => 0
  29439. *
  29440. * _.toLength(Infinity);
  29441. * // => 4294967295
  29442. *
  29443. * _.toLength('3.2');
  29444. * // => 3
  29445. */
  29446. function toLength(value) {
  29447. return value ? baseClamp(toInteger(value), 0, MAX_ARRAY_LENGTH) : 0;
  29448. }
  29449. /**
  29450. * Converts `value` to a number.
  29451. *
  29452. * @static
  29453. * @memberOf _
  29454. * @since 4.0.0
  29455. * @category Lang
  29456. * @param {*} value The value to process.
  29457. * @returns {number} Returns the number.
  29458. * @example
  29459. *
  29460. * _.toNumber(3.2);
  29461. * // => 3.2
  29462. *
  29463. * _.toNumber(Number.MIN_VALUE);
  29464. * // => 5e-324
  29465. *
  29466. * _.toNumber(Infinity);
  29467. * // => Infinity
  29468. *
  29469. * _.toNumber('3.2');
  29470. * // => 3.2
  29471. */
  29472. function toNumber(value) {
  29473. if (typeof value == 'number') {
  29474. return value;
  29475. }
  29476. if (isSymbol(value)) {
  29477. return NAN;
  29478. }
  29479. if (isObject(value)) {
  29480. var other = typeof value.valueOf == 'function' ? value.valueOf() : value;
  29481. value = isObject(other) ? (other + '') : other;
  29482. }
  29483. if (typeof value != 'string') {
  29484. return value === 0 ? value : +value;
  29485. }
  29486. value = value.replace(reTrim, '');
  29487. var isBinary = reIsBinary.test(value);
  29488. return (isBinary || reIsOctal.test(value))
  29489. ? freeParseInt(value.slice(2), isBinary ? 2 : 8)
  29490. : (reIsBadHex.test(value) ? NAN : +value);
  29491. }
  29492. /**
  29493. * Converts `value` to a plain object flattening inherited enumerable string
  29494. * keyed properties of `value` to own properties of the plain object.
  29495. *
  29496. * @static
  29497. * @memberOf _
  29498. * @since 3.0.0
  29499. * @category Lang
  29500. * @param {*} value The value to convert.
  29501. * @returns {Object} Returns the converted plain object.
  29502. * @example
  29503. *
  29504. * function Foo() {
  29505. * this.b = 2;
  29506. * }
  29507. *
  29508. * Foo.prototype.c = 3;
  29509. *
  29510. * _.assign({ 'a': 1 }, new Foo);
  29511. * // => { 'a': 1, 'b': 2 }
  29512. *
  29513. * _.assign({ 'a': 1 }, _.toPlainObject(new Foo));
  29514. * // => { 'a': 1, 'b': 2, 'c': 3 }
  29515. */
  29516. function toPlainObject(value) {
  29517. return copyObject(value, keysIn(value));
  29518. }
  29519. /**
  29520. * Converts `value` to a safe integer. A safe integer can be compared and
  29521. * represented correctly.
  29522. *
  29523. * @static
  29524. * @memberOf _
  29525. * @since 4.0.0
  29526. * @category Lang
  29527. * @param {*} value The value to convert.
  29528. * @returns {number} Returns the converted integer.
  29529. * @example
  29530. *
  29531. * _.toSafeInteger(3.2);
  29532. * // => 3
  29533. *
  29534. * _.toSafeInteger(Number.MIN_VALUE);
  29535. * // => 0
  29536. *
  29537. * _.toSafeInteger(Infinity);
  29538. * // => 9007199254740991
  29539. *
  29540. * _.toSafeInteger('3.2');
  29541. * // => 3
  29542. */
  29543. function toSafeInteger(value) {
  29544. return value
  29545. ? baseClamp(toInteger(value), -MAX_SAFE_INTEGER, MAX_SAFE_INTEGER)
  29546. : (value === 0 ? value : 0);
  29547. }
  29548. /**
  29549. * Converts `value` to a string. An empty string is returned for `null`
  29550. * and `undefined` values. The sign of `-0` is preserved.
  29551. *
  29552. * @static
  29553. * @memberOf _
  29554. * @since 4.0.0
  29555. * @category Lang
  29556. * @param {*} value The value to convert.
  29557. * @returns {string} Returns the converted string.
  29558. * @example
  29559. *
  29560. * _.toString(null);
  29561. * // => ''
  29562. *
  29563. * _.toString(-0);
  29564. * // => '-0'
  29565. *
  29566. * _.toString([1, 2, 3]);
  29567. * // => '1,2,3'
  29568. */
  29569. function toString(value) {
  29570. return value == null ? '' : baseToString(value);
  29571. }
  29572. /*------------------------------------------------------------------------*/
  29573. /**
  29574. * Assigns own enumerable string keyed properties of source objects to the
  29575. * destination object. Source objects are applied from left to right.
  29576. * Subsequent sources overwrite property assignments of previous sources.
  29577. *
  29578. * **Note:** This method mutates `object` and is loosely based on
  29579. * [`Object.assign`](https://mdn.io/Object/assign).
  29580. *
  29581. * @static
  29582. * @memberOf _
  29583. * @since 0.10.0
  29584. * @category Object
  29585. * @param {Object} object The destination object.
  29586. * @param {...Object} [sources] The source objects.
  29587. * @returns {Object} Returns `object`.
  29588. * @see _.assignIn
  29589. * @example
  29590. *
  29591. * function Foo() {
  29592. * this.a = 1;
  29593. * }
  29594. *
  29595. * function Bar() {
  29596. * this.c = 3;
  29597. * }
  29598. *
  29599. * Foo.prototype.b = 2;
  29600. * Bar.prototype.d = 4;
  29601. *
  29602. * _.assign({ 'a': 0 }, new Foo, new Bar);
  29603. * // => { 'a': 1, 'c': 3 }
  29604. */
  29605. var assign = createAssigner(function(object, source) {
  29606. if (isPrototype(source) || isArrayLike(source)) {
  29607. copyObject(source, keys(source), object);
  29608. return;
  29609. }
  29610. for (var key in source) {
  29611. if (hasOwnProperty.call(source, key)) {
  29612. assignValue(object, key, source[key]);
  29613. }
  29614. }
  29615. });
  29616. /**
  29617. * This method is like `_.assign` except that it iterates over own and
  29618. * inherited source properties.
  29619. *
  29620. * **Note:** This method mutates `object`.
  29621. *
  29622. * @static
  29623. * @memberOf _
  29624. * @since 4.0.0
  29625. * @alias extend
  29626. * @category Object
  29627. * @param {Object} object The destination object.
  29628. * @param {...Object} [sources] The source objects.
  29629. * @returns {Object} Returns `object`.
  29630. * @see _.assign
  29631. * @example
  29632. *
  29633. * function Foo() {
  29634. * this.a = 1;
  29635. * }
  29636. *
  29637. * function Bar() {
  29638. * this.c = 3;
  29639. * }
  29640. *
  29641. * Foo.prototype.b = 2;
  29642. * Bar.prototype.d = 4;
  29643. *
  29644. * _.assignIn({ 'a': 0 }, new Foo, new Bar);
  29645. * // => { 'a': 1, 'b': 2, 'c': 3, 'd': 4 }
  29646. */
  29647. var assignIn = createAssigner(function(object, source) {
  29648. copyObject(source, keysIn(source), object);
  29649. });
  29650. /**
  29651. * This method is like `_.assignIn` except that it accepts `customizer`
  29652. * which is invoked to produce the assigned values. If `customizer` returns
  29653. * `undefined`, assignment is handled by the method instead. The `customizer`
  29654. * is invoked with five arguments: (objValue, srcValue, key, object, source).
  29655. *
  29656. * **Note:** This method mutates `object`.
  29657. *
  29658. * @static
  29659. * @memberOf _
  29660. * @since 4.0.0
  29661. * @alias extendWith
  29662. * @category Object
  29663. * @param {Object} object The destination object.
  29664. * @param {...Object} sources The source objects.
  29665. * @param {Function} [customizer] The function to customize assigned values.
  29666. * @returns {Object} Returns `object`.
  29667. * @see _.assignWith
  29668. * @example
  29669. *
  29670. * function customizer(objValue, srcValue) {
  29671. * return _.isUndefined(objValue) ? srcValue : objValue;
  29672. * }
  29673. *
  29674. * var defaults = _.partialRight(_.assignInWith, customizer);
  29675. *
  29676. * defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
  29677. * // => { 'a': 1, 'b': 2 }
  29678. */
  29679. var assignInWith = createAssigner(function(object, source, srcIndex, customizer) {
  29680. copyObject(source, keysIn(source), object, customizer);
  29681. });
  29682. /**
  29683. * This method is like `_.assign` except that it accepts `customizer`
  29684. * which is invoked to produce the assigned values. If `customizer` returns
  29685. * `undefined`, assignment is handled by the method instead. The `customizer`
  29686. * is invoked with five arguments: (objValue, srcValue, key, object, source).
  29687. *
  29688. * **Note:** This method mutates `object`.
  29689. *
  29690. * @static
  29691. * @memberOf _
  29692. * @since 4.0.0
  29693. * @category Object
  29694. * @param {Object} object The destination object.
  29695. * @param {...Object} sources The source objects.
  29696. * @param {Function} [customizer] The function to customize assigned values.
  29697. * @returns {Object} Returns `object`.
  29698. * @see _.assignInWith
  29699. * @example
  29700. *
  29701. * function customizer(objValue, srcValue) {
  29702. * return _.isUndefined(objValue) ? srcValue : objValue;
  29703. * }
  29704. *
  29705. * var defaults = _.partialRight(_.assignWith, customizer);
  29706. *
  29707. * defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
  29708. * // => { 'a': 1, 'b': 2 }
  29709. */
  29710. var assignWith = createAssigner(function(object, source, srcIndex, customizer) {
  29711. copyObject(source, keys(source), object, customizer);
  29712. });
  29713. /**
  29714. * Creates an array of values corresponding to `paths` of `object`.
  29715. *
  29716. * @static
  29717. * @memberOf _
  29718. * @since 1.0.0
  29719. * @category Object
  29720. * @param {Object} object The object to iterate over.
  29721. * @param {...(string|string[])} [paths] The property paths to pick.
  29722. * @returns {Array} Returns the picked values.
  29723. * @example
  29724. *
  29725. * var object = { 'a': [{ 'b': { 'c': 3 } }, 4] };
  29726. *
  29727. * _.at(object, ['a[0].b.c', 'a[1]']);
  29728. * // => [3, 4]
  29729. */
  29730. var at = flatRest(baseAt);
  29731. /**
  29732. * Creates an object that inherits from the `prototype` object. If a
  29733. * `properties` object is given, its own enumerable string keyed properties
  29734. * are assigned to the created object.
  29735. *
  29736. * @static
  29737. * @memberOf _
  29738. * @since 2.3.0
  29739. * @category Object
  29740. * @param {Object} prototype The object to inherit from.
  29741. * @param {Object} [properties] The properties to assign to the object.
  29742. * @returns {Object} Returns the new object.
  29743. * @example
  29744. *
  29745. * function Shape() {
  29746. * this.x = 0;
  29747. * this.y = 0;
  29748. * }
  29749. *
  29750. * function Circle() {
  29751. * Shape.call(this);
  29752. * }
  29753. *
  29754. * Circle.prototype = _.create(Shape.prototype, {
  29755. * 'constructor': Circle
  29756. * });
  29757. *
  29758. * var circle = new Circle;
  29759. * circle instanceof Circle;
  29760. * // => true
  29761. *
  29762. * circle instanceof Shape;
  29763. * // => true
  29764. */
  29765. function create(prototype, properties) {
  29766. var result = baseCreate(prototype);
  29767. return properties == null ? result : baseAssign(result, properties);
  29768. }
  29769. /**
  29770. * Assigns own and inherited enumerable string keyed properties of source
  29771. * objects to the destination object for all destination properties that
  29772. * resolve to `undefined`. Source objects are applied from left to right.
  29773. * Once a property is set, additional values of the same property are ignored.
  29774. *
  29775. * **Note:** This method mutates `object`.
  29776. *
  29777. * @static
  29778. * @since 0.1.0
  29779. * @memberOf _
  29780. * @category Object
  29781. * @param {Object} object The destination object.
  29782. * @param {...Object} [sources] The source objects.
  29783. * @returns {Object} Returns `object`.
  29784. * @see _.defaultsDeep
  29785. * @example
  29786. *
  29787. * _.defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
  29788. * // => { 'a': 1, 'b': 2 }
  29789. */
  29790. var defaults = baseRest(function(object, sources) {
  29791. object = Object(object);
  29792. var index = -1;
  29793. var length = sources.length;
  29794. var guard = length > 2 ? sources[2] : undefined;
  29795. if (guard && isIterateeCall(sources[0], sources[1], guard)) {
  29796. length = 1;
  29797. }
  29798. while (++index < length) {
  29799. var source = sources[index];
  29800. var props = keysIn(source);
  29801. var propsIndex = -1;
  29802. var propsLength = props.length;
  29803. while (++propsIndex < propsLength) {
  29804. var key = props[propsIndex];
  29805. var value = object[key];
  29806. if (value === undefined ||
  29807. (eq(value, objectProto[key]) && !hasOwnProperty.call(object, key))) {
  29808. object[key] = source[key];
  29809. }
  29810. }
  29811. }
  29812. return object;
  29813. });
  29814. /**
  29815. * This method is like `_.defaults` except that it recursively assigns
  29816. * default properties.
  29817. *
  29818. * **Note:** This method mutates `object`.
  29819. *
  29820. * @static
  29821. * @memberOf _
  29822. * @since 3.10.0
  29823. * @category Object
  29824. * @param {Object} object The destination object.
  29825. * @param {...Object} [sources] The source objects.
  29826. * @returns {Object} Returns `object`.
  29827. * @see _.defaults
  29828. * @example
  29829. *
  29830. * _.defaultsDeep({ 'a': { 'b': 2 } }, { 'a': { 'b': 1, 'c': 3 } });
  29831. * // => { 'a': { 'b': 2, 'c': 3 } }
  29832. */
  29833. var defaultsDeep = baseRest(function(args) {
  29834. args.push(undefined, customDefaultsMerge);
  29835. return apply(mergeWith, undefined, args);
  29836. });
  29837. /**
  29838. * This method is like `_.find` except that it returns the key of the first
  29839. * element `predicate` returns truthy for instead of the element itself.
  29840. *
  29841. * @static
  29842. * @memberOf _
  29843. * @since 1.1.0
  29844. * @category Object
  29845. * @param {Object} object The object to inspect.
  29846. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  29847. * @returns {string|undefined} Returns the key of the matched element,
  29848. * else `undefined`.
  29849. * @example
  29850. *
  29851. * var users = {
  29852. * 'barney': { 'age': 36, 'active': true },
  29853. * 'fred': { 'age': 40, 'active': false },
  29854. * 'pebbles': { 'age': 1, 'active': true }
  29855. * };
  29856. *
  29857. * _.findKey(users, function(o) { return o.age < 40; });
  29858. * // => 'barney' (iteration order is not guaranteed)
  29859. *
  29860. * // The `_.matches` iteratee shorthand.
  29861. * _.findKey(users, { 'age': 1, 'active': true });
  29862. * // => 'pebbles'
  29863. *
  29864. * // The `_.matchesProperty` iteratee shorthand.
  29865. * _.findKey(users, ['active', false]);
  29866. * // => 'fred'
  29867. *
  29868. * // The `_.property` iteratee shorthand.
  29869. * _.findKey(users, 'active');
  29870. * // => 'barney'
  29871. */
  29872. function findKey(object, predicate) {
  29873. return baseFindKey(object, getIteratee(predicate, 3), baseForOwn);
  29874. }
  29875. /**
  29876. * This method is like `_.findKey` except that it iterates over elements of
  29877. * a collection in the opposite order.
  29878. *
  29879. * @static
  29880. * @memberOf _
  29881. * @since 2.0.0
  29882. * @category Object
  29883. * @param {Object} object The object to inspect.
  29884. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  29885. * @returns {string|undefined} Returns the key of the matched element,
  29886. * else `undefined`.
  29887. * @example
  29888. *
  29889. * var users = {
  29890. * 'barney': { 'age': 36, 'active': true },
  29891. * 'fred': { 'age': 40, 'active': false },
  29892. * 'pebbles': { 'age': 1, 'active': true }
  29893. * };
  29894. *
  29895. * _.findLastKey(users, function(o) { return o.age < 40; });
  29896. * // => returns 'pebbles' assuming `_.findKey` returns 'barney'
  29897. *
  29898. * // The `_.matches` iteratee shorthand.
  29899. * _.findLastKey(users, { 'age': 36, 'active': true });
  29900. * // => 'barney'
  29901. *
  29902. * // The `_.matchesProperty` iteratee shorthand.
  29903. * _.findLastKey(users, ['active', false]);
  29904. * // => 'fred'
  29905. *
  29906. * // The `_.property` iteratee shorthand.
  29907. * _.findLastKey(users, 'active');
  29908. * // => 'pebbles'
  29909. */
  29910. function findLastKey(object, predicate) {
  29911. return baseFindKey(object, getIteratee(predicate, 3), baseForOwnRight);
  29912. }
  29913. /**
  29914. * Iterates over own and inherited enumerable string keyed properties of an
  29915. * object and invokes `iteratee` for each property. The iteratee is invoked
  29916. * with three arguments: (value, key, object). Iteratee functions may exit
  29917. * iteration early by explicitly returning `false`.
  29918. *
  29919. * @static
  29920. * @memberOf _
  29921. * @since 0.3.0
  29922. * @category Object
  29923. * @param {Object} object The object to iterate over.
  29924. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  29925. * @returns {Object} Returns `object`.
  29926. * @see _.forInRight
  29927. * @example
  29928. *
  29929. * function Foo() {
  29930. * this.a = 1;
  29931. * this.b = 2;
  29932. * }
  29933. *
  29934. * Foo.prototype.c = 3;
  29935. *
  29936. * _.forIn(new Foo, function(value, key) {
  29937. * console.log(key);
  29938. * });
  29939. * // => Logs 'a', 'b', then 'c' (iteration order is not guaranteed).
  29940. */
  29941. function forIn(object, iteratee) {
  29942. return object == null
  29943. ? object
  29944. : baseFor(object, getIteratee(iteratee, 3), keysIn);
  29945. }
  29946. /**
  29947. * This method is like `_.forIn` except that it iterates over properties of
  29948. * `object` in the opposite order.
  29949. *
  29950. * @static
  29951. * @memberOf _
  29952. * @since 2.0.0
  29953. * @category Object
  29954. * @param {Object} object The object to iterate over.
  29955. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  29956. * @returns {Object} Returns `object`.
  29957. * @see _.forIn
  29958. * @example
  29959. *
  29960. * function Foo() {
  29961. * this.a = 1;
  29962. * this.b = 2;
  29963. * }
  29964. *
  29965. * Foo.prototype.c = 3;
  29966. *
  29967. * _.forInRight(new Foo, function(value, key) {
  29968. * console.log(key);
  29969. * });
  29970. * // => Logs 'c', 'b', then 'a' assuming `_.forIn` logs 'a', 'b', then 'c'.
  29971. */
  29972. function forInRight(object, iteratee) {
  29973. return object == null
  29974. ? object
  29975. : baseForRight(object, getIteratee(iteratee, 3), keysIn);
  29976. }
  29977. /**
  29978. * Iterates over own enumerable string keyed properties of an object and
  29979. * invokes `iteratee` for each property. The iteratee is invoked with three
  29980. * arguments: (value, key, object). Iteratee functions may exit iteration
  29981. * early by explicitly returning `false`.
  29982. *
  29983. * @static
  29984. * @memberOf _
  29985. * @since 0.3.0
  29986. * @category Object
  29987. * @param {Object} object The object to iterate over.
  29988. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  29989. * @returns {Object} Returns `object`.
  29990. * @see _.forOwnRight
  29991. * @example
  29992. *
  29993. * function Foo() {
  29994. * this.a = 1;
  29995. * this.b = 2;
  29996. * }
  29997. *
  29998. * Foo.prototype.c = 3;
  29999. *
  30000. * _.forOwn(new Foo, function(value, key) {
  30001. * console.log(key);
  30002. * });
  30003. * // => Logs 'a' then 'b' (iteration order is not guaranteed).
  30004. */
  30005. function forOwn(object, iteratee) {
  30006. return object && baseForOwn(object, getIteratee(iteratee, 3));
  30007. }
  30008. /**
  30009. * This method is like `_.forOwn` except that it iterates over properties of
  30010. * `object` in the opposite order.
  30011. *
  30012. * @static
  30013. * @memberOf _
  30014. * @since 2.0.0
  30015. * @category Object
  30016. * @param {Object} object The object to iterate over.
  30017. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  30018. * @returns {Object} Returns `object`.
  30019. * @see _.forOwn
  30020. * @example
  30021. *
  30022. * function Foo() {
  30023. * this.a = 1;
  30024. * this.b = 2;
  30025. * }
  30026. *
  30027. * Foo.prototype.c = 3;
  30028. *
  30029. * _.forOwnRight(new Foo, function(value, key) {
  30030. * console.log(key);
  30031. * });
  30032. * // => Logs 'b' then 'a' assuming `_.forOwn` logs 'a' then 'b'.
  30033. */
  30034. function forOwnRight(object, iteratee) {
  30035. return object && baseForOwnRight(object, getIteratee(iteratee, 3));
  30036. }
  30037. /**
  30038. * Creates an array of function property names from own enumerable properties
  30039. * of `object`.
  30040. *
  30041. * @static
  30042. * @since 0.1.0
  30043. * @memberOf _
  30044. * @category Object
  30045. * @param {Object} object The object to inspect.
  30046. * @returns {Array} Returns the function names.
  30047. * @see _.functionsIn
  30048. * @example
  30049. *
  30050. * function Foo() {
  30051. * this.a = _.constant('a');
  30052. * this.b = _.constant('b');
  30053. * }
  30054. *
  30055. * Foo.prototype.c = _.constant('c');
  30056. *
  30057. * _.functions(new Foo);
  30058. * // => ['a', 'b']
  30059. */
  30060. function functions(object) {
  30061. return object == null ? [] : baseFunctions(object, keys(object));
  30062. }
  30063. /**
  30064. * Creates an array of function property names from own and inherited
  30065. * enumerable properties of `object`.
  30066. *
  30067. * @static
  30068. * @memberOf _
  30069. * @since 4.0.0
  30070. * @category Object
  30071. * @param {Object} object The object to inspect.
  30072. * @returns {Array} Returns the function names.
  30073. * @see _.functions
  30074. * @example
  30075. *
  30076. * function Foo() {
  30077. * this.a = _.constant('a');
  30078. * this.b = _.constant('b');
  30079. * }
  30080. *
  30081. * Foo.prototype.c = _.constant('c');
  30082. *
  30083. * _.functionsIn(new Foo);
  30084. * // => ['a', 'b', 'c']
  30085. */
  30086. function functionsIn(object) {
  30087. return object == null ? [] : baseFunctions(object, keysIn(object));
  30088. }
  30089. /**
  30090. * Gets the value at `path` of `object`. If the resolved value is
  30091. * `undefined`, the `defaultValue` is returned in its place.
  30092. *
  30093. * @static
  30094. * @memberOf _
  30095. * @since 3.7.0
  30096. * @category Object
  30097. * @param {Object} object The object to query.
  30098. * @param {Array|string} path The path of the property to get.
  30099. * @param {*} [defaultValue] The value returned for `undefined` resolved values.
  30100. * @returns {*} Returns the resolved value.
  30101. * @example
  30102. *
  30103. * var object = { 'a': [{ 'b': { 'c': 3 } }] };
  30104. *
  30105. * _.get(object, 'a[0].b.c');
  30106. * // => 3
  30107. *
  30108. * _.get(object, ['a', '0', 'b', 'c']);
  30109. * // => 3
  30110. *
  30111. * _.get(object, 'a.b.c', 'default');
  30112. * // => 'default'
  30113. */
  30114. function get(object, path, defaultValue) {
  30115. var result = object == null ? undefined : baseGet(object, path);
  30116. return result === undefined ? defaultValue : result;
  30117. }
  30118. /**
  30119. * Checks if `path` is a direct property of `object`.
  30120. *
  30121. * @static
  30122. * @since 0.1.0
  30123. * @memberOf _
  30124. * @category Object
  30125. * @param {Object} object The object to query.
  30126. * @param {Array|string} path The path to check.
  30127. * @returns {boolean} Returns `true` if `path` exists, else `false`.
  30128. * @example
  30129. *
  30130. * var object = { 'a': { 'b': 2 } };
  30131. * var other = _.create({ 'a': _.create({ 'b': 2 }) });
  30132. *
  30133. * _.has(object, 'a');
  30134. * // => true
  30135. *
  30136. * _.has(object, 'a.b');
  30137. * // => true
  30138. *
  30139. * _.has(object, ['a', 'b']);
  30140. * // => true
  30141. *
  30142. * _.has(other, 'a');
  30143. * // => false
  30144. */
  30145. function has(object, path) {
  30146. return object != null && hasPath(object, path, baseHas);
  30147. }
  30148. /**
  30149. * Checks if `path` is a direct or inherited property of `object`.
  30150. *
  30151. * @static
  30152. * @memberOf _
  30153. * @since 4.0.0
  30154. * @category Object
  30155. * @param {Object} object The object to query.
  30156. * @param {Array|string} path The path to check.
  30157. * @returns {boolean} Returns `true` if `path` exists, else `false`.
  30158. * @example
  30159. *
  30160. * var object = _.create({ 'a': _.create({ 'b': 2 }) });
  30161. *
  30162. * _.hasIn(object, 'a');
  30163. * // => true
  30164. *
  30165. * _.hasIn(object, 'a.b');
  30166. * // => true
  30167. *
  30168. * _.hasIn(object, ['a', 'b']);
  30169. * // => true
  30170. *
  30171. * _.hasIn(object, 'b');
  30172. * // => false
  30173. */
  30174. function hasIn(object, path) {
  30175. return object != null && hasPath(object, path, baseHasIn);
  30176. }
  30177. /**
  30178. * Creates an object composed of the inverted keys and values of `object`.
  30179. * If `object` contains duplicate values, subsequent values overwrite
  30180. * property assignments of previous values.
  30181. *
  30182. * @static
  30183. * @memberOf _
  30184. * @since 0.7.0
  30185. * @category Object
  30186. * @param {Object} object The object to invert.
  30187. * @returns {Object} Returns the new inverted object.
  30188. * @example
  30189. *
  30190. * var object = { 'a': 1, 'b': 2, 'c': 1 };
  30191. *
  30192. * _.invert(object);
  30193. * // => { '1': 'c', '2': 'b' }
  30194. */
  30195. var invert = createInverter(function(result, value, key) {
  30196. if (value != null &&
  30197. typeof value.toString != 'function') {
  30198. value = nativeObjectToString.call(value);
  30199. }
  30200. result[value] = key;
  30201. }, constant(identity));
  30202. /**
  30203. * This method is like `_.invert` except that the inverted object is generated
  30204. * from the results of running each element of `object` thru `iteratee`. The
  30205. * corresponding inverted value of each inverted key is an array of keys
  30206. * responsible for generating the inverted value. The iteratee is invoked
  30207. * with one argument: (value).
  30208. *
  30209. * @static
  30210. * @memberOf _
  30211. * @since 4.1.0
  30212. * @category Object
  30213. * @param {Object} object The object to invert.
  30214. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  30215. * @returns {Object} Returns the new inverted object.
  30216. * @example
  30217. *
  30218. * var object = { 'a': 1, 'b': 2, 'c': 1 };
  30219. *
  30220. * _.invertBy(object);
  30221. * // => { '1': ['a', 'c'], '2': ['b'] }
  30222. *
  30223. * _.invertBy(object, function(value) {
  30224. * return 'group' + value;
  30225. * });
  30226. * // => { 'group1': ['a', 'c'], 'group2': ['b'] }
  30227. */
  30228. var invertBy = createInverter(function(result, value, key) {
  30229. if (value != null &&
  30230. typeof value.toString != 'function') {
  30231. value = nativeObjectToString.call(value);
  30232. }
  30233. if (hasOwnProperty.call(result, value)) {
  30234. result[value].push(key);
  30235. } else {
  30236. result[value] = [key];
  30237. }
  30238. }, getIteratee);
  30239. /**
  30240. * Invokes the method at `path` of `object`.
  30241. *
  30242. * @static
  30243. * @memberOf _
  30244. * @since 4.0.0
  30245. * @category Object
  30246. * @param {Object} object The object to query.
  30247. * @param {Array|string} path The path of the method to invoke.
  30248. * @param {...*} [args] The arguments to invoke the method with.
  30249. * @returns {*} Returns the result of the invoked method.
  30250. * @example
  30251. *
  30252. * var object = { 'a': [{ 'b': { 'c': [1, 2, 3, 4] } }] };
  30253. *
  30254. * _.invoke(object, 'a[0].b.c.slice', 1, 3);
  30255. * // => [2, 3]
  30256. */
  30257. var invoke = baseRest(baseInvoke);
  30258. /**
  30259. * Creates an array of the own enumerable property names of `object`.
  30260. *
  30261. * **Note:** Non-object values are coerced to objects. See the
  30262. * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
  30263. * for more details.
  30264. *
  30265. * @static
  30266. * @since 0.1.0
  30267. * @memberOf _
  30268. * @category Object
  30269. * @param {Object} object The object to query.
  30270. * @returns {Array} Returns the array of property names.
  30271. * @example
  30272. *
  30273. * function Foo() {
  30274. * this.a = 1;
  30275. * this.b = 2;
  30276. * }
  30277. *
  30278. * Foo.prototype.c = 3;
  30279. *
  30280. * _.keys(new Foo);
  30281. * // => ['a', 'b'] (iteration order is not guaranteed)
  30282. *
  30283. * _.keys('hi');
  30284. * // => ['0', '1']
  30285. */
  30286. function keys(object) {
  30287. return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object);
  30288. }
  30289. /**
  30290. * Creates an array of the own and inherited enumerable property names of `object`.
  30291. *
  30292. * **Note:** Non-object values are coerced to objects.
  30293. *
  30294. * @static
  30295. * @memberOf _
  30296. * @since 3.0.0
  30297. * @category Object
  30298. * @param {Object} object The object to query.
  30299. * @returns {Array} Returns the array of property names.
  30300. * @example
  30301. *
  30302. * function Foo() {
  30303. * this.a = 1;
  30304. * this.b = 2;
  30305. * }
  30306. *
  30307. * Foo.prototype.c = 3;
  30308. *
  30309. * _.keysIn(new Foo);
  30310. * // => ['a', 'b', 'c'] (iteration order is not guaranteed)
  30311. */
  30312. function keysIn(object) {
  30313. return isArrayLike(object) ? arrayLikeKeys(object, true) : baseKeysIn(object);
  30314. }
  30315. /**
  30316. * The opposite of `_.mapValues`; this method creates an object with the
  30317. * same values as `object` and keys generated by running each own enumerable
  30318. * string keyed property of `object` thru `iteratee`. The iteratee is invoked
  30319. * with three arguments: (value, key, object).
  30320. *
  30321. * @static
  30322. * @memberOf _
  30323. * @since 3.8.0
  30324. * @category Object
  30325. * @param {Object} object The object to iterate over.
  30326. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  30327. * @returns {Object} Returns the new mapped object.
  30328. * @see _.mapValues
  30329. * @example
  30330. *
  30331. * _.mapKeys({ 'a': 1, 'b': 2 }, function(value, key) {
  30332. * return key + value;
  30333. * });
  30334. * // => { 'a1': 1, 'b2': 2 }
  30335. */
  30336. function mapKeys(object, iteratee) {
  30337. var result = {};
  30338. iteratee = getIteratee(iteratee, 3);
  30339. baseForOwn(object, function(value, key, object) {
  30340. baseAssignValue(result, iteratee(value, key, object), value);
  30341. });
  30342. return result;
  30343. }
  30344. /**
  30345. * Creates an object with the same keys as `object` and values generated
  30346. * by running each own enumerable string keyed property of `object` thru
  30347. * `iteratee`. The iteratee is invoked with three arguments:
  30348. * (value, key, object).
  30349. *
  30350. * @static
  30351. * @memberOf _
  30352. * @since 2.4.0
  30353. * @category Object
  30354. * @param {Object} object The object to iterate over.
  30355. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  30356. * @returns {Object} Returns the new mapped object.
  30357. * @see _.mapKeys
  30358. * @example
  30359. *
  30360. * var users = {
  30361. * 'fred': { 'user': 'fred', 'age': 40 },
  30362. * 'pebbles': { 'user': 'pebbles', 'age': 1 }
  30363. * };
  30364. *
  30365. * _.mapValues(users, function(o) { return o.age; });
  30366. * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)
  30367. *
  30368. * // The `_.property` iteratee shorthand.
  30369. * _.mapValues(users, 'age');
  30370. * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)
  30371. */
  30372. function mapValues(object, iteratee) {
  30373. var result = {};
  30374. iteratee = getIteratee(iteratee, 3);
  30375. baseForOwn(object, function(value, key, object) {
  30376. baseAssignValue(result, key, iteratee(value, key, object));
  30377. });
  30378. return result;
  30379. }
  30380. /**
  30381. * This method is like `_.assign` except that it recursively merges own and
  30382. * inherited enumerable string keyed properties of source objects into the
  30383. * destination object. Source properties that resolve to `undefined` are
  30384. * skipped if a destination value exists. Array and plain object properties
  30385. * are merged recursively. Other objects and value types are overridden by
  30386. * assignment. Source objects are applied from left to right. Subsequent
  30387. * sources overwrite property assignments of previous sources.
  30388. *
  30389. * **Note:** This method mutates `object`.
  30390. *
  30391. * @static
  30392. * @memberOf _
  30393. * @since 0.5.0
  30394. * @category Object
  30395. * @param {Object} object The destination object.
  30396. * @param {...Object} [sources] The source objects.
  30397. * @returns {Object} Returns `object`.
  30398. * @example
  30399. *
  30400. * var object = {
  30401. * 'a': [{ 'b': 2 }, { 'd': 4 }]
  30402. * };
  30403. *
  30404. * var other = {
  30405. * 'a': [{ 'c': 3 }, { 'e': 5 }]
  30406. * };
  30407. *
  30408. * _.merge(object, other);
  30409. * // => { 'a': [{ 'b': 2, 'c': 3 }, { 'd': 4, 'e': 5 }] }
  30410. */
  30411. var merge = createAssigner(function(object, source, srcIndex) {
  30412. baseMerge(object, source, srcIndex);
  30413. });
  30414. /**
  30415. * This method is like `_.merge` except that it accepts `customizer` which
  30416. * is invoked to produce the merged values of the destination and source
  30417. * properties. If `customizer` returns `undefined`, merging is handled by the
  30418. * method instead. The `customizer` is invoked with six arguments:
  30419. * (objValue, srcValue, key, object, source, stack).
  30420. *
  30421. * **Note:** This method mutates `object`.
  30422. *
  30423. * @static
  30424. * @memberOf _
  30425. * @since 4.0.0
  30426. * @category Object
  30427. * @param {Object} object The destination object.
  30428. * @param {...Object} sources The source objects.
  30429. * @param {Function} customizer The function to customize assigned values.
  30430. * @returns {Object} Returns `object`.
  30431. * @example
  30432. *
  30433. * function customizer(objValue, srcValue) {
  30434. * if (_.isArray(objValue)) {
  30435. * return objValue.concat(srcValue);
  30436. * }
  30437. * }
  30438. *
  30439. * var object = { 'a': [1], 'b': [2] };
  30440. * var other = { 'a': [3], 'b': [4] };
  30441. *
  30442. * _.mergeWith(object, other, customizer);
  30443. * // => { 'a': [1, 3], 'b': [2, 4] }
  30444. */
  30445. var mergeWith = createAssigner(function(object, source, srcIndex, customizer) {
  30446. baseMerge(object, source, srcIndex, customizer);
  30447. });
  30448. /**
  30449. * The opposite of `_.pick`; this method creates an object composed of the
  30450. * own and inherited enumerable property paths of `object` that are not omitted.
  30451. *
  30452. * **Note:** This method is considerably slower than `_.pick`.
  30453. *
  30454. * @static
  30455. * @since 0.1.0
  30456. * @memberOf _
  30457. * @category Object
  30458. * @param {Object} object The source object.
  30459. * @param {...(string|string[])} [paths] The property paths to omit.
  30460. * @returns {Object} Returns the new object.
  30461. * @example
  30462. *
  30463. * var object = { 'a': 1, 'b': '2', 'c': 3 };
  30464. *
  30465. * _.omit(object, ['a', 'c']);
  30466. * // => { 'b': '2' }
  30467. */
  30468. var omit = flatRest(function(object, paths) {
  30469. var result = {};
  30470. if (object == null) {
  30471. return result;
  30472. }
  30473. var isDeep = false;
  30474. paths = arrayMap(paths, function(path) {
  30475. path = castPath(path, object);
  30476. isDeep || (isDeep = path.length > 1);
  30477. return path;
  30478. });
  30479. copyObject(object, getAllKeysIn(object), result);
  30480. if (isDeep) {
  30481. result = baseClone(result, CLONE_DEEP_FLAG | CLONE_FLAT_FLAG | CLONE_SYMBOLS_FLAG, customOmitClone);
  30482. }
  30483. var length = paths.length;
  30484. while (length--) {
  30485. baseUnset(result, paths[length]);
  30486. }
  30487. return result;
  30488. });
  30489. /**
  30490. * The opposite of `_.pickBy`; this method creates an object composed of
  30491. * the own and inherited enumerable string keyed properties of `object` that
  30492. * `predicate` doesn't return truthy for. The predicate is invoked with two
  30493. * arguments: (value, key).
  30494. *
  30495. * @static
  30496. * @memberOf _
  30497. * @since 4.0.0
  30498. * @category Object
  30499. * @param {Object} object The source object.
  30500. * @param {Function} [predicate=_.identity] The function invoked per property.
  30501. * @returns {Object} Returns the new object.
  30502. * @example
  30503. *
  30504. * var object = { 'a': 1, 'b': '2', 'c': 3 };
  30505. *
  30506. * _.omitBy(object, _.isNumber);
  30507. * // => { 'b': '2' }
  30508. */
  30509. function omitBy(object, predicate) {
  30510. return pickBy(object, negate(getIteratee(predicate)));
  30511. }
  30512. /**
  30513. * Creates an object composed of the picked `object` properties.
  30514. *
  30515. * @static
  30516. * @since 0.1.0
  30517. * @memberOf _
  30518. * @category Object
  30519. * @param {Object} object The source object.
  30520. * @param {...(string|string[])} [paths] The property paths to pick.
  30521. * @returns {Object} Returns the new object.
  30522. * @example
  30523. *
  30524. * var object = { 'a': 1, 'b': '2', 'c': 3 };
  30525. *
  30526. * _.pick(object, ['a', 'c']);
  30527. * // => { 'a': 1, 'c': 3 }
  30528. */
  30529. var pick = flatRest(function(object, paths) {
  30530. return object == null ? {} : basePick(object, paths);
  30531. });
  30532. /**
  30533. * Creates an object composed of the `object` properties `predicate` returns
  30534. * truthy for. The predicate is invoked with two arguments: (value, key).
  30535. *
  30536. * @static
  30537. * @memberOf _
  30538. * @since 4.0.0
  30539. * @category Object
  30540. * @param {Object} object The source object.
  30541. * @param {Function} [predicate=_.identity] The function invoked per property.
  30542. * @returns {Object} Returns the new object.
  30543. * @example
  30544. *
  30545. * var object = { 'a': 1, 'b': '2', 'c': 3 };
  30546. *
  30547. * _.pickBy(object, _.isNumber);
  30548. * // => { 'a': 1, 'c': 3 }
  30549. */
  30550. function pickBy(object, predicate) {
  30551. if (object == null) {
  30552. return {};
  30553. }
  30554. var props = arrayMap(getAllKeysIn(object), function(prop) {
  30555. return [prop];
  30556. });
  30557. predicate = getIteratee(predicate);
  30558. return basePickBy(object, props, function(value, path) {
  30559. return predicate(value, path[0]);
  30560. });
  30561. }
  30562. /**
  30563. * This method is like `_.get` except that if the resolved value is a
  30564. * function it's invoked with the `this` binding of its parent object and
  30565. * its result is returned.
  30566. *
  30567. * @static
  30568. * @since 0.1.0
  30569. * @memberOf _
  30570. * @category Object
  30571. * @param {Object} object The object to query.
  30572. * @param {Array|string} path The path of the property to resolve.
  30573. * @param {*} [defaultValue] The value returned for `undefined` resolved values.
  30574. * @returns {*} Returns the resolved value.
  30575. * @example
  30576. *
  30577. * var object = { 'a': [{ 'b': { 'c1': 3, 'c2': _.constant(4) } }] };
  30578. *
  30579. * _.result(object, 'a[0].b.c1');
  30580. * // => 3
  30581. *
  30582. * _.result(object, 'a[0].b.c2');
  30583. * // => 4
  30584. *
  30585. * _.result(object, 'a[0].b.c3', 'default');
  30586. * // => 'default'
  30587. *
  30588. * _.result(object, 'a[0].b.c3', _.constant('default'));
  30589. * // => 'default'
  30590. */
  30591. function result(object, path, defaultValue) {
  30592. path = castPath(path, object);
  30593. var index = -1,
  30594. length = path.length;
  30595. // Ensure the loop is entered when path is empty.
  30596. if (!length) {
  30597. length = 1;
  30598. object = undefined;
  30599. }
  30600. while (++index < length) {
  30601. var value = object == null ? undefined : object[toKey(path[index])];
  30602. if (value === undefined) {
  30603. index = length;
  30604. value = defaultValue;
  30605. }
  30606. object = isFunction(value) ? value.call(object) : value;
  30607. }
  30608. return object;
  30609. }
  30610. /**
  30611. * Sets the value at `path` of `object`. If a portion of `path` doesn't exist,
  30612. * it's created. Arrays are created for missing index properties while objects
  30613. * are created for all other missing properties. Use `_.setWith` to customize
  30614. * `path` creation.
  30615. *
  30616. * **Note:** This method mutates `object`.
  30617. *
  30618. * @static
  30619. * @memberOf _
  30620. * @since 3.7.0
  30621. * @category Object
  30622. * @param {Object} object The object to modify.
  30623. * @param {Array|string} path The path of the property to set.
  30624. * @param {*} value The value to set.
  30625. * @returns {Object} Returns `object`.
  30626. * @example
  30627. *
  30628. * var object = { 'a': [{ 'b': { 'c': 3 } }] };
  30629. *
  30630. * _.set(object, 'a[0].b.c', 4);
  30631. * console.log(object.a[0].b.c);
  30632. * // => 4
  30633. *
  30634. * _.set(object, ['x', '0', 'y', 'z'], 5);
  30635. * console.log(object.x[0].y.z);
  30636. * // => 5
  30637. */
  30638. function set(object, path, value) {
  30639. return object == null ? object : baseSet(object, path, value);
  30640. }
  30641. /**
  30642. * This method is like `_.set` except that it accepts `customizer` which is
  30643. * invoked to produce the objects of `path`. If `customizer` returns `undefined`
  30644. * path creation is handled by the method instead. The `customizer` is invoked
  30645. * with three arguments: (nsValue, key, nsObject).
  30646. *
  30647. * **Note:** This method mutates `object`.
  30648. *
  30649. * @static
  30650. * @memberOf _
  30651. * @since 4.0.0
  30652. * @category Object
  30653. * @param {Object} object The object to modify.
  30654. * @param {Array|string} path The path of the property to set.
  30655. * @param {*} value The value to set.
  30656. * @param {Function} [customizer] The function to customize assigned values.
  30657. * @returns {Object} Returns `object`.
  30658. * @example
  30659. *
  30660. * var object = {};
  30661. *
  30662. * _.setWith(object, '[0][1]', 'a', Object);
  30663. * // => { '0': { '1': 'a' } }
  30664. */
  30665. function setWith(object, path, value, customizer) {
  30666. customizer = typeof customizer == 'function' ? customizer : undefined;
  30667. return object == null ? object : baseSet(object, path, value, customizer);
  30668. }
  30669. /**
  30670. * Creates an array of own enumerable string keyed-value pairs for `object`
  30671. * which can be consumed by `_.fromPairs`. If `object` is a map or set, its
  30672. * entries are returned.
  30673. *
  30674. * @static
  30675. * @memberOf _
  30676. * @since 4.0.0
  30677. * @alias entries
  30678. * @category Object
  30679. * @param {Object} object The object to query.
  30680. * @returns {Array} Returns the key-value pairs.
  30681. * @example
  30682. *
  30683. * function Foo() {
  30684. * this.a = 1;
  30685. * this.b = 2;
  30686. * }
  30687. *
  30688. * Foo.prototype.c = 3;
  30689. *
  30690. * _.toPairs(new Foo);
  30691. * // => [['a', 1], ['b', 2]] (iteration order is not guaranteed)
  30692. */
  30693. var toPairs = createToPairs(keys);
  30694. /**
  30695. * Creates an array of own and inherited enumerable string keyed-value pairs
  30696. * for `object` which can be consumed by `_.fromPairs`. If `object` is a map
  30697. * or set, its entries are returned.
  30698. *
  30699. * @static
  30700. * @memberOf _
  30701. * @since 4.0.0
  30702. * @alias entriesIn
  30703. * @category Object
  30704. * @param {Object} object The object to query.
  30705. * @returns {Array} Returns the key-value pairs.
  30706. * @example
  30707. *
  30708. * function Foo() {
  30709. * this.a = 1;
  30710. * this.b = 2;
  30711. * }
  30712. *
  30713. * Foo.prototype.c = 3;
  30714. *
  30715. * _.toPairsIn(new Foo);
  30716. * // => [['a', 1], ['b', 2], ['c', 3]] (iteration order is not guaranteed)
  30717. */
  30718. var toPairsIn = createToPairs(keysIn);
  30719. /**
  30720. * An alternative to `_.reduce`; this method transforms `object` to a new
  30721. * `accumulator` object which is the result of running each of its own
  30722. * enumerable string keyed properties thru `iteratee`, with each invocation
  30723. * potentially mutating the `accumulator` object. If `accumulator` is not
  30724. * provided, a new object with the same `[[Prototype]]` will be used. The
  30725. * iteratee is invoked with four arguments: (accumulator, value, key, object).
  30726. * Iteratee functions may exit iteration early by explicitly returning `false`.
  30727. *
  30728. * @static
  30729. * @memberOf _
  30730. * @since 1.3.0
  30731. * @category Object
  30732. * @param {Object} object The object to iterate over.
  30733. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  30734. * @param {*} [accumulator] The custom accumulator value.
  30735. * @returns {*} Returns the accumulated value.
  30736. * @example
  30737. *
  30738. * _.transform([2, 3, 4], function(result, n) {
  30739. * result.push(n *= n);
  30740. * return n % 2 == 0;
  30741. * }, []);
  30742. * // => [4, 9]
  30743. *
  30744. * _.transform({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) {
  30745. * (result[value] || (result[value] = [])).push(key);
  30746. * }, {});
  30747. * // => { '1': ['a', 'c'], '2': ['b'] }
  30748. */
  30749. function transform(object, iteratee, accumulator) {
  30750. var isArr = isArray(object),
  30751. isArrLike = isArr || isBuffer(object) || isTypedArray(object);
  30752. iteratee = getIteratee(iteratee, 4);
  30753. if (accumulator == null) {
  30754. var Ctor = object && object.constructor;
  30755. if (isArrLike) {
  30756. accumulator = isArr ? new Ctor : [];
  30757. }
  30758. else if (isObject(object)) {
  30759. accumulator = isFunction(Ctor) ? baseCreate(getPrototype(object)) : {};
  30760. }
  30761. else {
  30762. accumulator = {};
  30763. }
  30764. }
  30765. (isArrLike ? arrayEach : baseForOwn)(object, function(value, index, object) {
  30766. return iteratee(accumulator, value, index, object);
  30767. });
  30768. return accumulator;
  30769. }
  30770. /**
  30771. * Removes the property at `path` of `object`.
  30772. *
  30773. * **Note:** This method mutates `object`.
  30774. *
  30775. * @static
  30776. * @memberOf _
  30777. * @since 4.0.0
  30778. * @category Object
  30779. * @param {Object} object The object to modify.
  30780. * @param {Array|string} path The path of the property to unset.
  30781. * @returns {boolean} Returns `true` if the property is deleted, else `false`.
  30782. * @example
  30783. *
  30784. * var object = { 'a': [{ 'b': { 'c': 7 } }] };
  30785. * _.unset(object, 'a[0].b.c');
  30786. * // => true
  30787. *
  30788. * console.log(object);
  30789. * // => { 'a': [{ 'b': {} }] };
  30790. *
  30791. * _.unset(object, ['a', '0', 'b', 'c']);
  30792. * // => true
  30793. *
  30794. * console.log(object);
  30795. * // => { 'a': [{ 'b': {} }] };
  30796. */
  30797. function unset(object, path) {
  30798. return object == null ? true : baseUnset(object, path);
  30799. }
  30800. /**
  30801. * This method is like `_.set` except that accepts `updater` to produce the
  30802. * value to set. Use `_.updateWith` to customize `path` creation. The `updater`
  30803. * is invoked with one argument: (value).
  30804. *
  30805. * **Note:** This method mutates `object`.
  30806. *
  30807. * @static
  30808. * @memberOf _
  30809. * @since 4.6.0
  30810. * @category Object
  30811. * @param {Object} object The object to modify.
  30812. * @param {Array|string} path The path of the property to set.
  30813. * @param {Function} updater The function to produce the updated value.
  30814. * @returns {Object} Returns `object`.
  30815. * @example
  30816. *
  30817. * var object = { 'a': [{ 'b': { 'c': 3 } }] };
  30818. *
  30819. * _.update(object, 'a[0].b.c', function(n) { return n * n; });
  30820. * console.log(object.a[0].b.c);
  30821. * // => 9
  30822. *
  30823. * _.update(object, 'x[0].y.z', function(n) { return n ? n + 1 : 0; });
  30824. * console.log(object.x[0].y.z);
  30825. * // => 0
  30826. */
  30827. function update(object, path, updater) {
  30828. return object == null ? object : baseUpdate(object, path, castFunction(updater));
  30829. }
  30830. /**
  30831. * This method is like `_.update` except that it accepts `customizer` which is
  30832. * invoked to produce the objects of `path`. If `customizer` returns `undefined`
  30833. * path creation is handled by the method instead. The `customizer` is invoked
  30834. * with three arguments: (nsValue, key, nsObject).
  30835. *
  30836. * **Note:** This method mutates `object`.
  30837. *
  30838. * @static
  30839. * @memberOf _
  30840. * @since 4.6.0
  30841. * @category Object
  30842. * @param {Object} object The object to modify.
  30843. * @param {Array|string} path The path of the property to set.
  30844. * @param {Function} updater The function to produce the updated value.
  30845. * @param {Function} [customizer] The function to customize assigned values.
  30846. * @returns {Object} Returns `object`.
  30847. * @example
  30848. *
  30849. * var object = {};
  30850. *
  30851. * _.updateWith(object, '[0][1]', _.constant('a'), Object);
  30852. * // => { '0': { '1': 'a' } }
  30853. */
  30854. function updateWith(object, path, updater, customizer) {
  30855. customizer = typeof customizer == 'function' ? customizer : undefined;
  30856. return object == null ? object : baseUpdate(object, path, castFunction(updater), customizer);
  30857. }
  30858. /**
  30859. * Creates an array of the own enumerable string keyed property values of `object`.
  30860. *
  30861. * **Note:** Non-object values are coerced to objects.
  30862. *
  30863. * @static
  30864. * @since 0.1.0
  30865. * @memberOf _
  30866. * @category Object
  30867. * @param {Object} object The object to query.
  30868. * @returns {Array} Returns the array of property values.
  30869. * @example
  30870. *
  30871. * function Foo() {
  30872. * this.a = 1;
  30873. * this.b = 2;
  30874. * }
  30875. *
  30876. * Foo.prototype.c = 3;
  30877. *
  30878. * _.values(new Foo);
  30879. * // => [1, 2] (iteration order is not guaranteed)
  30880. *
  30881. * _.values('hi');
  30882. * // => ['h', 'i']
  30883. */
  30884. function values(object) {
  30885. return object == null ? [] : baseValues(object, keys(object));
  30886. }
  30887. /**
  30888. * Creates an array of the own and inherited enumerable string keyed property
  30889. * values of `object`.
  30890. *
  30891. * **Note:** Non-object values are coerced to objects.
  30892. *
  30893. * @static
  30894. * @memberOf _
  30895. * @since 3.0.0
  30896. * @category Object
  30897. * @param {Object} object The object to query.
  30898. * @returns {Array} Returns the array of property values.
  30899. * @example
  30900. *
  30901. * function Foo() {
  30902. * this.a = 1;
  30903. * this.b = 2;
  30904. * }
  30905. *
  30906. * Foo.prototype.c = 3;
  30907. *
  30908. * _.valuesIn(new Foo);
  30909. * // => [1, 2, 3] (iteration order is not guaranteed)
  30910. */
  30911. function valuesIn(object) {
  30912. return object == null ? [] : baseValues(object, keysIn(object));
  30913. }
  30914. /*------------------------------------------------------------------------*/
  30915. /**
  30916. * Clamps `number` within the inclusive `lower` and `upper` bounds.
  30917. *
  30918. * @static
  30919. * @memberOf _
  30920. * @since 4.0.0
  30921. * @category Number
  30922. * @param {number} number The number to clamp.
  30923. * @param {number} [lower] The lower bound.
  30924. * @param {number} upper The upper bound.
  30925. * @returns {number} Returns the clamped number.
  30926. * @example
  30927. *
  30928. * _.clamp(-10, -5, 5);
  30929. * // => -5
  30930. *
  30931. * _.clamp(10, -5, 5);
  30932. * // => 5
  30933. */
  30934. function clamp(number, lower, upper) {
  30935. if (upper === undefined) {
  30936. upper = lower;
  30937. lower = undefined;
  30938. }
  30939. if (upper !== undefined) {
  30940. upper = toNumber(upper);
  30941. upper = upper === upper ? upper : 0;
  30942. }
  30943. if (lower !== undefined) {
  30944. lower = toNumber(lower);
  30945. lower = lower === lower ? lower : 0;
  30946. }
  30947. return baseClamp(toNumber(number), lower, upper);
  30948. }
  30949. /**
  30950. * Checks if `n` is between `start` and up to, but not including, `end`. If
  30951. * `end` is not specified, it's set to `start` with `start` then set to `0`.
  30952. * If `start` is greater than `end` the params are swapped to support
  30953. * negative ranges.
  30954. *
  30955. * @static
  30956. * @memberOf _
  30957. * @since 3.3.0
  30958. * @category Number
  30959. * @param {number} number The number to check.
  30960. * @param {number} [start=0] The start of the range.
  30961. * @param {number} end The end of the range.
  30962. * @returns {boolean} Returns `true` if `number` is in the range, else `false`.
  30963. * @see _.range, _.rangeRight
  30964. * @example
  30965. *
  30966. * _.inRange(3, 2, 4);
  30967. * // => true
  30968. *
  30969. * _.inRange(4, 8);
  30970. * // => true
  30971. *
  30972. * _.inRange(4, 2);
  30973. * // => false
  30974. *
  30975. * _.inRange(2, 2);
  30976. * // => false
  30977. *
  30978. * _.inRange(1.2, 2);
  30979. * // => true
  30980. *
  30981. * _.inRange(5.2, 4);
  30982. * // => false
  30983. *
  30984. * _.inRange(-3, -2, -6);
  30985. * // => true
  30986. */
  30987. function inRange(number, start, end) {
  30988. start = toFinite(start);
  30989. if (end === undefined) {
  30990. end = start;
  30991. start = 0;
  30992. } else {
  30993. end = toFinite(end);
  30994. }
  30995. number = toNumber(number);
  30996. return baseInRange(number, start, end);
  30997. }
  30998. /**
  30999. * Produces a random number between the inclusive `lower` and `upper` bounds.
  31000. * If only one argument is provided a number between `0` and the given number
  31001. * is returned. If `floating` is `true`, or either `lower` or `upper` are
  31002. * floats, a floating-point number is returned instead of an integer.
  31003. *
  31004. * **Note:** JavaScript follows the IEEE-754 standard for resolving
  31005. * floating-point values which can produce unexpected results.
  31006. *
  31007. * @static
  31008. * @memberOf _
  31009. * @since 0.7.0
  31010. * @category Number
  31011. * @param {number} [lower=0] The lower bound.
  31012. * @param {number} [upper=1] The upper bound.
  31013. * @param {boolean} [floating] Specify returning a floating-point number.
  31014. * @returns {number} Returns the random number.
  31015. * @example
  31016. *
  31017. * _.random(0, 5);
  31018. * // => an integer between 0 and 5
  31019. *
  31020. * _.random(5);
  31021. * // => also an integer between 0 and 5
  31022. *
  31023. * _.random(5, true);
  31024. * // => a floating-point number between 0 and 5
  31025. *
  31026. * _.random(1.2, 5.2);
  31027. * // => a floating-point number between 1.2 and 5.2
  31028. */
  31029. function random(lower, upper, floating) {
  31030. if (floating && typeof floating != 'boolean' && isIterateeCall(lower, upper, floating)) {
  31031. upper = floating = undefined;
  31032. }
  31033. if (floating === undefined) {
  31034. if (typeof upper == 'boolean') {
  31035. floating = upper;
  31036. upper = undefined;
  31037. }
  31038. else if (typeof lower == 'boolean') {
  31039. floating = lower;
  31040. lower = undefined;
  31041. }
  31042. }
  31043. if (lower === undefined && upper === undefined) {
  31044. lower = 0;
  31045. upper = 1;
  31046. }
  31047. else {
  31048. lower = toFinite(lower);
  31049. if (upper === undefined) {
  31050. upper = lower;
  31051. lower = 0;
  31052. } else {
  31053. upper = toFinite(upper);
  31054. }
  31055. }
  31056. if (lower > upper) {
  31057. var temp = lower;
  31058. lower = upper;
  31059. upper = temp;
  31060. }
  31061. if (floating || lower % 1 || upper % 1) {
  31062. var rand = nativeRandom();
  31063. return nativeMin(lower + (rand * (upper - lower + freeParseFloat('1e-' + ((rand + '').length - 1)))), upper);
  31064. }
  31065. return baseRandom(lower, upper);
  31066. }
  31067. /*------------------------------------------------------------------------*/
  31068. /**
  31069. * Converts `string` to [camel case](https://en.wikipedia.org/wiki/CamelCase).
  31070. *
  31071. * @static
  31072. * @memberOf _
  31073. * @since 3.0.0
  31074. * @category String
  31075. * @param {string} [string=''] The string to convert.
  31076. * @returns {string} Returns the camel cased string.
  31077. * @example
  31078. *
  31079. * _.camelCase('Foo Bar');
  31080. * // => 'fooBar'
  31081. *
  31082. * _.camelCase('--foo-bar--');
  31083. * // => 'fooBar'
  31084. *
  31085. * _.camelCase('__FOO_BAR__');
  31086. * // => 'fooBar'
  31087. */
  31088. var camelCase = createCompounder(function(result, word, index) {
  31089. word = word.toLowerCase();
  31090. return result + (index ? capitalize(word) : word);
  31091. });
  31092. /**
  31093. * Converts the first character of `string` to upper case and the remaining
  31094. * to lower case.
  31095. *
  31096. * @static
  31097. * @memberOf _
  31098. * @since 3.0.0
  31099. * @category String
  31100. * @param {string} [string=''] The string to capitalize.
  31101. * @returns {string} Returns the capitalized string.
  31102. * @example
  31103. *
  31104. * _.capitalize('FRED');
  31105. * // => 'Fred'
  31106. */
  31107. function capitalize(string) {
  31108. return upperFirst(toString(string).toLowerCase());
  31109. }
  31110. /**
  31111. * Deburrs `string` by converting
  31112. * [Latin-1 Supplement](https://en.wikipedia.org/wiki/Latin-1_Supplement_(Unicode_block)#Character_table)
  31113. * and [Latin Extended-A](https://en.wikipedia.org/wiki/Latin_Extended-A)
  31114. * letters to basic Latin letters and removing
  31115. * [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks).
  31116. *
  31117. * @static
  31118. * @memberOf _
  31119. * @since 3.0.0
  31120. * @category String
  31121. * @param {string} [string=''] The string to deburr.
  31122. * @returns {string} Returns the deburred string.
  31123. * @example
  31124. *
  31125. * _.deburr('déjà vu');
  31126. * // => 'deja vu'
  31127. */
  31128. function deburr(string) {
  31129. string = toString(string);
  31130. return string && string.replace(reLatin, deburrLetter).replace(reComboMark, '');
  31131. }
  31132. /**
  31133. * Checks if `string` ends with the given target string.
  31134. *
  31135. * @static
  31136. * @memberOf _
  31137. * @since 3.0.0
  31138. * @category String
  31139. * @param {string} [string=''] The string to inspect.
  31140. * @param {string} [target] The string to search for.
  31141. * @param {number} [position=string.length] The position to search up to.
  31142. * @returns {boolean} Returns `true` if `string` ends with `target`,
  31143. * else `false`.
  31144. * @example
  31145. *
  31146. * _.endsWith('abc', 'c');
  31147. * // => true
  31148. *
  31149. * _.endsWith('abc', 'b');
  31150. * // => false
  31151. *
  31152. * _.endsWith('abc', 'b', 2);
  31153. * // => true
  31154. */
  31155. function endsWith(string, target, position) {
  31156. string = toString(string);
  31157. target = baseToString(target);
  31158. var length = string.length;
  31159. position = position === undefined
  31160. ? length
  31161. : baseClamp(toInteger(position), 0, length);
  31162. var end = position;
  31163. position -= target.length;
  31164. return position >= 0 && string.slice(position, end) == target;
  31165. }
  31166. /**
  31167. * Converts the characters "&", "<", ">", '"', and "'" in `string` to their
  31168. * corresponding HTML entities.
  31169. *
  31170. * **Note:** No other characters are escaped. To escape additional
  31171. * characters use a third-party library like [_he_](https://mths.be/he).
  31172. *
  31173. * Though the ">" character is escaped for symmetry, characters like
  31174. * ">" and "/" don't need escaping in HTML and have no special meaning
  31175. * unless they're part of a tag or unquoted attribute value. See
  31176. * [Mathias Bynens's article](https://mathiasbynens.be/notes/ambiguous-ampersands)
  31177. * (under "semi-related fun fact") for more details.
  31178. *
  31179. * When working with HTML you should always
  31180. * [quote attribute values](http://wonko.com/post/html-escaping) to reduce
  31181. * XSS vectors.
  31182. *
  31183. * @static
  31184. * @since 0.1.0
  31185. * @memberOf _
  31186. * @category String
  31187. * @param {string} [string=''] The string to escape.
  31188. * @returns {string} Returns the escaped string.
  31189. * @example
  31190. *
  31191. * _.escape('fred, barney, & pebbles');
  31192. * // => 'fred, barney, &amp; pebbles'
  31193. */
  31194. function escape(string) {
  31195. string = toString(string);
  31196. return (string && reHasUnescapedHtml.test(string))
  31197. ? string.replace(reUnescapedHtml, escapeHtmlChar)
  31198. : string;
  31199. }
  31200. /**
  31201. * Escapes the `RegExp` special characters "^", "$", "\", ".", "*", "+",
  31202. * "?", "(", ")", "[", "]", "{", "}", and "|" in `string`.
  31203. *
  31204. * @static
  31205. * @memberOf _
  31206. * @since 3.0.0
  31207. * @category String
  31208. * @param {string} [string=''] The string to escape.
  31209. * @returns {string} Returns the escaped string.
  31210. * @example
  31211. *
  31212. * _.escapeRegExp('[lodash](https://lodash.com/)');
  31213. * // => '\[lodash\]\(https://lodash\.com/\)'
  31214. */
  31215. function escapeRegExp(string) {
  31216. string = toString(string);
  31217. return (string && reHasRegExpChar.test(string))
  31218. ? string.replace(reRegExpChar, '\\$&')
  31219. : string;
  31220. }
  31221. /**
  31222. * Converts `string` to
  31223. * [kebab case](https://en.wikipedia.org/wiki/Letter_case#Special_case_styles).
  31224. *
  31225. * @static
  31226. * @memberOf _
  31227. * @since 3.0.0
  31228. * @category String
  31229. * @param {string} [string=''] The string to convert.
  31230. * @returns {string} Returns the kebab cased string.
  31231. * @example
  31232. *
  31233. * _.kebabCase('Foo Bar');
  31234. * // => 'foo-bar'
  31235. *
  31236. * _.kebabCase('fooBar');
  31237. * // => 'foo-bar'
  31238. *
  31239. * _.kebabCase('__FOO_BAR__');
  31240. * // => 'foo-bar'
  31241. */
  31242. var kebabCase = createCompounder(function(result, word, index) {
  31243. return result + (index ? '-' : '') + word.toLowerCase();
  31244. });
  31245. /**
  31246. * Converts `string`, as space separated words, to lower case.
  31247. *
  31248. * @static
  31249. * @memberOf _
  31250. * @since 4.0.0
  31251. * @category String
  31252. * @param {string} [string=''] The string to convert.
  31253. * @returns {string} Returns the lower cased string.
  31254. * @example
  31255. *
  31256. * _.lowerCase('--Foo-Bar--');
  31257. * // => 'foo bar'
  31258. *
  31259. * _.lowerCase('fooBar');
  31260. * // => 'foo bar'
  31261. *
  31262. * _.lowerCase('__FOO_BAR__');
  31263. * // => 'foo bar'
  31264. */
  31265. var lowerCase = createCompounder(function(result, word, index) {
  31266. return result + (index ? ' ' : '') + word.toLowerCase();
  31267. });
  31268. /**
  31269. * Converts the first character of `string` to lower case.
  31270. *
  31271. * @static
  31272. * @memberOf _
  31273. * @since 4.0.0
  31274. * @category String
  31275. * @param {string} [string=''] The string to convert.
  31276. * @returns {string} Returns the converted string.
  31277. * @example
  31278. *
  31279. * _.lowerFirst('Fred');
  31280. * // => 'fred'
  31281. *
  31282. * _.lowerFirst('FRED');
  31283. * // => 'fRED'
  31284. */
  31285. var lowerFirst = createCaseFirst('toLowerCase');
  31286. /**
  31287. * Pads `string` on the left and right sides if it's shorter than `length`.
  31288. * Padding characters are truncated if they can't be evenly divided by `length`.
  31289. *
  31290. * @static
  31291. * @memberOf _
  31292. * @since 3.0.0
  31293. * @category String
  31294. * @param {string} [string=''] The string to pad.
  31295. * @param {number} [length=0] The padding length.
  31296. * @param {string} [chars=' '] The string used as padding.
  31297. * @returns {string} Returns the padded string.
  31298. * @example
  31299. *
  31300. * _.pad('abc', 8);
  31301. * // => ' abc '
  31302. *
  31303. * _.pad('abc', 8, '_-');
  31304. * // => '_-abc_-_'
  31305. *
  31306. * _.pad('abc', 3);
  31307. * // => 'abc'
  31308. */
  31309. function pad(string, length, chars) {
  31310. string = toString(string);
  31311. length = toInteger(length);
  31312. var strLength = length ? stringSize(string) : 0;
  31313. if (!length || strLength >= length) {
  31314. return string;
  31315. }
  31316. var mid = (length - strLength) / 2;
  31317. return (
  31318. createPadding(nativeFloor(mid), chars) +
  31319. string +
  31320. createPadding(nativeCeil(mid), chars)
  31321. );
  31322. }
  31323. /**
  31324. * Pads `string` on the right side if it's shorter than `length`. Padding
  31325. * characters are truncated if they exceed `length`.
  31326. *
  31327. * @static
  31328. * @memberOf _
  31329. * @since 4.0.0
  31330. * @category String
  31331. * @param {string} [string=''] The string to pad.
  31332. * @param {number} [length=0] The padding length.
  31333. * @param {string} [chars=' '] The string used as padding.
  31334. * @returns {string} Returns the padded string.
  31335. * @example
  31336. *
  31337. * _.padEnd('abc', 6);
  31338. * // => 'abc '
  31339. *
  31340. * _.padEnd('abc', 6, '_-');
  31341. * // => 'abc_-_'
  31342. *
  31343. * _.padEnd('abc', 3);
  31344. * // => 'abc'
  31345. */
  31346. function padEnd(string, length, chars) {
  31347. string = toString(string);
  31348. length = toInteger(length);
  31349. var strLength = length ? stringSize(string) : 0;
  31350. return (length && strLength < length)
  31351. ? (string + createPadding(length - strLength, chars))
  31352. : string;
  31353. }
  31354. /**
  31355. * Pads `string` on the left side if it's shorter than `length`. Padding
  31356. * characters are truncated if they exceed `length`.
  31357. *
  31358. * @static
  31359. * @memberOf _
  31360. * @since 4.0.0
  31361. * @category String
  31362. * @param {string} [string=''] The string to pad.
  31363. * @param {number} [length=0] The padding length.
  31364. * @param {string} [chars=' '] The string used as padding.
  31365. * @returns {string} Returns the padded string.
  31366. * @example
  31367. *
  31368. * _.padStart('abc', 6);
  31369. * // => ' abc'
  31370. *
  31371. * _.padStart('abc', 6, '_-');
  31372. * // => '_-_abc'
  31373. *
  31374. * _.padStart('abc', 3);
  31375. * // => 'abc'
  31376. */
  31377. function padStart(string, length, chars) {
  31378. string = toString(string);
  31379. length = toInteger(length);
  31380. var strLength = length ? stringSize(string) : 0;
  31381. return (length && strLength < length)
  31382. ? (createPadding(length - strLength, chars) + string)
  31383. : string;
  31384. }
  31385. /**
  31386. * Converts `string` to an integer of the specified radix. If `radix` is
  31387. * `undefined` or `0`, a `radix` of `10` is used unless `value` is a
  31388. * hexadecimal, in which case a `radix` of `16` is used.
  31389. *
  31390. * **Note:** This method aligns with the
  31391. * [ES5 implementation](https://es5.github.io/#x15.1.2.2) of `parseInt`.
  31392. *
  31393. * @static
  31394. * @memberOf _
  31395. * @since 1.1.0
  31396. * @category String
  31397. * @param {string} string The string to convert.
  31398. * @param {number} [radix=10] The radix to interpret `value` by.
  31399. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  31400. * @returns {number} Returns the converted integer.
  31401. * @example
  31402. *
  31403. * _.parseInt('08');
  31404. * // => 8
  31405. *
  31406. * _.map(['6', '08', '10'], _.parseInt);
  31407. * // => [6, 8, 10]
  31408. */
  31409. function parseInt(string, radix, guard) {
  31410. if (guard || radix == null) {
  31411. radix = 0;
  31412. } else if (radix) {
  31413. radix = +radix;
  31414. }
  31415. return nativeParseInt(toString(string).replace(reTrimStart, ''), radix || 0);
  31416. }
  31417. /**
  31418. * Repeats the given string `n` times.
  31419. *
  31420. * @static
  31421. * @memberOf _
  31422. * @since 3.0.0
  31423. * @category String
  31424. * @param {string} [string=''] The string to repeat.
  31425. * @param {number} [n=1] The number of times to repeat the string.
  31426. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  31427. * @returns {string} Returns the repeated string.
  31428. * @example
  31429. *
  31430. * _.repeat('*', 3);
  31431. * // => '***'
  31432. *
  31433. * _.repeat('abc', 2);
  31434. * // => 'abcabc'
  31435. *
  31436. * _.repeat('abc', 0);
  31437. * // => ''
  31438. */
  31439. function repeat(string, n, guard) {
  31440. if ((guard ? isIterateeCall(string, n, guard) : n === undefined)) {
  31441. n = 1;
  31442. } else {
  31443. n = toInteger(n);
  31444. }
  31445. return baseRepeat(toString(string), n);
  31446. }
  31447. /**
  31448. * Replaces matches for `pattern` in `string` with `replacement`.
  31449. *
  31450. * **Note:** This method is based on
  31451. * [`String#replace`](https://mdn.io/String/replace).
  31452. *
  31453. * @static
  31454. * @memberOf _
  31455. * @since 4.0.0
  31456. * @category String
  31457. * @param {string} [string=''] The string to modify.
  31458. * @param {RegExp|string} pattern The pattern to replace.
  31459. * @param {Function|string} replacement The match replacement.
  31460. * @returns {string} Returns the modified string.
  31461. * @example
  31462. *
  31463. * _.replace('Hi Fred', 'Fred', 'Barney');
  31464. * // => 'Hi Barney'
  31465. */
  31466. function replace() {
  31467. var args = arguments,
  31468. string = toString(args[0]);
  31469. return args.length < 3 ? string : string.replace(args[1], args[2]);
  31470. }
  31471. /**
  31472. * Converts `string` to
  31473. * [snake case](https://en.wikipedia.org/wiki/Snake_case).
  31474. *
  31475. * @static
  31476. * @memberOf _
  31477. * @since 3.0.0
  31478. * @category String
  31479. * @param {string} [string=''] The string to convert.
  31480. * @returns {string} Returns the snake cased string.
  31481. * @example
  31482. *
  31483. * _.snakeCase('Foo Bar');
  31484. * // => 'foo_bar'
  31485. *
  31486. * _.snakeCase('fooBar');
  31487. * // => 'foo_bar'
  31488. *
  31489. * _.snakeCase('--FOO-BAR--');
  31490. * // => 'foo_bar'
  31491. */
  31492. var snakeCase = createCompounder(function(result, word, index) {
  31493. return result + (index ? '_' : '') + word.toLowerCase();
  31494. });
  31495. /**
  31496. * Splits `string` by `separator`.
  31497. *
  31498. * **Note:** This method is based on
  31499. * [`String#split`](https://mdn.io/String/split).
  31500. *
  31501. * @static
  31502. * @memberOf _
  31503. * @since 4.0.0
  31504. * @category String
  31505. * @param {string} [string=''] The string to split.
  31506. * @param {RegExp|string} separator The separator pattern to split by.
  31507. * @param {number} [limit] The length to truncate results to.
  31508. * @returns {Array} Returns the string segments.
  31509. * @example
  31510. *
  31511. * _.split('a-b-c', '-', 2);
  31512. * // => ['a', 'b']
  31513. */
  31514. function split(string, separator, limit) {
  31515. if (limit && typeof limit != 'number' && isIterateeCall(string, separator, limit)) {
  31516. separator = limit = undefined;
  31517. }
  31518. limit = limit === undefined ? MAX_ARRAY_LENGTH : limit >>> 0;
  31519. if (!limit) {
  31520. return [];
  31521. }
  31522. string = toString(string);
  31523. if (string && (
  31524. typeof separator == 'string' ||
  31525. (separator != null && !isRegExp(separator))
  31526. )) {
  31527. separator = baseToString(separator);
  31528. if (!separator && hasUnicode(string)) {
  31529. return castSlice(stringToArray(string), 0, limit);
  31530. }
  31531. }
  31532. return string.split(separator, limit);
  31533. }
  31534. /**
  31535. * Converts `string` to
  31536. * [start case](https://en.wikipedia.org/wiki/Letter_case#Stylistic_or_specialised_usage).
  31537. *
  31538. * @static
  31539. * @memberOf _
  31540. * @since 3.1.0
  31541. * @category String
  31542. * @param {string} [string=''] The string to convert.
  31543. * @returns {string} Returns the start cased string.
  31544. * @example
  31545. *
  31546. * _.startCase('--foo-bar--');
  31547. * // => 'Foo Bar'
  31548. *
  31549. * _.startCase('fooBar');
  31550. * // => 'Foo Bar'
  31551. *
  31552. * _.startCase('__FOO_BAR__');
  31553. * // => 'FOO BAR'
  31554. */
  31555. var startCase = createCompounder(function(result, word, index) {
  31556. return result + (index ? ' ' : '') + upperFirst(word);
  31557. });
  31558. /**
  31559. * Checks if `string` starts with the given target string.
  31560. *
  31561. * @static
  31562. * @memberOf _
  31563. * @since 3.0.0
  31564. * @category String
  31565. * @param {string} [string=''] The string to inspect.
  31566. * @param {string} [target] The string to search for.
  31567. * @param {number} [position=0] The position to search from.
  31568. * @returns {boolean} Returns `true` if `string` starts with `target`,
  31569. * else `false`.
  31570. * @example
  31571. *
  31572. * _.startsWith('abc', 'a');
  31573. * // => true
  31574. *
  31575. * _.startsWith('abc', 'b');
  31576. * // => false
  31577. *
  31578. * _.startsWith('abc', 'b', 1);
  31579. * // => true
  31580. */
  31581. function startsWith(string, target, position) {
  31582. string = toString(string);
  31583. position = position == null
  31584. ? 0
  31585. : baseClamp(toInteger(position), 0, string.length);
  31586. target = baseToString(target);
  31587. return string.slice(position, position + target.length) == target;
  31588. }
  31589. /**
  31590. * Creates a compiled template function that can interpolate data properties
  31591. * in "interpolate" delimiters, HTML-escape interpolated data properties in
  31592. * "escape" delimiters, and execute JavaScript in "evaluate" delimiters. Data
  31593. * properties may be accessed as free variables in the template. If a setting
  31594. * object is given, it takes precedence over `_.templateSettings` values.
  31595. *
  31596. * **Note:** In the development build `_.template` utilizes
  31597. * [sourceURLs](http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/#toc-sourceurl)
  31598. * for easier debugging.
  31599. *
  31600. * For more information on precompiling templates see
  31601. * [lodash's custom builds documentation](https://lodash.com/custom-builds).
  31602. *
  31603. * For more information on Chrome extension sandboxes see
  31604. * [Chrome's extensions documentation](https://developer.chrome.com/extensions/sandboxingEval).
  31605. *
  31606. * @static
  31607. * @since 0.1.0
  31608. * @memberOf _
  31609. * @category String
  31610. * @param {string} [string=''] The template string.
  31611. * @param {Object} [options={}] The options object.
  31612. * @param {RegExp} [options.escape=_.templateSettings.escape]
  31613. * The HTML "escape" delimiter.
  31614. * @param {RegExp} [options.evaluate=_.templateSettings.evaluate]
  31615. * The "evaluate" delimiter.
  31616. * @param {Object} [options.imports=_.templateSettings.imports]
  31617. * An object to import into the template as free variables.
  31618. * @param {RegExp} [options.interpolate=_.templateSettings.interpolate]
  31619. * The "interpolate" delimiter.
  31620. * @param {string} [options.sourceURL='lodash.templateSources[n]']
  31621. * The sourceURL of the compiled template.
  31622. * @param {string} [options.variable='obj']
  31623. * The data object variable name.
  31624. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  31625. * @returns {Function} Returns the compiled template function.
  31626. * @example
  31627. *
  31628. * // Use the "interpolate" delimiter to create a compiled template.
  31629. * var compiled = _.template('hello <%= user %>!');
  31630. * compiled({ 'user': 'fred' });
  31631. * // => 'hello fred!'
  31632. *
  31633. * // Use the HTML "escape" delimiter to escape data property values.
  31634. * var compiled = _.template('<b><%- value %></b>');
  31635. * compiled({ 'value': '<script>' });
  31636. * // => '<b>&lt;script&gt;</b>'
  31637. *
  31638. * // Use the "evaluate" delimiter to execute JavaScript and generate HTML.
  31639. * var compiled = _.template('<% _.forEach(users, function(user) { %><li><%- user %></li><% }); %>');
  31640. * compiled({ 'users': ['fred', 'barney'] });
  31641. * // => '<li>fred</li><li>barney</li>'
  31642. *
  31643. * // Use the internal `print` function in "evaluate" delimiters.
  31644. * var compiled = _.template('<% print("hello " + user); %>!');
  31645. * compiled({ 'user': 'barney' });
  31646. * // => 'hello barney!'
  31647. *
  31648. * // Use the ES template literal delimiter as an "interpolate" delimiter.
  31649. * // Disable support by replacing the "interpolate" delimiter.
  31650. * var compiled = _.template('hello ${ user }!');
  31651. * compiled({ 'user': 'pebbles' });
  31652. * // => 'hello pebbles!'
  31653. *
  31654. * // Use backslashes to treat delimiters as plain text.
  31655. * var compiled = _.template('<%= "\\<%- value %\\>" %>');
  31656. * compiled({ 'value': 'ignored' });
  31657. * // => '<%- value %>'
  31658. *
  31659. * // Use the `imports` option to import `jQuery` as `jq`.
  31660. * var text = '<% jq.each(users, function(user) { %><li><%- user %></li><% }); %>';
  31661. * var compiled = _.template(text, { 'imports': { 'jq': jQuery } });
  31662. * compiled({ 'users': ['fred', 'barney'] });
  31663. * // => '<li>fred</li><li>barney</li>'
  31664. *
  31665. * // Use the `sourceURL` option to specify a custom sourceURL for the template.
  31666. * var compiled = _.template('hello <%= user %>!', { 'sourceURL': '/basic/greeting.jst' });
  31667. * compiled(data);
  31668. * // => Find the source of "greeting.jst" under the Sources tab or Resources panel of the web inspector.
  31669. *
  31670. * // Use the `variable` option to ensure a with-statement isn't used in the compiled template.
  31671. * var compiled = _.template('hi <%= data.user %>!', { 'variable': 'data' });
  31672. * compiled.source;
  31673. * // => function(data) {
  31674. * // var __t, __p = '';
  31675. * // __p += 'hi ' + ((__t = ( data.user )) == null ? '' : __t) + '!';
  31676. * // return __p;
  31677. * // }
  31678. *
  31679. * // Use custom template delimiters.
  31680. * _.templateSettings.interpolate = /{{([\s\S]+?)}}/g;
  31681. * var compiled = _.template('hello {{ user }}!');
  31682. * compiled({ 'user': 'mustache' });
  31683. * // => 'hello mustache!'
  31684. *
  31685. * // Use the `source` property to inline compiled templates for meaningful
  31686. * // line numbers in error messages and stack traces.
  31687. * fs.writeFileSync(path.join(process.cwd(), 'jst.js'), '\
  31688. * var JST = {\
  31689. * "main": ' + _.template(mainText).source + '\
  31690. * };\
  31691. * ');
  31692. */
  31693. function template(string, options, guard) {
  31694. // Based on John Resig's `tmpl` implementation
  31695. // (http://ejohn.org/blog/javascript-micro-templating/)
  31696. // and Laura Doktorova's doT.js (https://github.com/olado/doT).
  31697. var settings = lodash.templateSettings;
  31698. if (guard && isIterateeCall(string, options, guard)) {
  31699. options = undefined;
  31700. }
  31701. string = toString(string);
  31702. options = assignInWith({}, options, settings, customDefaultsAssignIn);
  31703. var imports = assignInWith({}, options.imports, settings.imports, customDefaultsAssignIn),
  31704. importsKeys = keys(imports),
  31705. importsValues = baseValues(imports, importsKeys);
  31706. var isEscaping,
  31707. isEvaluating,
  31708. index = 0,
  31709. interpolate = options.interpolate || reNoMatch,
  31710. source = "__p += '";
  31711. // Compile the regexp to match each delimiter.
  31712. var reDelimiters = RegExp(
  31713. (options.escape || reNoMatch).source + '|' +
  31714. interpolate.source + '|' +
  31715. (interpolate === reInterpolate ? reEsTemplate : reNoMatch).source + '|' +
  31716. (options.evaluate || reNoMatch).source + '|$'
  31717. , 'g');
  31718. // Use a sourceURL for easier debugging.
  31719. // The sourceURL gets injected into the source that's eval-ed, so be careful
  31720. // with lookup (in case of e.g. prototype pollution), and strip newlines if any.
  31721. // A newline wouldn't be a valid sourceURL anyway, and it'd enable code injection.
  31722. var sourceURL = '//# sourceURL=' +
  31723. (hasOwnProperty.call(options, 'sourceURL')
  31724. ? (options.sourceURL + '').replace(/[\r\n]/g, ' ')
  31725. : ('lodash.templateSources[' + (++templateCounter) + ']')
  31726. ) + '\n';
  31727. string.replace(reDelimiters, function(match, escapeValue, interpolateValue, esTemplateValue, evaluateValue, offset) {
  31728. interpolateValue || (interpolateValue = esTemplateValue);
  31729. // Escape characters that can't be included in string literals.
  31730. source += string.slice(index, offset).replace(reUnescapedString, escapeStringChar);
  31731. // Replace delimiters with snippets.
  31732. if (escapeValue) {
  31733. isEscaping = true;
  31734. source += "' +\n__e(" + escapeValue + ") +\n'";
  31735. }
  31736. if (evaluateValue) {
  31737. isEvaluating = true;
  31738. source += "';\n" + evaluateValue + ";\n__p += '";
  31739. }
  31740. if (interpolateValue) {
  31741. source += "' +\n((__t = (" + interpolateValue + ")) == null ? '' : __t) +\n'";
  31742. }
  31743. index = offset + match.length;
  31744. // The JS engine embedded in Adobe products needs `match` returned in
  31745. // order to produce the correct `offset` value.
  31746. return match;
  31747. });
  31748. source += "';\n";
  31749. // If `variable` is not specified wrap a with-statement around the generated
  31750. // code to add the data object to the top of the scope chain.
  31751. // Like with sourceURL, we take care to not check the option's prototype,
  31752. // as this configuration is a code injection vector.
  31753. var variable = hasOwnProperty.call(options, 'variable') && options.variable;
  31754. if (!variable) {
  31755. source = 'with (obj) {\n' + source + '\n}\n';
  31756. }
  31757. // Cleanup code by stripping empty strings.
  31758. source = (isEvaluating ? source.replace(reEmptyStringLeading, '') : source)
  31759. .replace(reEmptyStringMiddle, '$1')
  31760. .replace(reEmptyStringTrailing, '$1;');
  31761. // Frame code as the function body.
  31762. source = 'function(' + (variable || 'obj') + ') {\n' +
  31763. (variable
  31764. ? ''
  31765. : 'obj || (obj = {});\n'
  31766. ) +
  31767. "var __t, __p = ''" +
  31768. (isEscaping
  31769. ? ', __e = _.escape'
  31770. : ''
  31771. ) +
  31772. (isEvaluating
  31773. ? ', __j = Array.prototype.join;\n' +
  31774. "function print() { __p += __j.call(arguments, '') }\n"
  31775. : ';\n'
  31776. ) +
  31777. source +
  31778. 'return __p\n}';
  31779. var result = attempt(function() {
  31780. return Function(importsKeys, sourceURL + 'return ' + source)
  31781. .apply(undefined, importsValues);
  31782. });
  31783. // Provide the compiled function's source by its `toString` method or
  31784. // the `source` property as a convenience for inlining compiled templates.
  31785. result.source = source;
  31786. if (isError(result)) {
  31787. throw result;
  31788. }
  31789. return result;
  31790. }
  31791. /**
  31792. * Converts `string`, as a whole, to lower case just like
  31793. * [String#toLowerCase](https://mdn.io/toLowerCase).
  31794. *
  31795. * @static
  31796. * @memberOf _
  31797. * @since 4.0.0
  31798. * @category String
  31799. * @param {string} [string=''] The string to convert.
  31800. * @returns {string} Returns the lower cased string.
  31801. * @example
  31802. *
  31803. * _.toLower('--Foo-Bar--');
  31804. * // => '--foo-bar--'
  31805. *
  31806. * _.toLower('fooBar');
  31807. * // => 'foobar'
  31808. *
  31809. * _.toLower('__FOO_BAR__');
  31810. * // => '__foo_bar__'
  31811. */
  31812. function toLower(value) {
  31813. return toString(value).toLowerCase();
  31814. }
  31815. /**
  31816. * Converts `string`, as a whole, to upper case just like
  31817. * [String#toUpperCase](https://mdn.io/toUpperCase).
  31818. *
  31819. * @static
  31820. * @memberOf _
  31821. * @since 4.0.0
  31822. * @category String
  31823. * @param {string} [string=''] The string to convert.
  31824. * @returns {string} Returns the upper cased string.
  31825. * @example
  31826. *
  31827. * _.toUpper('--foo-bar--');
  31828. * // => '--FOO-BAR--'
  31829. *
  31830. * _.toUpper('fooBar');
  31831. * // => 'FOOBAR'
  31832. *
  31833. * _.toUpper('__foo_bar__');
  31834. * // => '__FOO_BAR__'
  31835. */
  31836. function toUpper(value) {
  31837. return toString(value).toUpperCase();
  31838. }
  31839. /**
  31840. * Removes leading and trailing whitespace or specified characters from `string`.
  31841. *
  31842. * @static
  31843. * @memberOf _
  31844. * @since 3.0.0
  31845. * @category String
  31846. * @param {string} [string=''] The string to trim.
  31847. * @param {string} [chars=whitespace] The characters to trim.
  31848. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  31849. * @returns {string} Returns the trimmed string.
  31850. * @example
  31851. *
  31852. * _.trim(' abc ');
  31853. * // => 'abc'
  31854. *
  31855. * _.trim('-_-abc-_-', '_-');
  31856. * // => 'abc'
  31857. *
  31858. * _.map([' foo ', ' bar '], _.trim);
  31859. * // => ['foo', 'bar']
  31860. */
  31861. function trim(string, chars, guard) {
  31862. string = toString(string);
  31863. if (string && (guard || chars === undefined)) {
  31864. return string.replace(reTrim, '');
  31865. }
  31866. if (!string || !(chars = baseToString(chars))) {
  31867. return string;
  31868. }
  31869. var strSymbols = stringToArray(string),
  31870. chrSymbols = stringToArray(chars),
  31871. start = charsStartIndex(strSymbols, chrSymbols),
  31872. end = charsEndIndex(strSymbols, chrSymbols) + 1;
  31873. return castSlice(strSymbols, start, end).join('');
  31874. }
  31875. /**
  31876. * Removes trailing whitespace or specified characters from `string`.
  31877. *
  31878. * @static
  31879. * @memberOf _
  31880. * @since 4.0.0
  31881. * @category String
  31882. * @param {string} [string=''] The string to trim.
  31883. * @param {string} [chars=whitespace] The characters to trim.
  31884. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  31885. * @returns {string} Returns the trimmed string.
  31886. * @example
  31887. *
  31888. * _.trimEnd(' abc ');
  31889. * // => ' abc'
  31890. *
  31891. * _.trimEnd('-_-abc-_-', '_-');
  31892. * // => '-_-abc'
  31893. */
  31894. function trimEnd(string, chars, guard) {
  31895. string = toString(string);
  31896. if (string && (guard || chars === undefined)) {
  31897. return string.replace(reTrimEnd, '');
  31898. }
  31899. if (!string || !(chars = baseToString(chars))) {
  31900. return string;
  31901. }
  31902. var strSymbols = stringToArray(string),
  31903. end = charsEndIndex(strSymbols, stringToArray(chars)) + 1;
  31904. return castSlice(strSymbols, 0, end).join('');
  31905. }
  31906. /**
  31907. * Removes leading whitespace or specified characters from `string`.
  31908. *
  31909. * @static
  31910. * @memberOf _
  31911. * @since 4.0.0
  31912. * @category String
  31913. * @param {string} [string=''] The string to trim.
  31914. * @param {string} [chars=whitespace] The characters to trim.
  31915. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  31916. * @returns {string} Returns the trimmed string.
  31917. * @example
  31918. *
  31919. * _.trimStart(' abc ');
  31920. * // => 'abc '
  31921. *
  31922. * _.trimStart('-_-abc-_-', '_-');
  31923. * // => 'abc-_-'
  31924. */
  31925. function trimStart(string, chars, guard) {
  31926. string = toString(string);
  31927. if (string && (guard || chars === undefined)) {
  31928. return string.replace(reTrimStart, '');
  31929. }
  31930. if (!string || !(chars = baseToString(chars))) {
  31931. return string;
  31932. }
  31933. var strSymbols = stringToArray(string),
  31934. start = charsStartIndex(strSymbols, stringToArray(chars));
  31935. return castSlice(strSymbols, start).join('');
  31936. }
  31937. /**
  31938. * Truncates `string` if it's longer than the given maximum string length.
  31939. * The last characters of the truncated string are replaced with the omission
  31940. * string which defaults to "...".
  31941. *
  31942. * @static
  31943. * @memberOf _
  31944. * @since 4.0.0
  31945. * @category String
  31946. * @param {string} [string=''] The string to truncate.
  31947. * @param {Object} [options={}] The options object.
  31948. * @param {number} [options.length=30] The maximum string length.
  31949. * @param {string} [options.omission='...'] The string to indicate text is omitted.
  31950. * @param {RegExp|string} [options.separator] The separator pattern to truncate to.
  31951. * @returns {string} Returns the truncated string.
  31952. * @example
  31953. *
  31954. * _.truncate('hi-diddly-ho there, neighborino');
  31955. * // => 'hi-diddly-ho there, neighbo...'
  31956. *
  31957. * _.truncate('hi-diddly-ho there, neighborino', {
  31958. * 'length': 24,
  31959. * 'separator': ' '
  31960. * });
  31961. * // => 'hi-diddly-ho there,...'
  31962. *
  31963. * _.truncate('hi-diddly-ho there, neighborino', {
  31964. * 'length': 24,
  31965. * 'separator': /,? +/
  31966. * });
  31967. * // => 'hi-diddly-ho there...'
  31968. *
  31969. * _.truncate('hi-diddly-ho there, neighborino', {
  31970. * 'omission': ' [...]'
  31971. * });
  31972. * // => 'hi-diddly-ho there, neig [...]'
  31973. */
  31974. function truncate(string, options) {
  31975. var length = DEFAULT_TRUNC_LENGTH,
  31976. omission = DEFAULT_TRUNC_OMISSION;
  31977. if (isObject(options)) {
  31978. var separator = 'separator' in options ? options.separator : separator;
  31979. length = 'length' in options ? toInteger(options.length) : length;
  31980. omission = 'omission' in options ? baseToString(options.omission) : omission;
  31981. }
  31982. string = toString(string);
  31983. var strLength = string.length;
  31984. if (hasUnicode(string)) {
  31985. var strSymbols = stringToArray(string);
  31986. strLength = strSymbols.length;
  31987. }
  31988. if (length >= strLength) {
  31989. return string;
  31990. }
  31991. var end = length - stringSize(omission);
  31992. if (end < 1) {
  31993. return omission;
  31994. }
  31995. var result = strSymbols
  31996. ? castSlice(strSymbols, 0, end).join('')
  31997. : string.slice(0, end);
  31998. if (separator === undefined) {
  31999. return result + omission;
  32000. }
  32001. if (strSymbols) {
  32002. end += (result.length - end);
  32003. }
  32004. if (isRegExp(separator)) {
  32005. if (string.slice(end).search(separator)) {
  32006. var match,
  32007. substring = result;
  32008. if (!separator.global) {
  32009. separator = RegExp(separator.source, toString(reFlags.exec(separator)) + 'g');
  32010. }
  32011. separator.lastIndex = 0;
  32012. while ((match = separator.exec(substring))) {
  32013. var newEnd = match.index;
  32014. }
  32015. result = result.slice(0, newEnd === undefined ? end : newEnd);
  32016. }
  32017. } else if (string.indexOf(baseToString(separator), end) != end) {
  32018. var index = result.lastIndexOf(separator);
  32019. if (index > -1) {
  32020. result = result.slice(0, index);
  32021. }
  32022. }
  32023. return result + omission;
  32024. }
  32025. /**
  32026. * The inverse of `_.escape`; this method converts the HTML entities
  32027. * `&amp;`, `&lt;`, `&gt;`, `&quot;`, and `&#39;` in `string` to
  32028. * their corresponding characters.
  32029. *
  32030. * **Note:** No other HTML entities are unescaped. To unescape additional
  32031. * HTML entities use a third-party library like [_he_](https://mths.be/he).
  32032. *
  32033. * @static
  32034. * @memberOf _
  32035. * @since 0.6.0
  32036. * @category String
  32037. * @param {string} [string=''] The string to unescape.
  32038. * @returns {string} Returns the unescaped string.
  32039. * @example
  32040. *
  32041. * _.unescape('fred, barney, &amp; pebbles');
  32042. * // => 'fred, barney, & pebbles'
  32043. */
  32044. function unescape(string) {
  32045. string = toString(string);
  32046. return (string && reHasEscapedHtml.test(string))
  32047. ? string.replace(reEscapedHtml, unescapeHtmlChar)
  32048. : string;
  32049. }
  32050. /**
  32051. * Converts `string`, as space separated words, to upper case.
  32052. *
  32053. * @static
  32054. * @memberOf _
  32055. * @since 4.0.0
  32056. * @category String
  32057. * @param {string} [string=''] The string to convert.
  32058. * @returns {string} Returns the upper cased string.
  32059. * @example
  32060. *
  32061. * _.upperCase('--foo-bar');
  32062. * // => 'FOO BAR'
  32063. *
  32064. * _.upperCase('fooBar');
  32065. * // => 'FOO BAR'
  32066. *
  32067. * _.upperCase('__foo_bar__');
  32068. * // => 'FOO BAR'
  32069. */
  32070. var upperCase = createCompounder(function(result, word, index) {
  32071. return result + (index ? ' ' : '') + word.toUpperCase();
  32072. });
  32073. /**
  32074. * Converts the first character of `string` to upper case.
  32075. *
  32076. * @static
  32077. * @memberOf _
  32078. * @since 4.0.0
  32079. * @category String
  32080. * @param {string} [string=''] The string to convert.
  32081. * @returns {string} Returns the converted string.
  32082. * @example
  32083. *
  32084. * _.upperFirst('fred');
  32085. * // => 'Fred'
  32086. *
  32087. * _.upperFirst('FRED');
  32088. * // => 'FRED'
  32089. */
  32090. var upperFirst = createCaseFirst('toUpperCase');
  32091. /**
  32092. * Splits `string` into an array of its words.
  32093. *
  32094. * @static
  32095. * @memberOf _
  32096. * @since 3.0.0
  32097. * @category String
  32098. * @param {string} [string=''] The string to inspect.
  32099. * @param {RegExp|string} [pattern] The pattern to match words.
  32100. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  32101. * @returns {Array} Returns the words of `string`.
  32102. * @example
  32103. *
  32104. * _.words('fred, barney, & pebbles');
  32105. * // => ['fred', 'barney', 'pebbles']
  32106. *
  32107. * _.words('fred, barney, & pebbles', /[^, ]+/g);
  32108. * // => ['fred', 'barney', '&', 'pebbles']
  32109. */
  32110. function words(string, pattern, guard) {
  32111. string = toString(string);
  32112. pattern = guard ? undefined : pattern;
  32113. if (pattern === undefined) {
  32114. return hasUnicodeWord(string) ? unicodeWords(string) : asciiWords(string);
  32115. }
  32116. return string.match(pattern) || [];
  32117. }
  32118. /*------------------------------------------------------------------------*/
  32119. /**
  32120. * Attempts to invoke `func`, returning either the result or the caught error
  32121. * object. Any additional arguments are provided to `func` when it's invoked.
  32122. *
  32123. * @static
  32124. * @memberOf _
  32125. * @since 3.0.0
  32126. * @category Util
  32127. * @param {Function} func The function to attempt.
  32128. * @param {...*} [args] The arguments to invoke `func` with.
  32129. * @returns {*} Returns the `func` result or error object.
  32130. * @example
  32131. *
  32132. * // Avoid throwing errors for invalid selectors.
  32133. * var elements = _.attempt(function(selector) {
  32134. * return document.querySelectorAll(selector);
  32135. * }, '>_>');
  32136. *
  32137. * if (_.isError(elements)) {
  32138. * elements = [];
  32139. * }
  32140. */
  32141. var attempt = baseRest(function(func, args) {
  32142. try {
  32143. return apply(func, undefined, args);
  32144. } catch (e) {
  32145. return isError(e) ? e : new Error(e);
  32146. }
  32147. });
  32148. /**
  32149. * Binds methods of an object to the object itself, overwriting the existing
  32150. * method.
  32151. *
  32152. * **Note:** This method doesn't set the "length" property of bound functions.
  32153. *
  32154. * @static
  32155. * @since 0.1.0
  32156. * @memberOf _
  32157. * @category Util
  32158. * @param {Object} object The object to bind and assign the bound methods to.
  32159. * @param {...(string|string[])} methodNames The object method names to bind.
  32160. * @returns {Object} Returns `object`.
  32161. * @example
  32162. *
  32163. * var view = {
  32164. * 'label': 'docs',
  32165. * 'click': function() {
  32166. * console.log('clicked ' + this.label);
  32167. * }
  32168. * };
  32169. *
  32170. * _.bindAll(view, ['click']);
  32171. * jQuery(element).on('click', view.click);
  32172. * // => Logs 'clicked docs' when clicked.
  32173. */
  32174. var bindAll = flatRest(function(object, methodNames) {
  32175. arrayEach(methodNames, function(key) {
  32176. key = toKey(key);
  32177. baseAssignValue(object, key, bind(object[key], object));
  32178. });
  32179. return object;
  32180. });
  32181. /**
  32182. * Creates a function that iterates over `pairs` and invokes the corresponding
  32183. * function of the first predicate to return truthy. The predicate-function
  32184. * pairs are invoked with the `this` binding and arguments of the created
  32185. * function.
  32186. *
  32187. * @static
  32188. * @memberOf _
  32189. * @since 4.0.0
  32190. * @category Util
  32191. * @param {Array} pairs The predicate-function pairs.
  32192. * @returns {Function} Returns the new composite function.
  32193. * @example
  32194. *
  32195. * var func = _.cond([
  32196. * [_.matches({ 'a': 1 }), _.constant('matches A')],
  32197. * [_.conforms({ 'b': _.isNumber }), _.constant('matches B')],
  32198. * [_.stubTrue, _.constant('no match')]
  32199. * ]);
  32200. *
  32201. * func({ 'a': 1, 'b': 2 });
  32202. * // => 'matches A'
  32203. *
  32204. * func({ 'a': 0, 'b': 1 });
  32205. * // => 'matches B'
  32206. *
  32207. * func({ 'a': '1', 'b': '2' });
  32208. * // => 'no match'
  32209. */
  32210. function cond(pairs) {
  32211. var length = pairs == null ? 0 : pairs.length,
  32212. toIteratee = getIteratee();
  32213. pairs = !length ? [] : arrayMap(pairs, function(pair) {
  32214. if (typeof pair[1] != 'function') {
  32215. throw new TypeError(FUNC_ERROR_TEXT);
  32216. }
  32217. return [toIteratee(pair[0]), pair[1]];
  32218. });
  32219. return baseRest(function(args) {
  32220. var index = -1;
  32221. while (++index < length) {
  32222. var pair = pairs[index];
  32223. if (apply(pair[0], this, args)) {
  32224. return apply(pair[1], this, args);
  32225. }
  32226. }
  32227. });
  32228. }
  32229. /**
  32230. * Creates a function that invokes the predicate properties of `source` with
  32231. * the corresponding property values of a given object, returning `true` if
  32232. * all predicates return truthy, else `false`.
  32233. *
  32234. * **Note:** The created function is equivalent to `_.conformsTo` with
  32235. * `source` partially applied.
  32236. *
  32237. * @static
  32238. * @memberOf _
  32239. * @since 4.0.0
  32240. * @category Util
  32241. * @param {Object} source The object of property predicates to conform to.
  32242. * @returns {Function} Returns the new spec function.
  32243. * @example
  32244. *
  32245. * var objects = [
  32246. * { 'a': 2, 'b': 1 },
  32247. * { 'a': 1, 'b': 2 }
  32248. * ];
  32249. *
  32250. * _.filter(objects, _.conforms({ 'b': function(n) { return n > 1; } }));
  32251. * // => [{ 'a': 1, 'b': 2 }]
  32252. */
  32253. function conforms(source) {
  32254. return baseConforms(baseClone(source, CLONE_DEEP_FLAG));
  32255. }
  32256. /**
  32257. * Creates a function that returns `value`.
  32258. *
  32259. * @static
  32260. * @memberOf _
  32261. * @since 2.4.0
  32262. * @category Util
  32263. * @param {*} value The value to return from the new function.
  32264. * @returns {Function} Returns the new constant function.
  32265. * @example
  32266. *
  32267. * var objects = _.times(2, _.constant({ 'a': 1 }));
  32268. *
  32269. * console.log(objects);
  32270. * // => [{ 'a': 1 }, { 'a': 1 }]
  32271. *
  32272. * console.log(objects[0] === objects[1]);
  32273. * // => true
  32274. */
  32275. function constant(value) {
  32276. return function() {
  32277. return value;
  32278. };
  32279. }
  32280. /**
  32281. * Checks `value` to determine whether a default value should be returned in
  32282. * its place. The `defaultValue` is returned if `value` is `NaN`, `null`,
  32283. * or `undefined`.
  32284. *
  32285. * @static
  32286. * @memberOf _
  32287. * @since 4.14.0
  32288. * @category Util
  32289. * @param {*} value The value to check.
  32290. * @param {*} defaultValue The default value.
  32291. * @returns {*} Returns the resolved value.
  32292. * @example
  32293. *
  32294. * _.defaultTo(1, 10);
  32295. * // => 1
  32296. *
  32297. * _.defaultTo(undefined, 10);
  32298. * // => 10
  32299. */
  32300. function defaultTo(value, defaultValue) {
  32301. return (value == null || value !== value) ? defaultValue : value;
  32302. }
  32303. /**
  32304. * Creates a function that returns the result of invoking the given functions
  32305. * with the `this` binding of the created function, where each successive
  32306. * invocation is supplied the return value of the previous.
  32307. *
  32308. * @static
  32309. * @memberOf _
  32310. * @since 3.0.0
  32311. * @category Util
  32312. * @param {...(Function|Function[])} [funcs] The functions to invoke.
  32313. * @returns {Function} Returns the new composite function.
  32314. * @see _.flowRight
  32315. * @example
  32316. *
  32317. * function square(n) {
  32318. * return n * n;
  32319. * }
  32320. *
  32321. * var addSquare = _.flow([_.add, square]);
  32322. * addSquare(1, 2);
  32323. * // => 9
  32324. */
  32325. var flow = createFlow();
  32326. /**
  32327. * This method is like `_.flow` except that it creates a function that
  32328. * invokes the given functions from right to left.
  32329. *
  32330. * @static
  32331. * @since 3.0.0
  32332. * @memberOf _
  32333. * @category Util
  32334. * @param {...(Function|Function[])} [funcs] The functions to invoke.
  32335. * @returns {Function} Returns the new composite function.
  32336. * @see _.flow
  32337. * @example
  32338. *
  32339. * function square(n) {
  32340. * return n * n;
  32341. * }
  32342. *
  32343. * var addSquare = _.flowRight([square, _.add]);
  32344. * addSquare(1, 2);
  32345. * // => 9
  32346. */
  32347. var flowRight = createFlow(true);
  32348. /**
  32349. * This method returns the first argument it receives.
  32350. *
  32351. * @static
  32352. * @since 0.1.0
  32353. * @memberOf _
  32354. * @category Util
  32355. * @param {*} value Any value.
  32356. * @returns {*} Returns `value`.
  32357. * @example
  32358. *
  32359. * var object = { 'a': 1 };
  32360. *
  32361. * console.log(_.identity(object) === object);
  32362. * // => true
  32363. */
  32364. function identity(value) {
  32365. return value;
  32366. }
  32367. /**
  32368. * Creates a function that invokes `func` with the arguments of the created
  32369. * function. If `func` is a property name, the created function returns the
  32370. * property value for a given element. If `func` is an array or object, the
  32371. * created function returns `true` for elements that contain the equivalent
  32372. * source properties, otherwise it returns `false`.
  32373. *
  32374. * @static
  32375. * @since 4.0.0
  32376. * @memberOf _
  32377. * @category Util
  32378. * @param {*} [func=_.identity] The value to convert to a callback.
  32379. * @returns {Function} Returns the callback.
  32380. * @example
  32381. *
  32382. * var users = [
  32383. * { 'user': 'barney', 'age': 36, 'active': true },
  32384. * { 'user': 'fred', 'age': 40, 'active': false }
  32385. * ];
  32386. *
  32387. * // The `_.matches` iteratee shorthand.
  32388. * _.filter(users, _.iteratee({ 'user': 'barney', 'active': true }));
  32389. * // => [{ 'user': 'barney', 'age': 36, 'active': true }]
  32390. *
  32391. * // The `_.matchesProperty` iteratee shorthand.
  32392. * _.filter(users, _.iteratee(['user', 'fred']));
  32393. * // => [{ 'user': 'fred', 'age': 40 }]
  32394. *
  32395. * // The `_.property` iteratee shorthand.
  32396. * _.map(users, _.iteratee('user'));
  32397. * // => ['barney', 'fred']
  32398. *
  32399. * // Create custom iteratee shorthands.
  32400. * _.iteratee = _.wrap(_.iteratee, function(iteratee, func) {
  32401. * return !_.isRegExp(func) ? iteratee(func) : function(string) {
  32402. * return func.test(string);
  32403. * };
  32404. * });
  32405. *
  32406. * _.filter(['abc', 'def'], /ef/);
  32407. * // => ['def']
  32408. */
  32409. function iteratee(func) {
  32410. return baseIteratee(typeof func == 'function' ? func : baseClone(func, CLONE_DEEP_FLAG));
  32411. }
  32412. /**
  32413. * Creates a function that performs a partial deep comparison between a given
  32414. * object and `source`, returning `true` if the given object has equivalent
  32415. * property values, else `false`.
  32416. *
  32417. * **Note:** The created function is equivalent to `_.isMatch` with `source`
  32418. * partially applied.
  32419. *
  32420. * Partial comparisons will match empty array and empty object `source`
  32421. * values against any array or object value, respectively. See `_.isEqual`
  32422. * for a list of supported value comparisons.
  32423. *
  32424. * @static
  32425. * @memberOf _
  32426. * @since 3.0.0
  32427. * @category Util
  32428. * @param {Object} source The object of property values to match.
  32429. * @returns {Function} Returns the new spec function.
  32430. * @example
  32431. *
  32432. * var objects = [
  32433. * { 'a': 1, 'b': 2, 'c': 3 },
  32434. * { 'a': 4, 'b': 5, 'c': 6 }
  32435. * ];
  32436. *
  32437. * _.filter(objects, _.matches({ 'a': 4, 'c': 6 }));
  32438. * // => [{ 'a': 4, 'b': 5, 'c': 6 }]
  32439. */
  32440. function matches(source) {
  32441. return baseMatches(baseClone(source, CLONE_DEEP_FLAG));
  32442. }
  32443. /**
  32444. * Creates a function that performs a partial deep comparison between the
  32445. * value at `path` of a given object to `srcValue`, returning `true` if the
  32446. * object value is equivalent, else `false`.
  32447. *
  32448. * **Note:** Partial comparisons will match empty array and empty object
  32449. * `srcValue` values against any array or object value, respectively. See
  32450. * `_.isEqual` for a list of supported value comparisons.
  32451. *
  32452. * @static
  32453. * @memberOf _
  32454. * @since 3.2.0
  32455. * @category Util
  32456. * @param {Array|string} path The path of the property to get.
  32457. * @param {*} srcValue The value to match.
  32458. * @returns {Function} Returns the new spec function.
  32459. * @example
  32460. *
  32461. * var objects = [
  32462. * { 'a': 1, 'b': 2, 'c': 3 },
  32463. * { 'a': 4, 'b': 5, 'c': 6 }
  32464. * ];
  32465. *
  32466. * _.find(objects, _.matchesProperty('a', 4));
  32467. * // => { 'a': 4, 'b': 5, 'c': 6 }
  32468. */
  32469. function matchesProperty(path, srcValue) {
  32470. return baseMatchesProperty(path, baseClone(srcValue, CLONE_DEEP_FLAG));
  32471. }
  32472. /**
  32473. * Creates a function that invokes the method at `path` of a given object.
  32474. * Any additional arguments are provided to the invoked method.
  32475. *
  32476. * @static
  32477. * @memberOf _
  32478. * @since 3.7.0
  32479. * @category Util
  32480. * @param {Array|string} path The path of the method to invoke.
  32481. * @param {...*} [args] The arguments to invoke the method with.
  32482. * @returns {Function} Returns the new invoker function.
  32483. * @example
  32484. *
  32485. * var objects = [
  32486. * { 'a': { 'b': _.constant(2) } },
  32487. * { 'a': { 'b': _.constant(1) } }
  32488. * ];
  32489. *
  32490. * _.map(objects, _.method('a.b'));
  32491. * // => [2, 1]
  32492. *
  32493. * _.map(objects, _.method(['a', 'b']));
  32494. * // => [2, 1]
  32495. */
  32496. var method = baseRest(function(path, args) {
  32497. return function(object) {
  32498. return baseInvoke(object, path, args);
  32499. };
  32500. });
  32501. /**
  32502. * The opposite of `_.method`; this method creates a function that invokes
  32503. * the method at a given path of `object`. Any additional arguments are
  32504. * provided to the invoked method.
  32505. *
  32506. * @static
  32507. * @memberOf _
  32508. * @since 3.7.0
  32509. * @category Util
  32510. * @param {Object} object The object to query.
  32511. * @param {...*} [args] The arguments to invoke the method with.
  32512. * @returns {Function} Returns the new invoker function.
  32513. * @example
  32514. *
  32515. * var array = _.times(3, _.constant),
  32516. * object = { 'a': array, 'b': array, 'c': array };
  32517. *
  32518. * _.map(['a[2]', 'c[0]'], _.methodOf(object));
  32519. * // => [2, 0]
  32520. *
  32521. * _.map([['a', '2'], ['c', '0']], _.methodOf(object));
  32522. * // => [2, 0]
  32523. */
  32524. var methodOf = baseRest(function(object, args) {
  32525. return function(path) {
  32526. return baseInvoke(object, path, args);
  32527. };
  32528. });
  32529. /**
  32530. * Adds all own enumerable string keyed function properties of a source
  32531. * object to the destination object. If `object` is a function, then methods
  32532. * are added to its prototype as well.
  32533. *
  32534. * **Note:** Use `_.runInContext` to create a pristine `lodash` function to
  32535. * avoid conflicts caused by modifying the original.
  32536. *
  32537. * @static
  32538. * @since 0.1.0
  32539. * @memberOf _
  32540. * @category Util
  32541. * @param {Function|Object} [object=lodash] The destination object.
  32542. * @param {Object} source The object of functions to add.
  32543. * @param {Object} [options={}] The options object.
  32544. * @param {boolean} [options.chain=true] Specify whether mixins are chainable.
  32545. * @returns {Function|Object} Returns `object`.
  32546. * @example
  32547. *
  32548. * function vowels(string) {
  32549. * return _.filter(string, function(v) {
  32550. * return /[aeiou]/i.test(v);
  32551. * });
  32552. * }
  32553. *
  32554. * _.mixin({ 'vowels': vowels });
  32555. * _.vowels('fred');
  32556. * // => ['e']
  32557. *
  32558. * _('fred').vowels().value();
  32559. * // => ['e']
  32560. *
  32561. * _.mixin({ 'vowels': vowels }, { 'chain': false });
  32562. * _('fred').vowels();
  32563. * // => ['e']
  32564. */
  32565. function mixin(object, source, options) {
  32566. var props = keys(source),
  32567. methodNames = baseFunctions(source, props);
  32568. if (options == null &&
  32569. !(isObject(source) && (methodNames.length || !props.length))) {
  32570. options = source;
  32571. source = object;
  32572. object = this;
  32573. methodNames = baseFunctions(source, keys(source));
  32574. }
  32575. var chain = !(isObject(options) && 'chain' in options) || !!options.chain,
  32576. isFunc = isFunction(object);
  32577. arrayEach(methodNames, function(methodName) {
  32578. var func = source[methodName];
  32579. object[methodName] = func;
  32580. if (isFunc) {
  32581. object.prototype[methodName] = function() {
  32582. var chainAll = this.__chain__;
  32583. if (chain || chainAll) {
  32584. var result = object(this.__wrapped__),
  32585. actions = result.__actions__ = copyArray(this.__actions__);
  32586. actions.push({ 'func': func, 'args': arguments, 'thisArg': object });
  32587. result.__chain__ = chainAll;
  32588. return result;
  32589. }
  32590. return func.apply(object, arrayPush([this.value()], arguments));
  32591. };
  32592. }
  32593. });
  32594. return object;
  32595. }
  32596. /**
  32597. * Reverts the `_` variable to its previous value and returns a reference to
  32598. * the `lodash` function.
  32599. *
  32600. * @static
  32601. * @since 0.1.0
  32602. * @memberOf _
  32603. * @category Util
  32604. * @returns {Function} Returns the `lodash` function.
  32605. * @example
  32606. *
  32607. * var lodash = _.noConflict();
  32608. */
  32609. function noConflict() {
  32610. if (root._ === this) {
  32611. root._ = oldDash;
  32612. }
  32613. return this;
  32614. }
  32615. /**
  32616. * This method returns `undefined`.
  32617. *
  32618. * @static
  32619. * @memberOf _
  32620. * @since 2.3.0
  32621. * @category Util
  32622. * @example
  32623. *
  32624. * _.times(2, _.noop);
  32625. * // => [undefined, undefined]
  32626. */
  32627. function noop() {
  32628. // No operation performed.
  32629. }
  32630. /**
  32631. * Creates a function that gets the argument at index `n`. If `n` is negative,
  32632. * the nth argument from the end is returned.
  32633. *
  32634. * @static
  32635. * @memberOf _
  32636. * @since 4.0.0
  32637. * @category Util
  32638. * @param {number} [n=0] The index of the argument to return.
  32639. * @returns {Function} Returns the new pass-thru function.
  32640. * @example
  32641. *
  32642. * var func = _.nthArg(1);
  32643. * func('a', 'b', 'c', 'd');
  32644. * // => 'b'
  32645. *
  32646. * var func = _.nthArg(-2);
  32647. * func('a', 'b', 'c', 'd');
  32648. * // => 'c'
  32649. */
  32650. function nthArg(n) {
  32651. n = toInteger(n);
  32652. return baseRest(function(args) {
  32653. return baseNth(args, n);
  32654. });
  32655. }
  32656. /**
  32657. * Creates a function that invokes `iteratees` with the arguments it receives
  32658. * and returns their results.
  32659. *
  32660. * @static
  32661. * @memberOf _
  32662. * @since 4.0.0
  32663. * @category Util
  32664. * @param {...(Function|Function[])} [iteratees=[_.identity]]
  32665. * The iteratees to invoke.
  32666. * @returns {Function} Returns the new function.
  32667. * @example
  32668. *
  32669. * var func = _.over([Math.max, Math.min]);
  32670. *
  32671. * func(1, 2, 3, 4);
  32672. * // => [4, 1]
  32673. */
  32674. var over = createOver(arrayMap);
  32675. /**
  32676. * Creates a function that checks if **all** of the `predicates` return
  32677. * truthy when invoked with the arguments it receives.
  32678. *
  32679. * @static
  32680. * @memberOf _
  32681. * @since 4.0.0
  32682. * @category Util
  32683. * @param {...(Function|Function[])} [predicates=[_.identity]]
  32684. * The predicates to check.
  32685. * @returns {Function} Returns the new function.
  32686. * @example
  32687. *
  32688. * var func = _.overEvery([Boolean, isFinite]);
  32689. *
  32690. * func('1');
  32691. * // => true
  32692. *
  32693. * func(null);
  32694. * // => false
  32695. *
  32696. * func(NaN);
  32697. * // => false
  32698. */
  32699. var overEvery = createOver(arrayEvery);
  32700. /**
  32701. * Creates a function that checks if **any** of the `predicates` return
  32702. * truthy when invoked with the arguments it receives.
  32703. *
  32704. * @static
  32705. * @memberOf _
  32706. * @since 4.0.0
  32707. * @category Util
  32708. * @param {...(Function|Function[])} [predicates=[_.identity]]
  32709. * The predicates to check.
  32710. * @returns {Function} Returns the new function.
  32711. * @example
  32712. *
  32713. * var func = _.overSome([Boolean, isFinite]);
  32714. *
  32715. * func('1');
  32716. * // => true
  32717. *
  32718. * func(null);
  32719. * // => true
  32720. *
  32721. * func(NaN);
  32722. * // => false
  32723. */
  32724. var overSome = createOver(arraySome);
  32725. /**
  32726. * Creates a function that returns the value at `path` of a given object.
  32727. *
  32728. * @static
  32729. * @memberOf _
  32730. * @since 2.4.0
  32731. * @category Util
  32732. * @param {Array|string} path The path of the property to get.
  32733. * @returns {Function} Returns the new accessor function.
  32734. * @example
  32735. *
  32736. * var objects = [
  32737. * { 'a': { 'b': 2 } },
  32738. * { 'a': { 'b': 1 } }
  32739. * ];
  32740. *
  32741. * _.map(objects, _.property('a.b'));
  32742. * // => [2, 1]
  32743. *
  32744. * _.map(_.sortBy(objects, _.property(['a', 'b'])), 'a.b');
  32745. * // => [1, 2]
  32746. */
  32747. function property(path) {
  32748. return isKey(path) ? baseProperty(toKey(path)) : basePropertyDeep(path);
  32749. }
  32750. /**
  32751. * The opposite of `_.property`; this method creates a function that returns
  32752. * the value at a given path of `object`.
  32753. *
  32754. * @static
  32755. * @memberOf _
  32756. * @since 3.0.0
  32757. * @category Util
  32758. * @param {Object} object The object to query.
  32759. * @returns {Function} Returns the new accessor function.
  32760. * @example
  32761. *
  32762. * var array = [0, 1, 2],
  32763. * object = { 'a': array, 'b': array, 'c': array };
  32764. *
  32765. * _.map(['a[2]', 'c[0]'], _.propertyOf(object));
  32766. * // => [2, 0]
  32767. *
  32768. * _.map([['a', '2'], ['c', '0']], _.propertyOf(object));
  32769. * // => [2, 0]
  32770. */
  32771. function propertyOf(object) {
  32772. return function(path) {
  32773. return object == null ? undefined : baseGet(object, path);
  32774. };
  32775. }
  32776. /**
  32777. * Creates an array of numbers (positive and/or negative) progressing from
  32778. * `start` up to, but not including, `end`. A step of `-1` is used if a negative
  32779. * `start` is specified without an `end` or `step`. If `end` is not specified,
  32780. * it's set to `start` with `start` then set to `0`.
  32781. *
  32782. * **Note:** JavaScript follows the IEEE-754 standard for resolving
  32783. * floating-point values which can produce unexpected results.
  32784. *
  32785. * @static
  32786. * @since 0.1.0
  32787. * @memberOf _
  32788. * @category Util
  32789. * @param {number} [start=0] The start of the range.
  32790. * @param {number} end The end of the range.
  32791. * @param {number} [step=1] The value to increment or decrement by.
  32792. * @returns {Array} Returns the range of numbers.
  32793. * @see _.inRange, _.rangeRight
  32794. * @example
  32795. *
  32796. * _.range(4);
  32797. * // => [0, 1, 2, 3]
  32798. *
  32799. * _.range(-4);
  32800. * // => [0, -1, -2, -3]
  32801. *
  32802. * _.range(1, 5);
  32803. * // => [1, 2, 3, 4]
  32804. *
  32805. * _.range(0, 20, 5);
  32806. * // => [0, 5, 10, 15]
  32807. *
  32808. * _.range(0, -4, -1);
  32809. * // => [0, -1, -2, -3]
  32810. *
  32811. * _.range(1, 4, 0);
  32812. * // => [1, 1, 1]
  32813. *
  32814. * _.range(0);
  32815. * // => []
  32816. */
  32817. var range = createRange();
  32818. /**
  32819. * This method is like `_.range` except that it populates values in
  32820. * descending order.
  32821. *
  32822. * @static
  32823. * @memberOf _
  32824. * @since 4.0.0
  32825. * @category Util
  32826. * @param {number} [start=0] The start of the range.
  32827. * @param {number} end The end of the range.
  32828. * @param {number} [step=1] The value to increment or decrement by.
  32829. * @returns {Array} Returns the range of numbers.
  32830. * @see _.inRange, _.range
  32831. * @example
  32832. *
  32833. * _.rangeRight(4);
  32834. * // => [3, 2, 1, 0]
  32835. *
  32836. * _.rangeRight(-4);
  32837. * // => [-3, -2, -1, 0]
  32838. *
  32839. * _.rangeRight(1, 5);
  32840. * // => [4, 3, 2, 1]
  32841. *
  32842. * _.rangeRight(0, 20, 5);
  32843. * // => [15, 10, 5, 0]
  32844. *
  32845. * _.rangeRight(0, -4, -1);
  32846. * // => [-3, -2, -1, 0]
  32847. *
  32848. * _.rangeRight(1, 4, 0);
  32849. * // => [1, 1, 1]
  32850. *
  32851. * _.rangeRight(0);
  32852. * // => []
  32853. */
  32854. var rangeRight = createRange(true);
  32855. /**
  32856. * This method returns a new empty array.
  32857. *
  32858. * @static
  32859. * @memberOf _
  32860. * @since 4.13.0
  32861. * @category Util
  32862. * @returns {Array} Returns the new empty array.
  32863. * @example
  32864. *
  32865. * var arrays = _.times(2, _.stubArray);
  32866. *
  32867. * console.log(arrays);
  32868. * // => [[], []]
  32869. *
  32870. * console.log(arrays[0] === arrays[1]);
  32871. * // => false
  32872. */
  32873. function stubArray() {
  32874. return [];
  32875. }
  32876. /**
  32877. * This method returns `false`.
  32878. *
  32879. * @static
  32880. * @memberOf _
  32881. * @since 4.13.0
  32882. * @category Util
  32883. * @returns {boolean} Returns `false`.
  32884. * @example
  32885. *
  32886. * _.times(2, _.stubFalse);
  32887. * // => [false, false]
  32888. */
  32889. function stubFalse() {
  32890. return false;
  32891. }
  32892. /**
  32893. * This method returns a new empty object.
  32894. *
  32895. * @static
  32896. * @memberOf _
  32897. * @since 4.13.0
  32898. * @category Util
  32899. * @returns {Object} Returns the new empty object.
  32900. * @example
  32901. *
  32902. * var objects = _.times(2, _.stubObject);
  32903. *
  32904. * console.log(objects);
  32905. * // => [{}, {}]
  32906. *
  32907. * console.log(objects[0] === objects[1]);
  32908. * // => false
  32909. */
  32910. function stubObject() {
  32911. return {};
  32912. }
  32913. /**
  32914. * This method returns an empty string.
  32915. *
  32916. * @static
  32917. * @memberOf _
  32918. * @since 4.13.0
  32919. * @category Util
  32920. * @returns {string} Returns the empty string.
  32921. * @example
  32922. *
  32923. * _.times(2, _.stubString);
  32924. * // => ['', '']
  32925. */
  32926. function stubString() {
  32927. return '';
  32928. }
  32929. /**
  32930. * This method returns `true`.
  32931. *
  32932. * @static
  32933. * @memberOf _
  32934. * @since 4.13.0
  32935. * @category Util
  32936. * @returns {boolean} Returns `true`.
  32937. * @example
  32938. *
  32939. * _.times(2, _.stubTrue);
  32940. * // => [true, true]
  32941. */
  32942. function stubTrue() {
  32943. return true;
  32944. }
  32945. /**
  32946. * Invokes the iteratee `n` times, returning an array of the results of
  32947. * each invocation. The iteratee is invoked with one argument; (index).
  32948. *
  32949. * @static
  32950. * @since 0.1.0
  32951. * @memberOf _
  32952. * @category Util
  32953. * @param {number} n The number of times to invoke `iteratee`.
  32954. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  32955. * @returns {Array} Returns the array of results.
  32956. * @example
  32957. *
  32958. * _.times(3, String);
  32959. * // => ['0', '1', '2']
  32960. *
  32961. * _.times(4, _.constant(0));
  32962. * // => [0, 0, 0, 0]
  32963. */
  32964. function times(n, iteratee) {
  32965. n = toInteger(n);
  32966. if (n < 1 || n > MAX_SAFE_INTEGER) {
  32967. return [];
  32968. }
  32969. var index = MAX_ARRAY_LENGTH,
  32970. length = nativeMin(n, MAX_ARRAY_LENGTH);
  32971. iteratee = getIteratee(iteratee);
  32972. n -= MAX_ARRAY_LENGTH;
  32973. var result = baseTimes(length, iteratee);
  32974. while (++index < n) {
  32975. iteratee(index);
  32976. }
  32977. return result;
  32978. }
  32979. /**
  32980. * Converts `value` to a property path array.
  32981. *
  32982. * @static
  32983. * @memberOf _
  32984. * @since 4.0.0
  32985. * @category Util
  32986. * @param {*} value The value to convert.
  32987. * @returns {Array} Returns the new property path array.
  32988. * @example
  32989. *
  32990. * _.toPath('a.b.c');
  32991. * // => ['a', 'b', 'c']
  32992. *
  32993. * _.toPath('a[0].b.c');
  32994. * // => ['a', '0', 'b', 'c']
  32995. */
  32996. function toPath(value) {
  32997. if (isArray(value)) {
  32998. return arrayMap(value, toKey);
  32999. }
  33000. return isSymbol(value) ? [value] : copyArray(stringToPath(toString(value)));
  33001. }
  33002. /**
  33003. * Generates a unique ID. If `prefix` is given, the ID is appended to it.
  33004. *
  33005. * @static
  33006. * @since 0.1.0
  33007. * @memberOf _
  33008. * @category Util
  33009. * @param {string} [prefix=''] The value to prefix the ID with.
  33010. * @returns {string} Returns the unique ID.
  33011. * @example
  33012. *
  33013. * _.uniqueId('contact_');
  33014. * // => 'contact_104'
  33015. *
  33016. * _.uniqueId();
  33017. * // => '105'
  33018. */
  33019. function uniqueId(prefix) {
  33020. var id = ++idCounter;
  33021. return toString(prefix) + id;
  33022. }
  33023. /*------------------------------------------------------------------------*/
  33024. /**
  33025. * Adds two numbers.
  33026. *
  33027. * @static
  33028. * @memberOf _
  33029. * @since 3.4.0
  33030. * @category Math
  33031. * @param {number} augend The first number in an addition.
  33032. * @param {number} addend The second number in an addition.
  33033. * @returns {number} Returns the total.
  33034. * @example
  33035. *
  33036. * _.add(6, 4);
  33037. * // => 10
  33038. */
  33039. var add = createMathOperation(function(augend, addend) {
  33040. return augend + addend;
  33041. }, 0);
  33042. /**
  33043. * Computes `number` rounded up to `precision`.
  33044. *
  33045. * @static
  33046. * @memberOf _
  33047. * @since 3.10.0
  33048. * @category Math
  33049. * @param {number} number The number to round up.
  33050. * @param {number} [precision=0] The precision to round up to.
  33051. * @returns {number} Returns the rounded up number.
  33052. * @example
  33053. *
  33054. * _.ceil(4.006);
  33055. * // => 5
  33056. *
  33057. * _.ceil(6.004, 2);
  33058. * // => 6.01
  33059. *
  33060. * _.ceil(6040, -2);
  33061. * // => 6100
  33062. */
  33063. var ceil = createRound('ceil');
  33064. /**
  33065. * Divide two numbers.
  33066. *
  33067. * @static
  33068. * @memberOf _
  33069. * @since 4.7.0
  33070. * @category Math
  33071. * @param {number} dividend The first number in a division.
  33072. * @param {number} divisor The second number in a division.
  33073. * @returns {number} Returns the quotient.
  33074. * @example
  33075. *
  33076. * _.divide(6, 4);
  33077. * // => 1.5
  33078. */
  33079. var divide = createMathOperation(function(dividend, divisor) {
  33080. return dividend / divisor;
  33081. }, 1);
  33082. /**
  33083. * Computes `number` rounded down to `precision`.
  33084. *
  33085. * @static
  33086. * @memberOf _
  33087. * @since 3.10.0
  33088. * @category Math
  33089. * @param {number} number The number to round down.
  33090. * @param {number} [precision=0] The precision to round down to.
  33091. * @returns {number} Returns the rounded down number.
  33092. * @example
  33093. *
  33094. * _.floor(4.006);
  33095. * // => 4
  33096. *
  33097. * _.floor(0.046, 2);
  33098. * // => 0.04
  33099. *
  33100. * _.floor(4060, -2);
  33101. * // => 4000
  33102. */
  33103. var floor = createRound('floor');
  33104. /**
  33105. * Computes the maximum value of `array`. If `array` is empty or falsey,
  33106. * `undefined` is returned.
  33107. *
  33108. * @static
  33109. * @since 0.1.0
  33110. * @memberOf _
  33111. * @category Math
  33112. * @param {Array} array The array to iterate over.
  33113. * @returns {*} Returns the maximum value.
  33114. * @example
  33115. *
  33116. * _.max([4, 2, 8, 6]);
  33117. * // => 8
  33118. *
  33119. * _.max([]);
  33120. * // => undefined
  33121. */
  33122. function max(array) {
  33123. return (array && array.length)
  33124. ? baseExtremum(array, identity, baseGt)
  33125. : undefined;
  33126. }
  33127. /**
  33128. * This method is like `_.max` except that it accepts `iteratee` which is
  33129. * invoked for each element in `array` to generate the criterion by which
  33130. * the value is ranked. The iteratee is invoked with one argument: (value).
  33131. *
  33132. * @static
  33133. * @memberOf _
  33134. * @since 4.0.0
  33135. * @category Math
  33136. * @param {Array} array The array to iterate over.
  33137. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  33138. * @returns {*} Returns the maximum value.
  33139. * @example
  33140. *
  33141. * var objects = [{ 'n': 1 }, { 'n': 2 }];
  33142. *
  33143. * _.maxBy(objects, function(o) { return o.n; });
  33144. * // => { 'n': 2 }
  33145. *
  33146. * // The `_.property` iteratee shorthand.
  33147. * _.maxBy(objects, 'n');
  33148. * // => { 'n': 2 }
  33149. */
  33150. function maxBy(array, iteratee) {
  33151. return (array && array.length)
  33152. ? baseExtremum(array, getIteratee(iteratee, 2), baseGt)
  33153. : undefined;
  33154. }
  33155. /**
  33156. * Computes the mean of the values in `array`.
  33157. *
  33158. * @static
  33159. * @memberOf _
  33160. * @since 4.0.0
  33161. * @category Math
  33162. * @param {Array} array The array to iterate over.
  33163. * @returns {number} Returns the mean.
  33164. * @example
  33165. *
  33166. * _.mean([4, 2, 8, 6]);
  33167. * // => 5
  33168. */
  33169. function mean(array) {
  33170. return baseMean(array, identity);
  33171. }
  33172. /**
  33173. * This method is like `_.mean` except that it accepts `iteratee` which is
  33174. * invoked for each element in `array` to generate the value to be averaged.
  33175. * The iteratee is invoked with one argument: (value).
  33176. *
  33177. * @static
  33178. * @memberOf _
  33179. * @since 4.7.0
  33180. * @category Math
  33181. * @param {Array} array The array to iterate over.
  33182. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  33183. * @returns {number} Returns the mean.
  33184. * @example
  33185. *
  33186. * var objects = [{ 'n': 4 }, { 'n': 2 }, { 'n': 8 }, { 'n': 6 }];
  33187. *
  33188. * _.meanBy(objects, function(o) { return o.n; });
  33189. * // => 5
  33190. *
  33191. * // The `_.property` iteratee shorthand.
  33192. * _.meanBy(objects, 'n');
  33193. * // => 5
  33194. */
  33195. function meanBy(array, iteratee) {
  33196. return baseMean(array, getIteratee(iteratee, 2));
  33197. }
  33198. /**
  33199. * Computes the minimum value of `array`. If `array` is empty or falsey,
  33200. * `undefined` is returned.
  33201. *
  33202. * @static
  33203. * @since 0.1.0
  33204. * @memberOf _
  33205. * @category Math
  33206. * @param {Array} array The array to iterate over.
  33207. * @returns {*} Returns the minimum value.
  33208. * @example
  33209. *
  33210. * _.min([4, 2, 8, 6]);
  33211. * // => 2
  33212. *
  33213. * _.min([]);
  33214. * // => undefined
  33215. */
  33216. function min(array) {
  33217. return (array && array.length)
  33218. ? baseExtremum(array, identity, baseLt)
  33219. : undefined;
  33220. }
  33221. /**
  33222. * This method is like `_.min` except that it accepts `iteratee` which is
  33223. * invoked for each element in `array` to generate the criterion by which
  33224. * the value is ranked. The iteratee is invoked with one argument: (value).
  33225. *
  33226. * @static
  33227. * @memberOf _
  33228. * @since 4.0.0
  33229. * @category Math
  33230. * @param {Array} array The array to iterate over.
  33231. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  33232. * @returns {*} Returns the minimum value.
  33233. * @example
  33234. *
  33235. * var objects = [{ 'n': 1 }, { 'n': 2 }];
  33236. *
  33237. * _.minBy(objects, function(o) { return o.n; });
  33238. * // => { 'n': 1 }
  33239. *
  33240. * // The `_.property` iteratee shorthand.
  33241. * _.minBy(objects, 'n');
  33242. * // => { 'n': 1 }
  33243. */
  33244. function minBy(array, iteratee) {
  33245. return (array && array.length)
  33246. ? baseExtremum(array, getIteratee(iteratee, 2), baseLt)
  33247. : undefined;
  33248. }
  33249. /**
  33250. * Multiply two numbers.
  33251. *
  33252. * @static
  33253. * @memberOf _
  33254. * @since 4.7.0
  33255. * @category Math
  33256. * @param {number} multiplier The first number in a multiplication.
  33257. * @param {number} multiplicand The second number in a multiplication.
  33258. * @returns {number} Returns the product.
  33259. * @example
  33260. *
  33261. * _.multiply(6, 4);
  33262. * // => 24
  33263. */
  33264. var multiply = createMathOperation(function(multiplier, multiplicand) {
  33265. return multiplier * multiplicand;
  33266. }, 1);
  33267. /**
  33268. * Computes `number` rounded to `precision`.
  33269. *
  33270. * @static
  33271. * @memberOf _
  33272. * @since 3.10.0
  33273. * @category Math
  33274. * @param {number} number The number to round.
  33275. * @param {number} [precision=0] The precision to round to.
  33276. * @returns {number} Returns the rounded number.
  33277. * @example
  33278. *
  33279. * _.round(4.006);
  33280. * // => 4
  33281. *
  33282. * _.round(4.006, 2);
  33283. * // => 4.01
  33284. *
  33285. * _.round(4060, -2);
  33286. * // => 4100
  33287. */
  33288. var round = createRound('round');
  33289. /**
  33290. * Subtract two numbers.
  33291. *
  33292. * @static
  33293. * @memberOf _
  33294. * @since 4.0.0
  33295. * @category Math
  33296. * @param {number} minuend The first number in a subtraction.
  33297. * @param {number} subtrahend The second number in a subtraction.
  33298. * @returns {number} Returns the difference.
  33299. * @example
  33300. *
  33301. * _.subtract(6, 4);
  33302. * // => 2
  33303. */
  33304. var subtract = createMathOperation(function(minuend, subtrahend) {
  33305. return minuend - subtrahend;
  33306. }, 0);
  33307. /**
  33308. * Computes the sum of the values in `array`.
  33309. *
  33310. * @static
  33311. * @memberOf _
  33312. * @since 3.4.0
  33313. * @category Math
  33314. * @param {Array} array The array to iterate over.
  33315. * @returns {number} Returns the sum.
  33316. * @example
  33317. *
  33318. * _.sum([4, 2, 8, 6]);
  33319. * // => 20
  33320. */
  33321. function sum(array) {
  33322. return (array && array.length)
  33323. ? baseSum(array, identity)
  33324. : 0;
  33325. }
  33326. /**
  33327. * This method is like `_.sum` except that it accepts `iteratee` which is
  33328. * invoked for each element in `array` to generate the value to be summed.
  33329. * The iteratee is invoked with one argument: (value).
  33330. *
  33331. * @static
  33332. * @memberOf _
  33333. * @since 4.0.0
  33334. * @category Math
  33335. * @param {Array} array The array to iterate over.
  33336. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  33337. * @returns {number} Returns the sum.
  33338. * @example
  33339. *
  33340. * var objects = [{ 'n': 4 }, { 'n': 2 }, { 'n': 8 }, { 'n': 6 }];
  33341. *
  33342. * _.sumBy(objects, function(o) { return o.n; });
  33343. * // => 20
  33344. *
  33345. * // The `_.property` iteratee shorthand.
  33346. * _.sumBy(objects, 'n');
  33347. * // => 20
  33348. */
  33349. function sumBy(array, iteratee) {
  33350. return (array && array.length)
  33351. ? baseSum(array, getIteratee(iteratee, 2))
  33352. : 0;
  33353. }
  33354. /*------------------------------------------------------------------------*/
  33355. // Add methods that return wrapped values in chain sequences.
  33356. lodash.after = after;
  33357. lodash.ary = ary;
  33358. lodash.assign = assign;
  33359. lodash.assignIn = assignIn;
  33360. lodash.assignInWith = assignInWith;
  33361. lodash.assignWith = assignWith;
  33362. lodash.at = at;
  33363. lodash.before = before;
  33364. lodash.bind = bind;
  33365. lodash.bindAll = bindAll;
  33366. lodash.bindKey = bindKey;
  33367. lodash.castArray = castArray;
  33368. lodash.chain = chain;
  33369. lodash.chunk = chunk;
  33370. lodash.compact = compact;
  33371. lodash.concat = concat;
  33372. lodash.cond = cond;
  33373. lodash.conforms = conforms;
  33374. lodash.constant = constant;
  33375. lodash.countBy = countBy;
  33376. lodash.create = create;
  33377. lodash.curry = curry;
  33378. lodash.curryRight = curryRight;
  33379. lodash.debounce = debounce;
  33380. lodash.defaults = defaults;
  33381. lodash.defaultsDeep = defaultsDeep;
  33382. lodash.defer = defer;
  33383. lodash.delay = delay;
  33384. lodash.difference = difference;
  33385. lodash.differenceBy = differenceBy;
  33386. lodash.differenceWith = differenceWith;
  33387. lodash.drop = drop;
  33388. lodash.dropRight = dropRight;
  33389. lodash.dropRightWhile = dropRightWhile;
  33390. lodash.dropWhile = dropWhile;
  33391. lodash.fill = fill;
  33392. lodash.filter = filter;
  33393. lodash.flatMap = flatMap;
  33394. lodash.flatMapDeep = flatMapDeep;
  33395. lodash.flatMapDepth = flatMapDepth;
  33396. lodash.flatten = flatten;
  33397. lodash.flattenDeep = flattenDeep;
  33398. lodash.flattenDepth = flattenDepth;
  33399. lodash.flip = flip;
  33400. lodash.flow = flow;
  33401. lodash.flowRight = flowRight;
  33402. lodash.fromPairs = fromPairs;
  33403. lodash.functions = functions;
  33404. lodash.functionsIn = functionsIn;
  33405. lodash.groupBy = groupBy;
  33406. lodash.initial = initial;
  33407. lodash.intersection = intersection;
  33408. lodash.intersectionBy = intersectionBy;
  33409. lodash.intersectionWith = intersectionWith;
  33410. lodash.invert = invert;
  33411. lodash.invertBy = invertBy;
  33412. lodash.invokeMap = invokeMap;
  33413. lodash.iteratee = iteratee;
  33414. lodash.keyBy = keyBy;
  33415. lodash.keys = keys;
  33416. lodash.keysIn = keysIn;
  33417. lodash.map = map;
  33418. lodash.mapKeys = mapKeys;
  33419. lodash.mapValues = mapValues;
  33420. lodash.matches = matches;
  33421. lodash.matchesProperty = matchesProperty;
  33422. lodash.memoize = memoize;
  33423. lodash.merge = merge;
  33424. lodash.mergeWith = mergeWith;
  33425. lodash.method = method;
  33426. lodash.methodOf = methodOf;
  33427. lodash.mixin = mixin;
  33428. lodash.negate = negate;
  33429. lodash.nthArg = nthArg;
  33430. lodash.omit = omit;
  33431. lodash.omitBy = omitBy;
  33432. lodash.once = once;
  33433. lodash.orderBy = orderBy;
  33434. lodash.over = over;
  33435. lodash.overArgs = overArgs;
  33436. lodash.overEvery = overEvery;
  33437. lodash.overSome = overSome;
  33438. lodash.partial = partial;
  33439. lodash.partialRight = partialRight;
  33440. lodash.partition = partition;
  33441. lodash.pick = pick;
  33442. lodash.pickBy = pickBy;
  33443. lodash.property = property;
  33444. lodash.propertyOf = propertyOf;
  33445. lodash.pull = pull;
  33446. lodash.pullAll = pullAll;
  33447. lodash.pullAllBy = pullAllBy;
  33448. lodash.pullAllWith = pullAllWith;
  33449. lodash.pullAt = pullAt;
  33450. lodash.range = range;
  33451. lodash.rangeRight = rangeRight;
  33452. lodash.rearg = rearg;
  33453. lodash.reject = reject;
  33454. lodash.remove = remove;
  33455. lodash.rest = rest;
  33456. lodash.reverse = reverse;
  33457. lodash.sampleSize = sampleSize;
  33458. lodash.set = set;
  33459. lodash.setWith = setWith;
  33460. lodash.shuffle = shuffle;
  33461. lodash.slice = slice;
  33462. lodash.sortBy = sortBy;
  33463. lodash.sortedUniq = sortedUniq;
  33464. lodash.sortedUniqBy = sortedUniqBy;
  33465. lodash.split = split;
  33466. lodash.spread = spread;
  33467. lodash.tail = tail;
  33468. lodash.take = take;
  33469. lodash.takeRight = takeRight;
  33470. lodash.takeRightWhile = takeRightWhile;
  33471. lodash.takeWhile = takeWhile;
  33472. lodash.tap = tap;
  33473. lodash.throttle = throttle;
  33474. lodash.thru = thru;
  33475. lodash.toArray = toArray;
  33476. lodash.toPairs = toPairs;
  33477. lodash.toPairsIn = toPairsIn;
  33478. lodash.toPath = toPath;
  33479. lodash.toPlainObject = toPlainObject;
  33480. lodash.transform = transform;
  33481. lodash.unary = unary;
  33482. lodash.union = union;
  33483. lodash.unionBy = unionBy;
  33484. lodash.unionWith = unionWith;
  33485. lodash.uniq = uniq;
  33486. lodash.uniqBy = uniqBy;
  33487. lodash.uniqWith = uniqWith;
  33488. lodash.unset = unset;
  33489. lodash.unzip = unzip;
  33490. lodash.unzipWith = unzipWith;
  33491. lodash.update = update;
  33492. lodash.updateWith = updateWith;
  33493. lodash.values = values;
  33494. lodash.valuesIn = valuesIn;
  33495. lodash.without = without;
  33496. lodash.words = words;
  33497. lodash.wrap = wrap;
  33498. lodash.xor = xor;
  33499. lodash.xorBy = xorBy;
  33500. lodash.xorWith = xorWith;
  33501. lodash.zip = zip;
  33502. lodash.zipObject = zipObject;
  33503. lodash.zipObjectDeep = zipObjectDeep;
  33504. lodash.zipWith = zipWith;
  33505. // Add aliases.
  33506. lodash.entries = toPairs;
  33507. lodash.entriesIn = toPairsIn;
  33508. lodash.extend = assignIn;
  33509. lodash.extendWith = assignInWith;
  33510. // Add methods to `lodash.prototype`.
  33511. mixin(lodash, lodash);
  33512. /*------------------------------------------------------------------------*/
  33513. // Add methods that return unwrapped values in chain sequences.
  33514. lodash.add = add;
  33515. lodash.attempt = attempt;
  33516. lodash.camelCase = camelCase;
  33517. lodash.capitalize = capitalize;
  33518. lodash.ceil = ceil;
  33519. lodash.clamp = clamp;
  33520. lodash.clone = clone;
  33521. lodash.cloneDeep = cloneDeep;
  33522. lodash.cloneDeepWith = cloneDeepWith;
  33523. lodash.cloneWith = cloneWith;
  33524. lodash.conformsTo = conformsTo;
  33525. lodash.deburr = deburr;
  33526. lodash.defaultTo = defaultTo;
  33527. lodash.divide = divide;
  33528. lodash.endsWith = endsWith;
  33529. lodash.eq = eq;
  33530. lodash.escape = escape;
  33531. lodash.escapeRegExp = escapeRegExp;
  33532. lodash.every = every;
  33533. lodash.find = find;
  33534. lodash.findIndex = findIndex;
  33535. lodash.findKey = findKey;
  33536. lodash.findLast = findLast;
  33537. lodash.findLastIndex = findLastIndex;
  33538. lodash.findLastKey = findLastKey;
  33539. lodash.floor = floor;
  33540. lodash.forEach = forEach;
  33541. lodash.forEachRight = forEachRight;
  33542. lodash.forIn = forIn;
  33543. lodash.forInRight = forInRight;
  33544. lodash.forOwn = forOwn;
  33545. lodash.forOwnRight = forOwnRight;
  33546. lodash.get = get;
  33547. lodash.gt = gt;
  33548. lodash.gte = gte;
  33549. lodash.has = has;
  33550. lodash.hasIn = hasIn;
  33551. lodash.head = head;
  33552. lodash.identity = identity;
  33553. lodash.includes = includes;
  33554. lodash.indexOf = indexOf;
  33555. lodash.inRange = inRange;
  33556. lodash.invoke = invoke;
  33557. lodash.isArguments = isArguments;
  33558. lodash.isArray = isArray;
  33559. lodash.isArrayBuffer = isArrayBuffer;
  33560. lodash.isArrayLike = isArrayLike;
  33561. lodash.isArrayLikeObject = isArrayLikeObject;
  33562. lodash.isBoolean = isBoolean;
  33563. lodash.isBuffer = isBuffer;
  33564. lodash.isDate = isDate;
  33565. lodash.isElement = isElement;
  33566. lodash.isEmpty = isEmpty;
  33567. lodash.isEqual = isEqual;
  33568. lodash.isEqualWith = isEqualWith;
  33569. lodash.isError = isError;
  33570. lodash.isFinite = isFinite;
  33571. lodash.isFunction = isFunction;
  33572. lodash.isInteger = isInteger;
  33573. lodash.isLength = isLength;
  33574. lodash.isMap = isMap;
  33575. lodash.isMatch = isMatch;
  33576. lodash.isMatchWith = isMatchWith;
  33577. lodash.isNaN = isNaN;
  33578. lodash.isNative = isNative;
  33579. lodash.isNil = isNil;
  33580. lodash.isNull = isNull;
  33581. lodash.isNumber = isNumber;
  33582. lodash.isObject = isObject;
  33583. lodash.isObjectLike = isObjectLike;
  33584. lodash.isPlainObject = isPlainObject;
  33585. lodash.isRegExp = isRegExp;
  33586. lodash.isSafeInteger = isSafeInteger;
  33587. lodash.isSet = isSet;
  33588. lodash.isString = isString;
  33589. lodash.isSymbol = isSymbol;
  33590. lodash.isTypedArray = isTypedArray;
  33591. lodash.isUndefined = isUndefined;
  33592. lodash.isWeakMap = isWeakMap;
  33593. lodash.isWeakSet = isWeakSet;
  33594. lodash.join = join;
  33595. lodash.kebabCase = kebabCase;
  33596. lodash.last = last;
  33597. lodash.lastIndexOf = lastIndexOf;
  33598. lodash.lowerCase = lowerCase;
  33599. lodash.lowerFirst = lowerFirst;
  33600. lodash.lt = lt;
  33601. lodash.lte = lte;
  33602. lodash.max = max;
  33603. lodash.maxBy = maxBy;
  33604. lodash.mean = mean;
  33605. lodash.meanBy = meanBy;
  33606. lodash.min = min;
  33607. lodash.minBy = minBy;
  33608. lodash.stubArray = stubArray;
  33609. lodash.stubFalse = stubFalse;
  33610. lodash.stubObject = stubObject;
  33611. lodash.stubString = stubString;
  33612. lodash.stubTrue = stubTrue;
  33613. lodash.multiply = multiply;
  33614. lodash.nth = nth;
  33615. lodash.noConflict = noConflict;
  33616. lodash.noop = noop;
  33617. lodash.now = now;
  33618. lodash.pad = pad;
  33619. lodash.padEnd = padEnd;
  33620. lodash.padStart = padStart;
  33621. lodash.parseInt = parseInt;
  33622. lodash.random = random;
  33623. lodash.reduce = reduce;
  33624. lodash.reduceRight = reduceRight;
  33625. lodash.repeat = repeat;
  33626. lodash.replace = replace;
  33627. lodash.result = result;
  33628. lodash.round = round;
  33629. lodash.runInContext = runInContext;
  33630. lodash.sample = sample;
  33631. lodash.size = size;
  33632. lodash.snakeCase = snakeCase;
  33633. lodash.some = some;
  33634. lodash.sortedIndex = sortedIndex;
  33635. lodash.sortedIndexBy = sortedIndexBy;
  33636. lodash.sortedIndexOf = sortedIndexOf;
  33637. lodash.sortedLastIndex = sortedLastIndex;
  33638. lodash.sortedLastIndexBy = sortedLastIndexBy;
  33639. lodash.sortedLastIndexOf = sortedLastIndexOf;
  33640. lodash.startCase = startCase;
  33641. lodash.startsWith = startsWith;
  33642. lodash.subtract = subtract;
  33643. lodash.sum = sum;
  33644. lodash.sumBy = sumBy;
  33645. lodash.template = template;
  33646. lodash.times = times;
  33647. lodash.toFinite = toFinite;
  33648. lodash.toInteger = toInteger;
  33649. lodash.toLength = toLength;
  33650. lodash.toLower = toLower;
  33651. lodash.toNumber = toNumber;
  33652. lodash.toSafeInteger = toSafeInteger;
  33653. lodash.toString = toString;
  33654. lodash.toUpper = toUpper;
  33655. lodash.trim = trim;
  33656. lodash.trimEnd = trimEnd;
  33657. lodash.trimStart = trimStart;
  33658. lodash.truncate = truncate;
  33659. lodash.unescape = unescape;
  33660. lodash.uniqueId = uniqueId;
  33661. lodash.upperCase = upperCase;
  33662. lodash.upperFirst = upperFirst;
  33663. // Add aliases.
  33664. lodash.each = forEach;
  33665. lodash.eachRight = forEachRight;
  33666. lodash.first = head;
  33667. mixin(lodash, (function() {
  33668. var source = {};
  33669. baseForOwn(lodash, function(func, methodName) {
  33670. if (!hasOwnProperty.call(lodash.prototype, methodName)) {
  33671. source[methodName] = func;
  33672. }
  33673. });
  33674. return source;
  33675. }()), { 'chain': false });
  33676. /*------------------------------------------------------------------------*/
  33677. /**
  33678. * The semantic version number.
  33679. *
  33680. * @static
  33681. * @memberOf _
  33682. * @type {string}
  33683. */
  33684. lodash.VERSION = VERSION;
  33685. // Assign default placeholders.
  33686. arrayEach(['bind', 'bindKey', 'curry', 'curryRight', 'partial', 'partialRight'], function(methodName) {
  33687. lodash[methodName].placeholder = lodash;
  33688. });
  33689. // Add `LazyWrapper` methods for `_.drop` and `_.take` variants.
  33690. arrayEach(['drop', 'take'], function(methodName, index) {
  33691. LazyWrapper.prototype[methodName] = function(n) {
  33692. n = n === undefined ? 1 : nativeMax(toInteger(n), 0);
  33693. var result = (this.__filtered__ && !index)
  33694. ? new LazyWrapper(this)
  33695. : this.clone();
  33696. if (result.__filtered__) {
  33697. result.__takeCount__ = nativeMin(n, result.__takeCount__);
  33698. } else {
  33699. result.__views__.push({
  33700. 'size': nativeMin(n, MAX_ARRAY_LENGTH),
  33701. 'type': methodName + (result.__dir__ < 0 ? 'Right' : '')
  33702. });
  33703. }
  33704. return result;
  33705. };
  33706. LazyWrapper.prototype[methodName + 'Right'] = function(n) {
  33707. return this.reverse()[methodName](n).reverse();
  33708. };
  33709. });
  33710. // Add `LazyWrapper` methods that accept an `iteratee` value.
  33711. arrayEach(['filter', 'map', 'takeWhile'], function(methodName, index) {
  33712. var type = index + 1,
  33713. isFilter = type == LAZY_FILTER_FLAG || type == LAZY_WHILE_FLAG;
  33714. LazyWrapper.prototype[methodName] = function(iteratee) {
  33715. var result = this.clone();
  33716. result.__iteratees__.push({
  33717. 'iteratee': getIteratee(iteratee, 3),
  33718. 'type': type
  33719. });
  33720. result.__filtered__ = result.__filtered__ || isFilter;
  33721. return result;
  33722. };
  33723. });
  33724. // Add `LazyWrapper` methods for `_.head` and `_.last`.
  33725. arrayEach(['head', 'last'], function(methodName, index) {
  33726. var takeName = 'take' + (index ? 'Right' : '');
  33727. LazyWrapper.prototype[methodName] = function() {
  33728. return this[takeName](1).value()[0];
  33729. };
  33730. });
  33731. // Add `LazyWrapper` methods for `_.initial` and `_.tail`.
  33732. arrayEach(['initial', 'tail'], function(methodName, index) {
  33733. var dropName = 'drop' + (index ? '' : 'Right');
  33734. LazyWrapper.prototype[methodName] = function() {
  33735. return this.__filtered__ ? new LazyWrapper(this) : this[dropName](1);
  33736. };
  33737. });
  33738. LazyWrapper.prototype.compact = function() {
  33739. return this.filter(identity);
  33740. };
  33741. LazyWrapper.prototype.find = function(predicate) {
  33742. return this.filter(predicate).head();
  33743. };
  33744. LazyWrapper.prototype.findLast = function(predicate) {
  33745. return this.reverse().find(predicate);
  33746. };
  33747. LazyWrapper.prototype.invokeMap = baseRest(function(path, args) {
  33748. if (typeof path == 'function') {
  33749. return new LazyWrapper(this);
  33750. }
  33751. return this.map(function(value) {
  33752. return baseInvoke(value, path, args);
  33753. });
  33754. });
  33755. LazyWrapper.prototype.reject = function(predicate) {
  33756. return this.filter(negate(getIteratee(predicate)));
  33757. };
  33758. LazyWrapper.prototype.slice = function(start, end) {
  33759. start = toInteger(start);
  33760. var result = this;
  33761. if (result.__filtered__ && (start > 0 || end < 0)) {
  33762. return new LazyWrapper(result);
  33763. }
  33764. if (start < 0) {
  33765. result = result.takeRight(-start);
  33766. } else if (start) {
  33767. result = result.drop(start);
  33768. }
  33769. if (end !== undefined) {
  33770. end = toInteger(end);
  33771. result = end < 0 ? result.dropRight(-end) : result.take(end - start);
  33772. }
  33773. return result;
  33774. };
  33775. LazyWrapper.prototype.takeRightWhile = function(predicate) {
  33776. return this.reverse().takeWhile(predicate).reverse();
  33777. };
  33778. LazyWrapper.prototype.toArray = function() {
  33779. return this.take(MAX_ARRAY_LENGTH);
  33780. };
  33781. // Add `LazyWrapper` methods to `lodash.prototype`.
  33782. baseForOwn(LazyWrapper.prototype, function(func, methodName) {
  33783. var checkIteratee = /^(?:filter|find|map|reject)|While$/.test(methodName),
  33784. isTaker = /^(?:head|last)$/.test(methodName),
  33785. lodashFunc = lodash[isTaker ? ('take' + (methodName == 'last' ? 'Right' : '')) : methodName],
  33786. retUnwrapped = isTaker || /^find/.test(methodName);
  33787. if (!lodashFunc) {
  33788. return;
  33789. }
  33790. lodash.prototype[methodName] = function() {
  33791. var value = this.__wrapped__,
  33792. args = isTaker ? [1] : arguments,
  33793. isLazy = value instanceof LazyWrapper,
  33794. iteratee = args[0],
  33795. useLazy = isLazy || isArray(value);
  33796. var interceptor = function(value) {
  33797. var result = lodashFunc.apply(lodash, arrayPush([value], args));
  33798. return (isTaker && chainAll) ? result[0] : result;
  33799. };
  33800. if (useLazy && checkIteratee && typeof iteratee == 'function' && iteratee.length != 1) {
  33801. // Avoid lazy use if the iteratee has a "length" value other than `1`.
  33802. isLazy = useLazy = false;
  33803. }
  33804. var chainAll = this.__chain__,
  33805. isHybrid = !!this.__actions__.length,
  33806. isUnwrapped = retUnwrapped && !chainAll,
  33807. onlyLazy = isLazy && !isHybrid;
  33808. if (!retUnwrapped && useLazy) {
  33809. value = onlyLazy ? value : new LazyWrapper(this);
  33810. var result = func.apply(value, args);
  33811. result.__actions__.push({ 'func': thru, 'args': [interceptor], 'thisArg': undefined });
  33812. return new LodashWrapper(result, chainAll);
  33813. }
  33814. if (isUnwrapped && onlyLazy) {
  33815. return func.apply(this, args);
  33816. }
  33817. result = this.thru(interceptor);
  33818. return isUnwrapped ? (isTaker ? result.value()[0] : result.value()) : result;
  33819. };
  33820. });
  33821. // Add `Array` methods to `lodash.prototype`.
  33822. arrayEach(['pop', 'push', 'shift', 'sort', 'splice', 'unshift'], function(methodName) {
  33823. var func = arrayProto[methodName],
  33824. chainName = /^(?:push|sort|unshift)$/.test(methodName) ? 'tap' : 'thru',
  33825. retUnwrapped = /^(?:pop|shift)$/.test(methodName);
  33826. lodash.prototype[methodName] = function() {
  33827. var args = arguments;
  33828. if (retUnwrapped && !this.__chain__) {
  33829. var value = this.value();
  33830. return func.apply(isArray(value) ? value : [], args);
  33831. }
  33832. return this[chainName](function(value) {
  33833. return func.apply(isArray(value) ? value : [], args);
  33834. });
  33835. };
  33836. });
  33837. // Map minified method names to their real names.
  33838. baseForOwn(LazyWrapper.prototype, function(func, methodName) {
  33839. var lodashFunc = lodash[methodName];
  33840. if (lodashFunc) {
  33841. var key = lodashFunc.name + '';
  33842. if (!hasOwnProperty.call(realNames, key)) {
  33843. realNames[key] = [];
  33844. }
  33845. realNames[key].push({ 'name': methodName, 'func': lodashFunc });
  33846. }
  33847. });
  33848. realNames[createHybrid(undefined, WRAP_BIND_KEY_FLAG).name] = [{
  33849. 'name': 'wrapper',
  33850. 'func': undefined
  33851. }];
  33852. // Add methods to `LazyWrapper`.
  33853. LazyWrapper.prototype.clone = lazyClone;
  33854. LazyWrapper.prototype.reverse = lazyReverse;
  33855. LazyWrapper.prototype.value = lazyValue;
  33856. // Add chain sequence methods to the `lodash` wrapper.
  33857. lodash.prototype.at = wrapperAt;
  33858. lodash.prototype.chain = wrapperChain;
  33859. lodash.prototype.commit = wrapperCommit;
  33860. lodash.prototype.next = wrapperNext;
  33861. lodash.prototype.plant = wrapperPlant;
  33862. lodash.prototype.reverse = wrapperReverse;
  33863. lodash.prototype.toJSON = lodash.prototype.valueOf = lodash.prototype.value = wrapperValue;
  33864. // Add lazy aliases.
  33865. lodash.prototype.first = lodash.prototype.head;
  33866. if (symIterator) {
  33867. lodash.prototype[symIterator] = wrapperToIterator;
  33868. }
  33869. return lodash;
  33870. });
  33871. /*--------------------------------------------------------------------------*/
  33872. // Export lodash.
  33873. var _ = runInContext();
  33874. // Some AMD build optimizers, like r.js, check for condition patterns like:
  33875. if (true) {
  33876. // Expose Lodash on the global object to prevent errors when Lodash is
  33877. // loaded by a script tag in the presence of an AMD loader.
  33878. // See http://requirejs.org/docs/errors.html#mismatch for more details.
  33879. // Use `_.noConflict` to remove Lodash from the global object.
  33880. root._ = _;
  33881. // Define as an anonymous module so, through path mapping, it can be
  33882. // referenced as the "underscore" module.
  33883. !(__WEBPACK_AMD_DEFINE_RESULT__ = (function() {
  33884. return _;
  33885. }).call(exports, __webpack_require__, exports, module),
  33886. __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
  33887. }
  33888. // Check for `exports` after `define` in case a build optimizer adds it.
  33889. else {}
  33890. }.call(this));
  33891. /* 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)))
  33892. /***/ }),
  33893. /***/ "./node_modules/popper.js/dist/esm/popper.js":
  33894. /*!***************************************************!*\
  33895. !*** ./node_modules/popper.js/dist/esm/popper.js ***!
  33896. \***************************************************/
  33897. /*! exports provided: default */
  33898. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  33899. "use strict";
  33900. __webpack_require__.r(__webpack_exports__);
  33901. /* WEBPACK VAR INJECTION */(function(global) {/**!
  33902. * @fileOverview Kickass library to create and place poppers near their reference elements.
  33903. * @version 1.16.1
  33904. * @license
  33905. * Copyright (c) 2016 Federico Zivolo and contributors
  33906. *
  33907. * Permission is hereby granted, free of charge, to any person obtaining a copy
  33908. * of this software and associated documentation files (the "Software"), to deal
  33909. * in the Software without restriction, including without limitation the rights
  33910. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  33911. * copies of the Software, and to permit persons to whom the Software is
  33912. * furnished to do so, subject to the following conditions:
  33913. *
  33914. * The above copyright notice and this permission notice shall be included in all
  33915. * copies or substantial portions of the Software.
  33916. *
  33917. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  33918. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  33919. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  33920. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  33921. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  33922. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  33923. * SOFTWARE.
  33924. */
  33925. var isBrowser = typeof window !== 'undefined' && typeof document !== 'undefined' && typeof navigator !== 'undefined';
  33926. var timeoutDuration = function () {
  33927. var longerTimeoutBrowsers = ['Edge', 'Trident', 'Firefox'];
  33928. for (var i = 0; i < longerTimeoutBrowsers.length; i += 1) {
  33929. if (isBrowser && navigator.userAgent.indexOf(longerTimeoutBrowsers[i]) >= 0) {
  33930. return 1;
  33931. }
  33932. }
  33933. return 0;
  33934. }();
  33935. function microtaskDebounce(fn) {
  33936. var called = false;
  33937. return function () {
  33938. if (called) {
  33939. return;
  33940. }
  33941. called = true;
  33942. window.Promise.resolve().then(function () {
  33943. called = false;
  33944. fn();
  33945. });
  33946. };
  33947. }
  33948. function taskDebounce(fn) {
  33949. var scheduled = false;
  33950. return function () {
  33951. if (!scheduled) {
  33952. scheduled = true;
  33953. setTimeout(function () {
  33954. scheduled = false;
  33955. fn();
  33956. }, timeoutDuration);
  33957. }
  33958. };
  33959. }
  33960. var supportsMicroTasks = isBrowser && window.Promise;
  33961. /**
  33962. * Create a debounced version of a method, that's asynchronously deferred
  33963. * but called in the minimum time possible.
  33964. *
  33965. * @method
  33966. * @memberof Popper.Utils
  33967. * @argument {Function} fn
  33968. * @returns {Function}
  33969. */
  33970. var debounce = supportsMicroTasks ? microtaskDebounce : taskDebounce;
  33971. /**
  33972. * Check if the given variable is a function
  33973. * @method
  33974. * @memberof Popper.Utils
  33975. * @argument {Any} functionToCheck - variable to check
  33976. * @returns {Boolean} answer to: is a function?
  33977. */
  33978. function isFunction(functionToCheck) {
  33979. var getType = {};
  33980. return functionToCheck && getType.toString.call(functionToCheck) === '[object Function]';
  33981. }
  33982. /**
  33983. * Get CSS computed property of the given element
  33984. * @method
  33985. * @memberof Popper.Utils
  33986. * @argument {Eement} element
  33987. * @argument {String} property
  33988. */
  33989. function getStyleComputedProperty(element, property) {
  33990. if (element.nodeType !== 1) {
  33991. return [];
  33992. }
  33993. // NOTE: 1 DOM access here
  33994. var window = element.ownerDocument.defaultView;
  33995. var css = window.getComputedStyle(element, null);
  33996. return property ? css[property] : css;
  33997. }
  33998. /**
  33999. * Returns the parentNode or the host of the element
  34000. * @method
  34001. * @memberof Popper.Utils
  34002. * @argument {Element} element
  34003. * @returns {Element} parent
  34004. */
  34005. function getParentNode(element) {
  34006. if (element.nodeName === 'HTML') {
  34007. return element;
  34008. }
  34009. return element.parentNode || element.host;
  34010. }
  34011. /**
  34012. * Returns the scrolling parent of the given element
  34013. * @method
  34014. * @memberof Popper.Utils
  34015. * @argument {Element} element
  34016. * @returns {Element} scroll parent
  34017. */
  34018. function getScrollParent(element) {
  34019. // Return body, `getScroll` will take care to get the correct `scrollTop` from it
  34020. if (!element) {
  34021. return document.body;
  34022. }
  34023. switch (element.nodeName) {
  34024. case 'HTML':
  34025. case 'BODY':
  34026. return element.ownerDocument.body;
  34027. case '#document':
  34028. return element.body;
  34029. }
  34030. // Firefox want us to check `-x` and `-y` variations as well
  34031. var _getStyleComputedProp = getStyleComputedProperty(element),
  34032. overflow = _getStyleComputedProp.overflow,
  34033. overflowX = _getStyleComputedProp.overflowX,
  34034. overflowY = _getStyleComputedProp.overflowY;
  34035. if (/(auto|scroll|overlay)/.test(overflow + overflowY + overflowX)) {
  34036. return element;
  34037. }
  34038. return getScrollParent(getParentNode(element));
  34039. }
  34040. /**
  34041. * Returns the reference node of the reference object, or the reference object itself.
  34042. * @method
  34043. * @memberof Popper.Utils
  34044. * @param {Element|Object} reference - the reference element (the popper will be relative to this)
  34045. * @returns {Element} parent
  34046. */
  34047. function getReferenceNode(reference) {
  34048. return reference && reference.referenceNode ? reference.referenceNode : reference;
  34049. }
  34050. var isIE11 = isBrowser && !!(window.MSInputMethodContext && document.documentMode);
  34051. var isIE10 = isBrowser && /MSIE 10/.test(navigator.userAgent);
  34052. /**
  34053. * Determines if the browser is Internet Explorer
  34054. * @method
  34055. * @memberof Popper.Utils
  34056. * @param {Number} version to check
  34057. * @returns {Boolean} isIE
  34058. */
  34059. function isIE(version) {
  34060. if (version === 11) {
  34061. return isIE11;
  34062. }
  34063. if (version === 10) {
  34064. return isIE10;
  34065. }
  34066. return isIE11 || isIE10;
  34067. }
  34068. /**
  34069. * Returns the offset parent of the given element
  34070. * @method
  34071. * @memberof Popper.Utils
  34072. * @argument {Element} element
  34073. * @returns {Element} offset parent
  34074. */
  34075. function getOffsetParent(element) {
  34076. if (!element) {
  34077. return document.documentElement;
  34078. }
  34079. var noOffsetParent = isIE(10) ? document.body : null;
  34080. // NOTE: 1 DOM access here
  34081. var offsetParent = element.offsetParent || null;
  34082. // Skip hidden elements which don't have an offsetParent
  34083. while (offsetParent === noOffsetParent && element.nextElementSibling) {
  34084. offsetParent = (element = element.nextElementSibling).offsetParent;
  34085. }
  34086. var nodeName = offsetParent && offsetParent.nodeName;
  34087. if (!nodeName || nodeName === 'BODY' || nodeName === 'HTML') {
  34088. return element ? element.ownerDocument.documentElement : document.documentElement;
  34089. }
  34090. // .offsetParent will return the closest TH, TD or TABLE in case
  34091. // no offsetParent is present, I hate this job...
  34092. if (['TH', 'TD', 'TABLE'].indexOf(offsetParent.nodeName) !== -1 && getStyleComputedProperty(offsetParent, 'position') === 'static') {
  34093. return getOffsetParent(offsetParent);
  34094. }
  34095. return offsetParent;
  34096. }
  34097. function isOffsetContainer(element) {
  34098. var nodeName = element.nodeName;
  34099. if (nodeName === 'BODY') {
  34100. return false;
  34101. }
  34102. return nodeName === 'HTML' || getOffsetParent(element.firstElementChild) === element;
  34103. }
  34104. /**
  34105. * Finds the root node (document, shadowDOM root) of the given element
  34106. * @method
  34107. * @memberof Popper.Utils
  34108. * @argument {Element} node
  34109. * @returns {Element} root node
  34110. */
  34111. function getRoot(node) {
  34112. if (node.parentNode !== null) {
  34113. return getRoot(node.parentNode);
  34114. }
  34115. return node;
  34116. }
  34117. /**
  34118. * Finds the offset parent common to the two provided nodes
  34119. * @method
  34120. * @memberof Popper.Utils
  34121. * @argument {Element} element1
  34122. * @argument {Element} element2
  34123. * @returns {Element} common offset parent
  34124. */
  34125. function findCommonOffsetParent(element1, element2) {
  34126. // This check is needed to avoid errors in case one of the elements isn't defined for any reason
  34127. if (!element1 || !element1.nodeType || !element2 || !element2.nodeType) {
  34128. return document.documentElement;
  34129. }
  34130. // Here we make sure to give as "start" the element that comes first in the DOM
  34131. var order = element1.compareDocumentPosition(element2) & Node.DOCUMENT_POSITION_FOLLOWING;
  34132. var start = order ? element1 : element2;
  34133. var end = order ? element2 : element1;
  34134. // Get common ancestor container
  34135. var range = document.createRange();
  34136. range.setStart(start, 0);
  34137. range.setEnd(end, 0);
  34138. var commonAncestorContainer = range.commonAncestorContainer;
  34139. // Both nodes are inside #document
  34140. if (element1 !== commonAncestorContainer && element2 !== commonAncestorContainer || start.contains(end)) {
  34141. if (isOffsetContainer(commonAncestorContainer)) {
  34142. return commonAncestorContainer;
  34143. }
  34144. return getOffsetParent(commonAncestorContainer);
  34145. }
  34146. // one of the nodes is inside shadowDOM, find which one
  34147. var element1root = getRoot(element1);
  34148. if (element1root.host) {
  34149. return findCommonOffsetParent(element1root.host, element2);
  34150. } else {
  34151. return findCommonOffsetParent(element1, getRoot(element2).host);
  34152. }
  34153. }
  34154. /**
  34155. * Gets the scroll value of the given element in the given side (top and left)
  34156. * @method
  34157. * @memberof Popper.Utils
  34158. * @argument {Element} element
  34159. * @argument {String} side `top` or `left`
  34160. * @returns {number} amount of scrolled pixels
  34161. */
  34162. function getScroll(element) {
  34163. var side = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'top';
  34164. var upperSide = side === 'top' ? 'scrollTop' : 'scrollLeft';
  34165. var nodeName = element.nodeName;
  34166. if (nodeName === 'BODY' || nodeName === 'HTML') {
  34167. var html = element.ownerDocument.documentElement;
  34168. var scrollingElement = element.ownerDocument.scrollingElement || html;
  34169. return scrollingElement[upperSide];
  34170. }
  34171. return element[upperSide];
  34172. }
  34173. /*
  34174. * Sum or subtract the element scroll values (left and top) from a given rect object
  34175. * @method
  34176. * @memberof Popper.Utils
  34177. * @param {Object} rect - Rect object you want to change
  34178. * @param {HTMLElement} element - The element from the function reads the scroll values
  34179. * @param {Boolean} subtract - set to true if you want to subtract the scroll values
  34180. * @return {Object} rect - The modifier rect object
  34181. */
  34182. function includeScroll(rect, element) {
  34183. var subtract = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  34184. var scrollTop = getScroll(element, 'top');
  34185. var scrollLeft = getScroll(element, 'left');
  34186. var modifier = subtract ? -1 : 1;
  34187. rect.top += scrollTop * modifier;
  34188. rect.bottom += scrollTop * modifier;
  34189. rect.left += scrollLeft * modifier;
  34190. rect.right += scrollLeft * modifier;
  34191. return rect;
  34192. }
  34193. /*
  34194. * Helper to detect borders of a given element
  34195. * @method
  34196. * @memberof Popper.Utils
  34197. * @param {CSSStyleDeclaration} styles
  34198. * Result of `getStyleComputedProperty` on the given element
  34199. * @param {String} axis - `x` or `y`
  34200. * @return {number} borders - The borders size of the given axis
  34201. */
  34202. function getBordersSize(styles, axis) {
  34203. var sideA = axis === 'x' ? 'Left' : 'Top';
  34204. var sideB = sideA === 'Left' ? 'Right' : 'Bottom';
  34205. return parseFloat(styles['border' + sideA + 'Width']) + parseFloat(styles['border' + sideB + 'Width']);
  34206. }
  34207. function getSize(axis, body, html, computedStyle) {
  34208. 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);
  34209. }
  34210. function getWindowSizes(document) {
  34211. var body = document.body;
  34212. var html = document.documentElement;
  34213. var computedStyle = isIE(10) && getComputedStyle(html);
  34214. return {
  34215. height: getSize('Height', body, html, computedStyle),
  34216. width: getSize('Width', body, html, computedStyle)
  34217. };
  34218. }
  34219. var classCallCheck = function (instance, Constructor) {
  34220. if (!(instance instanceof Constructor)) {
  34221. throw new TypeError("Cannot call a class as a function");
  34222. }
  34223. };
  34224. var createClass = function () {
  34225. function defineProperties(target, props) {
  34226. for (var i = 0; i < props.length; i++) {
  34227. var descriptor = props[i];
  34228. descriptor.enumerable = descriptor.enumerable || false;
  34229. descriptor.configurable = true;
  34230. if ("value" in descriptor) descriptor.writable = true;
  34231. Object.defineProperty(target, descriptor.key, descriptor);
  34232. }
  34233. }
  34234. return function (Constructor, protoProps, staticProps) {
  34235. if (protoProps) defineProperties(Constructor.prototype, protoProps);
  34236. if (staticProps) defineProperties(Constructor, staticProps);
  34237. return Constructor;
  34238. };
  34239. }();
  34240. var defineProperty = function (obj, key, value) {
  34241. if (key in obj) {
  34242. Object.defineProperty(obj, key, {
  34243. value: value,
  34244. enumerable: true,
  34245. configurable: true,
  34246. writable: true
  34247. });
  34248. } else {
  34249. obj[key] = value;
  34250. }
  34251. return obj;
  34252. };
  34253. var _extends = Object.assign || function (target) {
  34254. for (var i = 1; i < arguments.length; i++) {
  34255. var source = arguments[i];
  34256. for (var key in source) {
  34257. if (Object.prototype.hasOwnProperty.call(source, key)) {
  34258. target[key] = source[key];
  34259. }
  34260. }
  34261. }
  34262. return target;
  34263. };
  34264. /**
  34265. * Given element offsets, generate an output similar to getBoundingClientRect
  34266. * @method
  34267. * @memberof Popper.Utils
  34268. * @argument {Object} offsets
  34269. * @returns {Object} ClientRect like output
  34270. */
  34271. function getClientRect(offsets) {
  34272. return _extends({}, offsets, {
  34273. right: offsets.left + offsets.width,
  34274. bottom: offsets.top + offsets.height
  34275. });
  34276. }
  34277. /**
  34278. * Get bounding client rect of given element
  34279. * @method
  34280. * @memberof Popper.Utils
  34281. * @param {HTMLElement} element
  34282. * @return {Object} client rect
  34283. */
  34284. function getBoundingClientRect(element) {
  34285. var rect = {};
  34286. // IE10 10 FIX: Please, don't ask, the element isn't
  34287. // considered in DOM in some circumstances...
  34288. // This isn't reproducible in IE10 compatibility mode of IE11
  34289. try {
  34290. if (isIE(10)) {
  34291. rect = element.getBoundingClientRect();
  34292. var scrollTop = getScroll(element, 'top');
  34293. var scrollLeft = getScroll(element, 'left');
  34294. rect.top += scrollTop;
  34295. rect.left += scrollLeft;
  34296. rect.bottom += scrollTop;
  34297. rect.right += scrollLeft;
  34298. } else {
  34299. rect = element.getBoundingClientRect();
  34300. }
  34301. } catch (e) {}
  34302. var result = {
  34303. left: rect.left,
  34304. top: rect.top,
  34305. width: rect.right - rect.left,
  34306. height: rect.bottom - rect.top
  34307. };
  34308. // subtract scrollbar size from sizes
  34309. var sizes = element.nodeName === 'HTML' ? getWindowSizes(element.ownerDocument) : {};
  34310. var width = sizes.width || element.clientWidth || result.width;
  34311. var height = sizes.height || element.clientHeight || result.height;
  34312. var horizScrollbar = element.offsetWidth - width;
  34313. var vertScrollbar = element.offsetHeight - height;
  34314. // if an hypothetical scrollbar is detected, we must be sure it's not a `border`
  34315. // we make this check conditional for performance reasons
  34316. if (horizScrollbar || vertScrollbar) {
  34317. var styles = getStyleComputedProperty(element);
  34318. horizScrollbar -= getBordersSize(styles, 'x');
  34319. vertScrollbar -= getBordersSize(styles, 'y');
  34320. result.width -= horizScrollbar;
  34321. result.height -= vertScrollbar;
  34322. }
  34323. return getClientRect(result);
  34324. }
  34325. function getOffsetRectRelativeToArbitraryNode(children, parent) {
  34326. var fixedPosition = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  34327. var isIE10 = isIE(10);
  34328. var isHTML = parent.nodeName === 'HTML';
  34329. var childrenRect = getBoundingClientRect(children);
  34330. var parentRect = getBoundingClientRect(parent);
  34331. var scrollParent = getScrollParent(children);
  34332. var styles = getStyleComputedProperty(parent);
  34333. var borderTopWidth = parseFloat(styles.borderTopWidth);
  34334. var borderLeftWidth = parseFloat(styles.borderLeftWidth);
  34335. // In cases where the parent is fixed, we must ignore negative scroll in offset calc
  34336. if (fixedPosition && isHTML) {
  34337. parentRect.top = Math.max(parentRect.top, 0);
  34338. parentRect.left = Math.max(parentRect.left, 0);
  34339. }
  34340. var offsets = getClientRect({
  34341. top: childrenRect.top - parentRect.top - borderTopWidth,
  34342. left: childrenRect.left - parentRect.left - borderLeftWidth,
  34343. width: childrenRect.width,
  34344. height: childrenRect.height
  34345. });
  34346. offsets.marginTop = 0;
  34347. offsets.marginLeft = 0;
  34348. // Subtract margins of documentElement in case it's being used as parent
  34349. // we do this only on HTML because it's the only element that behaves
  34350. // differently when margins are applied to it. The margins are included in
  34351. // the box of the documentElement, in the other cases not.
  34352. if (!isIE10 && isHTML) {
  34353. var marginTop = parseFloat(styles.marginTop);
  34354. var marginLeft = parseFloat(styles.marginLeft);
  34355. offsets.top -= borderTopWidth - marginTop;
  34356. offsets.bottom -= borderTopWidth - marginTop;
  34357. offsets.left -= borderLeftWidth - marginLeft;
  34358. offsets.right -= borderLeftWidth - marginLeft;
  34359. // Attach marginTop and marginLeft because in some circumstances we may need them
  34360. offsets.marginTop = marginTop;
  34361. offsets.marginLeft = marginLeft;
  34362. }
  34363. if (isIE10 && !fixedPosition ? parent.contains(scrollParent) : parent === scrollParent && scrollParent.nodeName !== 'BODY') {
  34364. offsets = includeScroll(offsets, parent);
  34365. }
  34366. return offsets;
  34367. }
  34368. function getViewportOffsetRectRelativeToArtbitraryNode(element) {
  34369. var excludeScroll = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  34370. var html = element.ownerDocument.documentElement;
  34371. var relativeOffset = getOffsetRectRelativeToArbitraryNode(element, html);
  34372. var width = Math.max(html.clientWidth, window.innerWidth || 0);
  34373. var height = Math.max(html.clientHeight, window.innerHeight || 0);
  34374. var scrollTop = !excludeScroll ? getScroll(html) : 0;
  34375. var scrollLeft = !excludeScroll ? getScroll(html, 'left') : 0;
  34376. var offset = {
  34377. top: scrollTop - relativeOffset.top + relativeOffset.marginTop,
  34378. left: scrollLeft - relativeOffset.left + relativeOffset.marginLeft,
  34379. width: width,
  34380. height: height
  34381. };
  34382. return getClientRect(offset);
  34383. }
  34384. /**
  34385. * Check if the given element is fixed or is inside a fixed parent
  34386. * @method
  34387. * @memberof Popper.Utils
  34388. * @argument {Element} element
  34389. * @argument {Element} customContainer
  34390. * @returns {Boolean} answer to "isFixed?"
  34391. */
  34392. function isFixed(element) {
  34393. var nodeName = element.nodeName;
  34394. if (nodeName === 'BODY' || nodeName === 'HTML') {
  34395. return false;
  34396. }
  34397. if (getStyleComputedProperty(element, 'position') === 'fixed') {
  34398. return true;
  34399. }
  34400. var parentNode = getParentNode(element);
  34401. if (!parentNode) {
  34402. return false;
  34403. }
  34404. return isFixed(parentNode);
  34405. }
  34406. /**
  34407. * Finds the first parent of an element that has a transformed property defined
  34408. * @method
  34409. * @memberof Popper.Utils
  34410. * @argument {Element} element
  34411. * @returns {Element} first transformed parent or documentElement
  34412. */
  34413. function getFixedPositionOffsetParent(element) {
  34414. // This check is needed to avoid errors in case one of the elements isn't defined for any reason
  34415. if (!element || !element.parentElement || isIE()) {
  34416. return document.documentElement;
  34417. }
  34418. var el = element.parentElement;
  34419. while (el && getStyleComputedProperty(el, 'transform') === 'none') {
  34420. el = el.parentElement;
  34421. }
  34422. return el || document.documentElement;
  34423. }
  34424. /**
  34425. * Computed the boundaries limits and return them
  34426. * @method
  34427. * @memberof Popper.Utils
  34428. * @param {HTMLElement} popper
  34429. * @param {HTMLElement} reference
  34430. * @param {number} padding
  34431. * @param {HTMLElement} boundariesElement - Element used to define the boundaries
  34432. * @param {Boolean} fixedPosition - Is in fixed position mode
  34433. * @returns {Object} Coordinates of the boundaries
  34434. */
  34435. function getBoundaries(popper, reference, padding, boundariesElement) {
  34436. var fixedPosition = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
  34437. // NOTE: 1 DOM access here
  34438. var boundaries = { top: 0, left: 0 };
  34439. var offsetParent = fixedPosition ? getFixedPositionOffsetParent(popper) : findCommonOffsetParent(popper, getReferenceNode(reference));
  34440. // Handle viewport case
  34441. if (boundariesElement === 'viewport') {
  34442. boundaries = getViewportOffsetRectRelativeToArtbitraryNode(offsetParent, fixedPosition);
  34443. } else {
  34444. // Handle other cases based on DOM element used as boundaries
  34445. var boundariesNode = void 0;
  34446. if (boundariesElement === 'scrollParent') {
  34447. boundariesNode = getScrollParent(getParentNode(reference));
  34448. if (boundariesNode.nodeName === 'BODY') {
  34449. boundariesNode = popper.ownerDocument.documentElement;
  34450. }
  34451. } else if (boundariesElement === 'window') {
  34452. boundariesNode = popper.ownerDocument.documentElement;
  34453. } else {
  34454. boundariesNode = boundariesElement;
  34455. }
  34456. var offsets = getOffsetRectRelativeToArbitraryNode(boundariesNode, offsetParent, fixedPosition);
  34457. // In case of HTML, we need a different computation
  34458. if (boundariesNode.nodeName === 'HTML' && !isFixed(offsetParent)) {
  34459. var _getWindowSizes = getWindowSizes(popper.ownerDocument),
  34460. height = _getWindowSizes.height,
  34461. width = _getWindowSizes.width;
  34462. boundaries.top += offsets.top - offsets.marginTop;
  34463. boundaries.bottom = height + offsets.top;
  34464. boundaries.left += offsets.left - offsets.marginLeft;
  34465. boundaries.right = width + offsets.left;
  34466. } else {
  34467. // for all the other DOM elements, this one is good
  34468. boundaries = offsets;
  34469. }
  34470. }
  34471. // Add paddings
  34472. padding = padding || 0;
  34473. var isPaddingNumber = typeof padding === 'number';
  34474. boundaries.left += isPaddingNumber ? padding : padding.left || 0;
  34475. boundaries.top += isPaddingNumber ? padding : padding.top || 0;
  34476. boundaries.right -= isPaddingNumber ? padding : padding.right || 0;
  34477. boundaries.bottom -= isPaddingNumber ? padding : padding.bottom || 0;
  34478. return boundaries;
  34479. }
  34480. function getArea(_ref) {
  34481. var width = _ref.width,
  34482. height = _ref.height;
  34483. return width * height;
  34484. }
  34485. /**
  34486. * Utility used to transform the `auto` placement to the placement with more
  34487. * available space.
  34488. * @method
  34489. * @memberof Popper.Utils
  34490. * @argument {Object} data - The data object generated by update method
  34491. * @argument {Object} options - Modifiers configuration and options
  34492. * @returns {Object} The data object, properly modified
  34493. */
  34494. function computeAutoPlacement(placement, refRect, popper, reference, boundariesElement) {
  34495. var padding = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : 0;
  34496. if (placement.indexOf('auto') === -1) {
  34497. return placement;
  34498. }
  34499. var boundaries = getBoundaries(popper, reference, padding, boundariesElement);
  34500. var rects = {
  34501. top: {
  34502. width: boundaries.width,
  34503. height: refRect.top - boundaries.top
  34504. },
  34505. right: {
  34506. width: boundaries.right - refRect.right,
  34507. height: boundaries.height
  34508. },
  34509. bottom: {
  34510. width: boundaries.width,
  34511. height: boundaries.bottom - refRect.bottom
  34512. },
  34513. left: {
  34514. width: refRect.left - boundaries.left,
  34515. height: boundaries.height
  34516. }
  34517. };
  34518. var sortedAreas = Object.keys(rects).map(function (key) {
  34519. return _extends({
  34520. key: key
  34521. }, rects[key], {
  34522. area: getArea(rects[key])
  34523. });
  34524. }).sort(function (a, b) {
  34525. return b.area - a.area;
  34526. });
  34527. var filteredAreas = sortedAreas.filter(function (_ref2) {
  34528. var width = _ref2.width,
  34529. height = _ref2.height;
  34530. return width >= popper.clientWidth && height >= popper.clientHeight;
  34531. });
  34532. var computedPlacement = filteredAreas.length > 0 ? filteredAreas[0].key : sortedAreas[0].key;
  34533. var variation = placement.split('-')[1];
  34534. return computedPlacement + (variation ? '-' + variation : '');
  34535. }
  34536. /**
  34537. * Get offsets to the reference element
  34538. * @method
  34539. * @memberof Popper.Utils
  34540. * @param {Object} state
  34541. * @param {Element} popper - the popper element
  34542. * @param {Element} reference - the reference element (the popper will be relative to this)
  34543. * @param {Element} fixedPosition - is in fixed position mode
  34544. * @returns {Object} An object containing the offsets which will be applied to the popper
  34545. */
  34546. function getReferenceOffsets(state, popper, reference) {
  34547. var fixedPosition = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
  34548. var commonOffsetParent = fixedPosition ? getFixedPositionOffsetParent(popper) : findCommonOffsetParent(popper, getReferenceNode(reference));
  34549. return getOffsetRectRelativeToArbitraryNode(reference, commonOffsetParent, fixedPosition);
  34550. }
  34551. /**
  34552. * Get the outer sizes of the given element (offset size + margins)
  34553. * @method
  34554. * @memberof Popper.Utils
  34555. * @argument {Element} element
  34556. * @returns {Object} object containing width and height properties
  34557. */
  34558. function getOuterSizes(element) {
  34559. var window = element.ownerDocument.defaultView;
  34560. var styles = window.getComputedStyle(element);
  34561. var x = parseFloat(styles.marginTop || 0) + parseFloat(styles.marginBottom || 0);
  34562. var y = parseFloat(styles.marginLeft || 0) + parseFloat(styles.marginRight || 0);
  34563. var result = {
  34564. width: element.offsetWidth + y,
  34565. height: element.offsetHeight + x
  34566. };
  34567. return result;
  34568. }
  34569. /**
  34570. * Get the opposite placement of the given one
  34571. * @method
  34572. * @memberof Popper.Utils
  34573. * @argument {String} placement
  34574. * @returns {String} flipped placement
  34575. */
  34576. function getOppositePlacement(placement) {
  34577. var hash = { left: 'right', right: 'left', bottom: 'top', top: 'bottom' };
  34578. return placement.replace(/left|right|bottom|top/g, function (matched) {
  34579. return hash[matched];
  34580. });
  34581. }
  34582. /**
  34583. * Get offsets to the popper
  34584. * @method
  34585. * @memberof Popper.Utils
  34586. * @param {Object} position - CSS position the Popper will get applied
  34587. * @param {HTMLElement} popper - the popper element
  34588. * @param {Object} referenceOffsets - the reference offsets (the popper will be relative to this)
  34589. * @param {String} placement - one of the valid placement options
  34590. * @returns {Object} popperOffsets - An object containing the offsets which will be applied to the popper
  34591. */
  34592. function getPopperOffsets(popper, referenceOffsets, placement) {
  34593. placement = placement.split('-')[0];
  34594. // Get popper node sizes
  34595. var popperRect = getOuterSizes(popper);
  34596. // Add position, width and height to our offsets object
  34597. var popperOffsets = {
  34598. width: popperRect.width,
  34599. height: popperRect.height
  34600. };
  34601. // depending by the popper placement we have to compute its offsets slightly differently
  34602. var isHoriz = ['right', 'left'].indexOf(placement) !== -1;
  34603. var mainSide = isHoriz ? 'top' : 'left';
  34604. var secondarySide = isHoriz ? 'left' : 'top';
  34605. var measurement = isHoriz ? 'height' : 'width';
  34606. var secondaryMeasurement = !isHoriz ? 'height' : 'width';
  34607. popperOffsets[mainSide] = referenceOffsets[mainSide] + referenceOffsets[measurement] / 2 - popperRect[measurement] / 2;
  34608. if (placement === secondarySide) {
  34609. popperOffsets[secondarySide] = referenceOffsets[secondarySide] - popperRect[secondaryMeasurement];
  34610. } else {
  34611. popperOffsets[secondarySide] = referenceOffsets[getOppositePlacement(secondarySide)];
  34612. }
  34613. return popperOffsets;
  34614. }
  34615. /**
  34616. * Mimics the `find` method of Array
  34617. * @method
  34618. * @memberof Popper.Utils
  34619. * @argument {Array} arr
  34620. * @argument prop
  34621. * @argument value
  34622. * @returns index or -1
  34623. */
  34624. function find(arr, check) {
  34625. // use native find if supported
  34626. if (Array.prototype.find) {
  34627. return arr.find(check);
  34628. }
  34629. // use `filter` to obtain the same behavior of `find`
  34630. return arr.filter(check)[0];
  34631. }
  34632. /**
  34633. * Return the index of the matching object
  34634. * @method
  34635. * @memberof Popper.Utils
  34636. * @argument {Array} arr
  34637. * @argument prop
  34638. * @argument value
  34639. * @returns index or -1
  34640. */
  34641. function findIndex(arr, prop, value) {
  34642. // use native findIndex if supported
  34643. if (Array.prototype.findIndex) {
  34644. return arr.findIndex(function (cur) {
  34645. return cur[prop] === value;
  34646. });
  34647. }
  34648. // use `find` + `indexOf` if `findIndex` isn't supported
  34649. var match = find(arr, function (obj) {
  34650. return obj[prop] === value;
  34651. });
  34652. return arr.indexOf(match);
  34653. }
  34654. /**
  34655. * Loop trough the list of modifiers and run them in order,
  34656. * each of them will then edit the data object.
  34657. * @method
  34658. * @memberof Popper.Utils
  34659. * @param {dataObject} data
  34660. * @param {Array} modifiers
  34661. * @param {String} ends - Optional modifier name used as stopper
  34662. * @returns {dataObject}
  34663. */
  34664. function runModifiers(modifiers, data, ends) {
  34665. var modifiersToRun = ends === undefined ? modifiers : modifiers.slice(0, findIndex(modifiers, 'name', ends));
  34666. modifiersToRun.forEach(function (modifier) {
  34667. if (modifier['function']) {
  34668. // eslint-disable-line dot-notation
  34669. console.warn('`modifier.function` is deprecated, use `modifier.fn`!');
  34670. }
  34671. var fn = modifier['function'] || modifier.fn; // eslint-disable-line dot-notation
  34672. if (modifier.enabled && isFunction(fn)) {
  34673. // Add properties to offsets to make them a complete clientRect object
  34674. // we do this before each modifier to make sure the previous one doesn't
  34675. // mess with these values
  34676. data.offsets.popper = getClientRect(data.offsets.popper);
  34677. data.offsets.reference = getClientRect(data.offsets.reference);
  34678. data = fn(data, modifier);
  34679. }
  34680. });
  34681. return data;
  34682. }
  34683. /**
  34684. * Updates the position of the popper, computing the new offsets and applying
  34685. * the new style.<br />
  34686. * Prefer `scheduleUpdate` over `update` because of performance reasons.
  34687. * @method
  34688. * @memberof Popper
  34689. */
  34690. function update() {
  34691. // if popper is destroyed, don't perform any further update
  34692. if (this.state.isDestroyed) {
  34693. return;
  34694. }
  34695. var data = {
  34696. instance: this,
  34697. styles: {},
  34698. arrowStyles: {},
  34699. attributes: {},
  34700. flipped: false,
  34701. offsets: {}
  34702. };
  34703. // compute reference element offsets
  34704. data.offsets.reference = getReferenceOffsets(this.state, this.popper, this.reference, this.options.positionFixed);
  34705. // compute auto placement, store placement inside the data object,
  34706. // modifiers will be able to edit `placement` if needed
  34707. // and refer to originalPlacement to know the original value
  34708. data.placement = computeAutoPlacement(this.options.placement, data.offsets.reference, this.popper, this.reference, this.options.modifiers.flip.boundariesElement, this.options.modifiers.flip.padding);
  34709. // store the computed placement inside `originalPlacement`
  34710. data.originalPlacement = data.placement;
  34711. data.positionFixed = this.options.positionFixed;
  34712. // compute the popper offsets
  34713. data.offsets.popper = getPopperOffsets(this.popper, data.offsets.reference, data.placement);
  34714. data.offsets.popper.position = this.options.positionFixed ? 'fixed' : 'absolute';
  34715. // run the modifiers
  34716. data = runModifiers(this.modifiers, data);
  34717. // the first `update` will call `onCreate` callback
  34718. // the other ones will call `onUpdate` callback
  34719. if (!this.state.isCreated) {
  34720. this.state.isCreated = true;
  34721. this.options.onCreate(data);
  34722. } else {
  34723. this.options.onUpdate(data);
  34724. }
  34725. }
  34726. /**
  34727. * Helper used to know if the given modifier is enabled.
  34728. * @method
  34729. * @memberof Popper.Utils
  34730. * @returns {Boolean}
  34731. */
  34732. function isModifierEnabled(modifiers, modifierName) {
  34733. return modifiers.some(function (_ref) {
  34734. var name = _ref.name,
  34735. enabled = _ref.enabled;
  34736. return enabled && name === modifierName;
  34737. });
  34738. }
  34739. /**
  34740. * Get the prefixed supported property name
  34741. * @method
  34742. * @memberof Popper.Utils
  34743. * @argument {String} property (camelCase)
  34744. * @returns {String} prefixed property (camelCase or PascalCase, depending on the vendor prefix)
  34745. */
  34746. function getSupportedPropertyName(property) {
  34747. var prefixes = [false, 'ms', 'Webkit', 'Moz', 'O'];
  34748. var upperProp = property.charAt(0).toUpperCase() + property.slice(1);
  34749. for (var i = 0; i < prefixes.length; i++) {
  34750. var prefix = prefixes[i];
  34751. var toCheck = prefix ? '' + prefix + upperProp : property;
  34752. if (typeof document.body.style[toCheck] !== 'undefined') {
  34753. return toCheck;
  34754. }
  34755. }
  34756. return null;
  34757. }
  34758. /**
  34759. * Destroys the popper.
  34760. * @method
  34761. * @memberof Popper
  34762. */
  34763. function destroy() {
  34764. this.state.isDestroyed = true;
  34765. // touch DOM only if `applyStyle` modifier is enabled
  34766. if (isModifierEnabled(this.modifiers, 'applyStyle')) {
  34767. this.popper.removeAttribute('x-placement');
  34768. this.popper.style.position = '';
  34769. this.popper.style.top = '';
  34770. this.popper.style.left = '';
  34771. this.popper.style.right = '';
  34772. this.popper.style.bottom = '';
  34773. this.popper.style.willChange = '';
  34774. this.popper.style[getSupportedPropertyName('transform')] = '';
  34775. }
  34776. this.disableEventListeners();
  34777. // remove the popper if user explicitly asked for the deletion on destroy
  34778. // do not use `remove` because IE11 doesn't support it
  34779. if (this.options.removeOnDestroy) {
  34780. this.popper.parentNode.removeChild(this.popper);
  34781. }
  34782. return this;
  34783. }
  34784. /**
  34785. * Get the window associated with the element
  34786. * @argument {Element} element
  34787. * @returns {Window}
  34788. */
  34789. function getWindow(element) {
  34790. var ownerDocument = element.ownerDocument;
  34791. return ownerDocument ? ownerDocument.defaultView : window;
  34792. }
  34793. function attachToScrollParents(scrollParent, event, callback, scrollParents) {
  34794. var isBody = scrollParent.nodeName === 'BODY';
  34795. var target = isBody ? scrollParent.ownerDocument.defaultView : scrollParent;
  34796. target.addEventListener(event, callback, { passive: true });
  34797. if (!isBody) {
  34798. attachToScrollParents(getScrollParent(target.parentNode), event, callback, scrollParents);
  34799. }
  34800. scrollParents.push(target);
  34801. }
  34802. /**
  34803. * Setup needed event listeners used to update the popper position
  34804. * @method
  34805. * @memberof Popper.Utils
  34806. * @private
  34807. */
  34808. function setupEventListeners(reference, options, state, updateBound) {
  34809. // Resize event listener on window
  34810. state.updateBound = updateBound;
  34811. getWindow(reference).addEventListener('resize', state.updateBound, { passive: true });
  34812. // Scroll event listener on scroll parents
  34813. var scrollElement = getScrollParent(reference);
  34814. attachToScrollParents(scrollElement, 'scroll', state.updateBound, state.scrollParents);
  34815. state.scrollElement = scrollElement;
  34816. state.eventsEnabled = true;
  34817. return state;
  34818. }
  34819. /**
  34820. * It will add resize/scroll events and start recalculating
  34821. * position of the popper element when they are triggered.
  34822. * @method
  34823. * @memberof Popper
  34824. */
  34825. function enableEventListeners() {
  34826. if (!this.state.eventsEnabled) {
  34827. this.state = setupEventListeners(this.reference, this.options, this.state, this.scheduleUpdate);
  34828. }
  34829. }
  34830. /**
  34831. * Remove event listeners used to update the popper position
  34832. * @method
  34833. * @memberof Popper.Utils
  34834. * @private
  34835. */
  34836. function removeEventListeners(reference, state) {
  34837. // Remove resize event listener on window
  34838. getWindow(reference).removeEventListener('resize', state.updateBound);
  34839. // Remove scroll event listener on scroll parents
  34840. state.scrollParents.forEach(function (target) {
  34841. target.removeEventListener('scroll', state.updateBound);
  34842. });
  34843. // Reset state
  34844. state.updateBound = null;
  34845. state.scrollParents = [];
  34846. state.scrollElement = null;
  34847. state.eventsEnabled = false;
  34848. return state;
  34849. }
  34850. /**
  34851. * It will remove resize/scroll events and won't recalculate popper position
  34852. * when they are triggered. It also won't trigger `onUpdate` callback anymore,
  34853. * unless you call `update` method manually.
  34854. * @method
  34855. * @memberof Popper
  34856. */
  34857. function disableEventListeners() {
  34858. if (this.state.eventsEnabled) {
  34859. cancelAnimationFrame(this.scheduleUpdate);
  34860. this.state = removeEventListeners(this.reference, this.state);
  34861. }
  34862. }
  34863. /**
  34864. * Tells if a given input is a number
  34865. * @method
  34866. * @memberof Popper.Utils
  34867. * @param {*} input to check
  34868. * @return {Boolean}
  34869. */
  34870. function isNumeric(n) {
  34871. return n !== '' && !isNaN(parseFloat(n)) && isFinite(n);
  34872. }
  34873. /**
  34874. * Set the style to the given popper
  34875. * @method
  34876. * @memberof Popper.Utils
  34877. * @argument {Element} element - Element to apply the style to
  34878. * @argument {Object} styles
  34879. * Object with a list of properties and values which will be applied to the element
  34880. */
  34881. function setStyles(element, styles) {
  34882. Object.keys(styles).forEach(function (prop) {
  34883. var unit = '';
  34884. // add unit if the value is numeric and is one of the following
  34885. if (['width', 'height', 'top', 'right', 'bottom', 'left'].indexOf(prop) !== -1 && isNumeric(styles[prop])) {
  34886. unit = 'px';
  34887. }
  34888. element.style[prop] = styles[prop] + unit;
  34889. });
  34890. }
  34891. /**
  34892. * Set the attributes to the given popper
  34893. * @method
  34894. * @memberof Popper.Utils
  34895. * @argument {Element} element - Element to apply the attributes to
  34896. * @argument {Object} styles
  34897. * Object with a list of properties and values which will be applied to the element
  34898. */
  34899. function setAttributes(element, attributes) {
  34900. Object.keys(attributes).forEach(function (prop) {
  34901. var value = attributes[prop];
  34902. if (value !== false) {
  34903. element.setAttribute(prop, attributes[prop]);
  34904. } else {
  34905. element.removeAttribute(prop);
  34906. }
  34907. });
  34908. }
  34909. /**
  34910. * @function
  34911. * @memberof Modifiers
  34912. * @argument {Object} data - The data object generated by `update` method
  34913. * @argument {Object} data.styles - List of style properties - values to apply to popper element
  34914. * @argument {Object} data.attributes - List of attribute properties - values to apply to popper element
  34915. * @argument {Object} options - Modifiers configuration and options
  34916. * @returns {Object} The same data object
  34917. */
  34918. function applyStyle(data) {
  34919. // any property present in `data.styles` will be applied to the popper,
  34920. // in this way we can make the 3rd party modifiers add custom styles to it
  34921. // Be aware, modifiers could override the properties defined in the previous
  34922. // lines of this modifier!
  34923. setStyles(data.instance.popper, data.styles);
  34924. // any property present in `data.attributes` will be applied to the popper,
  34925. // they will be set as HTML attributes of the element
  34926. setAttributes(data.instance.popper, data.attributes);
  34927. // if arrowElement is defined and arrowStyles has some properties
  34928. if (data.arrowElement && Object.keys(data.arrowStyles).length) {
  34929. setStyles(data.arrowElement, data.arrowStyles);
  34930. }
  34931. return data;
  34932. }
  34933. /**
  34934. * Set the x-placement attribute before everything else because it could be used
  34935. * to add margins to the popper margins needs to be calculated to get the
  34936. * correct popper offsets.
  34937. * @method
  34938. * @memberof Popper.modifiers
  34939. * @param {HTMLElement} reference - The reference element used to position the popper
  34940. * @param {HTMLElement} popper - The HTML element used as popper
  34941. * @param {Object} options - Popper.js options
  34942. */
  34943. function applyStyleOnLoad(reference, popper, options, modifierOptions, state) {
  34944. // compute reference element offsets
  34945. var referenceOffsets = getReferenceOffsets(state, popper, reference, options.positionFixed);
  34946. // compute auto placement, store placement inside the data object,
  34947. // modifiers will be able to edit `placement` if needed
  34948. // and refer to originalPlacement to know the original value
  34949. var placement = computeAutoPlacement(options.placement, referenceOffsets, popper, reference, options.modifiers.flip.boundariesElement, options.modifiers.flip.padding);
  34950. popper.setAttribute('x-placement', placement);
  34951. // Apply `position` to popper before anything else because
  34952. // without the position applied we can't guarantee correct computations
  34953. setStyles(popper, { position: options.positionFixed ? 'fixed' : 'absolute' });
  34954. return options;
  34955. }
  34956. /**
  34957. * @function
  34958. * @memberof Popper.Utils
  34959. * @argument {Object} data - The data object generated by `update` method
  34960. * @argument {Boolean} shouldRound - If the offsets should be rounded at all
  34961. * @returns {Object} The popper's position offsets rounded
  34962. *
  34963. * The tale of pixel-perfect positioning. It's still not 100% perfect, but as
  34964. * good as it can be within reason.
  34965. * Discussion here: https://github.com/FezVrasta/popper.js/pull/715
  34966. *
  34967. * Low DPI screens cause a popper to be blurry if not using full pixels (Safari
  34968. * as well on High DPI screens).
  34969. *
  34970. * Firefox prefers no rounding for positioning and does not have blurriness on
  34971. * high DPI screens.
  34972. *
  34973. * Only horizontal placement and left/right values need to be considered.
  34974. */
  34975. function getRoundedOffsets(data, shouldRound) {
  34976. var _data$offsets = data.offsets,
  34977. popper = _data$offsets.popper,
  34978. reference = _data$offsets.reference;
  34979. var round = Math.round,
  34980. floor = Math.floor;
  34981. var noRound = function noRound(v) {
  34982. return v;
  34983. };
  34984. var referenceWidth = round(reference.width);
  34985. var popperWidth = round(popper.width);
  34986. var isVertical = ['left', 'right'].indexOf(data.placement) !== -1;
  34987. var isVariation = data.placement.indexOf('-') !== -1;
  34988. var sameWidthParity = referenceWidth % 2 === popperWidth % 2;
  34989. var bothOddWidth = referenceWidth % 2 === 1 && popperWidth % 2 === 1;
  34990. var horizontalToInteger = !shouldRound ? noRound : isVertical || isVariation || sameWidthParity ? round : floor;
  34991. var verticalToInteger = !shouldRound ? noRound : round;
  34992. return {
  34993. left: horizontalToInteger(bothOddWidth && !isVariation && shouldRound ? popper.left - 1 : popper.left),
  34994. top: verticalToInteger(popper.top),
  34995. bottom: verticalToInteger(popper.bottom),
  34996. right: horizontalToInteger(popper.right)
  34997. };
  34998. }
  34999. var isFirefox = isBrowser && /Firefox/i.test(navigator.userAgent);
  35000. /**
  35001. * @function
  35002. * @memberof Modifiers
  35003. * @argument {Object} data - The data object generated by `update` method
  35004. * @argument {Object} options - Modifiers configuration and options
  35005. * @returns {Object} The data object, properly modified
  35006. */
  35007. function computeStyle(data, options) {
  35008. var x = options.x,
  35009. y = options.y;
  35010. var popper = data.offsets.popper;
  35011. // Remove this legacy support in Popper.js v2
  35012. var legacyGpuAccelerationOption = find(data.instance.modifiers, function (modifier) {
  35013. return modifier.name === 'applyStyle';
  35014. }).gpuAcceleration;
  35015. if (legacyGpuAccelerationOption !== undefined) {
  35016. console.warn('WARNING: `gpuAcceleration` option moved to `computeStyle` modifier and will not be supported in future versions of Popper.js!');
  35017. }
  35018. var gpuAcceleration = legacyGpuAccelerationOption !== undefined ? legacyGpuAccelerationOption : options.gpuAcceleration;
  35019. var offsetParent = getOffsetParent(data.instance.popper);
  35020. var offsetParentRect = getBoundingClientRect(offsetParent);
  35021. // Styles
  35022. var styles = {
  35023. position: popper.position
  35024. };
  35025. var offsets = getRoundedOffsets(data, window.devicePixelRatio < 2 || !isFirefox);
  35026. var sideA = x === 'bottom' ? 'top' : 'bottom';
  35027. var sideB = y === 'right' ? 'left' : 'right';
  35028. // if gpuAcceleration is set to `true` and transform is supported,
  35029. // we use `translate3d` to apply the position to the popper we
  35030. // automatically use the supported prefixed version if needed
  35031. var prefixedProperty = getSupportedPropertyName('transform');
  35032. // now, let's make a step back and look at this code closely (wtf?)
  35033. // If the content of the popper grows once it's been positioned, it
  35034. // may happen that the popper gets misplaced because of the new content
  35035. // overflowing its reference element
  35036. // To avoid this problem, we provide two options (x and y), which allow
  35037. // the consumer to define the offset origin.
  35038. // If we position a popper on top of a reference element, we can set
  35039. // `x` to `top` to make the popper grow towards its top instead of
  35040. // its bottom.
  35041. var left = void 0,
  35042. top = void 0;
  35043. if (sideA === 'bottom') {
  35044. // when offsetParent is <html> the positioning is relative to the bottom of the screen (excluding the scrollbar)
  35045. // and not the bottom of the html element
  35046. if (offsetParent.nodeName === 'HTML') {
  35047. top = -offsetParent.clientHeight + offsets.bottom;
  35048. } else {
  35049. top = -offsetParentRect.height + offsets.bottom;
  35050. }
  35051. } else {
  35052. top = offsets.top;
  35053. }
  35054. if (sideB === 'right') {
  35055. if (offsetParent.nodeName === 'HTML') {
  35056. left = -offsetParent.clientWidth + offsets.right;
  35057. } else {
  35058. left = -offsetParentRect.width + offsets.right;
  35059. }
  35060. } else {
  35061. left = offsets.left;
  35062. }
  35063. if (gpuAcceleration && prefixedProperty) {
  35064. styles[prefixedProperty] = 'translate3d(' + left + 'px, ' + top + 'px, 0)';
  35065. styles[sideA] = 0;
  35066. styles[sideB] = 0;
  35067. styles.willChange = 'transform';
  35068. } else {
  35069. // othwerise, we use the standard `top`, `left`, `bottom` and `right` properties
  35070. var invertTop = sideA === 'bottom' ? -1 : 1;
  35071. var invertLeft = sideB === 'right' ? -1 : 1;
  35072. styles[sideA] = top * invertTop;
  35073. styles[sideB] = left * invertLeft;
  35074. styles.willChange = sideA + ', ' + sideB;
  35075. }
  35076. // Attributes
  35077. var attributes = {
  35078. 'x-placement': data.placement
  35079. };
  35080. // Update `data` attributes, styles and arrowStyles
  35081. data.attributes = _extends({}, attributes, data.attributes);
  35082. data.styles = _extends({}, styles, data.styles);
  35083. data.arrowStyles = _extends({}, data.offsets.arrow, data.arrowStyles);
  35084. return data;
  35085. }
  35086. /**
  35087. * Helper used to know if the given modifier depends from another one.<br />
  35088. * It checks if the needed modifier is listed and enabled.
  35089. * @method
  35090. * @memberof Popper.Utils
  35091. * @param {Array} modifiers - list of modifiers
  35092. * @param {String} requestingName - name of requesting modifier
  35093. * @param {String} requestedName - name of requested modifier
  35094. * @returns {Boolean}
  35095. */
  35096. function isModifierRequired(modifiers, requestingName, requestedName) {
  35097. var requesting = find(modifiers, function (_ref) {
  35098. var name = _ref.name;
  35099. return name === requestingName;
  35100. });
  35101. var isRequired = !!requesting && modifiers.some(function (modifier) {
  35102. return modifier.name === requestedName && modifier.enabled && modifier.order < requesting.order;
  35103. });
  35104. if (!isRequired) {
  35105. var _requesting = '`' + requestingName + '`';
  35106. var requested = '`' + requestedName + '`';
  35107. console.warn(requested + ' modifier is required by ' + _requesting + ' modifier in order to work, be sure to include it before ' + _requesting + '!');
  35108. }
  35109. return isRequired;
  35110. }
  35111. /**
  35112. * @function
  35113. * @memberof Modifiers
  35114. * @argument {Object} data - The data object generated by update method
  35115. * @argument {Object} options - Modifiers configuration and options
  35116. * @returns {Object} The data object, properly modified
  35117. */
  35118. function arrow(data, options) {
  35119. var _data$offsets$arrow;
  35120. // arrow depends on keepTogether in order to work
  35121. if (!isModifierRequired(data.instance.modifiers, 'arrow', 'keepTogether')) {
  35122. return data;
  35123. }
  35124. var arrowElement = options.element;
  35125. // if arrowElement is a string, suppose it's a CSS selector
  35126. if (typeof arrowElement === 'string') {
  35127. arrowElement = data.instance.popper.querySelector(arrowElement);
  35128. // if arrowElement is not found, don't run the modifier
  35129. if (!arrowElement) {
  35130. return data;
  35131. }
  35132. } else {
  35133. // if the arrowElement isn't a query selector we must check that the
  35134. // provided DOM node is child of its popper node
  35135. if (!data.instance.popper.contains(arrowElement)) {
  35136. console.warn('WARNING: `arrow.element` must be child of its popper element!');
  35137. return data;
  35138. }
  35139. }
  35140. var placement = data.placement.split('-')[0];
  35141. var _data$offsets = data.offsets,
  35142. popper = _data$offsets.popper,
  35143. reference = _data$offsets.reference;
  35144. var isVertical = ['left', 'right'].indexOf(placement) !== -1;
  35145. var len = isVertical ? 'height' : 'width';
  35146. var sideCapitalized = isVertical ? 'Top' : 'Left';
  35147. var side = sideCapitalized.toLowerCase();
  35148. var altSide = isVertical ? 'left' : 'top';
  35149. var opSide = isVertical ? 'bottom' : 'right';
  35150. var arrowElementSize = getOuterSizes(arrowElement)[len];
  35151. //
  35152. // extends keepTogether behavior making sure the popper and its
  35153. // reference have enough pixels in conjunction
  35154. //
  35155. // top/left side
  35156. if (reference[opSide] - arrowElementSize < popper[side]) {
  35157. data.offsets.popper[side] -= popper[side] - (reference[opSide] - arrowElementSize);
  35158. }
  35159. // bottom/right side
  35160. if (reference[side] + arrowElementSize > popper[opSide]) {
  35161. data.offsets.popper[side] += reference[side] + arrowElementSize - popper[opSide];
  35162. }
  35163. data.offsets.popper = getClientRect(data.offsets.popper);
  35164. // compute center of the popper
  35165. var center = reference[side] + reference[len] / 2 - arrowElementSize / 2;
  35166. // Compute the sideValue using the updated popper offsets
  35167. // take popper margin in account because we don't have this info available
  35168. var css = getStyleComputedProperty(data.instance.popper);
  35169. var popperMarginSide = parseFloat(css['margin' + sideCapitalized]);
  35170. var popperBorderSide = parseFloat(css['border' + sideCapitalized + 'Width']);
  35171. var sideValue = center - data.offsets.popper[side] - popperMarginSide - popperBorderSide;
  35172. // prevent arrowElement from being placed not contiguously to its popper
  35173. sideValue = Math.max(Math.min(popper[len] - arrowElementSize, sideValue), 0);
  35174. data.arrowElement = arrowElement;
  35175. data.offsets.arrow = (_data$offsets$arrow = {}, defineProperty(_data$offsets$arrow, side, Math.round(sideValue)), defineProperty(_data$offsets$arrow, altSide, ''), _data$offsets$arrow);
  35176. return data;
  35177. }
  35178. /**
  35179. * Get the opposite placement variation of the given one
  35180. * @method
  35181. * @memberof Popper.Utils
  35182. * @argument {String} placement variation
  35183. * @returns {String} flipped placement variation
  35184. */
  35185. function getOppositeVariation(variation) {
  35186. if (variation === 'end') {
  35187. return 'start';
  35188. } else if (variation === 'start') {
  35189. return 'end';
  35190. }
  35191. return variation;
  35192. }
  35193. /**
  35194. * List of accepted placements to use as values of the `placement` option.<br />
  35195. * Valid placements are:
  35196. * - `auto`
  35197. * - `top`
  35198. * - `right`
  35199. * - `bottom`
  35200. * - `left`
  35201. *
  35202. * Each placement can have a variation from this list:
  35203. * - `-start`
  35204. * - `-end`
  35205. *
  35206. * Variations are interpreted easily if you think of them as the left to right
  35207. * written languages. Horizontally (`top` and `bottom`), `start` is left and `end`
  35208. * is right.<br />
  35209. * Vertically (`left` and `right`), `start` is top and `end` is bottom.
  35210. *
  35211. * Some valid examples are:
  35212. * - `top-end` (on top of reference, right aligned)
  35213. * - `right-start` (on right of reference, top aligned)
  35214. * - `bottom` (on bottom, centered)
  35215. * - `auto-end` (on the side with more space available, alignment depends by placement)
  35216. *
  35217. * @static
  35218. * @type {Array}
  35219. * @enum {String}
  35220. * @readonly
  35221. * @method placements
  35222. * @memberof Popper
  35223. */
  35224. 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'];
  35225. // Get rid of `auto` `auto-start` and `auto-end`
  35226. var validPlacements = placements.slice(3);
  35227. /**
  35228. * Given an initial placement, returns all the subsequent placements
  35229. * clockwise (or counter-clockwise).
  35230. *
  35231. * @method
  35232. * @memberof Popper.Utils
  35233. * @argument {String} placement - A valid placement (it accepts variations)
  35234. * @argument {Boolean} counter - Set to true to walk the placements counterclockwise
  35235. * @returns {Array} placements including their variations
  35236. */
  35237. function clockwise(placement) {
  35238. var counter = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  35239. var index = validPlacements.indexOf(placement);
  35240. var arr = validPlacements.slice(index + 1).concat(validPlacements.slice(0, index));
  35241. return counter ? arr.reverse() : arr;
  35242. }
  35243. var BEHAVIORS = {
  35244. FLIP: 'flip',
  35245. CLOCKWISE: 'clockwise',
  35246. COUNTERCLOCKWISE: 'counterclockwise'
  35247. };
  35248. /**
  35249. * @function
  35250. * @memberof Modifiers
  35251. * @argument {Object} data - The data object generated by update method
  35252. * @argument {Object} options - Modifiers configuration and options
  35253. * @returns {Object} The data object, properly modified
  35254. */
  35255. function flip(data, options) {
  35256. // if `inner` modifier is enabled, we can't use the `flip` modifier
  35257. if (isModifierEnabled(data.instance.modifiers, 'inner')) {
  35258. return data;
  35259. }
  35260. if (data.flipped && data.placement === data.originalPlacement) {
  35261. // seems like flip is trying to loop, probably there's not enough space on any of the flippable sides
  35262. return data;
  35263. }
  35264. var boundaries = getBoundaries(data.instance.popper, data.instance.reference, options.padding, options.boundariesElement, data.positionFixed);
  35265. var placement = data.placement.split('-')[0];
  35266. var placementOpposite = getOppositePlacement(placement);
  35267. var variation = data.placement.split('-')[1] || '';
  35268. var flipOrder = [];
  35269. switch (options.behavior) {
  35270. case BEHAVIORS.FLIP:
  35271. flipOrder = [placement, placementOpposite];
  35272. break;
  35273. case BEHAVIORS.CLOCKWISE:
  35274. flipOrder = clockwise(placement);
  35275. break;
  35276. case BEHAVIORS.COUNTERCLOCKWISE:
  35277. flipOrder = clockwise(placement, true);
  35278. break;
  35279. default:
  35280. flipOrder = options.behavior;
  35281. }
  35282. flipOrder.forEach(function (step, index) {
  35283. if (placement !== step || flipOrder.length === index + 1) {
  35284. return data;
  35285. }
  35286. placement = data.placement.split('-')[0];
  35287. placementOpposite = getOppositePlacement(placement);
  35288. var popperOffsets = data.offsets.popper;
  35289. var refOffsets = data.offsets.reference;
  35290. // using floor because the reference offsets may contain decimals we are not going to consider here
  35291. var floor = Math.floor;
  35292. 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);
  35293. var overflowsLeft = floor(popperOffsets.left) < floor(boundaries.left);
  35294. var overflowsRight = floor(popperOffsets.right) > floor(boundaries.right);
  35295. var overflowsTop = floor(popperOffsets.top) < floor(boundaries.top);
  35296. var overflowsBottom = floor(popperOffsets.bottom) > floor(boundaries.bottom);
  35297. var overflowsBoundaries = placement === 'left' && overflowsLeft || placement === 'right' && overflowsRight || placement === 'top' && overflowsTop || placement === 'bottom' && overflowsBottom;
  35298. // flip the variation if required
  35299. var isVertical = ['top', 'bottom'].indexOf(placement) !== -1;
  35300. // flips variation if reference element overflows boundaries
  35301. var flippedVariationByRef = !!options.flipVariations && (isVertical && variation === 'start' && overflowsLeft || isVertical && variation === 'end' && overflowsRight || !isVertical && variation === 'start' && overflowsTop || !isVertical && variation === 'end' && overflowsBottom);
  35302. // flips variation if popper content overflows boundaries
  35303. var flippedVariationByContent = !!options.flipVariationsByContent && (isVertical && variation === 'start' && overflowsRight || isVertical && variation === 'end' && overflowsLeft || !isVertical && variation === 'start' && overflowsBottom || !isVertical && variation === 'end' && overflowsTop);
  35304. var flippedVariation = flippedVariationByRef || flippedVariationByContent;
  35305. if (overlapsRef || overflowsBoundaries || flippedVariation) {
  35306. // this boolean to detect any flip loop
  35307. data.flipped = true;
  35308. if (overlapsRef || overflowsBoundaries) {
  35309. placement = flipOrder[index + 1];
  35310. }
  35311. if (flippedVariation) {
  35312. variation = getOppositeVariation(variation);
  35313. }
  35314. data.placement = placement + (variation ? '-' + variation : '');
  35315. // this object contains `position`, we want to preserve it along with
  35316. // any additional property we may add in the future
  35317. data.offsets.popper = _extends({}, data.offsets.popper, getPopperOffsets(data.instance.popper, data.offsets.reference, data.placement));
  35318. data = runModifiers(data.instance.modifiers, data, 'flip');
  35319. }
  35320. });
  35321. return data;
  35322. }
  35323. /**
  35324. * @function
  35325. * @memberof Modifiers
  35326. * @argument {Object} data - The data object generated by update method
  35327. * @argument {Object} options - Modifiers configuration and options
  35328. * @returns {Object} The data object, properly modified
  35329. */
  35330. function keepTogether(data) {
  35331. var _data$offsets = data.offsets,
  35332. popper = _data$offsets.popper,
  35333. reference = _data$offsets.reference;
  35334. var placement = data.placement.split('-')[0];
  35335. var floor = Math.floor;
  35336. var isVertical = ['top', 'bottom'].indexOf(placement) !== -1;
  35337. var side = isVertical ? 'right' : 'bottom';
  35338. var opSide = isVertical ? 'left' : 'top';
  35339. var measurement = isVertical ? 'width' : 'height';
  35340. if (popper[side] < floor(reference[opSide])) {
  35341. data.offsets.popper[opSide] = floor(reference[opSide]) - popper[measurement];
  35342. }
  35343. if (popper[opSide] > floor(reference[side])) {
  35344. data.offsets.popper[opSide] = floor(reference[side]);
  35345. }
  35346. return data;
  35347. }
  35348. /**
  35349. * Converts a string containing value + unit into a px value number
  35350. * @function
  35351. * @memberof {modifiers~offset}
  35352. * @private
  35353. * @argument {String} str - Value + unit string
  35354. * @argument {String} measurement - `height` or `width`
  35355. * @argument {Object} popperOffsets
  35356. * @argument {Object} referenceOffsets
  35357. * @returns {Number|String}
  35358. * Value in pixels, or original string if no values were extracted
  35359. */
  35360. function toValue(str, measurement, popperOffsets, referenceOffsets) {
  35361. // separate value from unit
  35362. var split = str.match(/((?:\-|\+)?\d*\.?\d*)(.*)/);
  35363. var value = +split[1];
  35364. var unit = split[2];
  35365. // If it's not a number it's an operator, I guess
  35366. if (!value) {
  35367. return str;
  35368. }
  35369. if (unit.indexOf('%') === 0) {
  35370. var element = void 0;
  35371. switch (unit) {
  35372. case '%p':
  35373. element = popperOffsets;
  35374. break;
  35375. case '%':
  35376. case '%r':
  35377. default:
  35378. element = referenceOffsets;
  35379. }
  35380. var rect = getClientRect(element);
  35381. return rect[measurement] / 100 * value;
  35382. } else if (unit === 'vh' || unit === 'vw') {
  35383. // if is a vh or vw, we calculate the size based on the viewport
  35384. var size = void 0;
  35385. if (unit === 'vh') {
  35386. size = Math.max(document.documentElement.clientHeight, window.innerHeight || 0);
  35387. } else {
  35388. size = Math.max(document.documentElement.clientWidth, window.innerWidth || 0);
  35389. }
  35390. return size / 100 * value;
  35391. } else {
  35392. // if is an explicit pixel unit, we get rid of the unit and keep the value
  35393. // if is an implicit unit, it's px, and we return just the value
  35394. return value;
  35395. }
  35396. }
  35397. /**
  35398. * Parse an `offset` string to extrapolate `x` and `y` numeric offsets.
  35399. * @function
  35400. * @memberof {modifiers~offset}
  35401. * @private
  35402. * @argument {String} offset
  35403. * @argument {Object} popperOffsets
  35404. * @argument {Object} referenceOffsets
  35405. * @argument {String} basePlacement
  35406. * @returns {Array} a two cells array with x and y offsets in numbers
  35407. */
  35408. function parseOffset(offset, popperOffsets, referenceOffsets, basePlacement) {
  35409. var offsets = [0, 0];
  35410. // Use height if placement is left or right and index is 0 otherwise use width
  35411. // in this way the first offset will use an axis and the second one
  35412. // will use the other one
  35413. var useHeight = ['right', 'left'].indexOf(basePlacement) !== -1;
  35414. // Split the offset string to obtain a list of values and operands
  35415. // The regex addresses values with the plus or minus sign in front (+10, -20, etc)
  35416. var fragments = offset.split(/(\+|\-)/).map(function (frag) {
  35417. return frag.trim();
  35418. });
  35419. // Detect if the offset string contains a pair of values or a single one
  35420. // they could be separated by comma or space
  35421. var divider = fragments.indexOf(find(fragments, function (frag) {
  35422. return frag.search(/,|\s/) !== -1;
  35423. }));
  35424. if (fragments[divider] && fragments[divider].indexOf(',') === -1) {
  35425. console.warn('Offsets separated by white space(s) are deprecated, use a comma (,) instead.');
  35426. }
  35427. // If divider is found, we divide the list of values and operands to divide
  35428. // them by ofset X and Y.
  35429. var splitRegex = /\s*,\s*|\s+/;
  35430. 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];
  35431. // Convert the values with units to absolute pixels to allow our computations
  35432. ops = ops.map(function (op, index) {
  35433. // Most of the units rely on the orientation of the popper
  35434. var measurement = (index === 1 ? !useHeight : useHeight) ? 'height' : 'width';
  35435. var mergeWithPrevious = false;
  35436. return op
  35437. // This aggregates any `+` or `-` sign that aren't considered operators
  35438. // e.g.: 10 + +5 => [10, +, +5]
  35439. .reduce(function (a, b) {
  35440. if (a[a.length - 1] === '' && ['+', '-'].indexOf(b) !== -1) {
  35441. a[a.length - 1] = b;
  35442. mergeWithPrevious = true;
  35443. return a;
  35444. } else if (mergeWithPrevious) {
  35445. a[a.length - 1] += b;
  35446. mergeWithPrevious = false;
  35447. return a;
  35448. } else {
  35449. return a.concat(b);
  35450. }
  35451. }, [])
  35452. // Here we convert the string values into number values (in px)
  35453. .map(function (str) {
  35454. return toValue(str, measurement, popperOffsets, referenceOffsets);
  35455. });
  35456. });
  35457. // Loop trough the offsets arrays and execute the operations
  35458. ops.forEach(function (op, index) {
  35459. op.forEach(function (frag, index2) {
  35460. if (isNumeric(frag)) {
  35461. offsets[index] += frag * (op[index2 - 1] === '-' ? -1 : 1);
  35462. }
  35463. });
  35464. });
  35465. return offsets;
  35466. }
  35467. /**
  35468. * @function
  35469. * @memberof Modifiers
  35470. * @argument {Object} data - The data object generated by update method
  35471. * @argument {Object} options - Modifiers configuration and options
  35472. * @argument {Number|String} options.offset=0
  35473. * The offset value as described in the modifier description
  35474. * @returns {Object} The data object, properly modified
  35475. */
  35476. function offset(data, _ref) {
  35477. var offset = _ref.offset;
  35478. var placement = data.placement,
  35479. _data$offsets = data.offsets,
  35480. popper = _data$offsets.popper,
  35481. reference = _data$offsets.reference;
  35482. var basePlacement = placement.split('-')[0];
  35483. var offsets = void 0;
  35484. if (isNumeric(+offset)) {
  35485. offsets = [+offset, 0];
  35486. } else {
  35487. offsets = parseOffset(offset, popper, reference, basePlacement);
  35488. }
  35489. if (basePlacement === 'left') {
  35490. popper.top += offsets[0];
  35491. popper.left -= offsets[1];
  35492. } else if (basePlacement === 'right') {
  35493. popper.top += offsets[0];
  35494. popper.left += offsets[1];
  35495. } else if (basePlacement === 'top') {
  35496. popper.left += offsets[0];
  35497. popper.top -= offsets[1];
  35498. } else if (basePlacement === 'bottom') {
  35499. popper.left += offsets[0];
  35500. popper.top += offsets[1];
  35501. }
  35502. data.popper = popper;
  35503. return data;
  35504. }
  35505. /**
  35506. * @function
  35507. * @memberof Modifiers
  35508. * @argument {Object} data - The data object generated by `update` method
  35509. * @argument {Object} options - Modifiers configuration and options
  35510. * @returns {Object} The data object, properly modified
  35511. */
  35512. function preventOverflow(data, options) {
  35513. var boundariesElement = options.boundariesElement || getOffsetParent(data.instance.popper);
  35514. // If offsetParent is the reference element, we really want to
  35515. // go one step up and use the next offsetParent as reference to
  35516. // avoid to make this modifier completely useless and look like broken
  35517. if (data.instance.reference === boundariesElement) {
  35518. boundariesElement = getOffsetParent(boundariesElement);
  35519. }
  35520. // NOTE: DOM access here
  35521. // resets the popper's position so that the document size can be calculated excluding
  35522. // the size of the popper element itself
  35523. var transformProp = getSupportedPropertyName('transform');
  35524. var popperStyles = data.instance.popper.style; // assignment to help minification
  35525. var top = popperStyles.top,
  35526. left = popperStyles.left,
  35527. transform = popperStyles[transformProp];
  35528. popperStyles.top = '';
  35529. popperStyles.left = '';
  35530. popperStyles[transformProp] = '';
  35531. var boundaries = getBoundaries(data.instance.popper, data.instance.reference, options.padding, boundariesElement, data.positionFixed);
  35532. // NOTE: DOM access here
  35533. // restores the original style properties after the offsets have been computed
  35534. popperStyles.top = top;
  35535. popperStyles.left = left;
  35536. popperStyles[transformProp] = transform;
  35537. options.boundaries = boundaries;
  35538. var order = options.priority;
  35539. var popper = data.offsets.popper;
  35540. var check = {
  35541. primary: function primary(placement) {
  35542. var value = popper[placement];
  35543. if (popper[placement] < boundaries[placement] && !options.escapeWithReference) {
  35544. value = Math.max(popper[placement], boundaries[placement]);
  35545. }
  35546. return defineProperty({}, placement, value);
  35547. },
  35548. secondary: function secondary(placement) {
  35549. var mainSide = placement === 'right' ? 'left' : 'top';
  35550. var value = popper[mainSide];
  35551. if (popper[placement] > boundaries[placement] && !options.escapeWithReference) {
  35552. value = Math.min(popper[mainSide], boundaries[placement] - (placement === 'right' ? popper.width : popper.height));
  35553. }
  35554. return defineProperty({}, mainSide, value);
  35555. }
  35556. };
  35557. order.forEach(function (placement) {
  35558. var side = ['left', 'top'].indexOf(placement) !== -1 ? 'primary' : 'secondary';
  35559. popper = _extends({}, popper, check[side](placement));
  35560. });
  35561. data.offsets.popper = popper;
  35562. return data;
  35563. }
  35564. /**
  35565. * @function
  35566. * @memberof Modifiers
  35567. * @argument {Object} data - The data object generated by `update` method
  35568. * @argument {Object} options - Modifiers configuration and options
  35569. * @returns {Object} The data object, properly modified
  35570. */
  35571. function shift(data) {
  35572. var placement = data.placement;
  35573. var basePlacement = placement.split('-')[0];
  35574. var shiftvariation = placement.split('-')[1];
  35575. // if shift shiftvariation is specified, run the modifier
  35576. if (shiftvariation) {
  35577. var _data$offsets = data.offsets,
  35578. reference = _data$offsets.reference,
  35579. popper = _data$offsets.popper;
  35580. var isVertical = ['bottom', 'top'].indexOf(basePlacement) !== -1;
  35581. var side = isVertical ? 'left' : 'top';
  35582. var measurement = isVertical ? 'width' : 'height';
  35583. var shiftOffsets = {
  35584. start: defineProperty({}, side, reference[side]),
  35585. end: defineProperty({}, side, reference[side] + reference[measurement] - popper[measurement])
  35586. };
  35587. data.offsets.popper = _extends({}, popper, shiftOffsets[shiftvariation]);
  35588. }
  35589. return data;
  35590. }
  35591. /**
  35592. * @function
  35593. * @memberof Modifiers
  35594. * @argument {Object} data - The data object generated by update method
  35595. * @argument {Object} options - Modifiers configuration and options
  35596. * @returns {Object} The data object, properly modified
  35597. */
  35598. function hide(data) {
  35599. if (!isModifierRequired(data.instance.modifiers, 'hide', 'preventOverflow')) {
  35600. return data;
  35601. }
  35602. var refRect = data.offsets.reference;
  35603. var bound = find(data.instance.modifiers, function (modifier) {
  35604. return modifier.name === 'preventOverflow';
  35605. }).boundaries;
  35606. if (refRect.bottom < bound.top || refRect.left > bound.right || refRect.top > bound.bottom || refRect.right < bound.left) {
  35607. // Avoid unnecessary DOM access if visibility hasn't changed
  35608. if (data.hide === true) {
  35609. return data;
  35610. }
  35611. data.hide = true;
  35612. data.attributes['x-out-of-boundaries'] = '';
  35613. } else {
  35614. // Avoid unnecessary DOM access if visibility hasn't changed
  35615. if (data.hide === false) {
  35616. return data;
  35617. }
  35618. data.hide = false;
  35619. data.attributes['x-out-of-boundaries'] = false;
  35620. }
  35621. return data;
  35622. }
  35623. /**
  35624. * @function
  35625. * @memberof Modifiers
  35626. * @argument {Object} data - The data object generated by `update` method
  35627. * @argument {Object} options - Modifiers configuration and options
  35628. * @returns {Object} The data object, properly modified
  35629. */
  35630. function inner(data) {
  35631. var placement = data.placement;
  35632. var basePlacement = placement.split('-')[0];
  35633. var _data$offsets = data.offsets,
  35634. popper = _data$offsets.popper,
  35635. reference = _data$offsets.reference;
  35636. var isHoriz = ['left', 'right'].indexOf(basePlacement) !== -1;
  35637. var subtractLength = ['top', 'left'].indexOf(basePlacement) === -1;
  35638. popper[isHoriz ? 'left' : 'top'] = reference[basePlacement] - (subtractLength ? popper[isHoriz ? 'width' : 'height'] : 0);
  35639. data.placement = getOppositePlacement(placement);
  35640. data.offsets.popper = getClientRect(popper);
  35641. return data;
  35642. }
  35643. /**
  35644. * Modifier function, each modifier can have a function of this type assigned
  35645. * to its `fn` property.<br />
  35646. * These functions will be called on each update, this means that you must
  35647. * make sure they are performant enough to avoid performance bottlenecks.
  35648. *
  35649. * @function ModifierFn
  35650. * @argument {dataObject} data - The data object generated by `update` method
  35651. * @argument {Object} options - Modifiers configuration and options
  35652. * @returns {dataObject} The data object, properly modified
  35653. */
  35654. /**
  35655. * Modifiers are plugins used to alter the behavior of your poppers.<br />
  35656. * Popper.js uses a set of 9 modifiers to provide all the basic functionalities
  35657. * needed by the library.
  35658. *
  35659. * Usually you don't want to override the `order`, `fn` and `onLoad` props.
  35660. * All the other properties are configurations that could be tweaked.
  35661. * @namespace modifiers
  35662. */
  35663. var modifiers = {
  35664. /**
  35665. * Modifier used to shift the popper on the start or end of its reference
  35666. * element.<br />
  35667. * It will read the variation of the `placement` property.<br />
  35668. * It can be one either `-end` or `-start`.
  35669. * @memberof modifiers
  35670. * @inner
  35671. */
  35672. shift: {
  35673. /** @prop {number} order=100 - Index used to define the order of execution */
  35674. order: 100,
  35675. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  35676. enabled: true,
  35677. /** @prop {ModifierFn} */
  35678. fn: shift
  35679. },
  35680. /**
  35681. * The `offset` modifier can shift your popper on both its axis.
  35682. *
  35683. * It accepts the following units:
  35684. * - `px` or unit-less, interpreted as pixels
  35685. * - `%` or `%r`, percentage relative to the length of the reference element
  35686. * - `%p`, percentage relative to the length of the popper element
  35687. * - `vw`, CSS viewport width unit
  35688. * - `vh`, CSS viewport height unit
  35689. *
  35690. * For length is intended the main axis relative to the placement of the popper.<br />
  35691. * This means that if the placement is `top` or `bottom`, the length will be the
  35692. * `width`. In case of `left` or `right`, it will be the `height`.
  35693. *
  35694. * You can provide a single value (as `Number` or `String`), or a pair of values
  35695. * as `String` divided by a comma or one (or more) white spaces.<br />
  35696. * The latter is a deprecated method because it leads to confusion and will be
  35697. * removed in v2.<br />
  35698. * Additionally, it accepts additions and subtractions between different units.
  35699. * Note that multiplications and divisions aren't supported.
  35700. *
  35701. * Valid examples are:
  35702. * ```
  35703. * 10
  35704. * '10%'
  35705. * '10, 10'
  35706. * '10%, 10'
  35707. * '10 + 10%'
  35708. * '10 - 5vh + 3%'
  35709. * '-10px + 5vh, 5px - 6%'
  35710. * ```
  35711. * > **NB**: If you desire to apply offsets to your poppers in a way that may make them overlap
  35712. * > with their reference element, unfortunately, you will have to disable the `flip` modifier.
  35713. * > You can read more on this at this [issue](https://github.com/FezVrasta/popper.js/issues/373).
  35714. *
  35715. * @memberof modifiers
  35716. * @inner
  35717. */
  35718. offset: {
  35719. /** @prop {number} order=200 - Index used to define the order of execution */
  35720. order: 200,
  35721. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  35722. enabled: true,
  35723. /** @prop {ModifierFn} */
  35724. fn: offset,
  35725. /** @prop {Number|String} offset=0
  35726. * The offset value as described in the modifier description
  35727. */
  35728. offset: 0
  35729. },
  35730. /**
  35731. * Modifier used to prevent the popper from being positioned outside the boundary.
  35732. *
  35733. * A scenario exists where the reference itself is not within the boundaries.<br />
  35734. * We can say it has "escaped the boundaries" — or just "escaped".<br />
  35735. * In this case we need to decide whether the popper should either:
  35736. *
  35737. * - detach from the reference and remain "trapped" in the boundaries, or
  35738. * - if it should ignore the boundary and "escape with its reference"
  35739. *
  35740. * When `escapeWithReference` is set to`true` and reference is completely
  35741. * outside its boundaries, the popper will overflow (or completely leave)
  35742. * the boundaries in order to remain attached to the edge of the reference.
  35743. *
  35744. * @memberof modifiers
  35745. * @inner
  35746. */
  35747. preventOverflow: {
  35748. /** @prop {number} order=300 - Index used to define the order of execution */
  35749. order: 300,
  35750. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  35751. enabled: true,
  35752. /** @prop {ModifierFn} */
  35753. fn: preventOverflow,
  35754. /**
  35755. * @prop {Array} [priority=['left','right','top','bottom']]
  35756. * Popper will try to prevent overflow following these priorities by default,
  35757. * then, it could overflow on the left and on top of the `boundariesElement`
  35758. */
  35759. priority: ['left', 'right', 'top', 'bottom'],
  35760. /**
  35761. * @prop {number} padding=5
  35762. * Amount of pixel used to define a minimum distance between the boundaries
  35763. * and the popper. This makes sure the popper always has a little padding
  35764. * between the edges of its container
  35765. */
  35766. padding: 5,
  35767. /**
  35768. * @prop {String|HTMLElement} boundariesElement='scrollParent'
  35769. * Boundaries used by the modifier. Can be `scrollParent`, `window`,
  35770. * `viewport` or any DOM element.
  35771. */
  35772. boundariesElement: 'scrollParent'
  35773. },
  35774. /**
  35775. * Modifier used to make sure the reference and its popper stay near each other
  35776. * without leaving any gap between the two. Especially useful when the arrow is
  35777. * enabled and you want to ensure that it points to its reference element.
  35778. * It cares only about the first axis. You can still have poppers with margin
  35779. * between the popper and its reference element.
  35780. * @memberof modifiers
  35781. * @inner
  35782. */
  35783. keepTogether: {
  35784. /** @prop {number} order=400 - Index used to define the order of execution */
  35785. order: 400,
  35786. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  35787. enabled: true,
  35788. /** @prop {ModifierFn} */
  35789. fn: keepTogether
  35790. },
  35791. /**
  35792. * This modifier is used to move the `arrowElement` of the popper to make
  35793. * sure it is positioned between the reference element and its popper element.
  35794. * It will read the outer size of the `arrowElement` node to detect how many
  35795. * pixels of conjunction are needed.
  35796. *
  35797. * It has no effect if no `arrowElement` is provided.
  35798. * @memberof modifiers
  35799. * @inner
  35800. */
  35801. arrow: {
  35802. /** @prop {number} order=500 - Index used to define the order of execution */
  35803. order: 500,
  35804. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  35805. enabled: true,
  35806. /** @prop {ModifierFn} */
  35807. fn: arrow,
  35808. /** @prop {String|HTMLElement} element='[x-arrow]' - Selector or node used as arrow */
  35809. element: '[x-arrow]'
  35810. },
  35811. /**
  35812. * Modifier used to flip the popper's placement when it starts to overlap its
  35813. * reference element.
  35814. *
  35815. * Requires the `preventOverflow` modifier before it in order to work.
  35816. *
  35817. * **NOTE:** this modifier will interrupt the current update cycle and will
  35818. * restart it if it detects the need to flip the placement.
  35819. * @memberof modifiers
  35820. * @inner
  35821. */
  35822. flip: {
  35823. /** @prop {number} order=600 - Index used to define the order of execution */
  35824. order: 600,
  35825. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  35826. enabled: true,
  35827. /** @prop {ModifierFn} */
  35828. fn: flip,
  35829. /**
  35830. * @prop {String|Array} behavior='flip'
  35831. * The behavior used to change the popper's placement. It can be one of
  35832. * `flip`, `clockwise`, `counterclockwise` or an array with a list of valid
  35833. * placements (with optional variations)
  35834. */
  35835. behavior: 'flip',
  35836. /**
  35837. * @prop {number} padding=5
  35838. * The popper will flip if it hits the edges of the `boundariesElement`
  35839. */
  35840. padding: 5,
  35841. /**
  35842. * @prop {String|HTMLElement} boundariesElement='viewport'
  35843. * The element which will define the boundaries of the popper position.
  35844. * The popper will never be placed outside of the defined boundaries
  35845. * (except if `keepTogether` is enabled)
  35846. */
  35847. boundariesElement: 'viewport',
  35848. /**
  35849. * @prop {Boolean} flipVariations=false
  35850. * The popper will switch placement variation between `-start` and `-end` when
  35851. * the reference element overlaps its boundaries.
  35852. *
  35853. * The original placement should have a set variation.
  35854. */
  35855. flipVariations: false,
  35856. /**
  35857. * @prop {Boolean} flipVariationsByContent=false
  35858. * The popper will switch placement variation between `-start` and `-end` when
  35859. * the popper element overlaps its reference boundaries.
  35860. *
  35861. * The original placement should have a set variation.
  35862. */
  35863. flipVariationsByContent: false
  35864. },
  35865. /**
  35866. * Modifier used to make the popper flow toward the inner of the reference element.
  35867. * By default, when this modifier is disabled, the popper will be placed outside
  35868. * the reference element.
  35869. * @memberof modifiers
  35870. * @inner
  35871. */
  35872. inner: {
  35873. /** @prop {number} order=700 - Index used to define the order of execution */
  35874. order: 700,
  35875. /** @prop {Boolean} enabled=false - Whether the modifier is enabled or not */
  35876. enabled: false,
  35877. /** @prop {ModifierFn} */
  35878. fn: inner
  35879. },
  35880. /**
  35881. * Modifier used to hide the popper when its reference element is outside of the
  35882. * popper boundaries. It will set a `x-out-of-boundaries` attribute which can
  35883. * be used to hide with a CSS selector the popper when its reference is
  35884. * out of boundaries.
  35885. *
  35886. * Requires the `preventOverflow` modifier before it in order to work.
  35887. * @memberof modifiers
  35888. * @inner
  35889. */
  35890. hide: {
  35891. /** @prop {number} order=800 - Index used to define the order of execution */
  35892. order: 800,
  35893. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  35894. enabled: true,
  35895. /** @prop {ModifierFn} */
  35896. fn: hide
  35897. },
  35898. /**
  35899. * Computes the style that will be applied to the popper element to gets
  35900. * properly positioned.
  35901. *
  35902. * Note that this modifier will not touch the DOM, it just prepares the styles
  35903. * so that `applyStyle` modifier can apply it. This separation is useful
  35904. * in case you need to replace `applyStyle` with a custom implementation.
  35905. *
  35906. * This modifier has `850` as `order` value to maintain backward compatibility
  35907. * with previous versions of Popper.js. Expect the modifiers ordering method
  35908. * to change in future major versions of the library.
  35909. *
  35910. * @memberof modifiers
  35911. * @inner
  35912. */
  35913. computeStyle: {
  35914. /** @prop {number} order=850 - Index used to define the order of execution */
  35915. order: 850,
  35916. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  35917. enabled: true,
  35918. /** @prop {ModifierFn} */
  35919. fn: computeStyle,
  35920. /**
  35921. * @prop {Boolean} gpuAcceleration=true
  35922. * If true, it uses the CSS 3D transformation to position the popper.
  35923. * Otherwise, it will use the `top` and `left` properties
  35924. */
  35925. gpuAcceleration: true,
  35926. /**
  35927. * @prop {string} [x='bottom']
  35928. * Where to anchor the X axis (`bottom` or `top`). AKA X offset origin.
  35929. * Change this if your popper should grow in a direction different from `bottom`
  35930. */
  35931. x: 'bottom',
  35932. /**
  35933. * @prop {string} [x='left']
  35934. * Where to anchor the Y axis (`left` or `right`). AKA Y offset origin.
  35935. * Change this if your popper should grow in a direction different from `right`
  35936. */
  35937. y: 'right'
  35938. },
  35939. /**
  35940. * Applies the computed styles to the popper element.
  35941. *
  35942. * All the DOM manipulations are limited to this modifier. This is useful in case
  35943. * you want to integrate Popper.js inside a framework or view library and you
  35944. * want to delegate all the DOM manipulations to it.
  35945. *
  35946. * Note that if you disable this modifier, you must make sure the popper element
  35947. * has its position set to `absolute` before Popper.js can do its work!
  35948. *
  35949. * Just disable this modifier and define your own to achieve the desired effect.
  35950. *
  35951. * @memberof modifiers
  35952. * @inner
  35953. */
  35954. applyStyle: {
  35955. /** @prop {number} order=900 - Index used to define the order of execution */
  35956. order: 900,
  35957. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  35958. enabled: true,
  35959. /** @prop {ModifierFn} */
  35960. fn: applyStyle,
  35961. /** @prop {Function} */
  35962. onLoad: applyStyleOnLoad,
  35963. /**
  35964. * @deprecated since version 1.10.0, the property moved to `computeStyle` modifier
  35965. * @prop {Boolean} gpuAcceleration=true
  35966. * If true, it uses the CSS 3D transformation to position the popper.
  35967. * Otherwise, it will use the `top` and `left` properties
  35968. */
  35969. gpuAcceleration: undefined
  35970. }
  35971. };
  35972. /**
  35973. * The `dataObject` is an object containing all the information used by Popper.js.
  35974. * This object is passed to modifiers and to the `onCreate` and `onUpdate` callbacks.
  35975. * @name dataObject
  35976. * @property {Object} data.instance The Popper.js instance
  35977. * @property {String} data.placement Placement applied to popper
  35978. * @property {String} data.originalPlacement Placement originally defined on init
  35979. * @property {Boolean} data.flipped True if popper has been flipped by flip modifier
  35980. * @property {Boolean} data.hide True if the reference element is out of boundaries, useful to know when to hide the popper
  35981. * @property {HTMLElement} data.arrowElement Node used as arrow by arrow modifier
  35982. * @property {Object} data.styles Any CSS property defined here will be applied to the popper. It expects the JavaScript nomenclature (eg. `marginBottom`)
  35983. * @property {Object} data.arrowStyles Any CSS property defined here will be applied to the popper arrow. It expects the JavaScript nomenclature (eg. `marginBottom`)
  35984. * @property {Object} data.boundaries Offsets of the popper boundaries
  35985. * @property {Object} data.offsets The measurements of popper, reference and arrow elements
  35986. * @property {Object} data.offsets.popper `top`, `left`, `width`, `height` values
  35987. * @property {Object} data.offsets.reference `top`, `left`, `width`, `height` values
  35988. * @property {Object} data.offsets.arrow] `top` and `left` offsets, only one of them will be different from 0
  35989. */
  35990. /**
  35991. * Default options provided to Popper.js constructor.<br />
  35992. * These can be overridden using the `options` argument of Popper.js.<br />
  35993. * To override an option, simply pass an object with the same
  35994. * structure of the `options` object, as the 3rd argument. For example:
  35995. * ```
  35996. * new Popper(ref, pop, {
  35997. * modifiers: {
  35998. * preventOverflow: { enabled: false }
  35999. * }
  36000. * })
  36001. * ```
  36002. * @type {Object}
  36003. * @static
  36004. * @memberof Popper
  36005. */
  36006. var Defaults = {
  36007. /**
  36008. * Popper's placement.
  36009. * @prop {Popper.placements} placement='bottom'
  36010. */
  36011. placement: 'bottom',
  36012. /**
  36013. * Set this to true if you want popper to position it self in 'fixed' mode
  36014. * @prop {Boolean} positionFixed=false
  36015. */
  36016. positionFixed: false,
  36017. /**
  36018. * Whether events (resize, scroll) are initially enabled.
  36019. * @prop {Boolean} eventsEnabled=true
  36020. */
  36021. eventsEnabled: true,
  36022. /**
  36023. * Set to true if you want to automatically remove the popper when
  36024. * you call the `destroy` method.
  36025. * @prop {Boolean} removeOnDestroy=false
  36026. */
  36027. removeOnDestroy: false,
  36028. /**
  36029. * Callback called when the popper is created.<br />
  36030. * By default, it is set to no-op.<br />
  36031. * Access Popper.js instance with `data.instance`.
  36032. * @prop {onCreate}
  36033. */
  36034. onCreate: function onCreate() {},
  36035. /**
  36036. * Callback called when the popper is updated. This callback is not called
  36037. * on the initialization/creation of the popper, but only on subsequent
  36038. * updates.<br />
  36039. * By default, it is set to no-op.<br />
  36040. * Access Popper.js instance with `data.instance`.
  36041. * @prop {onUpdate}
  36042. */
  36043. onUpdate: function onUpdate() {},
  36044. /**
  36045. * List of modifiers used to modify the offsets before they are applied to the popper.
  36046. * They provide most of the functionalities of Popper.js.
  36047. * @prop {modifiers}
  36048. */
  36049. modifiers: modifiers
  36050. };
  36051. /**
  36052. * @callback onCreate
  36053. * @param {dataObject} data
  36054. */
  36055. /**
  36056. * @callback onUpdate
  36057. * @param {dataObject} data
  36058. */
  36059. // Utils
  36060. // Methods
  36061. var Popper = function () {
  36062. /**
  36063. * Creates a new Popper.js instance.
  36064. * @class Popper
  36065. * @param {Element|referenceObject} reference - The reference element used to position the popper
  36066. * @param {Element} popper - The HTML / XML element used as the popper
  36067. * @param {Object} options - Your custom options to override the ones defined in [Defaults](#defaults)
  36068. * @return {Object} instance - The generated Popper.js instance
  36069. */
  36070. function Popper(reference, popper) {
  36071. var _this = this;
  36072. var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
  36073. classCallCheck(this, Popper);
  36074. this.scheduleUpdate = function () {
  36075. return requestAnimationFrame(_this.update);
  36076. };
  36077. // make update() debounced, so that it only runs at most once-per-tick
  36078. this.update = debounce(this.update.bind(this));
  36079. // with {} we create a new object with the options inside it
  36080. this.options = _extends({}, Popper.Defaults, options);
  36081. // init state
  36082. this.state = {
  36083. isDestroyed: false,
  36084. isCreated: false,
  36085. scrollParents: []
  36086. };
  36087. // get reference and popper elements (allow jQuery wrappers)
  36088. this.reference = reference && reference.jquery ? reference[0] : reference;
  36089. this.popper = popper && popper.jquery ? popper[0] : popper;
  36090. // Deep merge modifiers options
  36091. this.options.modifiers = {};
  36092. Object.keys(_extends({}, Popper.Defaults.modifiers, options.modifiers)).forEach(function (name) {
  36093. _this.options.modifiers[name] = _extends({}, Popper.Defaults.modifiers[name] || {}, options.modifiers ? options.modifiers[name] : {});
  36094. });
  36095. // Refactoring modifiers' list (Object => Array)
  36096. this.modifiers = Object.keys(this.options.modifiers).map(function (name) {
  36097. return _extends({
  36098. name: name
  36099. }, _this.options.modifiers[name]);
  36100. })
  36101. // sort the modifiers by order
  36102. .sort(function (a, b) {
  36103. return a.order - b.order;
  36104. });
  36105. // modifiers have the ability to execute arbitrary code when Popper.js get inited
  36106. // such code is executed in the same order of its modifier
  36107. // they could add new properties to their options configuration
  36108. // BE AWARE: don't add options to `options.modifiers.name` but to `modifierOptions`!
  36109. this.modifiers.forEach(function (modifierOptions) {
  36110. if (modifierOptions.enabled && isFunction(modifierOptions.onLoad)) {
  36111. modifierOptions.onLoad(_this.reference, _this.popper, _this.options, modifierOptions, _this.state);
  36112. }
  36113. });
  36114. // fire the first update to position the popper in the right place
  36115. this.update();
  36116. var eventsEnabled = this.options.eventsEnabled;
  36117. if (eventsEnabled) {
  36118. // setup event listeners, they will take care of update the position in specific situations
  36119. this.enableEventListeners();
  36120. }
  36121. this.state.eventsEnabled = eventsEnabled;
  36122. }
  36123. // We can't use class properties because they don't get listed in the
  36124. // class prototype and break stuff like Sinon stubs
  36125. createClass(Popper, [{
  36126. key: 'update',
  36127. value: function update$$1() {
  36128. return update.call(this);
  36129. }
  36130. }, {
  36131. key: 'destroy',
  36132. value: function destroy$$1() {
  36133. return destroy.call(this);
  36134. }
  36135. }, {
  36136. key: 'enableEventListeners',
  36137. value: function enableEventListeners$$1() {
  36138. return enableEventListeners.call(this);
  36139. }
  36140. }, {
  36141. key: 'disableEventListeners',
  36142. value: function disableEventListeners$$1() {
  36143. return disableEventListeners.call(this);
  36144. }
  36145. /**
  36146. * Schedules an update. It will run on the next UI update available.
  36147. * @method scheduleUpdate
  36148. * @memberof Popper
  36149. */
  36150. /**
  36151. * Collection of utilities useful when writing custom modifiers.
  36152. * Starting from version 1.7, this method is available only if you
  36153. * include `popper-utils.js` before `popper.js`.
  36154. *
  36155. * **DEPRECATION**: This way to access PopperUtils is deprecated
  36156. * and will be removed in v2! Use the PopperUtils module directly instead.
  36157. * Due to the high instability of the methods contained in Utils, we can't
  36158. * guarantee them to follow semver. Use them at your own risk!
  36159. * @static
  36160. * @private
  36161. * @type {Object}
  36162. * @deprecated since version 1.8
  36163. * @member Utils
  36164. * @memberof Popper
  36165. */
  36166. }]);
  36167. return Popper;
  36168. }();
  36169. /**
  36170. * The `referenceObject` is an object that provides an interface compatible with Popper.js
  36171. * and lets you use it as replacement of a real DOM node.<br />
  36172. * You can use this method to position a popper relatively to a set of coordinates
  36173. * in case you don't have a DOM node to use as reference.
  36174. *
  36175. * ```
  36176. * new Popper(referenceObject, popperNode);
  36177. * ```
  36178. *
  36179. * NB: This feature isn't supported in Internet Explorer 10.
  36180. * @name referenceObject
  36181. * @property {Function} data.getBoundingClientRect
  36182. * A function that returns a set of coordinates compatible with the native `getBoundingClientRect` method.
  36183. * @property {number} data.clientWidth
  36184. * An ES6 getter that will return the width of the virtual reference element.
  36185. * @property {number} data.clientHeight
  36186. * An ES6 getter that will return the height of the virtual reference element.
  36187. */
  36188. Popper.Utils = (typeof window !== 'undefined' ? window : global).PopperUtils;
  36189. Popper.placements = placements;
  36190. Popper.Defaults = Defaults;
  36191. /* harmony default export */ __webpack_exports__["default"] = (Popper);
  36192. //# sourceMappingURL=popper.js.map
  36193. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../../webpack/buildin/global.js */ "./node_modules/webpack/buildin/global.js")))
  36194. /***/ }),
  36195. /***/ "./node_modules/process/browser.js":
  36196. /*!*****************************************!*\
  36197. !*** ./node_modules/process/browser.js ***!
  36198. \*****************************************/
  36199. /*! no static exports found */
  36200. /***/ (function(module, exports) {
  36201. // shim for using process in browser
  36202. var process = module.exports = {};
  36203. // cached from whatever global is present so that test runners that stub it
  36204. // don't break things. But we need to wrap it in a try catch in case it is
  36205. // wrapped in strict mode code which doesn't define any globals. It's inside a
  36206. // function because try/catches deoptimize in certain engines.
  36207. var cachedSetTimeout;
  36208. var cachedClearTimeout;
  36209. function defaultSetTimout() {
  36210. throw new Error('setTimeout has not been defined');
  36211. }
  36212. function defaultClearTimeout () {
  36213. throw new Error('clearTimeout has not been defined');
  36214. }
  36215. (function () {
  36216. try {
  36217. if (typeof setTimeout === 'function') {
  36218. cachedSetTimeout = setTimeout;
  36219. } else {
  36220. cachedSetTimeout = defaultSetTimout;
  36221. }
  36222. } catch (e) {
  36223. cachedSetTimeout = defaultSetTimout;
  36224. }
  36225. try {
  36226. if (typeof clearTimeout === 'function') {
  36227. cachedClearTimeout = clearTimeout;
  36228. } else {
  36229. cachedClearTimeout = defaultClearTimeout;
  36230. }
  36231. } catch (e) {
  36232. cachedClearTimeout = defaultClearTimeout;
  36233. }
  36234. } ())
  36235. function runTimeout(fun) {
  36236. if (cachedSetTimeout === setTimeout) {
  36237. //normal enviroments in sane situations
  36238. return setTimeout(fun, 0);
  36239. }
  36240. // if setTimeout wasn't available but was latter defined
  36241. if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
  36242. cachedSetTimeout = setTimeout;
  36243. return setTimeout(fun, 0);
  36244. }
  36245. try {
  36246. // when when somebody has screwed with setTimeout but no I.E. maddness
  36247. return cachedSetTimeout(fun, 0);
  36248. } catch(e){
  36249. try {
  36250. // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
  36251. return cachedSetTimeout.call(null, fun, 0);
  36252. } catch(e){
  36253. // 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
  36254. return cachedSetTimeout.call(this, fun, 0);
  36255. }
  36256. }
  36257. }
  36258. function runClearTimeout(marker) {
  36259. if (cachedClearTimeout === clearTimeout) {
  36260. //normal enviroments in sane situations
  36261. return clearTimeout(marker);
  36262. }
  36263. // if clearTimeout wasn't available but was latter defined
  36264. if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
  36265. cachedClearTimeout = clearTimeout;
  36266. return clearTimeout(marker);
  36267. }
  36268. try {
  36269. // when when somebody has screwed with setTimeout but no I.E. maddness
  36270. return cachedClearTimeout(marker);
  36271. } catch (e){
  36272. try {
  36273. // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
  36274. return cachedClearTimeout.call(null, marker);
  36275. } catch (e){
  36276. // 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.
  36277. // Some versions of I.E. have different rules for clearTimeout vs setTimeout
  36278. return cachedClearTimeout.call(this, marker);
  36279. }
  36280. }
  36281. }
  36282. var queue = [];
  36283. var draining = false;
  36284. var currentQueue;
  36285. var queueIndex = -1;
  36286. function cleanUpNextTick() {
  36287. if (!draining || !currentQueue) {
  36288. return;
  36289. }
  36290. draining = false;
  36291. if (currentQueue.length) {
  36292. queue = currentQueue.concat(queue);
  36293. } else {
  36294. queueIndex = -1;
  36295. }
  36296. if (queue.length) {
  36297. drainQueue();
  36298. }
  36299. }
  36300. function drainQueue() {
  36301. if (draining) {
  36302. return;
  36303. }
  36304. var timeout = runTimeout(cleanUpNextTick);
  36305. draining = true;
  36306. var len = queue.length;
  36307. while(len) {
  36308. currentQueue = queue;
  36309. queue = [];
  36310. while (++queueIndex < len) {
  36311. if (currentQueue) {
  36312. currentQueue[queueIndex].run();
  36313. }
  36314. }
  36315. queueIndex = -1;
  36316. len = queue.length;
  36317. }
  36318. currentQueue = null;
  36319. draining = false;
  36320. runClearTimeout(timeout);
  36321. }
  36322. process.nextTick = function (fun) {
  36323. var args = new Array(arguments.length - 1);
  36324. if (arguments.length > 1) {
  36325. for (var i = 1; i < arguments.length; i++) {
  36326. args[i - 1] = arguments[i];
  36327. }
  36328. }
  36329. queue.push(new Item(fun, args));
  36330. if (queue.length === 1 && !draining) {
  36331. runTimeout(drainQueue);
  36332. }
  36333. };
  36334. // v8 likes predictible objects
  36335. function Item(fun, array) {
  36336. this.fun = fun;
  36337. this.array = array;
  36338. }
  36339. Item.prototype.run = function () {
  36340. this.fun.apply(null, this.array);
  36341. };
  36342. process.title = 'browser';
  36343. process.browser = true;
  36344. process.env = {};
  36345. process.argv = [];
  36346. process.version = ''; // empty string to avoid regexp issues
  36347. process.versions = {};
  36348. function noop() {}
  36349. process.on = noop;
  36350. process.addListener = noop;
  36351. process.once = noop;
  36352. process.off = noop;
  36353. process.removeListener = noop;
  36354. process.removeAllListeners = noop;
  36355. process.emit = noop;
  36356. process.prependListener = noop;
  36357. process.prependOnceListener = noop;
  36358. process.listeners = function (name) { return [] }
  36359. process.binding = function (name) {
  36360. throw new Error('process.binding is not supported');
  36361. };
  36362. process.cwd = function () { return '/' };
  36363. process.chdir = function (dir) {
  36364. throw new Error('process.chdir is not supported');
  36365. };
  36366. process.umask = function() { return 0; };
  36367. /***/ }),
  36368. /***/ "./node_modules/pusher-js/dist/web/pusher.js":
  36369. /*!***************************************************!*\
  36370. !*** ./node_modules/pusher-js/dist/web/pusher.js ***!
  36371. \***************************************************/
  36372. /*! no static exports found */
  36373. /***/ (function(module, exports, __webpack_require__) {
  36374. /* WEBPACK VAR INJECTION */(function(Buffer) {/*!
  36375. * Pusher JavaScript Library v5.0.3
  36376. * https://pusher.com/
  36377. *
  36378. * Copyright 2017, Pusher
  36379. * Released under the MIT licence.
  36380. */
  36381. (function webpackUniversalModuleDefinition(root, factory) {
  36382. if(true)
  36383. module.exports = factory();
  36384. else {}
  36385. })(window, function() {
  36386. return /******/ (function(modules) { // webpackBootstrap
  36387. /******/ // The module cache
  36388. /******/ var installedModules = {};
  36389. /******/
  36390. /******/ // The require function
  36391. /******/ function __webpack_require__(moduleId) {
  36392. /******/
  36393. /******/ // Check if module is in cache
  36394. /******/ if(installedModules[moduleId]) {
  36395. /******/ return installedModules[moduleId].exports;
  36396. /******/ }
  36397. /******/ // Create a new module (and put it into the cache)
  36398. /******/ var module = installedModules[moduleId] = {
  36399. /******/ i: moduleId,
  36400. /******/ l: false,
  36401. /******/ exports: {}
  36402. /******/ };
  36403. /******/
  36404. /******/ // Execute the module function
  36405. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  36406. /******/
  36407. /******/ // Flag the module as loaded
  36408. /******/ module.l = true;
  36409. /******/
  36410. /******/ // Return the exports of the module
  36411. /******/ return module.exports;
  36412. /******/ }
  36413. /******/
  36414. /******/
  36415. /******/ // expose the modules object (__webpack_modules__)
  36416. /******/ __webpack_require__.m = modules;
  36417. /******/
  36418. /******/ // expose the module cache
  36419. /******/ __webpack_require__.c = installedModules;
  36420. /******/
  36421. /******/ // define getter function for harmony exports
  36422. /******/ __webpack_require__.d = function(exports, name, getter) {
  36423. /******/ if(!__webpack_require__.o(exports, name)) {
  36424. /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
  36425. /******/ }
  36426. /******/ };
  36427. /******/
  36428. /******/ // define __esModule on exports
  36429. /******/ __webpack_require__.r = function(exports) {
  36430. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  36431. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  36432. /******/ }
  36433. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  36434. /******/ };
  36435. /******/
  36436. /******/ // create a fake namespace object
  36437. /******/ // mode & 1: value is a module id, require it
  36438. /******/ // mode & 2: merge all properties of value into the ns
  36439. /******/ // mode & 4: return value when already ns object
  36440. /******/ // mode & 8|1: behave like require
  36441. /******/ __webpack_require__.t = function(value, mode) {
  36442. /******/ if(mode & 1) value = __webpack_require__(value);
  36443. /******/ if(mode & 8) return value;
  36444. /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
  36445. /******/ var ns = Object.create(null);
  36446. /******/ __webpack_require__.r(ns);
  36447. /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
  36448. /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
  36449. /******/ return ns;
  36450. /******/ };
  36451. /******/
  36452. /******/ // getDefaultExport function for compatibility with non-harmony modules
  36453. /******/ __webpack_require__.n = function(module) {
  36454. /******/ var getter = module && module.__esModule ?
  36455. /******/ function getDefault() { return module['default']; } :
  36456. /******/ function getModuleExports() { return module; };
  36457. /******/ __webpack_require__.d(getter, 'a', getter);
  36458. /******/ return getter;
  36459. /******/ };
  36460. /******/
  36461. /******/ // Object.prototype.hasOwnProperty.call
  36462. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  36463. /******/
  36464. /******/ // __webpack_public_path__
  36465. /******/ __webpack_require__.p = "";
  36466. /******/
  36467. /******/
  36468. /******/ // Load entry module and return exports
  36469. /******/ return __webpack_require__(__webpack_require__.s = 2);
  36470. /******/ })
  36471. /************************************************************************/
  36472. /******/ ([
  36473. /* 0 */
  36474. /***/ (function(module, exports, __webpack_require__) {
  36475. (function(nacl) {
  36476. 'use strict';
  36477. // Ported in 2014 by Dmitry Chestnykh and Devi Mandiri.
  36478. // Public domain.
  36479. //
  36480. // Implementation derived from TweetNaCl version 20140427.
  36481. // See for details: http://tweetnacl.cr.yp.to/
  36482. var gf = function(init) {
  36483. var i, r = new Float64Array(16);
  36484. if (init) for (i = 0; i < init.length; i++) r[i] = init[i];
  36485. return r;
  36486. };
  36487. // Pluggable, initialized in high-level API below.
  36488. var randombytes = function(/* x, n */) { throw new Error('no PRNG'); };
  36489. var _0 = new Uint8Array(16);
  36490. var _9 = new Uint8Array(32); _9[0] = 9;
  36491. var gf0 = gf(),
  36492. gf1 = gf([1]),
  36493. _121665 = gf([0xdb41, 1]),
  36494. D = gf([0x78a3, 0x1359, 0x4dca, 0x75eb, 0xd8ab, 0x4141, 0x0a4d, 0x0070, 0xe898, 0x7779, 0x4079, 0x8cc7, 0xfe73, 0x2b6f, 0x6cee, 0x5203]),
  36495. D2 = gf([0xf159, 0x26b2, 0x9b94, 0xebd6, 0xb156, 0x8283, 0x149a, 0x00e0, 0xd130, 0xeef3, 0x80f2, 0x198e, 0xfce7, 0x56df, 0xd9dc, 0x2406]),
  36496. X = gf([0xd51a, 0x8f25, 0x2d60, 0xc956, 0xa7b2, 0x9525, 0xc760, 0x692c, 0xdc5c, 0xfdd6, 0xe231, 0xc0a4, 0x53fe, 0xcd6e, 0x36d3, 0x2169]),
  36497. Y = gf([0x6658, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666]),
  36498. I = gf([0xa0b0, 0x4a0e, 0x1b27, 0xc4ee, 0xe478, 0xad2f, 0x1806, 0x2f43, 0xd7a7, 0x3dfb, 0x0099, 0x2b4d, 0xdf0b, 0x4fc1, 0x2480, 0x2b83]);
  36499. function ts64(x, i, h, l) {
  36500. x[i] = (h >> 24) & 0xff;
  36501. x[i+1] = (h >> 16) & 0xff;
  36502. x[i+2] = (h >> 8) & 0xff;
  36503. x[i+3] = h & 0xff;
  36504. x[i+4] = (l >> 24) & 0xff;
  36505. x[i+5] = (l >> 16) & 0xff;
  36506. x[i+6] = (l >> 8) & 0xff;
  36507. x[i+7] = l & 0xff;
  36508. }
  36509. function vn(x, xi, y, yi, n) {
  36510. var i,d = 0;
  36511. for (i = 0; i < n; i++) d |= x[xi+i]^y[yi+i];
  36512. return (1 & ((d - 1) >>> 8)) - 1;
  36513. }
  36514. function crypto_verify_16(x, xi, y, yi) {
  36515. return vn(x,xi,y,yi,16);
  36516. }
  36517. function crypto_verify_32(x, xi, y, yi) {
  36518. return vn(x,xi,y,yi,32);
  36519. }
  36520. function core_salsa20(o, p, k, c) {
  36521. var j0 = c[ 0] & 0xff | (c[ 1] & 0xff)<<8 | (c[ 2] & 0xff)<<16 | (c[ 3] & 0xff)<<24,
  36522. j1 = k[ 0] & 0xff | (k[ 1] & 0xff)<<8 | (k[ 2] & 0xff)<<16 | (k[ 3] & 0xff)<<24,
  36523. j2 = k[ 4] & 0xff | (k[ 5] & 0xff)<<8 | (k[ 6] & 0xff)<<16 | (k[ 7] & 0xff)<<24,
  36524. j3 = k[ 8] & 0xff | (k[ 9] & 0xff)<<8 | (k[10] & 0xff)<<16 | (k[11] & 0xff)<<24,
  36525. j4 = k[12] & 0xff | (k[13] & 0xff)<<8 | (k[14] & 0xff)<<16 | (k[15] & 0xff)<<24,
  36526. j5 = c[ 4] & 0xff | (c[ 5] & 0xff)<<8 | (c[ 6] & 0xff)<<16 | (c[ 7] & 0xff)<<24,
  36527. j6 = p[ 0] & 0xff | (p[ 1] & 0xff)<<8 | (p[ 2] & 0xff)<<16 | (p[ 3] & 0xff)<<24,
  36528. j7 = p[ 4] & 0xff | (p[ 5] & 0xff)<<8 | (p[ 6] & 0xff)<<16 | (p[ 7] & 0xff)<<24,
  36529. j8 = p[ 8] & 0xff | (p[ 9] & 0xff)<<8 | (p[10] & 0xff)<<16 | (p[11] & 0xff)<<24,
  36530. j9 = p[12] & 0xff | (p[13] & 0xff)<<8 | (p[14] & 0xff)<<16 | (p[15] & 0xff)<<24,
  36531. j10 = c[ 8] & 0xff | (c[ 9] & 0xff)<<8 | (c[10] & 0xff)<<16 | (c[11] & 0xff)<<24,
  36532. j11 = k[16] & 0xff | (k[17] & 0xff)<<8 | (k[18] & 0xff)<<16 | (k[19] & 0xff)<<24,
  36533. j12 = k[20] & 0xff | (k[21] & 0xff)<<8 | (k[22] & 0xff)<<16 | (k[23] & 0xff)<<24,
  36534. j13 = k[24] & 0xff | (k[25] & 0xff)<<8 | (k[26] & 0xff)<<16 | (k[27] & 0xff)<<24,
  36535. j14 = k[28] & 0xff | (k[29] & 0xff)<<8 | (k[30] & 0xff)<<16 | (k[31] & 0xff)<<24,
  36536. j15 = c[12] & 0xff | (c[13] & 0xff)<<8 | (c[14] & 0xff)<<16 | (c[15] & 0xff)<<24;
  36537. var x0 = j0, x1 = j1, x2 = j2, x3 = j3, x4 = j4, x5 = j5, x6 = j6, x7 = j7,
  36538. x8 = j8, x9 = j9, x10 = j10, x11 = j11, x12 = j12, x13 = j13, x14 = j14,
  36539. x15 = j15, u;
  36540. for (var i = 0; i < 20; i += 2) {
  36541. u = x0 + x12 | 0;
  36542. x4 ^= u<<7 | u>>>(32-7);
  36543. u = x4 + x0 | 0;
  36544. x8 ^= u<<9 | u>>>(32-9);
  36545. u = x8 + x4 | 0;
  36546. x12 ^= u<<13 | u>>>(32-13);
  36547. u = x12 + x8 | 0;
  36548. x0 ^= u<<18 | u>>>(32-18);
  36549. u = x5 + x1 | 0;
  36550. x9 ^= u<<7 | u>>>(32-7);
  36551. u = x9 + x5 | 0;
  36552. x13 ^= u<<9 | u>>>(32-9);
  36553. u = x13 + x9 | 0;
  36554. x1 ^= u<<13 | u>>>(32-13);
  36555. u = x1 + x13 | 0;
  36556. x5 ^= u<<18 | u>>>(32-18);
  36557. u = x10 + x6 | 0;
  36558. x14 ^= u<<7 | u>>>(32-7);
  36559. u = x14 + x10 | 0;
  36560. x2 ^= u<<9 | u>>>(32-9);
  36561. u = x2 + x14 | 0;
  36562. x6 ^= u<<13 | u>>>(32-13);
  36563. u = x6 + x2 | 0;
  36564. x10 ^= u<<18 | u>>>(32-18);
  36565. u = x15 + x11 | 0;
  36566. x3 ^= u<<7 | u>>>(32-7);
  36567. u = x3 + x15 | 0;
  36568. x7 ^= u<<9 | u>>>(32-9);
  36569. u = x7 + x3 | 0;
  36570. x11 ^= u<<13 | u>>>(32-13);
  36571. u = x11 + x7 | 0;
  36572. x15 ^= u<<18 | u>>>(32-18);
  36573. u = x0 + x3 | 0;
  36574. x1 ^= u<<7 | u>>>(32-7);
  36575. u = x1 + x0 | 0;
  36576. x2 ^= u<<9 | u>>>(32-9);
  36577. u = x2 + x1 | 0;
  36578. x3 ^= u<<13 | u>>>(32-13);
  36579. u = x3 + x2 | 0;
  36580. x0 ^= u<<18 | u>>>(32-18);
  36581. u = x5 + x4 | 0;
  36582. x6 ^= u<<7 | u>>>(32-7);
  36583. u = x6 + x5 | 0;
  36584. x7 ^= u<<9 | u>>>(32-9);
  36585. u = x7 + x6 | 0;
  36586. x4 ^= u<<13 | u>>>(32-13);
  36587. u = x4 + x7 | 0;
  36588. x5 ^= u<<18 | u>>>(32-18);
  36589. u = x10 + x9 | 0;
  36590. x11 ^= u<<7 | u>>>(32-7);
  36591. u = x11 + x10 | 0;
  36592. x8 ^= u<<9 | u>>>(32-9);
  36593. u = x8 + x11 | 0;
  36594. x9 ^= u<<13 | u>>>(32-13);
  36595. u = x9 + x8 | 0;
  36596. x10 ^= u<<18 | u>>>(32-18);
  36597. u = x15 + x14 | 0;
  36598. x12 ^= u<<7 | u>>>(32-7);
  36599. u = x12 + x15 | 0;
  36600. x13 ^= u<<9 | u>>>(32-9);
  36601. u = x13 + x12 | 0;
  36602. x14 ^= u<<13 | u>>>(32-13);
  36603. u = x14 + x13 | 0;
  36604. x15 ^= u<<18 | u>>>(32-18);
  36605. }
  36606. x0 = x0 + j0 | 0;
  36607. x1 = x1 + j1 | 0;
  36608. x2 = x2 + j2 | 0;
  36609. x3 = x3 + j3 | 0;
  36610. x4 = x4 + j4 | 0;
  36611. x5 = x5 + j5 | 0;
  36612. x6 = x6 + j6 | 0;
  36613. x7 = x7 + j7 | 0;
  36614. x8 = x8 + j8 | 0;
  36615. x9 = x9 + j9 | 0;
  36616. x10 = x10 + j10 | 0;
  36617. x11 = x11 + j11 | 0;
  36618. x12 = x12 + j12 | 0;
  36619. x13 = x13 + j13 | 0;
  36620. x14 = x14 + j14 | 0;
  36621. x15 = x15 + j15 | 0;
  36622. o[ 0] = x0 >>> 0 & 0xff;
  36623. o[ 1] = x0 >>> 8 & 0xff;
  36624. o[ 2] = x0 >>> 16 & 0xff;
  36625. o[ 3] = x0 >>> 24 & 0xff;
  36626. o[ 4] = x1 >>> 0 & 0xff;
  36627. o[ 5] = x1 >>> 8 & 0xff;
  36628. o[ 6] = x1 >>> 16 & 0xff;
  36629. o[ 7] = x1 >>> 24 & 0xff;
  36630. o[ 8] = x2 >>> 0 & 0xff;
  36631. o[ 9] = x2 >>> 8 & 0xff;
  36632. o[10] = x2 >>> 16 & 0xff;
  36633. o[11] = x2 >>> 24 & 0xff;
  36634. o[12] = x3 >>> 0 & 0xff;
  36635. o[13] = x3 >>> 8 & 0xff;
  36636. o[14] = x3 >>> 16 & 0xff;
  36637. o[15] = x3 >>> 24 & 0xff;
  36638. o[16] = x4 >>> 0 & 0xff;
  36639. o[17] = x4 >>> 8 & 0xff;
  36640. o[18] = x4 >>> 16 & 0xff;
  36641. o[19] = x4 >>> 24 & 0xff;
  36642. o[20] = x5 >>> 0 & 0xff;
  36643. o[21] = x5 >>> 8 & 0xff;
  36644. o[22] = x5 >>> 16 & 0xff;
  36645. o[23] = x5 >>> 24 & 0xff;
  36646. o[24] = x6 >>> 0 & 0xff;
  36647. o[25] = x6 >>> 8 & 0xff;
  36648. o[26] = x6 >>> 16 & 0xff;
  36649. o[27] = x6 >>> 24 & 0xff;
  36650. o[28] = x7 >>> 0 & 0xff;
  36651. o[29] = x7 >>> 8 & 0xff;
  36652. o[30] = x7 >>> 16 & 0xff;
  36653. o[31] = x7 >>> 24 & 0xff;
  36654. o[32] = x8 >>> 0 & 0xff;
  36655. o[33] = x8 >>> 8 & 0xff;
  36656. o[34] = x8 >>> 16 & 0xff;
  36657. o[35] = x8 >>> 24 & 0xff;
  36658. o[36] = x9 >>> 0 & 0xff;
  36659. o[37] = x9 >>> 8 & 0xff;
  36660. o[38] = x9 >>> 16 & 0xff;
  36661. o[39] = x9 >>> 24 & 0xff;
  36662. o[40] = x10 >>> 0 & 0xff;
  36663. o[41] = x10 >>> 8 & 0xff;
  36664. o[42] = x10 >>> 16 & 0xff;
  36665. o[43] = x10 >>> 24 & 0xff;
  36666. o[44] = x11 >>> 0 & 0xff;
  36667. o[45] = x11 >>> 8 & 0xff;
  36668. o[46] = x11 >>> 16 & 0xff;
  36669. o[47] = x11 >>> 24 & 0xff;
  36670. o[48] = x12 >>> 0 & 0xff;
  36671. o[49] = x12 >>> 8 & 0xff;
  36672. o[50] = x12 >>> 16 & 0xff;
  36673. o[51] = x12 >>> 24 & 0xff;
  36674. o[52] = x13 >>> 0 & 0xff;
  36675. o[53] = x13 >>> 8 & 0xff;
  36676. o[54] = x13 >>> 16 & 0xff;
  36677. o[55] = x13 >>> 24 & 0xff;
  36678. o[56] = x14 >>> 0 & 0xff;
  36679. o[57] = x14 >>> 8 & 0xff;
  36680. o[58] = x14 >>> 16 & 0xff;
  36681. o[59] = x14 >>> 24 & 0xff;
  36682. o[60] = x15 >>> 0 & 0xff;
  36683. o[61] = x15 >>> 8 & 0xff;
  36684. o[62] = x15 >>> 16 & 0xff;
  36685. o[63] = x15 >>> 24 & 0xff;
  36686. }
  36687. function core_hsalsa20(o,p,k,c) {
  36688. var j0 = c[ 0] & 0xff | (c[ 1] & 0xff)<<8 | (c[ 2] & 0xff)<<16 | (c[ 3] & 0xff)<<24,
  36689. j1 = k[ 0] & 0xff | (k[ 1] & 0xff)<<8 | (k[ 2] & 0xff)<<16 | (k[ 3] & 0xff)<<24,
  36690. j2 = k[ 4] & 0xff | (k[ 5] & 0xff)<<8 | (k[ 6] & 0xff)<<16 | (k[ 7] & 0xff)<<24,
  36691. j3 = k[ 8] & 0xff | (k[ 9] & 0xff)<<8 | (k[10] & 0xff)<<16 | (k[11] & 0xff)<<24,
  36692. j4 = k[12] & 0xff | (k[13] & 0xff)<<8 | (k[14] & 0xff)<<16 | (k[15] & 0xff)<<24,
  36693. j5 = c[ 4] & 0xff | (c[ 5] & 0xff)<<8 | (c[ 6] & 0xff)<<16 | (c[ 7] & 0xff)<<24,
  36694. j6 = p[ 0] & 0xff | (p[ 1] & 0xff)<<8 | (p[ 2] & 0xff)<<16 | (p[ 3] & 0xff)<<24,
  36695. j7 = p[ 4] & 0xff | (p[ 5] & 0xff)<<8 | (p[ 6] & 0xff)<<16 | (p[ 7] & 0xff)<<24,
  36696. j8 = p[ 8] & 0xff | (p[ 9] & 0xff)<<8 | (p[10] & 0xff)<<16 | (p[11] & 0xff)<<24,
  36697. j9 = p[12] & 0xff | (p[13] & 0xff)<<8 | (p[14] & 0xff)<<16 | (p[15] & 0xff)<<24,
  36698. j10 = c[ 8] & 0xff | (c[ 9] & 0xff)<<8 | (c[10] & 0xff)<<16 | (c[11] & 0xff)<<24,
  36699. j11 = k[16] & 0xff | (k[17] & 0xff)<<8 | (k[18] & 0xff)<<16 | (k[19] & 0xff)<<24,
  36700. j12 = k[20] & 0xff | (k[21] & 0xff)<<8 | (k[22] & 0xff)<<16 | (k[23] & 0xff)<<24,
  36701. j13 = k[24] & 0xff | (k[25] & 0xff)<<8 | (k[26] & 0xff)<<16 | (k[27] & 0xff)<<24,
  36702. j14 = k[28] & 0xff | (k[29] & 0xff)<<8 | (k[30] & 0xff)<<16 | (k[31] & 0xff)<<24,
  36703. j15 = c[12] & 0xff | (c[13] & 0xff)<<8 | (c[14] & 0xff)<<16 | (c[15] & 0xff)<<24;
  36704. var x0 = j0, x1 = j1, x2 = j2, x3 = j3, x4 = j4, x5 = j5, x6 = j6, x7 = j7,
  36705. x8 = j8, x9 = j9, x10 = j10, x11 = j11, x12 = j12, x13 = j13, x14 = j14,
  36706. x15 = j15, u;
  36707. for (var i = 0; i < 20; i += 2) {
  36708. u = x0 + x12 | 0;
  36709. x4 ^= u<<7 | u>>>(32-7);
  36710. u = x4 + x0 | 0;
  36711. x8 ^= u<<9 | u>>>(32-9);
  36712. u = x8 + x4 | 0;
  36713. x12 ^= u<<13 | u>>>(32-13);
  36714. u = x12 + x8 | 0;
  36715. x0 ^= u<<18 | u>>>(32-18);
  36716. u = x5 + x1 | 0;
  36717. x9 ^= u<<7 | u>>>(32-7);
  36718. u = x9 + x5 | 0;
  36719. x13 ^= u<<9 | u>>>(32-9);
  36720. u = x13 + x9 | 0;
  36721. x1 ^= u<<13 | u>>>(32-13);
  36722. u = x1 + x13 | 0;
  36723. x5 ^= u<<18 | u>>>(32-18);
  36724. u = x10 + x6 | 0;
  36725. x14 ^= u<<7 | u>>>(32-7);
  36726. u = x14 + x10 | 0;
  36727. x2 ^= u<<9 | u>>>(32-9);
  36728. u = x2 + x14 | 0;
  36729. x6 ^= u<<13 | u>>>(32-13);
  36730. u = x6 + x2 | 0;
  36731. x10 ^= u<<18 | u>>>(32-18);
  36732. u = x15 + x11 | 0;
  36733. x3 ^= u<<7 | u>>>(32-7);
  36734. u = x3 + x15 | 0;
  36735. x7 ^= u<<9 | u>>>(32-9);
  36736. u = x7 + x3 | 0;
  36737. x11 ^= u<<13 | u>>>(32-13);
  36738. u = x11 + x7 | 0;
  36739. x15 ^= u<<18 | u>>>(32-18);
  36740. u = x0 + x3 | 0;
  36741. x1 ^= u<<7 | u>>>(32-7);
  36742. u = x1 + x0 | 0;
  36743. x2 ^= u<<9 | u>>>(32-9);
  36744. u = x2 + x1 | 0;
  36745. x3 ^= u<<13 | u>>>(32-13);
  36746. u = x3 + x2 | 0;
  36747. x0 ^= u<<18 | u>>>(32-18);
  36748. u = x5 + x4 | 0;
  36749. x6 ^= u<<7 | u>>>(32-7);
  36750. u = x6 + x5 | 0;
  36751. x7 ^= u<<9 | u>>>(32-9);
  36752. u = x7 + x6 | 0;
  36753. x4 ^= u<<13 | u>>>(32-13);
  36754. u = x4 + x7 | 0;
  36755. x5 ^= u<<18 | u>>>(32-18);
  36756. u = x10 + x9 | 0;
  36757. x11 ^= u<<7 | u>>>(32-7);
  36758. u = x11 + x10 | 0;
  36759. x8 ^= u<<9 | u>>>(32-9);
  36760. u = x8 + x11 | 0;
  36761. x9 ^= u<<13 | u>>>(32-13);
  36762. u = x9 + x8 | 0;
  36763. x10 ^= u<<18 | u>>>(32-18);
  36764. u = x15 + x14 | 0;
  36765. x12 ^= u<<7 | u>>>(32-7);
  36766. u = x12 + x15 | 0;
  36767. x13 ^= u<<9 | u>>>(32-9);
  36768. u = x13 + x12 | 0;
  36769. x14 ^= u<<13 | u>>>(32-13);
  36770. u = x14 + x13 | 0;
  36771. x15 ^= u<<18 | u>>>(32-18);
  36772. }
  36773. o[ 0] = x0 >>> 0 & 0xff;
  36774. o[ 1] = x0 >>> 8 & 0xff;
  36775. o[ 2] = x0 >>> 16 & 0xff;
  36776. o[ 3] = x0 >>> 24 & 0xff;
  36777. o[ 4] = x5 >>> 0 & 0xff;
  36778. o[ 5] = x5 >>> 8 & 0xff;
  36779. o[ 6] = x5 >>> 16 & 0xff;
  36780. o[ 7] = x5 >>> 24 & 0xff;
  36781. o[ 8] = x10 >>> 0 & 0xff;
  36782. o[ 9] = x10 >>> 8 & 0xff;
  36783. o[10] = x10 >>> 16 & 0xff;
  36784. o[11] = x10 >>> 24 & 0xff;
  36785. o[12] = x15 >>> 0 & 0xff;
  36786. o[13] = x15 >>> 8 & 0xff;
  36787. o[14] = x15 >>> 16 & 0xff;
  36788. o[15] = x15 >>> 24 & 0xff;
  36789. o[16] = x6 >>> 0 & 0xff;
  36790. o[17] = x6 >>> 8 & 0xff;
  36791. o[18] = x6 >>> 16 & 0xff;
  36792. o[19] = x6 >>> 24 & 0xff;
  36793. o[20] = x7 >>> 0 & 0xff;
  36794. o[21] = x7 >>> 8 & 0xff;
  36795. o[22] = x7 >>> 16 & 0xff;
  36796. o[23] = x7 >>> 24 & 0xff;
  36797. o[24] = x8 >>> 0 & 0xff;
  36798. o[25] = x8 >>> 8 & 0xff;
  36799. o[26] = x8 >>> 16 & 0xff;
  36800. o[27] = x8 >>> 24 & 0xff;
  36801. o[28] = x9 >>> 0 & 0xff;
  36802. o[29] = x9 >>> 8 & 0xff;
  36803. o[30] = x9 >>> 16 & 0xff;
  36804. o[31] = x9 >>> 24 & 0xff;
  36805. }
  36806. function crypto_core_salsa20(out,inp,k,c) {
  36807. core_salsa20(out,inp,k,c);
  36808. }
  36809. function crypto_core_hsalsa20(out,inp,k,c) {
  36810. core_hsalsa20(out,inp,k,c);
  36811. }
  36812. var sigma = new Uint8Array([101, 120, 112, 97, 110, 100, 32, 51, 50, 45, 98, 121, 116, 101, 32, 107]);
  36813. // "expand 32-byte k"
  36814. function crypto_stream_salsa20_xor(c,cpos,m,mpos,b,n,k) {
  36815. var z = new Uint8Array(16), x = new Uint8Array(64);
  36816. var u, i;
  36817. for (i = 0; i < 16; i++) z[i] = 0;
  36818. for (i = 0; i < 8; i++) z[i] = n[i];
  36819. while (b >= 64) {
  36820. crypto_core_salsa20(x,z,k,sigma);
  36821. for (i = 0; i < 64; i++) c[cpos+i] = m[mpos+i] ^ x[i];
  36822. u = 1;
  36823. for (i = 8; i < 16; i++) {
  36824. u = u + (z[i] & 0xff) | 0;
  36825. z[i] = u & 0xff;
  36826. u >>>= 8;
  36827. }
  36828. b -= 64;
  36829. cpos += 64;
  36830. mpos += 64;
  36831. }
  36832. if (b > 0) {
  36833. crypto_core_salsa20(x,z,k,sigma);
  36834. for (i = 0; i < b; i++) c[cpos+i] = m[mpos+i] ^ x[i];
  36835. }
  36836. return 0;
  36837. }
  36838. function crypto_stream_salsa20(c,cpos,b,n,k) {
  36839. var z = new Uint8Array(16), x = new Uint8Array(64);
  36840. var u, i;
  36841. for (i = 0; i < 16; i++) z[i] = 0;
  36842. for (i = 0; i < 8; i++) z[i] = n[i];
  36843. while (b >= 64) {
  36844. crypto_core_salsa20(x,z,k,sigma);
  36845. for (i = 0; i < 64; i++) c[cpos+i] = x[i];
  36846. u = 1;
  36847. for (i = 8; i < 16; i++) {
  36848. u = u + (z[i] & 0xff) | 0;
  36849. z[i] = u & 0xff;
  36850. u >>>= 8;
  36851. }
  36852. b -= 64;
  36853. cpos += 64;
  36854. }
  36855. if (b > 0) {
  36856. crypto_core_salsa20(x,z,k,sigma);
  36857. for (i = 0; i < b; i++) c[cpos+i] = x[i];
  36858. }
  36859. return 0;
  36860. }
  36861. function crypto_stream(c,cpos,d,n,k) {
  36862. var s = new Uint8Array(32);
  36863. crypto_core_hsalsa20(s,n,k,sigma);
  36864. var sn = new Uint8Array(8);
  36865. for (var i = 0; i < 8; i++) sn[i] = n[i+16];
  36866. return crypto_stream_salsa20(c,cpos,d,sn,s);
  36867. }
  36868. function crypto_stream_xor(c,cpos,m,mpos,d,n,k) {
  36869. var s = new Uint8Array(32);
  36870. crypto_core_hsalsa20(s,n,k,sigma);
  36871. var sn = new Uint8Array(8);
  36872. for (var i = 0; i < 8; i++) sn[i] = n[i+16];
  36873. return crypto_stream_salsa20_xor(c,cpos,m,mpos,d,sn,s);
  36874. }
  36875. /*
  36876. * Port of Andrew Moon's Poly1305-donna-16. Public domain.
  36877. * https://github.com/floodyberry/poly1305-donna
  36878. */
  36879. var poly1305 = function(key) {
  36880. this.buffer = new Uint8Array(16);
  36881. this.r = new Uint16Array(10);
  36882. this.h = new Uint16Array(10);
  36883. this.pad = new Uint16Array(8);
  36884. this.leftover = 0;
  36885. this.fin = 0;
  36886. var t0, t1, t2, t3, t4, t5, t6, t7;
  36887. t0 = key[ 0] & 0xff | (key[ 1] & 0xff) << 8; this.r[0] = ( t0 ) & 0x1fff;
  36888. t1 = key[ 2] & 0xff | (key[ 3] & 0xff) << 8; this.r[1] = ((t0 >>> 13) | (t1 << 3)) & 0x1fff;
  36889. t2 = key[ 4] & 0xff | (key[ 5] & 0xff) << 8; this.r[2] = ((t1 >>> 10) | (t2 << 6)) & 0x1f03;
  36890. t3 = key[ 6] & 0xff | (key[ 7] & 0xff) << 8; this.r[3] = ((t2 >>> 7) | (t3 << 9)) & 0x1fff;
  36891. t4 = key[ 8] & 0xff | (key[ 9] & 0xff) << 8; this.r[4] = ((t3 >>> 4) | (t4 << 12)) & 0x00ff;
  36892. this.r[5] = ((t4 >>> 1)) & 0x1ffe;
  36893. t5 = key[10] & 0xff | (key[11] & 0xff) << 8; this.r[6] = ((t4 >>> 14) | (t5 << 2)) & 0x1fff;
  36894. t6 = key[12] & 0xff | (key[13] & 0xff) << 8; this.r[7] = ((t5 >>> 11) | (t6 << 5)) & 0x1f81;
  36895. t7 = key[14] & 0xff | (key[15] & 0xff) << 8; this.r[8] = ((t6 >>> 8) | (t7 << 8)) & 0x1fff;
  36896. this.r[9] = ((t7 >>> 5)) & 0x007f;
  36897. this.pad[0] = key[16] & 0xff | (key[17] & 0xff) << 8;
  36898. this.pad[1] = key[18] & 0xff | (key[19] & 0xff) << 8;
  36899. this.pad[2] = key[20] & 0xff | (key[21] & 0xff) << 8;
  36900. this.pad[3] = key[22] & 0xff | (key[23] & 0xff) << 8;
  36901. this.pad[4] = key[24] & 0xff | (key[25] & 0xff) << 8;
  36902. this.pad[5] = key[26] & 0xff | (key[27] & 0xff) << 8;
  36903. this.pad[6] = key[28] & 0xff | (key[29] & 0xff) << 8;
  36904. this.pad[7] = key[30] & 0xff | (key[31] & 0xff) << 8;
  36905. };
  36906. poly1305.prototype.blocks = function(m, mpos, bytes) {
  36907. var hibit = this.fin ? 0 : (1 << 11);
  36908. var t0, t1, t2, t3, t4, t5, t6, t7, c;
  36909. var d0, d1, d2, d3, d4, d5, d6, d7, d8, d9;
  36910. var h0 = this.h[0],
  36911. h1 = this.h[1],
  36912. h2 = this.h[2],
  36913. h3 = this.h[3],
  36914. h4 = this.h[4],
  36915. h5 = this.h[5],
  36916. h6 = this.h[6],
  36917. h7 = this.h[7],
  36918. h8 = this.h[8],
  36919. h9 = this.h[9];
  36920. var r0 = this.r[0],
  36921. r1 = this.r[1],
  36922. r2 = this.r[2],
  36923. r3 = this.r[3],
  36924. r4 = this.r[4],
  36925. r5 = this.r[5],
  36926. r6 = this.r[6],
  36927. r7 = this.r[7],
  36928. r8 = this.r[8],
  36929. r9 = this.r[9];
  36930. while (bytes >= 16) {
  36931. t0 = m[mpos+ 0] & 0xff | (m[mpos+ 1] & 0xff) << 8; h0 += ( t0 ) & 0x1fff;
  36932. t1 = m[mpos+ 2] & 0xff | (m[mpos+ 3] & 0xff) << 8; h1 += ((t0 >>> 13) | (t1 << 3)) & 0x1fff;
  36933. t2 = m[mpos+ 4] & 0xff | (m[mpos+ 5] & 0xff) << 8; h2 += ((t1 >>> 10) | (t2 << 6)) & 0x1fff;
  36934. t3 = m[mpos+ 6] & 0xff | (m[mpos+ 7] & 0xff) << 8; h3 += ((t2 >>> 7) | (t3 << 9)) & 0x1fff;
  36935. t4 = m[mpos+ 8] & 0xff | (m[mpos+ 9] & 0xff) << 8; h4 += ((t3 >>> 4) | (t4 << 12)) & 0x1fff;
  36936. h5 += ((t4 >>> 1)) & 0x1fff;
  36937. t5 = m[mpos+10] & 0xff | (m[mpos+11] & 0xff) << 8; h6 += ((t4 >>> 14) | (t5 << 2)) & 0x1fff;
  36938. t6 = m[mpos+12] & 0xff | (m[mpos+13] & 0xff) << 8; h7 += ((t5 >>> 11) | (t6 << 5)) & 0x1fff;
  36939. t7 = m[mpos+14] & 0xff | (m[mpos+15] & 0xff) << 8; h8 += ((t6 >>> 8) | (t7 << 8)) & 0x1fff;
  36940. h9 += ((t7 >>> 5)) | hibit;
  36941. c = 0;
  36942. d0 = c;
  36943. d0 += h0 * r0;
  36944. d0 += h1 * (5 * r9);
  36945. d0 += h2 * (5 * r8);
  36946. d0 += h3 * (5 * r7);
  36947. d0 += h4 * (5 * r6);
  36948. c = (d0 >>> 13); d0 &= 0x1fff;
  36949. d0 += h5 * (5 * r5);
  36950. d0 += h6 * (5 * r4);
  36951. d0 += h7 * (5 * r3);
  36952. d0 += h8 * (5 * r2);
  36953. d0 += h9 * (5 * r1);
  36954. c += (d0 >>> 13); d0 &= 0x1fff;
  36955. d1 = c;
  36956. d1 += h0 * r1;
  36957. d1 += h1 * r0;
  36958. d1 += h2 * (5 * r9);
  36959. d1 += h3 * (5 * r8);
  36960. d1 += h4 * (5 * r7);
  36961. c = (d1 >>> 13); d1 &= 0x1fff;
  36962. d1 += h5 * (5 * r6);
  36963. d1 += h6 * (5 * r5);
  36964. d1 += h7 * (5 * r4);
  36965. d1 += h8 * (5 * r3);
  36966. d1 += h9 * (5 * r2);
  36967. c += (d1 >>> 13); d1 &= 0x1fff;
  36968. d2 = c;
  36969. d2 += h0 * r2;
  36970. d2 += h1 * r1;
  36971. d2 += h2 * r0;
  36972. d2 += h3 * (5 * r9);
  36973. d2 += h4 * (5 * r8);
  36974. c = (d2 >>> 13); d2 &= 0x1fff;
  36975. d2 += h5 * (5 * r7);
  36976. d2 += h6 * (5 * r6);
  36977. d2 += h7 * (5 * r5);
  36978. d2 += h8 * (5 * r4);
  36979. d2 += h9 * (5 * r3);
  36980. c += (d2 >>> 13); d2 &= 0x1fff;
  36981. d3 = c;
  36982. d3 += h0 * r3;
  36983. d3 += h1 * r2;
  36984. d3 += h2 * r1;
  36985. d3 += h3 * r0;
  36986. d3 += h4 * (5 * r9);
  36987. c = (d3 >>> 13); d3 &= 0x1fff;
  36988. d3 += h5 * (5 * r8);
  36989. d3 += h6 * (5 * r7);
  36990. d3 += h7 * (5 * r6);
  36991. d3 += h8 * (5 * r5);
  36992. d3 += h9 * (5 * r4);
  36993. c += (d3 >>> 13); d3 &= 0x1fff;
  36994. d4 = c;
  36995. d4 += h0 * r4;
  36996. d4 += h1 * r3;
  36997. d4 += h2 * r2;
  36998. d4 += h3 * r1;
  36999. d4 += h4 * r0;
  37000. c = (d4 >>> 13); d4 &= 0x1fff;
  37001. d4 += h5 * (5 * r9);
  37002. d4 += h6 * (5 * r8);
  37003. d4 += h7 * (5 * r7);
  37004. d4 += h8 * (5 * r6);
  37005. d4 += h9 * (5 * r5);
  37006. c += (d4 >>> 13); d4 &= 0x1fff;
  37007. d5 = c;
  37008. d5 += h0 * r5;
  37009. d5 += h1 * r4;
  37010. d5 += h2 * r3;
  37011. d5 += h3 * r2;
  37012. d5 += h4 * r1;
  37013. c = (d5 >>> 13); d5 &= 0x1fff;
  37014. d5 += h5 * r0;
  37015. d5 += h6 * (5 * r9);
  37016. d5 += h7 * (5 * r8);
  37017. d5 += h8 * (5 * r7);
  37018. d5 += h9 * (5 * r6);
  37019. c += (d5 >>> 13); d5 &= 0x1fff;
  37020. d6 = c;
  37021. d6 += h0 * r6;
  37022. d6 += h1 * r5;
  37023. d6 += h2 * r4;
  37024. d6 += h3 * r3;
  37025. d6 += h4 * r2;
  37026. c = (d6 >>> 13); d6 &= 0x1fff;
  37027. d6 += h5 * r1;
  37028. d6 += h6 * r0;
  37029. d6 += h7 * (5 * r9);
  37030. d6 += h8 * (5 * r8);
  37031. d6 += h9 * (5 * r7);
  37032. c += (d6 >>> 13); d6 &= 0x1fff;
  37033. d7 = c;
  37034. d7 += h0 * r7;
  37035. d7 += h1 * r6;
  37036. d7 += h2 * r5;
  37037. d7 += h3 * r4;
  37038. d7 += h4 * r3;
  37039. c = (d7 >>> 13); d7 &= 0x1fff;
  37040. d7 += h5 * r2;
  37041. d7 += h6 * r1;
  37042. d7 += h7 * r0;
  37043. d7 += h8 * (5 * r9);
  37044. d7 += h9 * (5 * r8);
  37045. c += (d7 >>> 13); d7 &= 0x1fff;
  37046. d8 = c;
  37047. d8 += h0 * r8;
  37048. d8 += h1 * r7;
  37049. d8 += h2 * r6;
  37050. d8 += h3 * r5;
  37051. d8 += h4 * r4;
  37052. c = (d8 >>> 13); d8 &= 0x1fff;
  37053. d8 += h5 * r3;
  37054. d8 += h6 * r2;
  37055. d8 += h7 * r1;
  37056. d8 += h8 * r0;
  37057. d8 += h9 * (5 * r9);
  37058. c += (d8 >>> 13); d8 &= 0x1fff;
  37059. d9 = c;
  37060. d9 += h0 * r9;
  37061. d9 += h1 * r8;
  37062. d9 += h2 * r7;
  37063. d9 += h3 * r6;
  37064. d9 += h4 * r5;
  37065. c = (d9 >>> 13); d9 &= 0x1fff;
  37066. d9 += h5 * r4;
  37067. d9 += h6 * r3;
  37068. d9 += h7 * r2;
  37069. d9 += h8 * r1;
  37070. d9 += h9 * r0;
  37071. c += (d9 >>> 13); d9 &= 0x1fff;
  37072. c = (((c << 2) + c)) | 0;
  37073. c = (c + d0) | 0;
  37074. d0 = c & 0x1fff;
  37075. c = (c >>> 13);
  37076. d1 += c;
  37077. h0 = d0;
  37078. h1 = d1;
  37079. h2 = d2;
  37080. h3 = d3;
  37081. h4 = d4;
  37082. h5 = d5;
  37083. h6 = d6;
  37084. h7 = d7;
  37085. h8 = d8;
  37086. h9 = d9;
  37087. mpos += 16;
  37088. bytes -= 16;
  37089. }
  37090. this.h[0] = h0;
  37091. this.h[1] = h1;
  37092. this.h[2] = h2;
  37093. this.h[3] = h3;
  37094. this.h[4] = h4;
  37095. this.h[5] = h5;
  37096. this.h[6] = h6;
  37097. this.h[7] = h7;
  37098. this.h[8] = h8;
  37099. this.h[9] = h9;
  37100. };
  37101. poly1305.prototype.finish = function(mac, macpos) {
  37102. var g = new Uint16Array(10);
  37103. var c, mask, f, i;
  37104. if (this.leftover) {
  37105. i = this.leftover;
  37106. this.buffer[i++] = 1;
  37107. for (; i < 16; i++) this.buffer[i] = 0;
  37108. this.fin = 1;
  37109. this.blocks(this.buffer, 0, 16);
  37110. }
  37111. c = this.h[1] >>> 13;
  37112. this.h[1] &= 0x1fff;
  37113. for (i = 2; i < 10; i++) {
  37114. this.h[i] += c;
  37115. c = this.h[i] >>> 13;
  37116. this.h[i] &= 0x1fff;
  37117. }
  37118. this.h[0] += (c * 5);
  37119. c = this.h[0] >>> 13;
  37120. this.h[0] &= 0x1fff;
  37121. this.h[1] += c;
  37122. c = this.h[1] >>> 13;
  37123. this.h[1] &= 0x1fff;
  37124. this.h[2] += c;
  37125. g[0] = this.h[0] + 5;
  37126. c = g[0] >>> 13;
  37127. g[0] &= 0x1fff;
  37128. for (i = 1; i < 10; i++) {
  37129. g[i] = this.h[i] + c;
  37130. c = g[i] >>> 13;
  37131. g[i] &= 0x1fff;
  37132. }
  37133. g[9] -= (1 << 13);
  37134. mask = (c ^ 1) - 1;
  37135. for (i = 0; i < 10; i++) g[i] &= mask;
  37136. mask = ~mask;
  37137. for (i = 0; i < 10; i++) this.h[i] = (this.h[i] & mask) | g[i];
  37138. this.h[0] = ((this.h[0] ) | (this.h[1] << 13) ) & 0xffff;
  37139. this.h[1] = ((this.h[1] >>> 3) | (this.h[2] << 10) ) & 0xffff;
  37140. this.h[2] = ((this.h[2] >>> 6) | (this.h[3] << 7) ) & 0xffff;
  37141. this.h[3] = ((this.h[3] >>> 9) | (this.h[4] << 4) ) & 0xffff;
  37142. this.h[4] = ((this.h[4] >>> 12) | (this.h[5] << 1) | (this.h[6] << 14)) & 0xffff;
  37143. this.h[5] = ((this.h[6] >>> 2) | (this.h[7] << 11) ) & 0xffff;
  37144. this.h[6] = ((this.h[7] >>> 5) | (this.h[8] << 8) ) & 0xffff;
  37145. this.h[7] = ((this.h[8] >>> 8) | (this.h[9] << 5) ) & 0xffff;
  37146. f = this.h[0] + this.pad[0];
  37147. this.h[0] = f & 0xffff;
  37148. for (i = 1; i < 8; i++) {
  37149. f = (((this.h[i] + this.pad[i]) | 0) + (f >>> 16)) | 0;
  37150. this.h[i] = f & 0xffff;
  37151. }
  37152. mac[macpos+ 0] = (this.h[0] >>> 0) & 0xff;
  37153. mac[macpos+ 1] = (this.h[0] >>> 8) & 0xff;
  37154. mac[macpos+ 2] = (this.h[1] >>> 0) & 0xff;
  37155. mac[macpos+ 3] = (this.h[1] >>> 8) & 0xff;
  37156. mac[macpos+ 4] = (this.h[2] >>> 0) & 0xff;
  37157. mac[macpos+ 5] = (this.h[2] >>> 8) & 0xff;
  37158. mac[macpos+ 6] = (this.h[3] >>> 0) & 0xff;
  37159. mac[macpos+ 7] = (this.h[3] >>> 8) & 0xff;
  37160. mac[macpos+ 8] = (this.h[4] >>> 0) & 0xff;
  37161. mac[macpos+ 9] = (this.h[4] >>> 8) & 0xff;
  37162. mac[macpos+10] = (this.h[5] >>> 0) & 0xff;
  37163. mac[macpos+11] = (this.h[5] >>> 8) & 0xff;
  37164. mac[macpos+12] = (this.h[6] >>> 0) & 0xff;
  37165. mac[macpos+13] = (this.h[6] >>> 8) & 0xff;
  37166. mac[macpos+14] = (this.h[7] >>> 0) & 0xff;
  37167. mac[macpos+15] = (this.h[7] >>> 8) & 0xff;
  37168. };
  37169. poly1305.prototype.update = function(m, mpos, bytes) {
  37170. var i, want;
  37171. if (this.leftover) {
  37172. want = (16 - this.leftover);
  37173. if (want > bytes)
  37174. want = bytes;
  37175. for (i = 0; i < want; i++)
  37176. this.buffer[this.leftover + i] = m[mpos+i];
  37177. bytes -= want;
  37178. mpos += want;
  37179. this.leftover += want;
  37180. if (this.leftover < 16)
  37181. return;
  37182. this.blocks(this.buffer, 0, 16);
  37183. this.leftover = 0;
  37184. }
  37185. if (bytes >= 16) {
  37186. want = bytes - (bytes % 16);
  37187. this.blocks(m, mpos, want);
  37188. mpos += want;
  37189. bytes -= want;
  37190. }
  37191. if (bytes) {
  37192. for (i = 0; i < bytes; i++)
  37193. this.buffer[this.leftover + i] = m[mpos+i];
  37194. this.leftover += bytes;
  37195. }
  37196. };
  37197. function crypto_onetimeauth(out, outpos, m, mpos, n, k) {
  37198. var s = new poly1305(k);
  37199. s.update(m, mpos, n);
  37200. s.finish(out, outpos);
  37201. return 0;
  37202. }
  37203. function crypto_onetimeauth_verify(h, hpos, m, mpos, n, k) {
  37204. var x = new Uint8Array(16);
  37205. crypto_onetimeauth(x,0,m,mpos,n,k);
  37206. return crypto_verify_16(h,hpos,x,0);
  37207. }
  37208. function crypto_secretbox(c,m,d,n,k) {
  37209. var i;
  37210. if (d < 32) return -1;
  37211. crypto_stream_xor(c,0,m,0,d,n,k);
  37212. crypto_onetimeauth(c, 16, c, 32, d - 32, c);
  37213. for (i = 0; i < 16; i++) c[i] = 0;
  37214. return 0;
  37215. }
  37216. function crypto_secretbox_open(m,c,d,n,k) {
  37217. var i;
  37218. var x = new Uint8Array(32);
  37219. if (d < 32) return -1;
  37220. crypto_stream(x,0,32,n,k);
  37221. if (crypto_onetimeauth_verify(c, 16,c, 32,d - 32,x) !== 0) return -1;
  37222. crypto_stream_xor(m,0,c,0,d,n,k);
  37223. for (i = 0; i < 32; i++) m[i] = 0;
  37224. return 0;
  37225. }
  37226. function set25519(r, a) {
  37227. var i;
  37228. for (i = 0; i < 16; i++) r[i] = a[i]|0;
  37229. }
  37230. function car25519(o) {
  37231. var i, v, c = 1;
  37232. for (i = 0; i < 16; i++) {
  37233. v = o[i] + c + 65535;
  37234. c = Math.floor(v / 65536);
  37235. o[i] = v - c * 65536;
  37236. }
  37237. o[0] += c-1 + 37 * (c-1);
  37238. }
  37239. function sel25519(p, q, b) {
  37240. var t, c = ~(b-1);
  37241. for (var i = 0; i < 16; i++) {
  37242. t = c & (p[i] ^ q[i]);
  37243. p[i] ^= t;
  37244. q[i] ^= t;
  37245. }
  37246. }
  37247. function pack25519(o, n) {
  37248. var i, j, b;
  37249. var m = gf(), t = gf();
  37250. for (i = 0; i < 16; i++) t[i] = n[i];
  37251. car25519(t);
  37252. car25519(t);
  37253. car25519(t);
  37254. for (j = 0; j < 2; j++) {
  37255. m[0] = t[0] - 0xffed;
  37256. for (i = 1; i < 15; i++) {
  37257. m[i] = t[i] - 0xffff - ((m[i-1]>>16) & 1);
  37258. m[i-1] &= 0xffff;
  37259. }
  37260. m[15] = t[15] - 0x7fff - ((m[14]>>16) & 1);
  37261. b = (m[15]>>16) & 1;
  37262. m[14] &= 0xffff;
  37263. sel25519(t, m, 1-b);
  37264. }
  37265. for (i = 0; i < 16; i++) {
  37266. o[2*i] = t[i] & 0xff;
  37267. o[2*i+1] = t[i]>>8;
  37268. }
  37269. }
  37270. function neq25519(a, b) {
  37271. var c = new Uint8Array(32), d = new Uint8Array(32);
  37272. pack25519(c, a);
  37273. pack25519(d, b);
  37274. return crypto_verify_32(c, 0, d, 0);
  37275. }
  37276. function par25519(a) {
  37277. var d = new Uint8Array(32);
  37278. pack25519(d, a);
  37279. return d[0] & 1;
  37280. }
  37281. function unpack25519(o, n) {
  37282. var i;
  37283. for (i = 0; i < 16; i++) o[i] = n[2*i] + (n[2*i+1] << 8);
  37284. o[15] &= 0x7fff;
  37285. }
  37286. function A(o, a, b) {
  37287. for (var i = 0; i < 16; i++) o[i] = a[i] + b[i];
  37288. }
  37289. function Z(o, a, b) {
  37290. for (var i = 0; i < 16; i++) o[i] = a[i] - b[i];
  37291. }
  37292. function M(o, a, b) {
  37293. var v, c,
  37294. t0 = 0, t1 = 0, t2 = 0, t3 = 0, t4 = 0, t5 = 0, t6 = 0, t7 = 0,
  37295. t8 = 0, t9 = 0, t10 = 0, t11 = 0, t12 = 0, t13 = 0, t14 = 0, t15 = 0,
  37296. t16 = 0, t17 = 0, t18 = 0, t19 = 0, t20 = 0, t21 = 0, t22 = 0, t23 = 0,
  37297. t24 = 0, t25 = 0, t26 = 0, t27 = 0, t28 = 0, t29 = 0, t30 = 0,
  37298. b0 = b[0],
  37299. b1 = b[1],
  37300. b2 = b[2],
  37301. b3 = b[3],
  37302. b4 = b[4],
  37303. b5 = b[5],
  37304. b6 = b[6],
  37305. b7 = b[7],
  37306. b8 = b[8],
  37307. b9 = b[9],
  37308. b10 = b[10],
  37309. b11 = b[11],
  37310. b12 = b[12],
  37311. b13 = b[13],
  37312. b14 = b[14],
  37313. b15 = b[15];
  37314. v = a[0];
  37315. t0 += v * b0;
  37316. t1 += v * b1;
  37317. t2 += v * b2;
  37318. t3 += v * b3;
  37319. t4 += v * b4;
  37320. t5 += v * b5;
  37321. t6 += v * b6;
  37322. t7 += v * b7;
  37323. t8 += v * b8;
  37324. t9 += v * b9;
  37325. t10 += v * b10;
  37326. t11 += v * b11;
  37327. t12 += v * b12;
  37328. t13 += v * b13;
  37329. t14 += v * b14;
  37330. t15 += v * b15;
  37331. v = a[1];
  37332. t1 += v * b0;
  37333. t2 += v * b1;
  37334. t3 += v * b2;
  37335. t4 += v * b3;
  37336. t5 += v * b4;
  37337. t6 += v * b5;
  37338. t7 += v * b6;
  37339. t8 += v * b7;
  37340. t9 += v * b8;
  37341. t10 += v * b9;
  37342. t11 += v * b10;
  37343. t12 += v * b11;
  37344. t13 += v * b12;
  37345. t14 += v * b13;
  37346. t15 += v * b14;
  37347. t16 += v * b15;
  37348. v = a[2];
  37349. t2 += v * b0;
  37350. t3 += v * b1;
  37351. t4 += v * b2;
  37352. t5 += v * b3;
  37353. t6 += v * b4;
  37354. t7 += v * b5;
  37355. t8 += v * b6;
  37356. t9 += v * b7;
  37357. t10 += v * b8;
  37358. t11 += v * b9;
  37359. t12 += v * b10;
  37360. t13 += v * b11;
  37361. t14 += v * b12;
  37362. t15 += v * b13;
  37363. t16 += v * b14;
  37364. t17 += v * b15;
  37365. v = a[3];
  37366. t3 += v * b0;
  37367. t4 += v * b1;
  37368. t5 += v * b2;
  37369. t6 += v * b3;
  37370. t7 += v * b4;
  37371. t8 += v * b5;
  37372. t9 += v * b6;
  37373. t10 += v * b7;
  37374. t11 += v * b8;
  37375. t12 += v * b9;
  37376. t13 += v * b10;
  37377. t14 += v * b11;
  37378. t15 += v * b12;
  37379. t16 += v * b13;
  37380. t17 += v * b14;
  37381. t18 += v * b15;
  37382. v = a[4];
  37383. t4 += v * b0;
  37384. t5 += v * b1;
  37385. t6 += v * b2;
  37386. t7 += v * b3;
  37387. t8 += v * b4;
  37388. t9 += v * b5;
  37389. t10 += v * b6;
  37390. t11 += v * b7;
  37391. t12 += v * b8;
  37392. t13 += v * b9;
  37393. t14 += v * b10;
  37394. t15 += v * b11;
  37395. t16 += v * b12;
  37396. t17 += v * b13;
  37397. t18 += v * b14;
  37398. t19 += v * b15;
  37399. v = a[5];
  37400. t5 += v * b0;
  37401. t6 += v * b1;
  37402. t7 += v * b2;
  37403. t8 += v * b3;
  37404. t9 += v * b4;
  37405. t10 += v * b5;
  37406. t11 += v * b6;
  37407. t12 += v * b7;
  37408. t13 += v * b8;
  37409. t14 += v * b9;
  37410. t15 += v * b10;
  37411. t16 += v * b11;
  37412. t17 += v * b12;
  37413. t18 += v * b13;
  37414. t19 += v * b14;
  37415. t20 += v * b15;
  37416. v = a[6];
  37417. t6 += v * b0;
  37418. t7 += v * b1;
  37419. t8 += v * b2;
  37420. t9 += v * b3;
  37421. t10 += v * b4;
  37422. t11 += v * b5;
  37423. t12 += v * b6;
  37424. t13 += v * b7;
  37425. t14 += v * b8;
  37426. t15 += v * b9;
  37427. t16 += v * b10;
  37428. t17 += v * b11;
  37429. t18 += v * b12;
  37430. t19 += v * b13;
  37431. t20 += v * b14;
  37432. t21 += v * b15;
  37433. v = a[7];
  37434. t7 += v * b0;
  37435. t8 += v * b1;
  37436. t9 += v * b2;
  37437. t10 += v * b3;
  37438. t11 += v * b4;
  37439. t12 += v * b5;
  37440. t13 += v * b6;
  37441. t14 += v * b7;
  37442. t15 += v * b8;
  37443. t16 += v * b9;
  37444. t17 += v * b10;
  37445. t18 += v * b11;
  37446. t19 += v * b12;
  37447. t20 += v * b13;
  37448. t21 += v * b14;
  37449. t22 += v * b15;
  37450. v = a[8];
  37451. t8 += v * b0;
  37452. t9 += v * b1;
  37453. t10 += v * b2;
  37454. t11 += v * b3;
  37455. t12 += v * b4;
  37456. t13 += v * b5;
  37457. t14 += v * b6;
  37458. t15 += v * b7;
  37459. t16 += v * b8;
  37460. t17 += v * b9;
  37461. t18 += v * b10;
  37462. t19 += v * b11;
  37463. t20 += v * b12;
  37464. t21 += v * b13;
  37465. t22 += v * b14;
  37466. t23 += v * b15;
  37467. v = a[9];
  37468. t9 += v * b0;
  37469. t10 += v * b1;
  37470. t11 += v * b2;
  37471. t12 += v * b3;
  37472. t13 += v * b4;
  37473. t14 += v * b5;
  37474. t15 += v * b6;
  37475. t16 += v * b7;
  37476. t17 += v * b8;
  37477. t18 += v * b9;
  37478. t19 += v * b10;
  37479. t20 += v * b11;
  37480. t21 += v * b12;
  37481. t22 += v * b13;
  37482. t23 += v * b14;
  37483. t24 += v * b15;
  37484. v = a[10];
  37485. t10 += v * b0;
  37486. t11 += v * b1;
  37487. t12 += v * b2;
  37488. t13 += v * b3;
  37489. t14 += v * b4;
  37490. t15 += v * b5;
  37491. t16 += v * b6;
  37492. t17 += v * b7;
  37493. t18 += v * b8;
  37494. t19 += v * b9;
  37495. t20 += v * b10;
  37496. t21 += v * b11;
  37497. t22 += v * b12;
  37498. t23 += v * b13;
  37499. t24 += v * b14;
  37500. t25 += v * b15;
  37501. v = a[11];
  37502. t11 += v * b0;
  37503. t12 += v * b1;
  37504. t13 += v * b2;
  37505. t14 += v * b3;
  37506. t15 += v * b4;
  37507. t16 += v * b5;
  37508. t17 += v * b6;
  37509. t18 += v * b7;
  37510. t19 += v * b8;
  37511. t20 += v * b9;
  37512. t21 += v * b10;
  37513. t22 += v * b11;
  37514. t23 += v * b12;
  37515. t24 += v * b13;
  37516. t25 += v * b14;
  37517. t26 += v * b15;
  37518. v = a[12];
  37519. t12 += v * b0;
  37520. t13 += v * b1;
  37521. t14 += v * b2;
  37522. t15 += v * b3;
  37523. t16 += v * b4;
  37524. t17 += v * b5;
  37525. t18 += v * b6;
  37526. t19 += v * b7;
  37527. t20 += v * b8;
  37528. t21 += v * b9;
  37529. t22 += v * b10;
  37530. t23 += v * b11;
  37531. t24 += v * b12;
  37532. t25 += v * b13;
  37533. t26 += v * b14;
  37534. t27 += v * b15;
  37535. v = a[13];
  37536. t13 += v * b0;
  37537. t14 += v * b1;
  37538. t15 += v * b2;
  37539. t16 += v * b3;
  37540. t17 += v * b4;
  37541. t18 += v * b5;
  37542. t19 += v * b6;
  37543. t20 += v * b7;
  37544. t21 += v * b8;
  37545. t22 += v * b9;
  37546. t23 += v * b10;
  37547. t24 += v * b11;
  37548. t25 += v * b12;
  37549. t26 += v * b13;
  37550. t27 += v * b14;
  37551. t28 += v * b15;
  37552. v = a[14];
  37553. t14 += v * b0;
  37554. t15 += v * b1;
  37555. t16 += v * b2;
  37556. t17 += v * b3;
  37557. t18 += v * b4;
  37558. t19 += v * b5;
  37559. t20 += v * b6;
  37560. t21 += v * b7;
  37561. t22 += v * b8;
  37562. t23 += v * b9;
  37563. t24 += v * b10;
  37564. t25 += v * b11;
  37565. t26 += v * b12;
  37566. t27 += v * b13;
  37567. t28 += v * b14;
  37568. t29 += v * b15;
  37569. v = a[15];
  37570. t15 += v * b0;
  37571. t16 += v * b1;
  37572. t17 += v * b2;
  37573. t18 += v * b3;
  37574. t19 += v * b4;
  37575. t20 += v * b5;
  37576. t21 += v * b6;
  37577. t22 += v * b7;
  37578. t23 += v * b8;
  37579. t24 += v * b9;
  37580. t25 += v * b10;
  37581. t26 += v * b11;
  37582. t27 += v * b12;
  37583. t28 += v * b13;
  37584. t29 += v * b14;
  37585. t30 += v * b15;
  37586. t0 += 38 * t16;
  37587. t1 += 38 * t17;
  37588. t2 += 38 * t18;
  37589. t3 += 38 * t19;
  37590. t4 += 38 * t20;
  37591. t5 += 38 * t21;
  37592. t6 += 38 * t22;
  37593. t7 += 38 * t23;
  37594. t8 += 38 * t24;
  37595. t9 += 38 * t25;
  37596. t10 += 38 * t26;
  37597. t11 += 38 * t27;
  37598. t12 += 38 * t28;
  37599. t13 += 38 * t29;
  37600. t14 += 38 * t30;
  37601. // t15 left as is
  37602. // first car
  37603. c = 1;
  37604. v = t0 + c + 65535; c = Math.floor(v / 65536); t0 = v - c * 65536;
  37605. v = t1 + c + 65535; c = Math.floor(v / 65536); t1 = v - c * 65536;
  37606. v = t2 + c + 65535; c = Math.floor(v / 65536); t2 = v - c * 65536;
  37607. v = t3 + c + 65535; c = Math.floor(v / 65536); t3 = v - c * 65536;
  37608. v = t4 + c + 65535; c = Math.floor(v / 65536); t4 = v - c * 65536;
  37609. v = t5 + c + 65535; c = Math.floor(v / 65536); t5 = v - c * 65536;
  37610. v = t6 + c + 65535; c = Math.floor(v / 65536); t6 = v - c * 65536;
  37611. v = t7 + c + 65535; c = Math.floor(v / 65536); t7 = v - c * 65536;
  37612. v = t8 + c + 65535; c = Math.floor(v / 65536); t8 = v - c * 65536;
  37613. v = t9 + c + 65535; c = Math.floor(v / 65536); t9 = v - c * 65536;
  37614. v = t10 + c + 65535; c = Math.floor(v / 65536); t10 = v - c * 65536;
  37615. v = t11 + c + 65535; c = Math.floor(v / 65536); t11 = v - c * 65536;
  37616. v = t12 + c + 65535; c = Math.floor(v / 65536); t12 = v - c * 65536;
  37617. v = t13 + c + 65535; c = Math.floor(v / 65536); t13 = v - c * 65536;
  37618. v = t14 + c + 65535; c = Math.floor(v / 65536); t14 = v - c * 65536;
  37619. v = t15 + c + 65535; c = Math.floor(v / 65536); t15 = v - c * 65536;
  37620. t0 += c-1 + 37 * (c-1);
  37621. // second car
  37622. c = 1;
  37623. v = t0 + c + 65535; c = Math.floor(v / 65536); t0 = v - c * 65536;
  37624. v = t1 + c + 65535; c = Math.floor(v / 65536); t1 = v - c * 65536;
  37625. v = t2 + c + 65535; c = Math.floor(v / 65536); t2 = v - c * 65536;
  37626. v = t3 + c + 65535; c = Math.floor(v / 65536); t3 = v - c * 65536;
  37627. v = t4 + c + 65535; c = Math.floor(v / 65536); t4 = v - c * 65536;
  37628. v = t5 + c + 65535; c = Math.floor(v / 65536); t5 = v - c * 65536;
  37629. v = t6 + c + 65535; c = Math.floor(v / 65536); t6 = v - c * 65536;
  37630. v = t7 + c + 65535; c = Math.floor(v / 65536); t7 = v - c * 65536;
  37631. v = t8 + c + 65535; c = Math.floor(v / 65536); t8 = v - c * 65536;
  37632. v = t9 + c + 65535; c = Math.floor(v / 65536); t9 = v - c * 65536;
  37633. v = t10 + c + 65535; c = Math.floor(v / 65536); t10 = v - c * 65536;
  37634. v = t11 + c + 65535; c = Math.floor(v / 65536); t11 = v - c * 65536;
  37635. v = t12 + c + 65535; c = Math.floor(v / 65536); t12 = v - c * 65536;
  37636. v = t13 + c + 65535; c = Math.floor(v / 65536); t13 = v - c * 65536;
  37637. v = t14 + c + 65535; c = Math.floor(v / 65536); t14 = v - c * 65536;
  37638. v = t15 + c + 65535; c = Math.floor(v / 65536); t15 = v - c * 65536;
  37639. t0 += c-1 + 37 * (c-1);
  37640. o[ 0] = t0;
  37641. o[ 1] = t1;
  37642. o[ 2] = t2;
  37643. o[ 3] = t3;
  37644. o[ 4] = t4;
  37645. o[ 5] = t5;
  37646. o[ 6] = t6;
  37647. o[ 7] = t7;
  37648. o[ 8] = t8;
  37649. o[ 9] = t9;
  37650. o[10] = t10;
  37651. o[11] = t11;
  37652. o[12] = t12;
  37653. o[13] = t13;
  37654. o[14] = t14;
  37655. o[15] = t15;
  37656. }
  37657. function S(o, a) {
  37658. M(o, a, a);
  37659. }
  37660. function inv25519(o, i) {
  37661. var c = gf();
  37662. var a;
  37663. for (a = 0; a < 16; a++) c[a] = i[a];
  37664. for (a = 253; a >= 0; a--) {
  37665. S(c, c);
  37666. if(a !== 2 && a !== 4) M(c, c, i);
  37667. }
  37668. for (a = 0; a < 16; a++) o[a] = c[a];
  37669. }
  37670. function pow2523(o, i) {
  37671. var c = gf();
  37672. var a;
  37673. for (a = 0; a < 16; a++) c[a] = i[a];
  37674. for (a = 250; a >= 0; a--) {
  37675. S(c, c);
  37676. if(a !== 1) M(c, c, i);
  37677. }
  37678. for (a = 0; a < 16; a++) o[a] = c[a];
  37679. }
  37680. function crypto_scalarmult(q, n, p) {
  37681. var z = new Uint8Array(32);
  37682. var x = new Float64Array(80), r, i;
  37683. var a = gf(), b = gf(), c = gf(),
  37684. d = gf(), e = gf(), f = gf();
  37685. for (i = 0; i < 31; i++) z[i] = n[i];
  37686. z[31]=(n[31]&127)|64;
  37687. z[0]&=248;
  37688. unpack25519(x,p);
  37689. for (i = 0; i < 16; i++) {
  37690. b[i]=x[i];
  37691. d[i]=a[i]=c[i]=0;
  37692. }
  37693. a[0]=d[0]=1;
  37694. for (i=254; i>=0; --i) {
  37695. r=(z[i>>>3]>>>(i&7))&1;
  37696. sel25519(a,b,r);
  37697. sel25519(c,d,r);
  37698. A(e,a,c);
  37699. Z(a,a,c);
  37700. A(c,b,d);
  37701. Z(b,b,d);
  37702. S(d,e);
  37703. S(f,a);
  37704. M(a,c,a);
  37705. M(c,b,e);
  37706. A(e,a,c);
  37707. Z(a,a,c);
  37708. S(b,a);
  37709. Z(c,d,f);
  37710. M(a,c,_121665);
  37711. A(a,a,d);
  37712. M(c,c,a);
  37713. M(a,d,f);
  37714. M(d,b,x);
  37715. S(b,e);
  37716. sel25519(a,b,r);
  37717. sel25519(c,d,r);
  37718. }
  37719. for (i = 0; i < 16; i++) {
  37720. x[i+16]=a[i];
  37721. x[i+32]=c[i];
  37722. x[i+48]=b[i];
  37723. x[i+64]=d[i];
  37724. }
  37725. var x32 = x.subarray(32);
  37726. var x16 = x.subarray(16);
  37727. inv25519(x32,x32);
  37728. M(x16,x16,x32);
  37729. pack25519(q,x16);
  37730. return 0;
  37731. }
  37732. function crypto_scalarmult_base(q, n) {
  37733. return crypto_scalarmult(q, n, _9);
  37734. }
  37735. function crypto_box_keypair(y, x) {
  37736. randombytes(x, 32);
  37737. return crypto_scalarmult_base(y, x);
  37738. }
  37739. function crypto_box_beforenm(k, y, x) {
  37740. var s = new Uint8Array(32);
  37741. crypto_scalarmult(s, x, y);
  37742. return crypto_core_hsalsa20(k, _0, s, sigma);
  37743. }
  37744. var crypto_box_afternm = crypto_secretbox;
  37745. var crypto_box_open_afternm = crypto_secretbox_open;
  37746. function crypto_box(c, m, d, n, y, x) {
  37747. var k = new Uint8Array(32);
  37748. crypto_box_beforenm(k, y, x);
  37749. return crypto_box_afternm(c, m, d, n, k);
  37750. }
  37751. function crypto_box_open(m, c, d, n, y, x) {
  37752. var k = new Uint8Array(32);
  37753. crypto_box_beforenm(k, y, x);
  37754. return crypto_box_open_afternm(m, c, d, n, k);
  37755. }
  37756. var K = [
  37757. 0x428a2f98, 0xd728ae22, 0x71374491, 0x23ef65cd,
  37758. 0xb5c0fbcf, 0xec4d3b2f, 0xe9b5dba5, 0x8189dbbc,
  37759. 0x3956c25b, 0xf348b538, 0x59f111f1, 0xb605d019,
  37760. 0x923f82a4, 0xaf194f9b, 0xab1c5ed5, 0xda6d8118,
  37761. 0xd807aa98, 0xa3030242, 0x12835b01, 0x45706fbe,
  37762. 0x243185be, 0x4ee4b28c, 0x550c7dc3, 0xd5ffb4e2,
  37763. 0x72be5d74, 0xf27b896f, 0x80deb1fe, 0x3b1696b1,
  37764. 0x9bdc06a7, 0x25c71235, 0xc19bf174, 0xcf692694,
  37765. 0xe49b69c1, 0x9ef14ad2, 0xefbe4786, 0x384f25e3,
  37766. 0x0fc19dc6, 0x8b8cd5b5, 0x240ca1cc, 0x77ac9c65,
  37767. 0x2de92c6f, 0x592b0275, 0x4a7484aa, 0x6ea6e483,
  37768. 0x5cb0a9dc, 0xbd41fbd4, 0x76f988da, 0x831153b5,
  37769. 0x983e5152, 0xee66dfab, 0xa831c66d, 0x2db43210,
  37770. 0xb00327c8, 0x98fb213f, 0xbf597fc7, 0xbeef0ee4,
  37771. 0xc6e00bf3, 0x3da88fc2, 0xd5a79147, 0x930aa725,
  37772. 0x06ca6351, 0xe003826f, 0x14292967, 0x0a0e6e70,
  37773. 0x27b70a85, 0x46d22ffc, 0x2e1b2138, 0x5c26c926,
  37774. 0x4d2c6dfc, 0x5ac42aed, 0x53380d13, 0x9d95b3df,
  37775. 0x650a7354, 0x8baf63de, 0x766a0abb, 0x3c77b2a8,
  37776. 0x81c2c92e, 0x47edaee6, 0x92722c85, 0x1482353b,
  37777. 0xa2bfe8a1, 0x4cf10364, 0xa81a664b, 0xbc423001,
  37778. 0xc24b8b70, 0xd0f89791, 0xc76c51a3, 0x0654be30,
  37779. 0xd192e819, 0xd6ef5218, 0xd6990624, 0x5565a910,
  37780. 0xf40e3585, 0x5771202a, 0x106aa070, 0x32bbd1b8,
  37781. 0x19a4c116, 0xb8d2d0c8, 0x1e376c08, 0x5141ab53,
  37782. 0x2748774c, 0xdf8eeb99, 0x34b0bcb5, 0xe19b48a8,
  37783. 0x391c0cb3, 0xc5c95a63, 0x4ed8aa4a, 0xe3418acb,
  37784. 0x5b9cca4f, 0x7763e373, 0x682e6ff3, 0xd6b2b8a3,
  37785. 0x748f82ee, 0x5defb2fc, 0x78a5636f, 0x43172f60,
  37786. 0x84c87814, 0xa1f0ab72, 0x8cc70208, 0x1a6439ec,
  37787. 0x90befffa, 0x23631e28, 0xa4506ceb, 0xde82bde9,
  37788. 0xbef9a3f7, 0xb2c67915, 0xc67178f2, 0xe372532b,
  37789. 0xca273ece, 0xea26619c, 0xd186b8c7, 0x21c0c207,
  37790. 0xeada7dd6, 0xcde0eb1e, 0xf57d4f7f, 0xee6ed178,
  37791. 0x06f067aa, 0x72176fba, 0x0a637dc5, 0xa2c898a6,
  37792. 0x113f9804, 0xbef90dae, 0x1b710b35, 0x131c471b,
  37793. 0x28db77f5, 0x23047d84, 0x32caab7b, 0x40c72493,
  37794. 0x3c9ebe0a, 0x15c9bebc, 0x431d67c4, 0x9c100d4c,
  37795. 0x4cc5d4be, 0xcb3e42b6, 0x597f299c, 0xfc657e2a,
  37796. 0x5fcb6fab, 0x3ad6faec, 0x6c44198c, 0x4a475817
  37797. ];
  37798. function crypto_hashblocks_hl(hh, hl, m, n) {
  37799. var wh = new Int32Array(16), wl = new Int32Array(16),
  37800. bh0, bh1, bh2, bh3, bh4, bh5, bh6, bh7,
  37801. bl0, bl1, bl2, bl3, bl4, bl5, bl6, bl7,
  37802. th, tl, i, j, h, l, a, b, c, d;
  37803. var ah0 = hh[0],
  37804. ah1 = hh[1],
  37805. ah2 = hh[2],
  37806. ah3 = hh[3],
  37807. ah4 = hh[4],
  37808. ah5 = hh[5],
  37809. ah6 = hh[6],
  37810. ah7 = hh[7],
  37811. al0 = hl[0],
  37812. al1 = hl[1],
  37813. al2 = hl[2],
  37814. al3 = hl[3],
  37815. al4 = hl[4],
  37816. al5 = hl[5],
  37817. al6 = hl[6],
  37818. al7 = hl[7];
  37819. var pos = 0;
  37820. while (n >= 128) {
  37821. for (i = 0; i < 16; i++) {
  37822. j = 8 * i + pos;
  37823. wh[i] = (m[j+0] << 24) | (m[j+1] << 16) | (m[j+2] << 8) | m[j+3];
  37824. wl[i] = (m[j+4] << 24) | (m[j+5] << 16) | (m[j+6] << 8) | m[j+7];
  37825. }
  37826. for (i = 0; i < 80; i++) {
  37827. bh0 = ah0;
  37828. bh1 = ah1;
  37829. bh2 = ah2;
  37830. bh3 = ah3;
  37831. bh4 = ah4;
  37832. bh5 = ah5;
  37833. bh6 = ah6;
  37834. bh7 = ah7;
  37835. bl0 = al0;
  37836. bl1 = al1;
  37837. bl2 = al2;
  37838. bl3 = al3;
  37839. bl4 = al4;
  37840. bl5 = al5;
  37841. bl6 = al6;
  37842. bl7 = al7;
  37843. // add
  37844. h = ah7;
  37845. l = al7;
  37846. a = l & 0xffff; b = l >>> 16;
  37847. c = h & 0xffff; d = h >>> 16;
  37848. // Sigma1
  37849. h = ((ah4 >>> 14) | (al4 << (32-14))) ^ ((ah4 >>> 18) | (al4 << (32-18))) ^ ((al4 >>> (41-32)) | (ah4 << (32-(41-32))));
  37850. l = ((al4 >>> 14) | (ah4 << (32-14))) ^ ((al4 >>> 18) | (ah4 << (32-18))) ^ ((ah4 >>> (41-32)) | (al4 << (32-(41-32))));
  37851. a += l & 0xffff; b += l >>> 16;
  37852. c += h & 0xffff; d += h >>> 16;
  37853. // Ch
  37854. h = (ah4 & ah5) ^ (~ah4 & ah6);
  37855. l = (al4 & al5) ^ (~al4 & al6);
  37856. a += l & 0xffff; b += l >>> 16;
  37857. c += h & 0xffff; d += h >>> 16;
  37858. // K
  37859. h = K[i*2];
  37860. l = K[i*2+1];
  37861. a += l & 0xffff; b += l >>> 16;
  37862. c += h & 0xffff; d += h >>> 16;
  37863. // w
  37864. h = wh[i%16];
  37865. l = wl[i%16];
  37866. a += l & 0xffff; b += l >>> 16;
  37867. c += h & 0xffff; d += h >>> 16;
  37868. b += a >>> 16;
  37869. c += b >>> 16;
  37870. d += c >>> 16;
  37871. th = c & 0xffff | d << 16;
  37872. tl = a & 0xffff | b << 16;
  37873. // add
  37874. h = th;
  37875. l = tl;
  37876. a = l & 0xffff; b = l >>> 16;
  37877. c = h & 0xffff; d = h >>> 16;
  37878. // Sigma0
  37879. h = ((ah0 >>> 28) | (al0 << (32-28))) ^ ((al0 >>> (34-32)) | (ah0 << (32-(34-32)))) ^ ((al0 >>> (39-32)) | (ah0 << (32-(39-32))));
  37880. l = ((al0 >>> 28) | (ah0 << (32-28))) ^ ((ah0 >>> (34-32)) | (al0 << (32-(34-32)))) ^ ((ah0 >>> (39-32)) | (al0 << (32-(39-32))));
  37881. a += l & 0xffff; b += l >>> 16;
  37882. c += h & 0xffff; d += h >>> 16;
  37883. // Maj
  37884. h = (ah0 & ah1) ^ (ah0 & ah2) ^ (ah1 & ah2);
  37885. l = (al0 & al1) ^ (al0 & al2) ^ (al1 & al2);
  37886. a += l & 0xffff; b += l >>> 16;
  37887. c += h & 0xffff; d += h >>> 16;
  37888. b += a >>> 16;
  37889. c += b >>> 16;
  37890. d += c >>> 16;
  37891. bh7 = (c & 0xffff) | (d << 16);
  37892. bl7 = (a & 0xffff) | (b << 16);
  37893. // add
  37894. h = bh3;
  37895. l = bl3;
  37896. a = l & 0xffff; b = l >>> 16;
  37897. c = h & 0xffff; d = h >>> 16;
  37898. h = th;
  37899. l = tl;
  37900. a += l & 0xffff; b += l >>> 16;
  37901. c += h & 0xffff; d += h >>> 16;
  37902. b += a >>> 16;
  37903. c += b >>> 16;
  37904. d += c >>> 16;
  37905. bh3 = (c & 0xffff) | (d << 16);
  37906. bl3 = (a & 0xffff) | (b << 16);
  37907. ah1 = bh0;
  37908. ah2 = bh1;
  37909. ah3 = bh2;
  37910. ah4 = bh3;
  37911. ah5 = bh4;
  37912. ah6 = bh5;
  37913. ah7 = bh6;
  37914. ah0 = bh7;
  37915. al1 = bl0;
  37916. al2 = bl1;
  37917. al3 = bl2;
  37918. al4 = bl3;
  37919. al5 = bl4;
  37920. al6 = bl5;
  37921. al7 = bl6;
  37922. al0 = bl7;
  37923. if (i%16 === 15) {
  37924. for (j = 0; j < 16; j++) {
  37925. // add
  37926. h = wh[j];
  37927. l = wl[j];
  37928. a = l & 0xffff; b = l >>> 16;
  37929. c = h & 0xffff; d = h >>> 16;
  37930. h = wh[(j+9)%16];
  37931. l = wl[(j+9)%16];
  37932. a += l & 0xffff; b += l >>> 16;
  37933. c += h & 0xffff; d += h >>> 16;
  37934. // sigma0
  37935. th = wh[(j+1)%16];
  37936. tl = wl[(j+1)%16];
  37937. h = ((th >>> 1) | (tl << (32-1))) ^ ((th >>> 8) | (tl << (32-8))) ^ (th >>> 7);
  37938. l = ((tl >>> 1) | (th << (32-1))) ^ ((tl >>> 8) | (th << (32-8))) ^ ((tl >>> 7) | (th << (32-7)));
  37939. a += l & 0xffff; b += l >>> 16;
  37940. c += h & 0xffff; d += h >>> 16;
  37941. // sigma1
  37942. th = wh[(j+14)%16];
  37943. tl = wl[(j+14)%16];
  37944. h = ((th >>> 19) | (tl << (32-19))) ^ ((tl >>> (61-32)) | (th << (32-(61-32)))) ^ (th >>> 6);
  37945. l = ((tl >>> 19) | (th << (32-19))) ^ ((th >>> (61-32)) | (tl << (32-(61-32)))) ^ ((tl >>> 6) | (th << (32-6)));
  37946. a += l & 0xffff; b += l >>> 16;
  37947. c += h & 0xffff; d += h >>> 16;
  37948. b += a >>> 16;
  37949. c += b >>> 16;
  37950. d += c >>> 16;
  37951. wh[j] = (c & 0xffff) | (d << 16);
  37952. wl[j] = (a & 0xffff) | (b << 16);
  37953. }
  37954. }
  37955. }
  37956. // add
  37957. h = ah0;
  37958. l = al0;
  37959. a = l & 0xffff; b = l >>> 16;
  37960. c = h & 0xffff; d = h >>> 16;
  37961. h = hh[0];
  37962. l = hl[0];
  37963. a += l & 0xffff; b += l >>> 16;
  37964. c += h & 0xffff; d += h >>> 16;
  37965. b += a >>> 16;
  37966. c += b >>> 16;
  37967. d += c >>> 16;
  37968. hh[0] = ah0 = (c & 0xffff) | (d << 16);
  37969. hl[0] = al0 = (a & 0xffff) | (b << 16);
  37970. h = ah1;
  37971. l = al1;
  37972. a = l & 0xffff; b = l >>> 16;
  37973. c = h & 0xffff; d = h >>> 16;
  37974. h = hh[1];
  37975. l = hl[1];
  37976. a += l & 0xffff; b += l >>> 16;
  37977. c += h & 0xffff; d += h >>> 16;
  37978. b += a >>> 16;
  37979. c += b >>> 16;
  37980. d += c >>> 16;
  37981. hh[1] = ah1 = (c & 0xffff) | (d << 16);
  37982. hl[1] = al1 = (a & 0xffff) | (b << 16);
  37983. h = ah2;
  37984. l = al2;
  37985. a = l & 0xffff; b = l >>> 16;
  37986. c = h & 0xffff; d = h >>> 16;
  37987. h = hh[2];
  37988. l = hl[2];
  37989. a += l & 0xffff; b += l >>> 16;
  37990. c += h & 0xffff; d += h >>> 16;
  37991. b += a >>> 16;
  37992. c += b >>> 16;
  37993. d += c >>> 16;
  37994. hh[2] = ah2 = (c & 0xffff) | (d << 16);
  37995. hl[2] = al2 = (a & 0xffff) | (b << 16);
  37996. h = ah3;
  37997. l = al3;
  37998. a = l & 0xffff; b = l >>> 16;
  37999. c = h & 0xffff; d = h >>> 16;
  38000. h = hh[3];
  38001. l = hl[3];
  38002. a += l & 0xffff; b += l >>> 16;
  38003. c += h & 0xffff; d += h >>> 16;
  38004. b += a >>> 16;
  38005. c += b >>> 16;
  38006. d += c >>> 16;
  38007. hh[3] = ah3 = (c & 0xffff) | (d << 16);
  38008. hl[3] = al3 = (a & 0xffff) | (b << 16);
  38009. h = ah4;
  38010. l = al4;
  38011. a = l & 0xffff; b = l >>> 16;
  38012. c = h & 0xffff; d = h >>> 16;
  38013. h = hh[4];
  38014. l = hl[4];
  38015. a += l & 0xffff; b += l >>> 16;
  38016. c += h & 0xffff; d += h >>> 16;
  38017. b += a >>> 16;
  38018. c += b >>> 16;
  38019. d += c >>> 16;
  38020. hh[4] = ah4 = (c & 0xffff) | (d << 16);
  38021. hl[4] = al4 = (a & 0xffff) | (b << 16);
  38022. h = ah5;
  38023. l = al5;
  38024. a = l & 0xffff; b = l >>> 16;
  38025. c = h & 0xffff; d = h >>> 16;
  38026. h = hh[5];
  38027. l = hl[5];
  38028. a += l & 0xffff; b += l >>> 16;
  38029. c += h & 0xffff; d += h >>> 16;
  38030. b += a >>> 16;
  38031. c += b >>> 16;
  38032. d += c >>> 16;
  38033. hh[5] = ah5 = (c & 0xffff) | (d << 16);
  38034. hl[5] = al5 = (a & 0xffff) | (b << 16);
  38035. h = ah6;
  38036. l = al6;
  38037. a = l & 0xffff; b = l >>> 16;
  38038. c = h & 0xffff; d = h >>> 16;
  38039. h = hh[6];
  38040. l = hl[6];
  38041. a += l & 0xffff; b += l >>> 16;
  38042. c += h & 0xffff; d += h >>> 16;
  38043. b += a >>> 16;
  38044. c += b >>> 16;
  38045. d += c >>> 16;
  38046. hh[6] = ah6 = (c & 0xffff) | (d << 16);
  38047. hl[6] = al6 = (a & 0xffff) | (b << 16);
  38048. h = ah7;
  38049. l = al7;
  38050. a = l & 0xffff; b = l >>> 16;
  38051. c = h & 0xffff; d = h >>> 16;
  38052. h = hh[7];
  38053. l = hl[7];
  38054. a += l & 0xffff; b += l >>> 16;
  38055. c += h & 0xffff; d += h >>> 16;
  38056. b += a >>> 16;
  38057. c += b >>> 16;
  38058. d += c >>> 16;
  38059. hh[7] = ah7 = (c & 0xffff) | (d << 16);
  38060. hl[7] = al7 = (a & 0xffff) | (b << 16);
  38061. pos += 128;
  38062. n -= 128;
  38063. }
  38064. return n;
  38065. }
  38066. function crypto_hash(out, m, n) {
  38067. var hh = new Int32Array(8),
  38068. hl = new Int32Array(8),
  38069. x = new Uint8Array(256),
  38070. i, b = n;
  38071. hh[0] = 0x6a09e667;
  38072. hh[1] = 0xbb67ae85;
  38073. hh[2] = 0x3c6ef372;
  38074. hh[3] = 0xa54ff53a;
  38075. hh[4] = 0x510e527f;
  38076. hh[5] = 0x9b05688c;
  38077. hh[6] = 0x1f83d9ab;
  38078. hh[7] = 0x5be0cd19;
  38079. hl[0] = 0xf3bcc908;
  38080. hl[1] = 0x84caa73b;
  38081. hl[2] = 0xfe94f82b;
  38082. hl[3] = 0x5f1d36f1;
  38083. hl[4] = 0xade682d1;
  38084. hl[5] = 0x2b3e6c1f;
  38085. hl[6] = 0xfb41bd6b;
  38086. hl[7] = 0x137e2179;
  38087. crypto_hashblocks_hl(hh, hl, m, n);
  38088. n %= 128;
  38089. for (i = 0; i < n; i++) x[i] = m[b-n+i];
  38090. x[n] = 128;
  38091. n = 256-128*(n<112?1:0);
  38092. x[n-9] = 0;
  38093. ts64(x, n-8, (b / 0x20000000) | 0, b << 3);
  38094. crypto_hashblocks_hl(hh, hl, x, n);
  38095. for (i = 0; i < 8; i++) ts64(out, 8*i, hh[i], hl[i]);
  38096. return 0;
  38097. }
  38098. function add(p, q) {
  38099. var a = gf(), b = gf(), c = gf(),
  38100. d = gf(), e = gf(), f = gf(),
  38101. g = gf(), h = gf(), t = gf();
  38102. Z(a, p[1], p[0]);
  38103. Z(t, q[1], q[0]);
  38104. M(a, a, t);
  38105. A(b, p[0], p[1]);
  38106. A(t, q[0], q[1]);
  38107. M(b, b, t);
  38108. M(c, p[3], q[3]);
  38109. M(c, c, D2);
  38110. M(d, p[2], q[2]);
  38111. A(d, d, d);
  38112. Z(e, b, a);
  38113. Z(f, d, c);
  38114. A(g, d, c);
  38115. A(h, b, a);
  38116. M(p[0], e, f);
  38117. M(p[1], h, g);
  38118. M(p[2], g, f);
  38119. M(p[3], e, h);
  38120. }
  38121. function cswap(p, q, b) {
  38122. var i;
  38123. for (i = 0; i < 4; i++) {
  38124. sel25519(p[i], q[i], b);
  38125. }
  38126. }
  38127. function pack(r, p) {
  38128. var tx = gf(), ty = gf(), zi = gf();
  38129. inv25519(zi, p[2]);
  38130. M(tx, p[0], zi);
  38131. M(ty, p[1], zi);
  38132. pack25519(r, ty);
  38133. r[31] ^= par25519(tx) << 7;
  38134. }
  38135. function scalarmult(p, q, s) {
  38136. var b, i;
  38137. set25519(p[0], gf0);
  38138. set25519(p[1], gf1);
  38139. set25519(p[2], gf1);
  38140. set25519(p[3], gf0);
  38141. for (i = 255; i >= 0; --i) {
  38142. b = (s[(i/8)|0] >> (i&7)) & 1;
  38143. cswap(p, q, b);
  38144. add(q, p);
  38145. add(p, p);
  38146. cswap(p, q, b);
  38147. }
  38148. }
  38149. function scalarbase(p, s) {
  38150. var q = [gf(), gf(), gf(), gf()];
  38151. set25519(q[0], X);
  38152. set25519(q[1], Y);
  38153. set25519(q[2], gf1);
  38154. M(q[3], X, Y);
  38155. scalarmult(p, q, s);
  38156. }
  38157. function crypto_sign_keypair(pk, sk, seeded) {
  38158. var d = new Uint8Array(64);
  38159. var p = [gf(), gf(), gf(), gf()];
  38160. var i;
  38161. if (!seeded) randombytes(sk, 32);
  38162. crypto_hash(d, sk, 32);
  38163. d[0] &= 248;
  38164. d[31] &= 127;
  38165. d[31] |= 64;
  38166. scalarbase(p, d);
  38167. pack(pk, p);
  38168. for (i = 0; i < 32; i++) sk[i+32] = pk[i];
  38169. return 0;
  38170. }
  38171. 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]);
  38172. function modL(r, x) {
  38173. var carry, i, j, k;
  38174. for (i = 63; i >= 32; --i) {
  38175. carry = 0;
  38176. for (j = i - 32, k = i - 12; j < k; ++j) {
  38177. x[j] += carry - 16 * x[i] * L[j - (i - 32)];
  38178. carry = (x[j] + 128) >> 8;
  38179. x[j] -= carry * 256;
  38180. }
  38181. x[j] += carry;
  38182. x[i] = 0;
  38183. }
  38184. carry = 0;
  38185. for (j = 0; j < 32; j++) {
  38186. x[j] += carry - (x[31] >> 4) * L[j];
  38187. carry = x[j] >> 8;
  38188. x[j] &= 255;
  38189. }
  38190. for (j = 0; j < 32; j++) x[j] -= carry * L[j];
  38191. for (i = 0; i < 32; i++) {
  38192. x[i+1] += x[i] >> 8;
  38193. r[i] = x[i] & 255;
  38194. }
  38195. }
  38196. function reduce(r) {
  38197. var x = new Float64Array(64), i;
  38198. for (i = 0; i < 64; i++) x[i] = r[i];
  38199. for (i = 0; i < 64; i++) r[i] = 0;
  38200. modL(r, x);
  38201. }
  38202. // Note: difference from C - smlen returned, not passed as argument.
  38203. function crypto_sign(sm, m, n, sk) {
  38204. var d = new Uint8Array(64), h = new Uint8Array(64), r = new Uint8Array(64);
  38205. var i, j, x = new Float64Array(64);
  38206. var p = [gf(), gf(), gf(), gf()];
  38207. crypto_hash(d, sk, 32);
  38208. d[0] &= 248;
  38209. d[31] &= 127;
  38210. d[31] |= 64;
  38211. var smlen = n + 64;
  38212. for (i = 0; i < n; i++) sm[64 + i] = m[i];
  38213. for (i = 0; i < 32; i++) sm[32 + i] = d[32 + i];
  38214. crypto_hash(r, sm.subarray(32), n+32);
  38215. reduce(r);
  38216. scalarbase(p, r);
  38217. pack(sm, p);
  38218. for (i = 32; i < 64; i++) sm[i] = sk[i];
  38219. crypto_hash(h, sm, n + 64);
  38220. reduce(h);
  38221. for (i = 0; i < 64; i++) x[i] = 0;
  38222. for (i = 0; i < 32; i++) x[i] = r[i];
  38223. for (i = 0; i < 32; i++) {
  38224. for (j = 0; j < 32; j++) {
  38225. x[i+j] += h[i] * d[j];
  38226. }
  38227. }
  38228. modL(sm.subarray(32), x);
  38229. return smlen;
  38230. }
  38231. function unpackneg(r, p) {
  38232. var t = gf(), chk = gf(), num = gf(),
  38233. den = gf(), den2 = gf(), den4 = gf(),
  38234. den6 = gf();
  38235. set25519(r[2], gf1);
  38236. unpack25519(r[1], p);
  38237. S(num, r[1]);
  38238. M(den, num, D);
  38239. Z(num, num, r[2]);
  38240. A(den, r[2], den);
  38241. S(den2, den);
  38242. S(den4, den2);
  38243. M(den6, den4, den2);
  38244. M(t, den6, num);
  38245. M(t, t, den);
  38246. pow2523(t, t);
  38247. M(t, t, num);
  38248. M(t, t, den);
  38249. M(t, t, den);
  38250. M(r[0], t, den);
  38251. S(chk, r[0]);
  38252. M(chk, chk, den);
  38253. if (neq25519(chk, num)) M(r[0], r[0], I);
  38254. S(chk, r[0]);
  38255. M(chk, chk, den);
  38256. if (neq25519(chk, num)) return -1;
  38257. if (par25519(r[0]) === (p[31]>>7)) Z(r[0], gf0, r[0]);
  38258. M(r[3], r[0], r[1]);
  38259. return 0;
  38260. }
  38261. function crypto_sign_open(m, sm, n, pk) {
  38262. var i, mlen;
  38263. var t = new Uint8Array(32), h = new Uint8Array(64);
  38264. var p = [gf(), gf(), gf(), gf()],
  38265. q = [gf(), gf(), gf(), gf()];
  38266. mlen = -1;
  38267. if (n < 64) return -1;
  38268. if (unpackneg(q, pk)) return -1;
  38269. for (i = 0; i < n; i++) m[i] = sm[i];
  38270. for (i = 0; i < 32; i++) m[i+32] = pk[i];
  38271. crypto_hash(h, m, n);
  38272. reduce(h);
  38273. scalarmult(p, q, h);
  38274. scalarbase(q, sm.subarray(32));
  38275. add(p, q);
  38276. pack(t, p);
  38277. n -= 64;
  38278. if (crypto_verify_32(sm, 0, t, 0)) {
  38279. for (i = 0; i < n; i++) m[i] = 0;
  38280. return -1;
  38281. }
  38282. for (i = 0; i < n; i++) m[i] = sm[i + 64];
  38283. mlen = n;
  38284. return mlen;
  38285. }
  38286. var crypto_secretbox_KEYBYTES = 32,
  38287. crypto_secretbox_NONCEBYTES = 24,
  38288. crypto_secretbox_ZEROBYTES = 32,
  38289. crypto_secretbox_BOXZEROBYTES = 16,
  38290. crypto_scalarmult_BYTES = 32,
  38291. crypto_scalarmult_SCALARBYTES = 32,
  38292. crypto_box_PUBLICKEYBYTES = 32,
  38293. crypto_box_SECRETKEYBYTES = 32,
  38294. crypto_box_BEFORENMBYTES = 32,
  38295. crypto_box_NONCEBYTES = crypto_secretbox_NONCEBYTES,
  38296. crypto_box_ZEROBYTES = crypto_secretbox_ZEROBYTES,
  38297. crypto_box_BOXZEROBYTES = crypto_secretbox_BOXZEROBYTES,
  38298. crypto_sign_BYTES = 64,
  38299. crypto_sign_PUBLICKEYBYTES = 32,
  38300. crypto_sign_SECRETKEYBYTES = 64,
  38301. crypto_sign_SEEDBYTES = 32,
  38302. crypto_hash_BYTES = 64;
  38303. nacl.lowlevel = {
  38304. crypto_core_hsalsa20: crypto_core_hsalsa20,
  38305. crypto_stream_xor: crypto_stream_xor,
  38306. crypto_stream: crypto_stream,
  38307. crypto_stream_salsa20_xor: crypto_stream_salsa20_xor,
  38308. crypto_stream_salsa20: crypto_stream_salsa20,
  38309. crypto_onetimeauth: crypto_onetimeauth,
  38310. crypto_onetimeauth_verify: crypto_onetimeauth_verify,
  38311. crypto_verify_16: crypto_verify_16,
  38312. crypto_verify_32: crypto_verify_32,
  38313. crypto_secretbox: crypto_secretbox,
  38314. crypto_secretbox_open: crypto_secretbox_open,
  38315. crypto_scalarmult: crypto_scalarmult,
  38316. crypto_scalarmult_base: crypto_scalarmult_base,
  38317. crypto_box_beforenm: crypto_box_beforenm,
  38318. crypto_box_afternm: crypto_box_afternm,
  38319. crypto_box: crypto_box,
  38320. crypto_box_open: crypto_box_open,
  38321. crypto_box_keypair: crypto_box_keypair,
  38322. crypto_hash: crypto_hash,
  38323. crypto_sign: crypto_sign,
  38324. crypto_sign_keypair: crypto_sign_keypair,
  38325. crypto_sign_open: crypto_sign_open,
  38326. crypto_secretbox_KEYBYTES: crypto_secretbox_KEYBYTES,
  38327. crypto_secretbox_NONCEBYTES: crypto_secretbox_NONCEBYTES,
  38328. crypto_secretbox_ZEROBYTES: crypto_secretbox_ZEROBYTES,
  38329. crypto_secretbox_BOXZEROBYTES: crypto_secretbox_BOXZEROBYTES,
  38330. crypto_scalarmult_BYTES: crypto_scalarmult_BYTES,
  38331. crypto_scalarmult_SCALARBYTES: crypto_scalarmult_SCALARBYTES,
  38332. crypto_box_PUBLICKEYBYTES: crypto_box_PUBLICKEYBYTES,
  38333. crypto_box_SECRETKEYBYTES: crypto_box_SECRETKEYBYTES,
  38334. crypto_box_BEFORENMBYTES: crypto_box_BEFORENMBYTES,
  38335. crypto_box_NONCEBYTES: crypto_box_NONCEBYTES,
  38336. crypto_box_ZEROBYTES: crypto_box_ZEROBYTES,
  38337. crypto_box_BOXZEROBYTES: crypto_box_BOXZEROBYTES,
  38338. crypto_sign_BYTES: crypto_sign_BYTES,
  38339. crypto_sign_PUBLICKEYBYTES: crypto_sign_PUBLICKEYBYTES,
  38340. crypto_sign_SECRETKEYBYTES: crypto_sign_SECRETKEYBYTES,
  38341. crypto_sign_SEEDBYTES: crypto_sign_SEEDBYTES,
  38342. crypto_hash_BYTES: crypto_hash_BYTES
  38343. };
  38344. /* High-level API */
  38345. function checkLengths(k, n) {
  38346. if (k.length !== crypto_secretbox_KEYBYTES) throw new Error('bad key size');
  38347. if (n.length !== crypto_secretbox_NONCEBYTES) throw new Error('bad nonce size');
  38348. }
  38349. function checkBoxLengths(pk, sk) {
  38350. if (pk.length !== crypto_box_PUBLICKEYBYTES) throw new Error('bad public key size');
  38351. if (sk.length !== crypto_box_SECRETKEYBYTES) throw new Error('bad secret key size');
  38352. }
  38353. function checkArrayTypes() {
  38354. for (var i = 0; i < arguments.length; i++) {
  38355. if (!(arguments[i] instanceof Uint8Array))
  38356. throw new TypeError('unexpected type, use Uint8Array');
  38357. }
  38358. }
  38359. function cleanup(arr) {
  38360. for (var i = 0; i < arr.length; i++) arr[i] = 0;
  38361. }
  38362. nacl.randomBytes = function(n) {
  38363. var b = new Uint8Array(n);
  38364. randombytes(b, n);
  38365. return b;
  38366. };
  38367. nacl.secretbox = function(msg, nonce, key) {
  38368. checkArrayTypes(msg, nonce, key);
  38369. checkLengths(key, nonce);
  38370. var m = new Uint8Array(crypto_secretbox_ZEROBYTES + msg.length);
  38371. var c = new Uint8Array(m.length);
  38372. for (var i = 0; i < msg.length; i++) m[i+crypto_secretbox_ZEROBYTES] = msg[i];
  38373. crypto_secretbox(c, m, m.length, nonce, key);
  38374. return c.subarray(crypto_secretbox_BOXZEROBYTES);
  38375. };
  38376. nacl.secretbox.open = function(box, nonce, key) {
  38377. checkArrayTypes(box, nonce, key);
  38378. checkLengths(key, nonce);
  38379. var c = new Uint8Array(crypto_secretbox_BOXZEROBYTES + box.length);
  38380. var m = new Uint8Array(c.length);
  38381. for (var i = 0; i < box.length; i++) c[i+crypto_secretbox_BOXZEROBYTES] = box[i];
  38382. if (c.length < 32) return null;
  38383. if (crypto_secretbox_open(m, c, c.length, nonce, key) !== 0) return null;
  38384. return m.subarray(crypto_secretbox_ZEROBYTES);
  38385. };
  38386. nacl.secretbox.keyLength = crypto_secretbox_KEYBYTES;
  38387. nacl.secretbox.nonceLength = crypto_secretbox_NONCEBYTES;
  38388. nacl.secretbox.overheadLength = crypto_secretbox_BOXZEROBYTES;
  38389. nacl.scalarMult = function(n, p) {
  38390. checkArrayTypes(n, p);
  38391. if (n.length !== crypto_scalarmult_SCALARBYTES) throw new Error('bad n size');
  38392. if (p.length !== crypto_scalarmult_BYTES) throw new Error('bad p size');
  38393. var q = new Uint8Array(crypto_scalarmult_BYTES);
  38394. crypto_scalarmult(q, n, p);
  38395. return q;
  38396. };
  38397. nacl.scalarMult.base = function(n) {
  38398. checkArrayTypes(n);
  38399. if (n.length !== crypto_scalarmult_SCALARBYTES) throw new Error('bad n size');
  38400. var q = new Uint8Array(crypto_scalarmult_BYTES);
  38401. crypto_scalarmult_base(q, n);
  38402. return q;
  38403. };
  38404. nacl.scalarMult.scalarLength = crypto_scalarmult_SCALARBYTES;
  38405. nacl.scalarMult.groupElementLength = crypto_scalarmult_BYTES;
  38406. nacl.box = function(msg, nonce, publicKey, secretKey) {
  38407. var k = nacl.box.before(publicKey, secretKey);
  38408. return nacl.secretbox(msg, nonce, k);
  38409. };
  38410. nacl.box.before = function(publicKey, secretKey) {
  38411. checkArrayTypes(publicKey, secretKey);
  38412. checkBoxLengths(publicKey, secretKey);
  38413. var k = new Uint8Array(crypto_box_BEFORENMBYTES);
  38414. crypto_box_beforenm(k, publicKey, secretKey);
  38415. return k;
  38416. };
  38417. nacl.box.after = nacl.secretbox;
  38418. nacl.box.open = function(msg, nonce, publicKey, secretKey) {
  38419. var k = nacl.box.before(publicKey, secretKey);
  38420. return nacl.secretbox.open(msg, nonce, k);
  38421. };
  38422. nacl.box.open.after = nacl.secretbox.open;
  38423. nacl.box.keyPair = function() {
  38424. var pk = new Uint8Array(crypto_box_PUBLICKEYBYTES);
  38425. var sk = new Uint8Array(crypto_box_SECRETKEYBYTES);
  38426. crypto_box_keypair(pk, sk);
  38427. return {publicKey: pk, secretKey: sk};
  38428. };
  38429. nacl.box.keyPair.fromSecretKey = function(secretKey) {
  38430. checkArrayTypes(secretKey);
  38431. if (secretKey.length !== crypto_box_SECRETKEYBYTES)
  38432. throw new Error('bad secret key size');
  38433. var pk = new Uint8Array(crypto_box_PUBLICKEYBYTES);
  38434. crypto_scalarmult_base(pk, secretKey);
  38435. return {publicKey: pk, secretKey: new Uint8Array(secretKey)};
  38436. };
  38437. nacl.box.publicKeyLength = crypto_box_PUBLICKEYBYTES;
  38438. nacl.box.secretKeyLength = crypto_box_SECRETKEYBYTES;
  38439. nacl.box.sharedKeyLength = crypto_box_BEFORENMBYTES;
  38440. nacl.box.nonceLength = crypto_box_NONCEBYTES;
  38441. nacl.box.overheadLength = nacl.secretbox.overheadLength;
  38442. nacl.sign = function(msg, secretKey) {
  38443. checkArrayTypes(msg, secretKey);
  38444. if (secretKey.length !== crypto_sign_SECRETKEYBYTES)
  38445. throw new Error('bad secret key size');
  38446. var signedMsg = new Uint8Array(crypto_sign_BYTES+msg.length);
  38447. crypto_sign(signedMsg, msg, msg.length, secretKey);
  38448. return signedMsg;
  38449. };
  38450. nacl.sign.open = function(signedMsg, publicKey) {
  38451. checkArrayTypes(signedMsg, publicKey);
  38452. if (publicKey.length !== crypto_sign_PUBLICKEYBYTES)
  38453. throw new Error('bad public key size');
  38454. var tmp = new Uint8Array(signedMsg.length);
  38455. var mlen = crypto_sign_open(tmp, signedMsg, signedMsg.length, publicKey);
  38456. if (mlen < 0) return null;
  38457. var m = new Uint8Array(mlen);
  38458. for (var i = 0; i < m.length; i++) m[i] = tmp[i];
  38459. return m;
  38460. };
  38461. nacl.sign.detached = function(msg, secretKey) {
  38462. var signedMsg = nacl.sign(msg, secretKey);
  38463. var sig = new Uint8Array(crypto_sign_BYTES);
  38464. for (var i = 0; i < sig.length; i++) sig[i] = signedMsg[i];
  38465. return sig;
  38466. };
  38467. nacl.sign.detached.verify = function(msg, sig, publicKey) {
  38468. checkArrayTypes(msg, sig, publicKey);
  38469. if (sig.length !== crypto_sign_BYTES)
  38470. throw new Error('bad signature size');
  38471. if (publicKey.length !== crypto_sign_PUBLICKEYBYTES)
  38472. throw new Error('bad public key size');
  38473. var sm = new Uint8Array(crypto_sign_BYTES + msg.length);
  38474. var m = new Uint8Array(crypto_sign_BYTES + msg.length);
  38475. var i;
  38476. for (i = 0; i < crypto_sign_BYTES; i++) sm[i] = sig[i];
  38477. for (i = 0; i < msg.length; i++) sm[i+crypto_sign_BYTES] = msg[i];
  38478. return (crypto_sign_open(m, sm, sm.length, publicKey) >= 0);
  38479. };
  38480. nacl.sign.keyPair = function() {
  38481. var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);
  38482. var sk = new Uint8Array(crypto_sign_SECRETKEYBYTES);
  38483. crypto_sign_keypair(pk, sk);
  38484. return {publicKey: pk, secretKey: sk};
  38485. };
  38486. nacl.sign.keyPair.fromSecretKey = function(secretKey) {
  38487. checkArrayTypes(secretKey);
  38488. if (secretKey.length !== crypto_sign_SECRETKEYBYTES)
  38489. throw new Error('bad secret key size');
  38490. var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);
  38491. for (var i = 0; i < pk.length; i++) pk[i] = secretKey[32+i];
  38492. return {publicKey: pk, secretKey: new Uint8Array(secretKey)};
  38493. };
  38494. nacl.sign.keyPair.fromSeed = function(seed) {
  38495. checkArrayTypes(seed);
  38496. if (seed.length !== crypto_sign_SEEDBYTES)
  38497. throw new Error('bad seed size');
  38498. var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);
  38499. var sk = new Uint8Array(crypto_sign_SECRETKEYBYTES);
  38500. for (var i = 0; i < 32; i++) sk[i] = seed[i];
  38501. crypto_sign_keypair(pk, sk, true);
  38502. return {publicKey: pk, secretKey: sk};
  38503. };
  38504. nacl.sign.publicKeyLength = crypto_sign_PUBLICKEYBYTES;
  38505. nacl.sign.secretKeyLength = crypto_sign_SECRETKEYBYTES;
  38506. nacl.sign.seedLength = crypto_sign_SEEDBYTES;
  38507. nacl.sign.signatureLength = crypto_sign_BYTES;
  38508. nacl.hash = function(msg) {
  38509. checkArrayTypes(msg);
  38510. var h = new Uint8Array(crypto_hash_BYTES);
  38511. crypto_hash(h, msg, msg.length);
  38512. return h;
  38513. };
  38514. nacl.hash.hashLength = crypto_hash_BYTES;
  38515. nacl.verify = function(x, y) {
  38516. checkArrayTypes(x, y);
  38517. // Zero length arguments are considered not equal.
  38518. if (x.length === 0 || y.length === 0) return false;
  38519. if (x.length !== y.length) return false;
  38520. return (vn(x, 0, y, 0, x.length) === 0) ? true : false;
  38521. };
  38522. nacl.setPRNG = function(fn) {
  38523. randombytes = fn;
  38524. };
  38525. (function() {
  38526. // Initialize PRNG if environment provides CSPRNG.
  38527. // If not, methods calling randombytes will throw.
  38528. var crypto = typeof self !== 'undefined' ? (self.crypto || self.msCrypto) : null;
  38529. if (crypto && crypto.getRandomValues) {
  38530. // Browsers.
  38531. var QUOTA = 65536;
  38532. nacl.setPRNG(function(x, n) {
  38533. var i, v = new Uint8Array(n);
  38534. for (i = 0; i < n; i += QUOTA) {
  38535. crypto.getRandomValues(v.subarray(i, i + Math.min(n - i, QUOTA)));
  38536. }
  38537. for (i = 0; i < n; i++) x[i] = v[i];
  38538. cleanup(v);
  38539. });
  38540. } else if (true) {
  38541. // Node.js.
  38542. crypto = __webpack_require__(3);
  38543. if (crypto && crypto.randomBytes) {
  38544. nacl.setPRNG(function(x, n) {
  38545. var i, v = crypto.randomBytes(n);
  38546. for (i = 0; i < n; i++) x[i] = v[i];
  38547. cleanup(v);
  38548. });
  38549. }
  38550. }
  38551. })();
  38552. })( true && module.exports ? module.exports : (self.nacl = self.nacl || {}));
  38553. /***/ }),
  38554. /* 1 */
  38555. /***/ (function(module, exports, __webpack_require__) {
  38556. // Written in 2014-2016 by Dmitry Chestnykh and Devi Mandiri.
  38557. // Public domain.
  38558. (function(root, f) {
  38559. 'use strict';
  38560. if ( true && module.exports) module.exports = f();
  38561. else if (root.nacl) root.nacl.util = f();
  38562. else {
  38563. root.nacl = {};
  38564. root.nacl.util = f();
  38565. }
  38566. }(this, function() {
  38567. 'use strict';
  38568. var util = {};
  38569. function validateBase64(s) {
  38570. if (!(/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(s))) {
  38571. throw new TypeError('invalid encoding');
  38572. }
  38573. }
  38574. util.decodeUTF8 = function(s) {
  38575. if (typeof s !== 'string') throw new TypeError('expected string');
  38576. var i, d = unescape(encodeURIComponent(s)), b = new Uint8Array(d.length);
  38577. for (i = 0; i < d.length; i++) b[i] = d.charCodeAt(i);
  38578. return b;
  38579. };
  38580. util.encodeUTF8 = function(arr) {
  38581. var i, s = [];
  38582. for (i = 0; i < arr.length; i++) s.push(String.fromCharCode(arr[i]));
  38583. return decodeURIComponent(escape(s.join('')));
  38584. };
  38585. if (typeof atob === 'undefined') {
  38586. // Node.js
  38587. if (typeof Buffer.from !== 'undefined') {
  38588. // Node v6 and later
  38589. util.encodeBase64 = function (arr) { // v6 and later
  38590. return Buffer.from(arr).toString('base64');
  38591. };
  38592. util.decodeBase64 = function (s) {
  38593. validateBase64(s);
  38594. return new Uint8Array(Array.prototype.slice.call(Buffer.from(s, 'base64'), 0));
  38595. };
  38596. } else {
  38597. // Node earlier than v6
  38598. util.encodeBase64 = function (arr) { // v6 and later
  38599. return (new Buffer(arr)).toString('base64');
  38600. };
  38601. util.decodeBase64 = function(s) {
  38602. validateBase64(s);
  38603. return new Uint8Array(Array.prototype.slice.call(new Buffer(s, 'base64'), 0));
  38604. };
  38605. }
  38606. } else {
  38607. // Browsers
  38608. util.encodeBase64 = function(arr) {
  38609. var i, s = [], len = arr.length;
  38610. for (i = 0; i < len; i++) s.push(String.fromCharCode(arr[i]));
  38611. return btoa(s.join(''));
  38612. };
  38613. util.decodeBase64 = function(s) {
  38614. validateBase64(s);
  38615. var i, d = atob(s), b = new Uint8Array(d.length);
  38616. for (i = 0; i < d.length; i++) b[i] = d.charCodeAt(i);
  38617. return b;
  38618. };
  38619. }
  38620. return util;
  38621. }));
  38622. /***/ }),
  38623. /* 2 */
  38624. /***/ (function(module, exports, __webpack_require__) {
  38625. // required so we don't have to do require('pusher').default etc.
  38626. module.exports = __webpack_require__(4).default;
  38627. /***/ }),
  38628. /* 3 */
  38629. /***/ (function(module, exports) {
  38630. /* (ignored) */
  38631. /***/ }),
  38632. /* 4 */
  38633. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  38634. "use strict";
  38635. __webpack_require__.r(__webpack_exports__);
  38636. // CONCATENATED MODULE: ./src/runtimes/web/dom/script_receiver_factory.ts
  38637. var ScriptReceiverFactory = (function () {
  38638. function ScriptReceiverFactory(prefix, name) {
  38639. this.lastId = 0;
  38640. this.prefix = prefix;
  38641. this.name = name;
  38642. }
  38643. ScriptReceiverFactory.prototype.create = function (callback) {
  38644. this.lastId++;
  38645. var number = this.lastId;
  38646. var id = this.prefix + number;
  38647. var name = this.name + "[" + number + "]";
  38648. var called = false;
  38649. var callbackWrapper = function () {
  38650. if (!called) {
  38651. callback.apply(null, arguments);
  38652. called = true;
  38653. }
  38654. };
  38655. this[number] = callbackWrapper;
  38656. return { number: number, id: id, name: name, callback: callbackWrapper };
  38657. };
  38658. ScriptReceiverFactory.prototype.remove = function (receiver) {
  38659. delete this[receiver.number];
  38660. };
  38661. return ScriptReceiverFactory;
  38662. }());
  38663. var ScriptReceivers = new ScriptReceiverFactory("_pusher_script_", "Pusher.ScriptReceivers");
  38664. // CONCATENATED MODULE: ./src/core/defaults.ts
  38665. var Defaults = {
  38666. VERSION: "5.0.3",
  38667. PROTOCOL: 7,
  38668. host: 'ws.pusherapp.com',
  38669. ws_port: 80,
  38670. wss_port: 443,
  38671. ws_path: '',
  38672. sockjs_host: 'sockjs.pusher.com',
  38673. sockjs_http_port: 80,
  38674. sockjs_https_port: 443,
  38675. sockjs_path: '/pusher',
  38676. stats_host: 'stats.pusher.com',
  38677. channel_auth_endpoint: '/pusher/auth',
  38678. channel_auth_transport: 'ajax',
  38679. activity_timeout: 120000,
  38680. pong_timeout: 30000,
  38681. unavailable_timeout: 10000,
  38682. cdn_http: "http://js.pusher.com",
  38683. cdn_https: "https://js.pusher.com",
  38684. dependency_suffix: ""
  38685. };
  38686. /* harmony default export */ var defaults = (Defaults);
  38687. // CONCATENATED MODULE: ./src/runtimes/web/dom/dependency_loader.ts
  38688. var dependency_loader_DependencyLoader = (function () {
  38689. function DependencyLoader(options) {
  38690. this.options = options;
  38691. this.receivers = options.receivers || ScriptReceivers;
  38692. this.loading = {};
  38693. }
  38694. DependencyLoader.prototype.load = function (name, options, callback) {
  38695. var self = this;
  38696. if (self.loading[name] && self.loading[name].length > 0) {
  38697. self.loading[name].push(callback);
  38698. }
  38699. else {
  38700. self.loading[name] = [callback];
  38701. var request = runtime.createScriptRequest(self.getPath(name, options));
  38702. var receiver = self.receivers.create(function (error) {
  38703. self.receivers.remove(receiver);
  38704. if (self.loading[name]) {
  38705. var callbacks = self.loading[name];
  38706. delete self.loading[name];
  38707. var successCallback = function (wasSuccessful) {
  38708. if (!wasSuccessful) {
  38709. request.cleanup();
  38710. }
  38711. };
  38712. for (var i = 0; i < callbacks.length; i++) {
  38713. callbacks[i](error, successCallback);
  38714. }
  38715. }
  38716. });
  38717. request.send(receiver);
  38718. }
  38719. };
  38720. DependencyLoader.prototype.getRoot = function (options) {
  38721. var cdn;
  38722. var protocol = runtime.getDocument().location.protocol;
  38723. if ((options && options.useTLS) || protocol === "https:") {
  38724. cdn = this.options.cdn_https;
  38725. }
  38726. else {
  38727. cdn = this.options.cdn_http;
  38728. }
  38729. return cdn.replace(/\/*$/, "") + "/" + this.options.version;
  38730. };
  38731. DependencyLoader.prototype.getPath = function (name, options) {
  38732. return this.getRoot(options) + '/' + name + this.options.suffix + '.js';
  38733. };
  38734. ;
  38735. return DependencyLoader;
  38736. }());
  38737. /* harmony default export */ var dependency_loader = (dependency_loader_DependencyLoader);
  38738. // CONCATENATED MODULE: ./src/runtimes/web/dom/dependencies.ts
  38739. var DependenciesReceivers = new ScriptReceiverFactory("_pusher_dependencies", "Pusher.DependenciesReceivers");
  38740. var Dependencies = new dependency_loader({
  38741. cdn_http: defaults.cdn_http,
  38742. cdn_https: defaults.cdn_https,
  38743. version: defaults.VERSION,
  38744. suffix: defaults.dependency_suffix,
  38745. receivers: DependenciesReceivers
  38746. });
  38747. // CONCATENATED MODULE: ./src/core/base64.ts
  38748. function encode(s) {
  38749. return btoa(utob(s));
  38750. }
  38751. var fromCharCode = String.fromCharCode;
  38752. var b64chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
  38753. var b64tab = {};
  38754. for (var base64_i = 0, l = b64chars.length; base64_i < l; base64_i++) {
  38755. b64tab[b64chars.charAt(base64_i)] = base64_i;
  38756. }
  38757. var cb_utob = function (c) {
  38758. var cc = c.charCodeAt(0);
  38759. return cc < 0x80
  38760. ? c
  38761. : cc < 0x800
  38762. ? fromCharCode(0xc0 | (cc >>> 6)) + fromCharCode(0x80 | (cc & 0x3f))
  38763. : fromCharCode(0xe0 | ((cc >>> 12) & 0x0f)) +
  38764. fromCharCode(0x80 | ((cc >>> 6) & 0x3f)) +
  38765. fromCharCode(0x80 | (cc & 0x3f));
  38766. };
  38767. var utob = function (u) {
  38768. return u.replace(/[^\x00-\x7F]/g, cb_utob);
  38769. };
  38770. var cb_encode = function (ccc) {
  38771. var padlen = [0, 2, 1][ccc.length % 3];
  38772. var ord = (ccc.charCodeAt(0) << 16) |
  38773. ((ccc.length > 1 ? ccc.charCodeAt(1) : 0) << 8) |
  38774. (ccc.length > 2 ? ccc.charCodeAt(2) : 0);
  38775. var chars = [
  38776. b64chars.charAt(ord >>> 18),
  38777. b64chars.charAt((ord >>> 12) & 63),
  38778. padlen >= 2 ? '=' : b64chars.charAt((ord >>> 6) & 63),
  38779. padlen >= 1 ? '=' : b64chars.charAt(ord & 63)
  38780. ];
  38781. return chars.join('');
  38782. };
  38783. var btoa = window.btoa ||
  38784. function (b) {
  38785. return b.replace(/[\s\S]{1,3}/g, cb_encode);
  38786. };
  38787. // CONCATENATED MODULE: ./src/core/utils/timers/abstract_timer.ts
  38788. var Timer = (function () {
  38789. function Timer(set, clear, delay, callback) {
  38790. var _this = this;
  38791. this.clear = clear;
  38792. this.timer = set(function () {
  38793. if (_this.timer) {
  38794. _this.timer = callback(_this.timer);
  38795. }
  38796. }, delay);
  38797. }
  38798. Timer.prototype.isRunning = function () {
  38799. return this.timer !== null;
  38800. };
  38801. Timer.prototype.ensureAborted = function () {
  38802. if (this.timer) {
  38803. this.clear(this.timer);
  38804. this.timer = null;
  38805. }
  38806. };
  38807. return Timer;
  38808. }());
  38809. /* harmony default export */ var abstract_timer = (Timer);
  38810. // CONCATENATED MODULE: ./src/core/utils/timers/index.ts
  38811. var __extends = (undefined && undefined.__extends) || (function () {
  38812. var extendStatics = function (d, b) {
  38813. extendStatics = Object.setPrototypeOf ||
  38814. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  38815. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  38816. return extendStatics(d, b);
  38817. };
  38818. return function (d, b) {
  38819. extendStatics(d, b);
  38820. function __() { this.constructor = d; }
  38821. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  38822. };
  38823. })();
  38824. function timers_clearTimeout(timer) {
  38825. window.clearTimeout(timer);
  38826. }
  38827. function timers_clearInterval(timer) {
  38828. window.clearInterval(timer);
  38829. }
  38830. var OneOffTimer = (function (_super) {
  38831. __extends(OneOffTimer, _super);
  38832. function OneOffTimer(delay, callback) {
  38833. return _super.call(this, setTimeout, timers_clearTimeout, delay, function (timer) {
  38834. callback();
  38835. return null;
  38836. }) || this;
  38837. }
  38838. return OneOffTimer;
  38839. }(abstract_timer));
  38840. var PeriodicTimer = (function (_super) {
  38841. __extends(PeriodicTimer, _super);
  38842. function PeriodicTimer(delay, callback) {
  38843. return _super.call(this, setInterval, timers_clearInterval, delay, function (timer) {
  38844. callback();
  38845. return timer;
  38846. }) || this;
  38847. }
  38848. return PeriodicTimer;
  38849. }(abstract_timer));
  38850. // CONCATENATED MODULE: ./src/core/util.ts
  38851. var Util = {
  38852. now: function () {
  38853. if (Date.now) {
  38854. return Date.now();
  38855. }
  38856. else {
  38857. return new Date().valueOf();
  38858. }
  38859. },
  38860. defer: function (callback) {
  38861. return new OneOffTimer(0, callback);
  38862. },
  38863. method: function (name) {
  38864. var args = [];
  38865. for (var _i = 1; _i < arguments.length; _i++) {
  38866. args[_i - 1] = arguments[_i];
  38867. }
  38868. var boundArguments = Array.prototype.slice.call(arguments, 1);
  38869. return function (object) {
  38870. return object[name].apply(object, boundArguments.concat(arguments));
  38871. };
  38872. }
  38873. };
  38874. /* harmony default export */ var util = (Util);
  38875. // CONCATENATED MODULE: ./src/core/utils/collections.ts
  38876. function extend(target) {
  38877. var sources = [];
  38878. for (var _i = 1; _i < arguments.length; _i++) {
  38879. sources[_i - 1] = arguments[_i];
  38880. }
  38881. for (var i = 0; i < sources.length; i++) {
  38882. var extensions = sources[i];
  38883. for (var property in extensions) {
  38884. if (extensions[property] && extensions[property].constructor &&
  38885. extensions[property].constructor === Object) {
  38886. target[property] = extend(target[property] || {}, extensions[property]);
  38887. }
  38888. else {
  38889. target[property] = extensions[property];
  38890. }
  38891. }
  38892. }
  38893. return target;
  38894. }
  38895. function stringify() {
  38896. var m = ["Pusher"];
  38897. for (var i = 0; i < arguments.length; i++) {
  38898. if (typeof arguments[i] === "string") {
  38899. m.push(arguments[i]);
  38900. }
  38901. else {
  38902. m.push(safeJSONStringify(arguments[i]));
  38903. }
  38904. }
  38905. return m.join(" : ");
  38906. }
  38907. function arrayIndexOf(array, item) {
  38908. var nativeIndexOf = Array.prototype.indexOf;
  38909. if (array === null) {
  38910. return -1;
  38911. }
  38912. if (nativeIndexOf && array.indexOf === nativeIndexOf) {
  38913. return array.indexOf(item);
  38914. }
  38915. for (var i = 0, l = array.length; i < l; i++) {
  38916. if (array[i] === item) {
  38917. return i;
  38918. }
  38919. }
  38920. return -1;
  38921. }
  38922. function objectApply(object, f) {
  38923. for (var key in object) {
  38924. if (Object.prototype.hasOwnProperty.call(object, key)) {
  38925. f(object[key], key, object);
  38926. }
  38927. }
  38928. }
  38929. function keys(object) {
  38930. var keys = [];
  38931. objectApply(object, function (_, key) {
  38932. keys.push(key);
  38933. });
  38934. return keys;
  38935. }
  38936. function values(object) {
  38937. var values = [];
  38938. objectApply(object, function (value) {
  38939. values.push(value);
  38940. });
  38941. return values;
  38942. }
  38943. function apply(array, f, context) {
  38944. for (var i = 0; i < array.length; i++) {
  38945. f.call(context || window, array[i], i, array);
  38946. }
  38947. }
  38948. function map(array, f) {
  38949. var result = [];
  38950. for (var i = 0; i < array.length; i++) {
  38951. result.push(f(array[i], i, array, result));
  38952. }
  38953. return result;
  38954. }
  38955. function mapObject(object, f) {
  38956. var result = {};
  38957. objectApply(object, function (value, key) {
  38958. result[key] = f(value);
  38959. });
  38960. return result;
  38961. }
  38962. function filter(array, test) {
  38963. test = test || function (value) { return !!value; };
  38964. var result = [];
  38965. for (var i = 0; i < array.length; i++) {
  38966. if (test(array[i], i, array, result)) {
  38967. result.push(array[i]);
  38968. }
  38969. }
  38970. return result;
  38971. }
  38972. function filterObject(object, test) {
  38973. var result = {};
  38974. objectApply(object, function (value, key) {
  38975. if ((test && test(value, key, object, result)) || Boolean(value)) {
  38976. result[key] = value;
  38977. }
  38978. });
  38979. return result;
  38980. }
  38981. function flatten(object) {
  38982. var result = [];
  38983. objectApply(object, function (value, key) {
  38984. result.push([key, value]);
  38985. });
  38986. return result;
  38987. }
  38988. function any(array, test) {
  38989. for (var i = 0; i < array.length; i++) {
  38990. if (test(array[i], i, array)) {
  38991. return true;
  38992. }
  38993. }
  38994. return false;
  38995. }
  38996. function collections_all(array, test) {
  38997. for (var i = 0; i < array.length; i++) {
  38998. if (!test(array[i], i, array)) {
  38999. return false;
  39000. }
  39001. }
  39002. return true;
  39003. }
  39004. function encodeParamsObject(data) {
  39005. return mapObject(data, function (value) {
  39006. if (typeof value === "object") {
  39007. value = safeJSONStringify(value);
  39008. }
  39009. return encodeURIComponent(encode(value.toString()));
  39010. });
  39011. }
  39012. function buildQueryString(data) {
  39013. var params = filterObject(data, function (value) {
  39014. return value !== undefined;
  39015. });
  39016. var query = map(flatten(encodeParamsObject(params)), util.method("join", "=")).join("&");
  39017. return query;
  39018. }
  39019. function decycleObject(object) {
  39020. var objects = [], paths = [];
  39021. return (function derez(value, path) {
  39022. var i, name, nu;
  39023. switch (typeof value) {
  39024. case 'object':
  39025. if (!value) {
  39026. return null;
  39027. }
  39028. for (i = 0; i < objects.length; i += 1) {
  39029. if (objects[i] === value) {
  39030. return { $ref: paths[i] };
  39031. }
  39032. }
  39033. objects.push(value);
  39034. paths.push(path);
  39035. if (Object.prototype.toString.apply(value) === '[object Array]') {
  39036. nu = [];
  39037. for (i = 0; i < value.length; i += 1) {
  39038. nu[i] = derez(value[i], path + '[' + i + ']');
  39039. }
  39040. }
  39041. else {
  39042. nu = {};
  39043. for (name in value) {
  39044. if (Object.prototype.hasOwnProperty.call(value, name)) {
  39045. nu[name] = derez(value[name], path + '[' + JSON.stringify(name) + ']');
  39046. }
  39047. }
  39048. }
  39049. return nu;
  39050. case 'number':
  39051. case 'string':
  39052. case 'boolean':
  39053. return value;
  39054. }
  39055. }(object, '$'));
  39056. }
  39057. function safeJSONStringify(source) {
  39058. try {
  39059. return JSON.stringify(source);
  39060. }
  39061. catch (e) {
  39062. return JSON.stringify(decycleObject(source));
  39063. }
  39064. }
  39065. // CONCATENATED MODULE: ./src/core/logger.ts
  39066. var logger_Logger = (function () {
  39067. function Logger() {
  39068. this.globalLog = function (message) {
  39069. if (window.console && window.console.log) {
  39070. window.console.log(message);
  39071. }
  39072. };
  39073. }
  39074. Logger.prototype.debug = function () {
  39075. var args = [];
  39076. for (var _i = 0; _i < arguments.length; _i++) {
  39077. args[_i] = arguments[_i];
  39078. }
  39079. this.log(this.globalLog, args);
  39080. };
  39081. Logger.prototype.warn = function () {
  39082. var args = [];
  39083. for (var _i = 0; _i < arguments.length; _i++) {
  39084. args[_i] = arguments[_i];
  39085. }
  39086. this.log(this.globalLogWarn, args);
  39087. };
  39088. Logger.prototype.error = function () {
  39089. var args = [];
  39090. for (var _i = 0; _i < arguments.length; _i++) {
  39091. args[_i] = arguments[_i];
  39092. }
  39093. this.log(this.globalLogError, args);
  39094. };
  39095. Logger.prototype.globalLogWarn = function (message) {
  39096. if (window.console && window.console.warn) {
  39097. window.console.warn(message);
  39098. }
  39099. else {
  39100. this.globalLog(message);
  39101. }
  39102. };
  39103. Logger.prototype.globalLogError = function (message) {
  39104. if (window.console && window.console.error) {
  39105. window.console.error(message);
  39106. }
  39107. else {
  39108. this.globalLogWarn(message);
  39109. }
  39110. };
  39111. Logger.prototype.log = function (defaultLoggingFunction) {
  39112. var args = [];
  39113. for (var _i = 1; _i < arguments.length; _i++) {
  39114. args[_i - 1] = arguments[_i];
  39115. }
  39116. var message = stringify.apply(this, arguments);
  39117. if (core_pusher.log) {
  39118. core_pusher.log(message);
  39119. }
  39120. else if (core_pusher.logToConsole) {
  39121. var log = defaultLoggingFunction.bind(this);
  39122. log(message);
  39123. }
  39124. };
  39125. return Logger;
  39126. }());
  39127. /* harmony default export */ var logger = (new logger_Logger());
  39128. // CONCATENATED MODULE: ./src/core/utils/url_store.ts
  39129. var urlStore = {
  39130. baseUrl: "https://pusher.com",
  39131. urls: {
  39132. authenticationEndpoint: {
  39133. path: "/docs/authenticating_users",
  39134. },
  39135. javascriptQuickStart: {
  39136. path: "/docs/javascript_quick_start"
  39137. },
  39138. triggeringClientEvents: {
  39139. path: "/docs/client_api_guide/client_events#trigger-events"
  39140. }
  39141. }
  39142. };
  39143. var buildLogSuffix = function (key) {
  39144. var urlPrefix = "See:";
  39145. var urlObj = urlStore.urls[key];
  39146. if (!urlObj)
  39147. return "";
  39148. var url;
  39149. if (urlObj.fullUrl) {
  39150. url = urlObj.fullUrl;
  39151. }
  39152. else if (urlObj.path) {
  39153. url = urlStore.baseUrl + urlObj.path;
  39154. }
  39155. if (!url)
  39156. return "";
  39157. return urlPrefix + " " + url;
  39158. };
  39159. /* harmony default export */ var url_store = ({ buildLogSuffix: buildLogSuffix });
  39160. // CONCATENATED MODULE: ./src/runtimes/isomorphic/auth/xhr_auth.ts
  39161. var ajax = function (context, socketId, callback) {
  39162. var self = this, xhr;
  39163. xhr = runtime.createXHR();
  39164. xhr.open("POST", self.options.authEndpoint, true);
  39165. xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
  39166. for (var headerName in this.authOptions.headers) {
  39167. xhr.setRequestHeader(headerName, this.authOptions.headers[headerName]);
  39168. }
  39169. xhr.onreadystatechange = function () {
  39170. if (xhr.readyState === 4) {
  39171. if (xhr.status === 200) {
  39172. var data, parsed = false;
  39173. try {
  39174. data = JSON.parse(xhr.responseText);
  39175. parsed = true;
  39176. }
  39177. catch (e) {
  39178. callback(true, 'JSON returned from auth endpoint was invalid, yet status code was 200. Data was: ' + xhr.responseText);
  39179. }
  39180. if (parsed) {
  39181. callback(false, data);
  39182. }
  39183. }
  39184. else {
  39185. var suffix = url_store.buildLogSuffix("authenticationEndpoint");
  39186. logger.error('Unable to retrieve auth string from auth endpoint - ' +
  39187. ("received status " + xhr.status + " from " + self.options.authEndpoint + ". ") +
  39188. ("Clients must be authenticated to join private or presence channels. " + suffix));
  39189. callback(true, xhr.status);
  39190. }
  39191. }
  39192. };
  39193. xhr.send(this.composeQuery(socketId));
  39194. return xhr;
  39195. };
  39196. /* harmony default export */ var xhr_auth = (ajax);
  39197. // CONCATENATED MODULE: ./src/runtimes/web/auth/jsonp_auth.ts
  39198. var jsonp = function (context, socketId, callback) {
  39199. if (this.authOptions.headers !== undefined) {
  39200. logger.warn('To send headers with the auth request, you must use AJAX, rather than JSONP.');
  39201. }
  39202. var callbackName = context.nextAuthCallbackID.toString();
  39203. context.nextAuthCallbackID++;
  39204. var document = context.getDocument();
  39205. var script = document.createElement("script");
  39206. context.auth_callbacks[callbackName] = function (data) {
  39207. callback(false, data);
  39208. };
  39209. var callback_name = "Pusher.auth_callbacks['" + callbackName + "']";
  39210. script.src = this.options.authEndpoint +
  39211. '?callback=' +
  39212. encodeURIComponent(callback_name) +
  39213. '&' +
  39214. this.composeQuery(socketId);
  39215. var head = document.getElementsByTagName("head")[0] || document.documentElement;
  39216. head.insertBefore(script, head.firstChild);
  39217. };
  39218. /* harmony default export */ var jsonp_auth = (jsonp);
  39219. // CONCATENATED MODULE: ./src/runtimes/web/dom/script_request.ts
  39220. var ScriptRequest = (function () {
  39221. function ScriptRequest(src) {
  39222. this.src = src;
  39223. }
  39224. ScriptRequest.prototype.send = function (receiver) {
  39225. var self = this;
  39226. var errorString = "Error loading " + self.src;
  39227. self.script = document.createElement("script");
  39228. self.script.id = receiver.id;
  39229. self.script.src = self.src;
  39230. self.script.type = "text/javascript";
  39231. self.script.charset = "UTF-8";
  39232. if (self.script.addEventListener) {
  39233. self.script.onerror = function () {
  39234. receiver.callback(errorString);
  39235. };
  39236. self.script.onload = function () {
  39237. receiver.callback(null);
  39238. };
  39239. }
  39240. else {
  39241. self.script.onreadystatechange = function () {
  39242. if (self.script.readyState === 'loaded' ||
  39243. self.script.readyState === 'complete') {
  39244. receiver.callback(null);
  39245. }
  39246. };
  39247. }
  39248. if (self.script.async === undefined && document.attachEvent &&
  39249. /opera/i.test(navigator.userAgent)) {
  39250. self.errorScript = document.createElement("script");
  39251. self.errorScript.id = receiver.id + "_error";
  39252. self.errorScript.text = receiver.name + "('" + errorString + "');";
  39253. self.script.async = self.errorScript.async = false;
  39254. }
  39255. else {
  39256. self.script.async = true;
  39257. }
  39258. var head = document.getElementsByTagName('head')[0];
  39259. head.insertBefore(self.script, head.firstChild);
  39260. if (self.errorScript) {
  39261. head.insertBefore(self.errorScript, self.script.nextSibling);
  39262. }
  39263. };
  39264. ScriptRequest.prototype.cleanup = function () {
  39265. if (this.script) {
  39266. this.script.onload = this.script.onerror = null;
  39267. this.script.onreadystatechange = null;
  39268. }
  39269. if (this.script && this.script.parentNode) {
  39270. this.script.parentNode.removeChild(this.script);
  39271. }
  39272. if (this.errorScript && this.errorScript.parentNode) {
  39273. this.errorScript.parentNode.removeChild(this.errorScript);
  39274. }
  39275. this.script = null;
  39276. this.errorScript = null;
  39277. };
  39278. return ScriptRequest;
  39279. }());
  39280. /* harmony default export */ var script_request = (ScriptRequest);
  39281. // CONCATENATED MODULE: ./src/runtimes/web/dom/jsonp_request.ts
  39282. var jsonp_request_JSONPRequest = (function () {
  39283. function JSONPRequest(url, data) {
  39284. this.url = url;
  39285. this.data = data;
  39286. }
  39287. JSONPRequest.prototype.send = function (receiver) {
  39288. if (this.request) {
  39289. return;
  39290. }
  39291. var query = buildQueryString(this.data);
  39292. var url = this.url + "/" + receiver.number + "?" + query;
  39293. this.request = runtime.createScriptRequest(url);
  39294. this.request.send(receiver);
  39295. };
  39296. JSONPRequest.prototype.cleanup = function () {
  39297. if (this.request) {
  39298. this.request.cleanup();
  39299. }
  39300. };
  39301. return JSONPRequest;
  39302. }());
  39303. /* harmony default export */ var jsonp_request = (jsonp_request_JSONPRequest);
  39304. // CONCATENATED MODULE: ./src/runtimes/web/timeline/jsonp_timeline.ts
  39305. var getAgent = function (sender, useTLS) {
  39306. return function (data, callback) {
  39307. var scheme = "http" + (useTLS ? "s" : "") + "://";
  39308. var url = scheme + (sender.host || sender.options.host) + sender.options.path;
  39309. var request = runtime.createJSONPRequest(url, data);
  39310. var receiver = runtime.ScriptReceivers.create(function (error, result) {
  39311. ScriptReceivers.remove(receiver);
  39312. request.cleanup();
  39313. if (result && result.host) {
  39314. sender.host = result.host;
  39315. }
  39316. if (callback) {
  39317. callback(error, result);
  39318. }
  39319. });
  39320. request.send(receiver);
  39321. };
  39322. };
  39323. var jsonp_timeline_jsonp = {
  39324. name: 'jsonp',
  39325. getAgent: getAgent
  39326. };
  39327. /* harmony default export */ var jsonp_timeline = (jsonp_timeline_jsonp);
  39328. // CONCATENATED MODULE: ./src/core/transports/url_schemes.ts
  39329. function getGenericURL(baseScheme, params, path) {
  39330. var scheme = baseScheme + (params.useTLS ? "s" : "");
  39331. var host = params.useTLS ? params.hostTLS : params.hostNonTLS;
  39332. return scheme + "://" + host + path;
  39333. }
  39334. function getGenericPath(key, queryString) {
  39335. var path = "/app/" + key;
  39336. var query = "?protocol=" + defaults.PROTOCOL +
  39337. "&client=js" +
  39338. "&version=" + defaults.VERSION +
  39339. (queryString ? ("&" + queryString) : "");
  39340. return path + query;
  39341. }
  39342. var ws = {
  39343. getInitial: function (key, params) {
  39344. var path = (params.httpPath || "") + getGenericPath(key, "flash=false");
  39345. return getGenericURL("ws", params, path);
  39346. }
  39347. };
  39348. var http = {
  39349. getInitial: function (key, params) {
  39350. var path = (params.httpPath || "/pusher") + getGenericPath(key);
  39351. return getGenericURL("http", params, path);
  39352. }
  39353. };
  39354. var sockjs = {
  39355. getInitial: function (key, params) {
  39356. return getGenericURL("http", params, params.httpPath || "/pusher");
  39357. },
  39358. getPath: function (key, params) {
  39359. return getGenericPath(key);
  39360. }
  39361. };
  39362. // CONCATENATED MODULE: ./src/core/events/callback_registry.ts
  39363. var callback_registry_CallbackRegistry = (function () {
  39364. function CallbackRegistry() {
  39365. this._callbacks = {};
  39366. }
  39367. CallbackRegistry.prototype.get = function (name) {
  39368. return this._callbacks[prefix(name)];
  39369. };
  39370. CallbackRegistry.prototype.add = function (name, callback, context) {
  39371. var prefixedEventName = prefix(name);
  39372. this._callbacks[prefixedEventName] = this._callbacks[prefixedEventName] || [];
  39373. this._callbacks[prefixedEventName].push({
  39374. fn: callback,
  39375. context: context
  39376. });
  39377. };
  39378. CallbackRegistry.prototype.remove = function (name, callback, context) {
  39379. if (!name && !callback && !context) {
  39380. this._callbacks = {};
  39381. return;
  39382. }
  39383. var names = name ? [prefix(name)] : keys(this._callbacks);
  39384. if (callback || context) {
  39385. this.removeCallback(names, callback, context);
  39386. }
  39387. else {
  39388. this.removeAllCallbacks(names);
  39389. }
  39390. };
  39391. CallbackRegistry.prototype.removeCallback = function (names, callback, context) {
  39392. apply(names, function (name) {
  39393. this._callbacks[name] = filter(this._callbacks[name] || [], function (binding) {
  39394. return (callback && callback !== binding.fn) ||
  39395. (context && context !== binding.context);
  39396. });
  39397. if (this._callbacks[name].length === 0) {
  39398. delete this._callbacks[name];
  39399. }
  39400. }, this);
  39401. };
  39402. CallbackRegistry.prototype.removeAllCallbacks = function (names) {
  39403. apply(names, function (name) {
  39404. delete this._callbacks[name];
  39405. }, this);
  39406. };
  39407. return CallbackRegistry;
  39408. }());
  39409. /* harmony default export */ var callback_registry = (callback_registry_CallbackRegistry);
  39410. function prefix(name) {
  39411. return "_" + name;
  39412. }
  39413. // CONCATENATED MODULE: ./src/core/events/dispatcher.ts
  39414. var dispatcher_Dispatcher = (function () {
  39415. function Dispatcher(failThrough) {
  39416. this.callbacks = new callback_registry();
  39417. this.global_callbacks = [];
  39418. this.failThrough = failThrough;
  39419. }
  39420. Dispatcher.prototype.bind = function (eventName, callback, context) {
  39421. this.callbacks.add(eventName, callback, context);
  39422. return this;
  39423. };
  39424. Dispatcher.prototype.bind_global = function (callback) {
  39425. this.global_callbacks.push(callback);
  39426. return this;
  39427. };
  39428. Dispatcher.prototype.unbind = function (eventName, callback, context) {
  39429. this.callbacks.remove(eventName, callback, context);
  39430. return this;
  39431. };
  39432. Dispatcher.prototype.unbind_global = function (callback) {
  39433. if (!callback) {
  39434. this.global_callbacks = [];
  39435. return this;
  39436. }
  39437. this.global_callbacks = filter(this.global_callbacks || [], function (c) { return c !== callback; });
  39438. return this;
  39439. };
  39440. Dispatcher.prototype.unbind_all = function () {
  39441. this.unbind();
  39442. this.unbind_global();
  39443. return this;
  39444. };
  39445. Dispatcher.prototype.emit = function (eventName, data, metadata) {
  39446. for (var i = 0; i < this.global_callbacks.length; i++) {
  39447. this.global_callbacks[i](eventName, data);
  39448. }
  39449. var callbacks = this.callbacks.get(eventName);
  39450. var args = [];
  39451. if (metadata) {
  39452. args.push(data, metadata);
  39453. }
  39454. else if (data) {
  39455. args.push(data);
  39456. }
  39457. if (callbacks && callbacks.length > 0) {
  39458. for (var i = 0; i < callbacks.length; i++) {
  39459. callbacks[i].fn.apply(callbacks[i].context || window, args);
  39460. }
  39461. }
  39462. else if (this.failThrough) {
  39463. this.failThrough(eventName, data);
  39464. }
  39465. return this;
  39466. };
  39467. return Dispatcher;
  39468. }());
  39469. /* harmony default export */ var dispatcher = (dispatcher_Dispatcher);
  39470. // CONCATENATED MODULE: ./src/core/transports/transport_connection.ts
  39471. var transport_connection_extends = (undefined && undefined.__extends) || (function () {
  39472. var extendStatics = function (d, b) {
  39473. extendStatics = Object.setPrototypeOf ||
  39474. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  39475. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  39476. return extendStatics(d, b);
  39477. };
  39478. return function (d, b) {
  39479. extendStatics(d, b);
  39480. function __() { this.constructor = d; }
  39481. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  39482. };
  39483. })();
  39484. var transport_connection_TransportConnection = (function (_super) {
  39485. transport_connection_extends(TransportConnection, _super);
  39486. function TransportConnection(hooks, name, priority, key, options) {
  39487. var _this = _super.call(this) || this;
  39488. _this.initialize = runtime.transportConnectionInitializer;
  39489. _this.hooks = hooks;
  39490. _this.name = name;
  39491. _this.priority = priority;
  39492. _this.key = key;
  39493. _this.options = options;
  39494. _this.state = "new";
  39495. _this.timeline = options.timeline;
  39496. _this.activityTimeout = options.activityTimeout;
  39497. _this.id = _this.timeline.generateUniqueID();
  39498. return _this;
  39499. }
  39500. TransportConnection.prototype.handlesActivityChecks = function () {
  39501. return Boolean(this.hooks.handlesActivityChecks);
  39502. };
  39503. TransportConnection.prototype.supportsPing = function () {
  39504. return Boolean(this.hooks.supportsPing);
  39505. };
  39506. TransportConnection.prototype.connect = function () {
  39507. var _this = this;
  39508. if (this.socket || this.state !== "initialized") {
  39509. return false;
  39510. }
  39511. var url = this.hooks.urls.getInitial(this.key, this.options);
  39512. try {
  39513. this.socket = this.hooks.getSocket(url, this.options);
  39514. }
  39515. catch (e) {
  39516. util.defer(function () {
  39517. _this.onError(e);
  39518. _this.changeState("closed");
  39519. });
  39520. return false;
  39521. }
  39522. this.bindListeners();
  39523. logger.debug("Connecting", { transport: this.name, url: url });
  39524. this.changeState("connecting");
  39525. return true;
  39526. };
  39527. TransportConnection.prototype.close = function () {
  39528. if (this.socket) {
  39529. this.socket.close();
  39530. return true;
  39531. }
  39532. else {
  39533. return false;
  39534. }
  39535. };
  39536. TransportConnection.prototype.send = function (data) {
  39537. var _this = this;
  39538. if (this.state === "open") {
  39539. util.defer(function () {
  39540. if (_this.socket) {
  39541. _this.socket.send(data);
  39542. }
  39543. });
  39544. return true;
  39545. }
  39546. else {
  39547. return false;
  39548. }
  39549. };
  39550. TransportConnection.prototype.ping = function () {
  39551. if (this.state === "open" && this.supportsPing()) {
  39552. this.socket.ping();
  39553. }
  39554. };
  39555. TransportConnection.prototype.onOpen = function () {
  39556. if (this.hooks.beforeOpen) {
  39557. this.hooks.beforeOpen(this.socket, this.hooks.urls.getPath(this.key, this.options));
  39558. }
  39559. this.changeState("open");
  39560. this.socket.onopen = undefined;
  39561. };
  39562. TransportConnection.prototype.onError = function (error) {
  39563. this.emit("error", { type: 'WebSocketError', error: error });
  39564. this.timeline.error(this.buildTimelineMessage({ error: error.toString() }));
  39565. };
  39566. TransportConnection.prototype.onClose = function (closeEvent) {
  39567. if (closeEvent) {
  39568. this.changeState("closed", {
  39569. code: closeEvent.code,
  39570. reason: closeEvent.reason,
  39571. wasClean: closeEvent.wasClean
  39572. });
  39573. }
  39574. else {
  39575. this.changeState("closed");
  39576. }
  39577. this.unbindListeners();
  39578. this.socket = undefined;
  39579. };
  39580. TransportConnection.prototype.onMessage = function (message) {
  39581. this.emit("message", message);
  39582. };
  39583. TransportConnection.prototype.onActivity = function () {
  39584. this.emit("activity");
  39585. };
  39586. TransportConnection.prototype.bindListeners = function () {
  39587. var _this = this;
  39588. this.socket.onopen = function () {
  39589. _this.onOpen();
  39590. };
  39591. this.socket.onerror = function (error) {
  39592. _this.onError(error);
  39593. };
  39594. this.socket.onclose = function (closeEvent) {
  39595. _this.onClose(closeEvent);
  39596. };
  39597. this.socket.onmessage = function (message) {
  39598. _this.onMessage(message);
  39599. };
  39600. if (this.supportsPing()) {
  39601. this.socket.onactivity = function () { _this.onActivity(); };
  39602. }
  39603. };
  39604. TransportConnection.prototype.unbindListeners = function () {
  39605. if (this.socket) {
  39606. this.socket.onopen = undefined;
  39607. this.socket.onerror = undefined;
  39608. this.socket.onclose = undefined;
  39609. this.socket.onmessage = undefined;
  39610. if (this.supportsPing()) {
  39611. this.socket.onactivity = undefined;
  39612. }
  39613. }
  39614. };
  39615. TransportConnection.prototype.changeState = function (state, params) {
  39616. this.state = state;
  39617. this.timeline.info(this.buildTimelineMessage({
  39618. state: state,
  39619. params: params
  39620. }));
  39621. this.emit(state, params);
  39622. };
  39623. TransportConnection.prototype.buildTimelineMessage = function (message) {
  39624. return extend({ cid: this.id }, message);
  39625. };
  39626. return TransportConnection;
  39627. }(dispatcher));
  39628. /* harmony default export */ var transport_connection = (transport_connection_TransportConnection);
  39629. // CONCATENATED MODULE: ./src/core/transports/transport.ts
  39630. var transport_Transport = (function () {
  39631. function Transport(hooks) {
  39632. this.hooks = hooks;
  39633. }
  39634. Transport.prototype.isSupported = function (environment) {
  39635. return this.hooks.isSupported(environment);
  39636. };
  39637. Transport.prototype.createConnection = function (name, priority, key, options) {
  39638. return new transport_connection(this.hooks, name, priority, key, options);
  39639. };
  39640. return Transport;
  39641. }());
  39642. /* harmony default export */ var transports_transport = (transport_Transport);
  39643. // CONCATENATED MODULE: ./src/runtimes/isomorphic/transports/transports.ts
  39644. var WSTransport = new transports_transport({
  39645. urls: ws,
  39646. handlesActivityChecks: false,
  39647. supportsPing: false,
  39648. isInitialized: function () {
  39649. return Boolean(runtime.getWebSocketAPI());
  39650. },
  39651. isSupported: function () {
  39652. return Boolean(runtime.getWebSocketAPI());
  39653. },
  39654. getSocket: function (url) {
  39655. return runtime.createWebSocket(url);
  39656. }
  39657. });
  39658. var httpConfiguration = {
  39659. urls: http,
  39660. handlesActivityChecks: false,
  39661. supportsPing: true,
  39662. isInitialized: function () {
  39663. return true;
  39664. }
  39665. };
  39666. var streamingConfiguration = extend({ getSocket: function (url) {
  39667. return runtime.HTTPFactory.createStreamingSocket(url);
  39668. }
  39669. }, httpConfiguration);
  39670. var pollingConfiguration = extend({ getSocket: function (url) {
  39671. return runtime.HTTPFactory.createPollingSocket(url);
  39672. }
  39673. }, httpConfiguration);
  39674. var xhrConfiguration = {
  39675. isSupported: function () {
  39676. return runtime.isXHRSupported();
  39677. }
  39678. };
  39679. var XHRStreamingTransport = new transports_transport(extend({}, streamingConfiguration, xhrConfiguration));
  39680. var XHRPollingTransport = new transports_transport(extend({}, pollingConfiguration, xhrConfiguration));
  39681. var Transports = {
  39682. ws: WSTransport,
  39683. xhr_streaming: XHRStreamingTransport,
  39684. xhr_polling: XHRPollingTransport
  39685. };
  39686. /* harmony default export */ var transports = (Transports);
  39687. // CONCATENATED MODULE: ./src/runtimes/web/transports/transports.ts
  39688. var SockJSTransport = new transports_transport({
  39689. file: "sockjs",
  39690. urls: sockjs,
  39691. handlesActivityChecks: true,
  39692. supportsPing: false,
  39693. isSupported: function () {
  39694. return true;
  39695. },
  39696. isInitialized: function () {
  39697. return window.SockJS !== undefined;
  39698. },
  39699. getSocket: function (url, options) {
  39700. return new window.SockJS(url, null, {
  39701. js_path: Dependencies.getPath("sockjs", {
  39702. useTLS: options.useTLS
  39703. }),
  39704. ignore_null_origin: options.ignoreNullOrigin
  39705. });
  39706. },
  39707. beforeOpen: function (socket, path) {
  39708. socket.send(JSON.stringify({
  39709. path: path
  39710. }));
  39711. }
  39712. });
  39713. var xdrConfiguration = {
  39714. isSupported: function (environment) {
  39715. var yes = runtime.isXDRSupported(environment.useTLS);
  39716. return yes;
  39717. }
  39718. };
  39719. var XDRStreamingTransport = new transports_transport(extend({}, streamingConfiguration, xdrConfiguration));
  39720. var XDRPollingTransport = new transports_transport(extend({}, pollingConfiguration, xdrConfiguration));
  39721. transports.xdr_streaming = XDRStreamingTransport;
  39722. transports.xdr_polling = XDRPollingTransport;
  39723. transports.sockjs = SockJSTransport;
  39724. /* harmony default export */ var transports_transports = (transports);
  39725. // CONCATENATED MODULE: ./src/runtimes/web/net_info.ts
  39726. var net_info_extends = (undefined && undefined.__extends) || (function () {
  39727. var extendStatics = function (d, b) {
  39728. extendStatics = Object.setPrototypeOf ||
  39729. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  39730. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  39731. return extendStatics(d, b);
  39732. };
  39733. return function (d, b) {
  39734. extendStatics(d, b);
  39735. function __() { this.constructor = d; }
  39736. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  39737. };
  39738. })();
  39739. var NetInfo = (function (_super) {
  39740. net_info_extends(NetInfo, _super);
  39741. function NetInfo() {
  39742. var _this = _super.call(this) || this;
  39743. var self = _this;
  39744. if (window.addEventListener !== undefined) {
  39745. window.addEventListener("online", function () {
  39746. self.emit('online');
  39747. }, false);
  39748. window.addEventListener("offline", function () {
  39749. self.emit('offline');
  39750. }, false);
  39751. }
  39752. return _this;
  39753. }
  39754. NetInfo.prototype.isOnline = function () {
  39755. if (window.navigator.onLine === undefined) {
  39756. return true;
  39757. }
  39758. else {
  39759. return window.navigator.onLine;
  39760. }
  39761. };
  39762. return NetInfo;
  39763. }(dispatcher));
  39764. var net_info_Network = new NetInfo();
  39765. // CONCATENATED MODULE: ./src/core/transports/assistant_to_the_transport_manager.ts
  39766. var assistant_to_the_transport_manager_AssistantToTheTransportManager = (function () {
  39767. function AssistantToTheTransportManager(manager, transport, options) {
  39768. this.manager = manager;
  39769. this.transport = transport;
  39770. this.minPingDelay = options.minPingDelay;
  39771. this.maxPingDelay = options.maxPingDelay;
  39772. this.pingDelay = undefined;
  39773. }
  39774. AssistantToTheTransportManager.prototype.createConnection = function (name, priority, key, options) {
  39775. var _this = this;
  39776. options = extend({}, options, {
  39777. activityTimeout: this.pingDelay
  39778. });
  39779. var connection = this.transport.createConnection(name, priority, key, options);
  39780. var openTimestamp = null;
  39781. var onOpen = function () {
  39782. connection.unbind("open", onOpen);
  39783. connection.bind("closed", onClosed);
  39784. openTimestamp = util.now();
  39785. };
  39786. var onClosed = function (closeEvent) {
  39787. connection.unbind("closed", onClosed);
  39788. if (closeEvent.code === 1002 || closeEvent.code === 1003) {
  39789. _this.manager.reportDeath();
  39790. }
  39791. else if (!closeEvent.wasClean && openTimestamp) {
  39792. var lifespan = util.now() - openTimestamp;
  39793. if (lifespan < 2 * _this.maxPingDelay) {
  39794. _this.manager.reportDeath();
  39795. _this.pingDelay = Math.max(lifespan / 2, _this.minPingDelay);
  39796. }
  39797. }
  39798. };
  39799. connection.bind("open", onOpen);
  39800. return connection;
  39801. };
  39802. AssistantToTheTransportManager.prototype.isSupported = function (environment) {
  39803. return this.manager.isAlive() && this.transport.isSupported(environment);
  39804. };
  39805. return AssistantToTheTransportManager;
  39806. }());
  39807. /* harmony default export */ var assistant_to_the_transport_manager = (assistant_to_the_transport_manager_AssistantToTheTransportManager);
  39808. // CONCATENATED MODULE: ./src/core/connection/protocol/protocol.ts
  39809. var Protocol = {
  39810. decodeMessage: function (messageEvent) {
  39811. try {
  39812. var messageData = JSON.parse(messageEvent.data);
  39813. var pusherEventData = messageData.data;
  39814. if (typeof pusherEventData === 'string') {
  39815. try {
  39816. pusherEventData = JSON.parse(messageData.data);
  39817. }
  39818. catch (e) { }
  39819. }
  39820. var pusherEvent = {
  39821. event: messageData.event,
  39822. channel: messageData.channel,
  39823. data: pusherEventData,
  39824. };
  39825. if (messageData.user_id) {
  39826. pusherEvent.user_id = messageData.user_id;
  39827. }
  39828. return pusherEvent;
  39829. }
  39830. catch (e) {
  39831. throw { type: 'MessageParseError', error: e, data: messageEvent.data };
  39832. }
  39833. },
  39834. encodeMessage: function (event) {
  39835. return JSON.stringify(event);
  39836. },
  39837. processHandshake: function (messageEvent) {
  39838. var message = Protocol.decodeMessage(messageEvent);
  39839. if (message.event === "pusher:connection_established") {
  39840. if (!message.data.activity_timeout) {
  39841. throw "No activity timeout specified in handshake";
  39842. }
  39843. return {
  39844. action: "connected",
  39845. id: message.data.socket_id,
  39846. activityTimeout: message.data.activity_timeout * 1000
  39847. };
  39848. }
  39849. else if (message.event === "pusher:error") {
  39850. return {
  39851. action: this.getCloseAction(message.data),
  39852. error: this.getCloseError(message.data)
  39853. };
  39854. }
  39855. else {
  39856. throw "Invalid handshake";
  39857. }
  39858. },
  39859. getCloseAction: function (closeEvent) {
  39860. if (closeEvent.code < 4000) {
  39861. if (closeEvent.code >= 1002 && closeEvent.code <= 1004) {
  39862. return "backoff";
  39863. }
  39864. else {
  39865. return null;
  39866. }
  39867. }
  39868. else if (closeEvent.code === 4000) {
  39869. return "tls_only";
  39870. }
  39871. else if (closeEvent.code < 4100) {
  39872. return "refused";
  39873. }
  39874. else if (closeEvent.code < 4200) {
  39875. return "backoff";
  39876. }
  39877. else if (closeEvent.code < 4300) {
  39878. return "retry";
  39879. }
  39880. else {
  39881. return "refused";
  39882. }
  39883. },
  39884. getCloseError: function (closeEvent) {
  39885. if (closeEvent.code !== 1000 && closeEvent.code !== 1001) {
  39886. return {
  39887. type: 'PusherError',
  39888. data: {
  39889. code: closeEvent.code,
  39890. message: closeEvent.reason || closeEvent.message
  39891. }
  39892. };
  39893. }
  39894. else {
  39895. return null;
  39896. }
  39897. }
  39898. };
  39899. /* harmony default export */ var protocol_protocol = (Protocol);
  39900. // CONCATENATED MODULE: ./src/core/connection/connection.ts
  39901. var connection_extends = (undefined && undefined.__extends) || (function () {
  39902. var extendStatics = function (d, b) {
  39903. extendStatics = Object.setPrototypeOf ||
  39904. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  39905. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  39906. return extendStatics(d, b);
  39907. };
  39908. return function (d, b) {
  39909. extendStatics(d, b);
  39910. function __() { this.constructor = d; }
  39911. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  39912. };
  39913. })();
  39914. var connection_Connection = (function (_super) {
  39915. connection_extends(Connection, _super);
  39916. function Connection(id, transport) {
  39917. var _this = _super.call(this) || this;
  39918. _this.id = id;
  39919. _this.transport = transport;
  39920. _this.activityTimeout = transport.activityTimeout;
  39921. _this.bindListeners();
  39922. return _this;
  39923. }
  39924. Connection.prototype.handlesActivityChecks = function () {
  39925. return this.transport.handlesActivityChecks();
  39926. };
  39927. Connection.prototype.send = function (data) {
  39928. return this.transport.send(data);
  39929. };
  39930. Connection.prototype.send_event = function (name, data, channel) {
  39931. var event = { event: name, data: data };
  39932. if (channel) {
  39933. event.channel = channel;
  39934. }
  39935. logger.debug('Event sent', event);
  39936. return this.send(protocol_protocol.encodeMessage(event));
  39937. };
  39938. Connection.prototype.ping = function () {
  39939. if (this.transport.supportsPing()) {
  39940. this.transport.ping();
  39941. }
  39942. else {
  39943. this.send_event('pusher:ping', {});
  39944. }
  39945. };
  39946. Connection.prototype.close = function () {
  39947. this.transport.close();
  39948. };
  39949. Connection.prototype.bindListeners = function () {
  39950. var _this = this;
  39951. var listeners = {
  39952. message: function (messageEvent) {
  39953. var pusherEvent;
  39954. try {
  39955. pusherEvent = protocol_protocol.decodeMessage(messageEvent);
  39956. }
  39957. catch (e) {
  39958. _this.emit('error', {
  39959. type: 'MessageParseError',
  39960. error: e,
  39961. data: messageEvent.data
  39962. });
  39963. }
  39964. if (pusherEvent !== undefined) {
  39965. logger.debug('Event recd', pusherEvent);
  39966. switch (pusherEvent.event) {
  39967. case 'pusher:error':
  39968. _this.emit('error', { type: 'PusherError', data: pusherEvent.data });
  39969. break;
  39970. case 'pusher:ping':
  39971. _this.emit("ping");
  39972. break;
  39973. case 'pusher:pong':
  39974. _this.emit("pong");
  39975. break;
  39976. }
  39977. _this.emit('message', pusherEvent);
  39978. }
  39979. },
  39980. activity: function () {
  39981. _this.emit("activity");
  39982. },
  39983. error: function (error) {
  39984. _this.emit("error", { type: "WebSocketError", error: error });
  39985. },
  39986. closed: function (closeEvent) {
  39987. unbindListeners();
  39988. if (closeEvent && closeEvent.code) {
  39989. _this.handleCloseEvent(closeEvent);
  39990. }
  39991. _this.transport = null;
  39992. _this.emit("closed");
  39993. }
  39994. };
  39995. var unbindListeners = function () {
  39996. objectApply(listeners, function (listener, event) {
  39997. _this.transport.unbind(event, listener);
  39998. });
  39999. };
  40000. objectApply(listeners, function (listener, event) {
  40001. _this.transport.bind(event, listener);
  40002. });
  40003. };
  40004. Connection.prototype.handleCloseEvent = function (closeEvent) {
  40005. var action = protocol_protocol.getCloseAction(closeEvent);
  40006. var error = protocol_protocol.getCloseError(closeEvent);
  40007. if (error) {
  40008. this.emit('error', error);
  40009. }
  40010. if (action) {
  40011. this.emit(action, { action: action, error: error });
  40012. }
  40013. };
  40014. return Connection;
  40015. }(dispatcher));
  40016. /* harmony default export */ var connection_connection = (connection_Connection);
  40017. // CONCATENATED MODULE: ./src/core/connection/handshake/index.ts
  40018. var handshake_Handshake = (function () {
  40019. function Handshake(transport, callback) {
  40020. this.transport = transport;
  40021. this.callback = callback;
  40022. this.bindListeners();
  40023. }
  40024. Handshake.prototype.close = function () {
  40025. this.unbindListeners();
  40026. this.transport.close();
  40027. };
  40028. Handshake.prototype.bindListeners = function () {
  40029. var _this = this;
  40030. this.onMessage = function (m) {
  40031. _this.unbindListeners();
  40032. var result;
  40033. try {
  40034. result = protocol_protocol.processHandshake(m);
  40035. }
  40036. catch (e) {
  40037. _this.finish("error", { error: e });
  40038. _this.transport.close();
  40039. return;
  40040. }
  40041. if (result.action === "connected") {
  40042. _this.finish("connected", {
  40043. connection: new connection_connection(result.id, _this.transport),
  40044. activityTimeout: result.activityTimeout
  40045. });
  40046. }
  40047. else {
  40048. _this.finish(result.action, { error: result.error });
  40049. _this.transport.close();
  40050. }
  40051. };
  40052. this.onClosed = function (closeEvent) {
  40053. _this.unbindListeners();
  40054. var action = protocol_protocol.getCloseAction(closeEvent) || "backoff";
  40055. var error = protocol_protocol.getCloseError(closeEvent);
  40056. _this.finish(action, { error: error });
  40057. };
  40058. this.transport.bind("message", this.onMessage);
  40059. this.transport.bind("closed", this.onClosed);
  40060. };
  40061. Handshake.prototype.unbindListeners = function () {
  40062. this.transport.unbind("message", this.onMessage);
  40063. this.transport.unbind("closed", this.onClosed);
  40064. };
  40065. Handshake.prototype.finish = function (action, params) {
  40066. this.callback(extend({ transport: this.transport, action: action }, params));
  40067. };
  40068. return Handshake;
  40069. }());
  40070. /* harmony default export */ var connection_handshake = (handshake_Handshake);
  40071. // CONCATENATED MODULE: ./src/core/auth/pusher_authorizer.ts
  40072. var pusher_authorizer_PusherAuthorizer = (function () {
  40073. function PusherAuthorizer(channel, options) {
  40074. this.channel = channel;
  40075. var authTransport = options.authTransport;
  40076. if (typeof runtime.getAuthorizers()[authTransport] === "undefined") {
  40077. throw "'" + authTransport + "' is not a recognized auth transport";
  40078. }
  40079. this.type = authTransport;
  40080. this.options = options;
  40081. this.authOptions = (options || {}).auth || {};
  40082. }
  40083. PusherAuthorizer.prototype.composeQuery = function (socketId) {
  40084. var query = 'socket_id=' + encodeURIComponent(socketId) +
  40085. '&channel_name=' + encodeURIComponent(this.channel.name);
  40086. for (var i in this.authOptions.params) {
  40087. query += "&" + encodeURIComponent(i) + "=" + encodeURIComponent(this.authOptions.params[i]);
  40088. }
  40089. return query;
  40090. };
  40091. PusherAuthorizer.prototype.authorize = function (socketId, callback) {
  40092. PusherAuthorizer.authorizers = PusherAuthorizer.authorizers || runtime.getAuthorizers();
  40093. return PusherAuthorizer.authorizers[this.type].call(this, runtime, socketId, callback);
  40094. };
  40095. return PusherAuthorizer;
  40096. }());
  40097. /* harmony default export */ var pusher_authorizer = (pusher_authorizer_PusherAuthorizer);
  40098. // CONCATENATED MODULE: ./src/core/timeline/timeline_sender.ts
  40099. var timeline_sender_TimelineSender = (function () {
  40100. function TimelineSender(timeline, options) {
  40101. this.timeline = timeline;
  40102. this.options = options || {};
  40103. }
  40104. TimelineSender.prototype.send = function (useTLS, callback) {
  40105. if (this.timeline.isEmpty()) {
  40106. return;
  40107. }
  40108. this.timeline.send(runtime.TimelineTransport.getAgent(this, useTLS), callback);
  40109. };
  40110. return TimelineSender;
  40111. }());
  40112. /* harmony default export */ var timeline_sender = (timeline_sender_TimelineSender);
  40113. // CONCATENATED MODULE: ./src/core/errors.ts
  40114. var errors_extends = (undefined && undefined.__extends) || (function () {
  40115. var extendStatics = function (d, b) {
  40116. extendStatics = Object.setPrototypeOf ||
  40117. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  40118. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  40119. return extendStatics(d, b);
  40120. };
  40121. return function (d, b) {
  40122. extendStatics(d, b);
  40123. function __() { this.constructor = d; }
  40124. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  40125. };
  40126. })();
  40127. var BadEventName = (function (_super) {
  40128. errors_extends(BadEventName, _super);
  40129. function BadEventName(msg) {
  40130. var _newTarget = this.constructor;
  40131. var _this = _super.call(this, msg) || this;
  40132. Object.setPrototypeOf(_this, _newTarget.prototype);
  40133. return _this;
  40134. }
  40135. return BadEventName;
  40136. }(Error));
  40137. var RequestTimedOut = (function (_super) {
  40138. errors_extends(RequestTimedOut, _super);
  40139. function RequestTimedOut(msg) {
  40140. var _newTarget = this.constructor;
  40141. var _this = _super.call(this, msg) || this;
  40142. Object.setPrototypeOf(_this, _newTarget.prototype);
  40143. return _this;
  40144. }
  40145. return RequestTimedOut;
  40146. }(Error));
  40147. var TransportPriorityTooLow = (function (_super) {
  40148. errors_extends(TransportPriorityTooLow, _super);
  40149. function TransportPriorityTooLow(msg) {
  40150. var _newTarget = this.constructor;
  40151. var _this = _super.call(this, msg) || this;
  40152. Object.setPrototypeOf(_this, _newTarget.prototype);
  40153. return _this;
  40154. }
  40155. return TransportPriorityTooLow;
  40156. }(Error));
  40157. var TransportClosed = (function (_super) {
  40158. errors_extends(TransportClosed, _super);
  40159. function TransportClosed(msg) {
  40160. var _newTarget = this.constructor;
  40161. var _this = _super.call(this, msg) || this;
  40162. Object.setPrototypeOf(_this, _newTarget.prototype);
  40163. return _this;
  40164. }
  40165. return TransportClosed;
  40166. }(Error));
  40167. var UnsupportedFeature = (function (_super) {
  40168. errors_extends(UnsupportedFeature, _super);
  40169. function UnsupportedFeature(msg) {
  40170. var _newTarget = this.constructor;
  40171. var _this = _super.call(this, msg) || this;
  40172. Object.setPrototypeOf(_this, _newTarget.prototype);
  40173. return _this;
  40174. }
  40175. return UnsupportedFeature;
  40176. }(Error));
  40177. var UnsupportedTransport = (function (_super) {
  40178. errors_extends(UnsupportedTransport, _super);
  40179. function UnsupportedTransport(msg) {
  40180. var _newTarget = this.constructor;
  40181. var _this = _super.call(this, msg) || this;
  40182. Object.setPrototypeOf(_this, _newTarget.prototype);
  40183. return _this;
  40184. }
  40185. return UnsupportedTransport;
  40186. }(Error));
  40187. var UnsupportedStrategy = (function (_super) {
  40188. errors_extends(UnsupportedStrategy, _super);
  40189. function UnsupportedStrategy(msg) {
  40190. var _newTarget = this.constructor;
  40191. var _this = _super.call(this, msg) || this;
  40192. Object.setPrototypeOf(_this, _newTarget.prototype);
  40193. return _this;
  40194. }
  40195. return UnsupportedStrategy;
  40196. }(Error));
  40197. // CONCATENATED MODULE: ./src/core/channels/channel.ts
  40198. var channel_extends = (undefined && undefined.__extends) || (function () {
  40199. var extendStatics = function (d, b) {
  40200. extendStatics = Object.setPrototypeOf ||
  40201. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  40202. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  40203. return extendStatics(d, b);
  40204. };
  40205. return function (d, b) {
  40206. extendStatics(d, b);
  40207. function __() { this.constructor = d; }
  40208. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  40209. };
  40210. })();
  40211. var channel_Channel = (function (_super) {
  40212. channel_extends(Channel, _super);
  40213. function Channel(name, pusher) {
  40214. var _this = _super.call(this, function (event, data) {
  40215. logger.debug('No callbacks on ' + name + ' for ' + event);
  40216. }) || this;
  40217. _this.name = name;
  40218. _this.pusher = pusher;
  40219. _this.subscribed = false;
  40220. _this.subscriptionPending = false;
  40221. _this.subscriptionCancelled = false;
  40222. return _this;
  40223. }
  40224. Channel.prototype.authorize = function (socketId, callback) {
  40225. return callback(false, {});
  40226. };
  40227. Channel.prototype.trigger = function (event, data) {
  40228. if (event.indexOf("client-") !== 0) {
  40229. throw new BadEventName("Event '" + event + "' does not start with 'client-'");
  40230. }
  40231. if (!this.subscribed) {
  40232. var suffix = url_store.buildLogSuffix("triggeringClientEvents");
  40233. logger.warn("Client event triggered before channel 'subscription_succeeded' event . " + suffix);
  40234. }
  40235. return this.pusher.send_event(event, data, this.name);
  40236. };
  40237. Channel.prototype.disconnect = function () {
  40238. this.subscribed = false;
  40239. this.subscriptionPending = false;
  40240. };
  40241. Channel.prototype.handleEvent = function (event) {
  40242. var eventName = event.event;
  40243. var data = event.data;
  40244. if (eventName === "pusher_internal:subscription_succeeded") {
  40245. this.handleSubscriptionSucceededEvent(event);
  40246. }
  40247. else if (eventName.indexOf("pusher_internal:") !== 0) {
  40248. var metadata = {};
  40249. this.emit(eventName, data, metadata);
  40250. }
  40251. };
  40252. Channel.prototype.handleSubscriptionSucceededEvent = function (event) {
  40253. this.subscriptionPending = false;
  40254. this.subscribed = true;
  40255. if (this.subscriptionCancelled) {
  40256. this.pusher.unsubscribe(this.name);
  40257. }
  40258. else {
  40259. this.emit("pusher:subscription_succeeded", event.data);
  40260. }
  40261. };
  40262. Channel.prototype.subscribe = function () {
  40263. var _this = this;
  40264. if (this.subscribed) {
  40265. return;
  40266. }
  40267. this.subscriptionPending = true;
  40268. this.subscriptionCancelled = false;
  40269. this.authorize(this.pusher.connection.socket_id, function (error, data) {
  40270. if (error) {
  40271. logger.error(data);
  40272. _this.emit('pusher:subscription_error', data);
  40273. }
  40274. else {
  40275. _this.pusher.send_event('pusher:subscribe', {
  40276. auth: data.auth,
  40277. channel_data: data.channel_data,
  40278. channel: _this.name
  40279. });
  40280. }
  40281. });
  40282. };
  40283. Channel.prototype.unsubscribe = function () {
  40284. this.subscribed = false;
  40285. this.pusher.send_event('pusher:unsubscribe', {
  40286. channel: this.name
  40287. });
  40288. };
  40289. Channel.prototype.cancelSubscription = function () {
  40290. this.subscriptionCancelled = true;
  40291. };
  40292. Channel.prototype.reinstateSubscription = function () {
  40293. this.subscriptionCancelled = false;
  40294. };
  40295. return Channel;
  40296. }(dispatcher));
  40297. /* harmony default export */ var channels_channel = (channel_Channel);
  40298. // CONCATENATED MODULE: ./src/core/channels/private_channel.ts
  40299. var private_channel_extends = (undefined && undefined.__extends) || (function () {
  40300. var extendStatics = function (d, b) {
  40301. extendStatics = Object.setPrototypeOf ||
  40302. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  40303. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  40304. return extendStatics(d, b);
  40305. };
  40306. return function (d, b) {
  40307. extendStatics(d, b);
  40308. function __() { this.constructor = d; }
  40309. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  40310. };
  40311. })();
  40312. var private_channel_PrivateChannel = (function (_super) {
  40313. private_channel_extends(PrivateChannel, _super);
  40314. function PrivateChannel() {
  40315. return _super !== null && _super.apply(this, arguments) || this;
  40316. }
  40317. PrivateChannel.prototype.authorize = function (socketId, callback) {
  40318. var authorizer = factory.createAuthorizer(this, this.pusher.config);
  40319. return authorizer.authorize(socketId, callback);
  40320. };
  40321. return PrivateChannel;
  40322. }(channels_channel));
  40323. /* harmony default export */ var private_channel = (private_channel_PrivateChannel);
  40324. // CONCATENATED MODULE: ./src/core/channels/members.ts
  40325. var members_Members = (function () {
  40326. function Members() {
  40327. this.reset();
  40328. }
  40329. Members.prototype.get = function (id) {
  40330. if (Object.prototype.hasOwnProperty.call(this.members, id)) {
  40331. return {
  40332. id: id,
  40333. info: this.members[id]
  40334. };
  40335. }
  40336. else {
  40337. return null;
  40338. }
  40339. };
  40340. Members.prototype.each = function (callback) {
  40341. var _this = this;
  40342. objectApply(this.members, function (member, id) {
  40343. callback(_this.get(id));
  40344. });
  40345. };
  40346. Members.prototype.setMyID = function (id) {
  40347. this.myID = id;
  40348. };
  40349. Members.prototype.onSubscription = function (subscriptionData) {
  40350. this.members = subscriptionData.presence.hash;
  40351. this.count = subscriptionData.presence.count;
  40352. this.me = this.get(this.myID);
  40353. };
  40354. Members.prototype.addMember = function (memberData) {
  40355. if (this.get(memberData.user_id) === null) {
  40356. this.count++;
  40357. }
  40358. this.members[memberData.user_id] = memberData.user_info;
  40359. return this.get(memberData.user_id);
  40360. };
  40361. Members.prototype.removeMember = function (memberData) {
  40362. var member = this.get(memberData.user_id);
  40363. if (member) {
  40364. delete this.members[memberData.user_id];
  40365. this.count--;
  40366. }
  40367. return member;
  40368. };
  40369. Members.prototype.reset = function () {
  40370. this.members = {};
  40371. this.count = 0;
  40372. this.myID = null;
  40373. this.me = null;
  40374. };
  40375. return Members;
  40376. }());
  40377. /* harmony default export */ var members = (members_Members);
  40378. // CONCATENATED MODULE: ./src/core/channels/presence_channel.ts
  40379. var presence_channel_extends = (undefined && undefined.__extends) || (function () {
  40380. var extendStatics = function (d, b) {
  40381. extendStatics = Object.setPrototypeOf ||
  40382. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  40383. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  40384. return extendStatics(d, b);
  40385. };
  40386. return function (d, b) {
  40387. extendStatics(d, b);
  40388. function __() { this.constructor = d; }
  40389. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  40390. };
  40391. })();
  40392. var presence_channel_PresenceChannel = (function (_super) {
  40393. presence_channel_extends(PresenceChannel, _super);
  40394. function PresenceChannel(name, pusher) {
  40395. var _this = _super.call(this, name, pusher) || this;
  40396. _this.members = new members();
  40397. return _this;
  40398. }
  40399. PresenceChannel.prototype.authorize = function (socketId, callback) {
  40400. var _this = this;
  40401. _super.prototype.authorize.call(this, socketId, function (error, authData) {
  40402. if (!error) {
  40403. if (authData.channel_data === undefined) {
  40404. var suffix = url_store.buildLogSuffix("authenticationEndpoint");
  40405. logger.error("Invalid auth response for channel '" + _this.name + "'," +
  40406. ("expected 'channel_data' field. " + suffix));
  40407. callback("Invalid auth response");
  40408. return;
  40409. }
  40410. var channelData = JSON.parse(authData.channel_data);
  40411. _this.members.setMyID(channelData.user_id);
  40412. }
  40413. callback(error, authData);
  40414. });
  40415. };
  40416. PresenceChannel.prototype.handleEvent = function (event) {
  40417. var eventName = event.event;
  40418. if (eventName.indexOf("pusher_internal:") === 0) {
  40419. this.handleInternalEvent(event);
  40420. }
  40421. else {
  40422. var data = event.data;
  40423. var metadata = {};
  40424. if (event.user_id) {
  40425. metadata.user_id = event.user_id;
  40426. }
  40427. this.emit(eventName, data, metadata);
  40428. }
  40429. };
  40430. PresenceChannel.prototype.handleInternalEvent = function (event) {
  40431. var eventName = event.event;
  40432. var data = event.data;
  40433. switch (eventName) {
  40434. case "pusher_internal:subscription_succeeded":
  40435. this.handleSubscriptionSucceededEvent(event);
  40436. break;
  40437. case "pusher_internal:member_added":
  40438. var addedMember = this.members.addMember(data);
  40439. this.emit('pusher:member_added', addedMember);
  40440. break;
  40441. case "pusher_internal:member_removed":
  40442. var removedMember = this.members.removeMember(data);
  40443. if (removedMember) {
  40444. this.emit('pusher:member_removed', removedMember);
  40445. }
  40446. break;
  40447. }
  40448. };
  40449. PresenceChannel.prototype.handleSubscriptionSucceededEvent = function (event) {
  40450. this.subscriptionPending = false;
  40451. this.subscribed = true;
  40452. if (this.subscriptionCancelled) {
  40453. this.pusher.unsubscribe(this.name);
  40454. }
  40455. else {
  40456. this.members.onSubscription(event.data);
  40457. this.emit("pusher:subscription_succeeded", this.members);
  40458. }
  40459. };
  40460. PresenceChannel.prototype.disconnect = function () {
  40461. this.members.reset();
  40462. _super.prototype.disconnect.call(this);
  40463. };
  40464. return PresenceChannel;
  40465. }(private_channel));
  40466. /* harmony default export */ var presence_channel = (presence_channel_PresenceChannel);
  40467. // EXTERNAL MODULE: ./node_modules/tweetnacl/nacl-fast.js
  40468. var nacl_fast = __webpack_require__(0);
  40469. // EXTERNAL MODULE: ./node_modules/tweetnacl-util/nacl-util.js
  40470. var nacl_util = __webpack_require__(1);
  40471. // CONCATENATED MODULE: ./src/core/channels/encrypted_channel.ts
  40472. var encrypted_channel_extends = (undefined && undefined.__extends) || (function () {
  40473. var extendStatics = function (d, b) {
  40474. extendStatics = Object.setPrototypeOf ||
  40475. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  40476. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  40477. return extendStatics(d, b);
  40478. };
  40479. return function (d, b) {
  40480. extendStatics(d, b);
  40481. function __() { this.constructor = d; }
  40482. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  40483. };
  40484. })();
  40485. var encrypted_channel_EncryptedChannel = (function (_super) {
  40486. encrypted_channel_extends(EncryptedChannel, _super);
  40487. function EncryptedChannel() {
  40488. var _this = _super !== null && _super.apply(this, arguments) || this;
  40489. _this.key = null;
  40490. return _this;
  40491. }
  40492. EncryptedChannel.prototype.authorize = function (socketId, callback) {
  40493. var _this = this;
  40494. _super.prototype.authorize.call(this, socketId, function (error, authData) {
  40495. if (error) {
  40496. callback(true, authData);
  40497. return;
  40498. }
  40499. var sharedSecret = authData["shared_secret"];
  40500. if (!sharedSecret) {
  40501. var errorMsg = "No shared_secret key in auth payload for encrypted channel: " + _this.name;
  40502. callback(true, errorMsg);
  40503. return;
  40504. }
  40505. _this.key = Object(nacl_util["decodeBase64"])(sharedSecret);
  40506. delete authData["shared_secret"];
  40507. callback(false, authData);
  40508. });
  40509. };
  40510. EncryptedChannel.prototype.trigger = function (event, data) {
  40511. throw new UnsupportedFeature('Client events are not currently supported for encrypted channels');
  40512. };
  40513. EncryptedChannel.prototype.handleEvent = function (event) {
  40514. var eventName = event.event;
  40515. var data = event.data;
  40516. if (eventName.indexOf("pusher_internal:") === 0 || eventName.indexOf("pusher:") === 0) {
  40517. _super.prototype.handleEvent.call(this, event);
  40518. return;
  40519. }
  40520. this.handleEncryptedEvent(eventName, data);
  40521. };
  40522. EncryptedChannel.prototype.handleEncryptedEvent = function (event, data) {
  40523. var _this = this;
  40524. if (!this.key) {
  40525. logger.debug('Received encrypted event before key has been retrieved from the authEndpoint');
  40526. return;
  40527. }
  40528. if (!data.ciphertext || !data.nonce) {
  40529. logger.error('Unexpected format for encrypted event, expected object with `ciphertext` and `nonce` fields, got: ' + data);
  40530. return;
  40531. }
  40532. var cipherText = Object(nacl_util["decodeBase64"])(data.ciphertext);
  40533. if (cipherText.length < nacl_fast["secretbox"].overheadLength) {
  40534. logger.error("Expected encrypted event ciphertext length to be " + nacl_fast["secretbox"].overheadLength + ", got: " + cipherText.length);
  40535. return;
  40536. }
  40537. var nonce = Object(nacl_util["decodeBase64"])(data.nonce);
  40538. if (nonce.length < nacl_fast["secretbox"].nonceLength) {
  40539. logger.error("Expected encrypted event nonce length to be " + nacl_fast["secretbox"].nonceLength + ", got: " + nonce.length);
  40540. return;
  40541. }
  40542. var bytes = nacl_fast["secretbox"].open(cipherText, nonce, this.key);
  40543. if (bytes === null) {
  40544. logger.debug('Failed to decrypt an event, probably because it was encrypted with a different key. Fetching a new key from the authEndpoint...');
  40545. this.authorize(this.pusher.connection.socket_id, function (error, authData) {
  40546. if (error) {
  40547. logger.error("Failed to make a request to the authEndpoint: " + authData + ". Unable to fetch new key, so dropping encrypted event");
  40548. return;
  40549. }
  40550. bytes = nacl_fast["secretbox"].open(cipherText, nonce, _this.key);
  40551. if (bytes === null) {
  40552. logger.error("Failed to decrypt event with new key. Dropping encrypted event");
  40553. return;
  40554. }
  40555. _this.emitJSON(event, Object(nacl_util["encodeUTF8"])(bytes));
  40556. return;
  40557. });
  40558. return;
  40559. }
  40560. this.emitJSON(event, Object(nacl_util["encodeUTF8"])(bytes));
  40561. };
  40562. EncryptedChannel.prototype.emitJSON = function (eventName, data) {
  40563. try {
  40564. this.emit(eventName, JSON.parse(data));
  40565. }
  40566. catch (e) {
  40567. this.emit(eventName, data);
  40568. }
  40569. return this;
  40570. };
  40571. return EncryptedChannel;
  40572. }(private_channel));
  40573. /* harmony default export */ var encrypted_channel = (encrypted_channel_EncryptedChannel);
  40574. // CONCATENATED MODULE: ./src/core/connection/connection_manager.ts
  40575. var connection_manager_extends = (undefined && undefined.__extends) || (function () {
  40576. var extendStatics = function (d, b) {
  40577. extendStatics = Object.setPrototypeOf ||
  40578. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  40579. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  40580. return extendStatics(d, b);
  40581. };
  40582. return function (d, b) {
  40583. extendStatics(d, b);
  40584. function __() { this.constructor = d; }
  40585. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  40586. };
  40587. })();
  40588. var connection_manager_ConnectionManager = (function (_super) {
  40589. connection_manager_extends(ConnectionManager, _super);
  40590. function ConnectionManager(key, options) {
  40591. var _this = _super.call(this) || this;
  40592. _this.key = key;
  40593. _this.options = options || {};
  40594. _this.state = "initialized";
  40595. _this.connection = null;
  40596. _this.usingTLS = !!options.useTLS;
  40597. _this.timeline = _this.options.timeline;
  40598. _this.errorCallbacks = _this.buildErrorCallbacks();
  40599. _this.connectionCallbacks = _this.buildConnectionCallbacks(_this.errorCallbacks);
  40600. _this.handshakeCallbacks = _this.buildHandshakeCallbacks(_this.errorCallbacks);
  40601. var Network = runtime.getNetwork();
  40602. Network.bind("online", function () {
  40603. _this.timeline.info({ netinfo: "online" });
  40604. if (_this.state === "connecting" || _this.state === "unavailable") {
  40605. _this.retryIn(0);
  40606. }
  40607. });
  40608. Network.bind("offline", function () {
  40609. _this.timeline.info({ netinfo: "offline" });
  40610. if (_this.connection) {
  40611. _this.sendActivityCheck();
  40612. }
  40613. });
  40614. _this.updateStrategy();
  40615. return _this;
  40616. }
  40617. ConnectionManager.prototype.connect = function () {
  40618. if (this.connection || this.runner) {
  40619. return;
  40620. }
  40621. if (!this.strategy.isSupported()) {
  40622. this.updateState("failed");
  40623. return;
  40624. }
  40625. this.updateState("connecting");
  40626. this.startConnecting();
  40627. this.setUnavailableTimer();
  40628. };
  40629. ;
  40630. ConnectionManager.prototype.send = function (data) {
  40631. if (this.connection) {
  40632. return this.connection.send(data);
  40633. }
  40634. else {
  40635. return false;
  40636. }
  40637. };
  40638. ;
  40639. ConnectionManager.prototype.send_event = function (name, data, channel) {
  40640. if (this.connection) {
  40641. return this.connection.send_event(name, data, channel);
  40642. }
  40643. else {
  40644. return false;
  40645. }
  40646. };
  40647. ;
  40648. ConnectionManager.prototype.disconnect = function () {
  40649. this.disconnectInternally();
  40650. this.updateState("disconnected");
  40651. };
  40652. ;
  40653. ConnectionManager.prototype.isUsingTLS = function () {
  40654. return this.usingTLS;
  40655. };
  40656. ;
  40657. ConnectionManager.prototype.startConnecting = function () {
  40658. var _this = this;
  40659. var callback = function (error, handshake) {
  40660. if (error) {
  40661. _this.runner = _this.strategy.connect(0, callback);
  40662. }
  40663. else {
  40664. if (handshake.action === "error") {
  40665. _this.emit("error", { type: "HandshakeError", error: handshake.error });
  40666. _this.timeline.error({ handshakeError: handshake.error });
  40667. }
  40668. else {
  40669. _this.abortConnecting();
  40670. _this.handshakeCallbacks[handshake.action](handshake);
  40671. }
  40672. }
  40673. };
  40674. this.runner = this.strategy.connect(0, callback);
  40675. };
  40676. ;
  40677. ConnectionManager.prototype.abortConnecting = function () {
  40678. if (this.runner) {
  40679. this.runner.abort();
  40680. this.runner = null;
  40681. }
  40682. };
  40683. ;
  40684. ConnectionManager.prototype.disconnectInternally = function () {
  40685. this.abortConnecting();
  40686. this.clearRetryTimer();
  40687. this.clearUnavailableTimer();
  40688. if (this.connection) {
  40689. var connection = this.abandonConnection();
  40690. connection.close();
  40691. }
  40692. };
  40693. ;
  40694. ConnectionManager.prototype.updateStrategy = function () {
  40695. this.strategy = this.options.getStrategy({
  40696. key: this.key,
  40697. timeline: this.timeline,
  40698. useTLS: this.usingTLS
  40699. });
  40700. };
  40701. ;
  40702. ConnectionManager.prototype.retryIn = function (delay) {
  40703. var _this = this;
  40704. this.timeline.info({ action: "retry", delay: delay });
  40705. if (delay > 0) {
  40706. this.emit("connecting_in", Math.round(delay / 1000));
  40707. }
  40708. this.retryTimer = new OneOffTimer(delay || 0, function () {
  40709. _this.disconnectInternally();
  40710. _this.connect();
  40711. });
  40712. };
  40713. ;
  40714. ConnectionManager.prototype.clearRetryTimer = function () {
  40715. if (this.retryTimer) {
  40716. this.retryTimer.ensureAborted();
  40717. this.retryTimer = null;
  40718. }
  40719. };
  40720. ;
  40721. ConnectionManager.prototype.setUnavailableTimer = function () {
  40722. var _this = this;
  40723. this.unavailableTimer = new OneOffTimer(this.options.unavailableTimeout, function () {
  40724. _this.updateState("unavailable");
  40725. });
  40726. };
  40727. ;
  40728. ConnectionManager.prototype.clearUnavailableTimer = function () {
  40729. if (this.unavailableTimer) {
  40730. this.unavailableTimer.ensureAborted();
  40731. }
  40732. };
  40733. ;
  40734. ConnectionManager.prototype.sendActivityCheck = function () {
  40735. var _this = this;
  40736. this.stopActivityCheck();
  40737. this.connection.ping();
  40738. this.activityTimer = new OneOffTimer(this.options.pongTimeout, function () {
  40739. _this.timeline.error({ pong_timed_out: _this.options.pongTimeout });
  40740. _this.retryIn(0);
  40741. });
  40742. };
  40743. ;
  40744. ConnectionManager.prototype.resetActivityCheck = function () {
  40745. var _this = this;
  40746. this.stopActivityCheck();
  40747. if (this.connection && !this.connection.handlesActivityChecks()) {
  40748. this.activityTimer = new OneOffTimer(this.activityTimeout, function () {
  40749. _this.sendActivityCheck();
  40750. });
  40751. }
  40752. };
  40753. ;
  40754. ConnectionManager.prototype.stopActivityCheck = function () {
  40755. if (this.activityTimer) {
  40756. this.activityTimer.ensureAborted();
  40757. }
  40758. };
  40759. ;
  40760. ConnectionManager.prototype.buildConnectionCallbacks = function (errorCallbacks) {
  40761. var _this = this;
  40762. return extend({}, errorCallbacks, {
  40763. message: function (message) {
  40764. _this.resetActivityCheck();
  40765. _this.emit('message', message);
  40766. },
  40767. ping: function () {
  40768. _this.send_event('pusher:pong', {});
  40769. },
  40770. activity: function () {
  40771. _this.resetActivityCheck();
  40772. },
  40773. error: function (error) {
  40774. _this.emit("error", { type: "WebSocketError", error: error });
  40775. },
  40776. closed: function () {
  40777. _this.abandonConnection();
  40778. if (_this.shouldRetry()) {
  40779. _this.retryIn(1000);
  40780. }
  40781. }
  40782. });
  40783. };
  40784. ;
  40785. ConnectionManager.prototype.buildHandshakeCallbacks = function (errorCallbacks) {
  40786. var _this = this;
  40787. return extend({}, errorCallbacks, {
  40788. connected: function (handshake) {
  40789. _this.activityTimeout = Math.min(_this.options.activityTimeout, handshake.activityTimeout, handshake.connection.activityTimeout || Infinity);
  40790. _this.clearUnavailableTimer();
  40791. _this.setConnection(handshake.connection);
  40792. _this.socket_id = _this.connection.id;
  40793. _this.updateState("connected", { socket_id: _this.socket_id });
  40794. }
  40795. });
  40796. };
  40797. ;
  40798. ConnectionManager.prototype.buildErrorCallbacks = function () {
  40799. var _this = this;
  40800. var withErrorEmitted = function (callback) {
  40801. return function (result) {
  40802. if (result.error) {
  40803. _this.emit("error", { type: "WebSocketError", error: result.error });
  40804. }
  40805. callback(result);
  40806. };
  40807. };
  40808. return {
  40809. tls_only: withErrorEmitted(function () {
  40810. _this.usingTLS = true;
  40811. _this.updateStrategy();
  40812. _this.retryIn(0);
  40813. }),
  40814. refused: withErrorEmitted(function () {
  40815. _this.disconnect();
  40816. }),
  40817. backoff: withErrorEmitted(function () {
  40818. _this.retryIn(1000);
  40819. }),
  40820. retry: withErrorEmitted(function () {
  40821. _this.retryIn(0);
  40822. })
  40823. };
  40824. };
  40825. ;
  40826. ConnectionManager.prototype.setConnection = function (connection) {
  40827. this.connection = connection;
  40828. for (var event in this.connectionCallbacks) {
  40829. this.connection.bind(event, this.connectionCallbacks[event]);
  40830. }
  40831. this.resetActivityCheck();
  40832. };
  40833. ;
  40834. ConnectionManager.prototype.abandonConnection = function () {
  40835. if (!this.connection) {
  40836. return;
  40837. }
  40838. this.stopActivityCheck();
  40839. for (var event in this.connectionCallbacks) {
  40840. this.connection.unbind(event, this.connectionCallbacks[event]);
  40841. }
  40842. var connection = this.connection;
  40843. this.connection = null;
  40844. return connection;
  40845. };
  40846. ConnectionManager.prototype.updateState = function (newState, data) {
  40847. var previousState = this.state;
  40848. this.state = newState;
  40849. if (previousState !== newState) {
  40850. var newStateDescription = newState;
  40851. if (newStateDescription === "connected") {
  40852. newStateDescription += " with new socket ID " + data.socket_id;
  40853. }
  40854. logger.debug('State changed', previousState + ' -> ' + newStateDescription);
  40855. this.timeline.info({ state: newState, params: data });
  40856. this.emit('state_change', { previous: previousState, current: newState });
  40857. this.emit(newState, data);
  40858. }
  40859. };
  40860. ConnectionManager.prototype.shouldRetry = function () {
  40861. return this.state === "connecting" || this.state === "connected";
  40862. };
  40863. return ConnectionManager;
  40864. }(dispatcher));
  40865. /* harmony default export */ var connection_manager = (connection_manager_ConnectionManager);
  40866. // CONCATENATED MODULE: ./src/core/channels/channels.ts
  40867. var channels_Channels = (function () {
  40868. function Channels() {
  40869. this.channels = {};
  40870. }
  40871. Channels.prototype.add = function (name, pusher) {
  40872. if (!this.channels[name]) {
  40873. this.channels[name] = createChannel(name, pusher);
  40874. }
  40875. return this.channels[name];
  40876. };
  40877. Channels.prototype.all = function () {
  40878. return values(this.channels);
  40879. };
  40880. Channels.prototype.find = function (name) {
  40881. return this.channels[name];
  40882. };
  40883. Channels.prototype.remove = function (name) {
  40884. var channel = this.channels[name];
  40885. delete this.channels[name];
  40886. return channel;
  40887. };
  40888. Channels.prototype.disconnect = function () {
  40889. objectApply(this.channels, function (channel) {
  40890. channel.disconnect();
  40891. });
  40892. };
  40893. return Channels;
  40894. }());
  40895. /* harmony default export */ var channels = (channels_Channels);
  40896. function createChannel(name, pusher) {
  40897. if (name.indexOf('private-encrypted-') === 0) {
  40898. if (false) { var errorMsg; }
  40899. return factory.createEncryptedChannel(name, pusher);
  40900. }
  40901. else if (name.indexOf('private-') === 0) {
  40902. return factory.createPrivateChannel(name, pusher);
  40903. }
  40904. else if (name.indexOf('presence-') === 0) {
  40905. return factory.createPresenceChannel(name, pusher);
  40906. }
  40907. else {
  40908. return factory.createChannel(name, pusher);
  40909. }
  40910. }
  40911. // CONCATENATED MODULE: ./src/core/utils/factory.ts
  40912. var Factory = {
  40913. createChannels: function () {
  40914. return new channels();
  40915. },
  40916. createConnectionManager: function (key, options) {
  40917. return new connection_manager(key, options);
  40918. },
  40919. createChannel: function (name, pusher) {
  40920. return new channels_channel(name, pusher);
  40921. },
  40922. createPrivateChannel: function (name, pusher) {
  40923. return new private_channel(name, pusher);
  40924. },
  40925. createPresenceChannel: function (name, pusher) {
  40926. return new presence_channel(name, pusher);
  40927. },
  40928. createEncryptedChannel: function (name, pusher) {
  40929. return new encrypted_channel(name, pusher);
  40930. },
  40931. createTimelineSender: function (timeline, options) {
  40932. return new timeline_sender(timeline, options);
  40933. },
  40934. createAuthorizer: function (channel, options) {
  40935. if (options.authorizer) {
  40936. return options.authorizer(channel, options);
  40937. }
  40938. return new pusher_authorizer(channel, options);
  40939. },
  40940. createHandshake: function (transport, callback) {
  40941. return new connection_handshake(transport, callback);
  40942. },
  40943. createAssistantToTheTransportManager: function (manager, transport, options) {
  40944. return new assistant_to_the_transport_manager(manager, transport, options);
  40945. }
  40946. };
  40947. /* harmony default export */ var factory = (Factory);
  40948. // CONCATENATED MODULE: ./src/core/transports/transport_manager.ts
  40949. var transport_manager_TransportManager = (function () {
  40950. function TransportManager(options) {
  40951. this.options = options || {};
  40952. this.livesLeft = this.options.lives || Infinity;
  40953. }
  40954. TransportManager.prototype.getAssistant = function (transport) {
  40955. return factory.createAssistantToTheTransportManager(this, transport, {
  40956. minPingDelay: this.options.minPingDelay,
  40957. maxPingDelay: this.options.maxPingDelay
  40958. });
  40959. };
  40960. TransportManager.prototype.isAlive = function () {
  40961. return this.livesLeft > 0;
  40962. };
  40963. TransportManager.prototype.reportDeath = function () {
  40964. this.livesLeft -= 1;
  40965. };
  40966. return TransportManager;
  40967. }());
  40968. /* harmony default export */ var transport_manager = (transport_manager_TransportManager);
  40969. // CONCATENATED MODULE: ./src/core/strategies/sequential_strategy.ts
  40970. var sequential_strategy_SequentialStrategy = (function () {
  40971. function SequentialStrategy(strategies, options) {
  40972. this.strategies = strategies;
  40973. this.loop = Boolean(options.loop);
  40974. this.failFast = Boolean(options.failFast);
  40975. this.timeout = options.timeout;
  40976. this.timeoutLimit = options.timeoutLimit;
  40977. }
  40978. SequentialStrategy.prototype.isSupported = function () {
  40979. return any(this.strategies, util.method("isSupported"));
  40980. };
  40981. SequentialStrategy.prototype.connect = function (minPriority, callback) {
  40982. var _this = this;
  40983. var strategies = this.strategies;
  40984. var current = 0;
  40985. var timeout = this.timeout;
  40986. var runner = null;
  40987. var tryNextStrategy = function (error, handshake) {
  40988. if (handshake) {
  40989. callback(null, handshake);
  40990. }
  40991. else {
  40992. current = current + 1;
  40993. if (_this.loop) {
  40994. current = current % strategies.length;
  40995. }
  40996. if (current < strategies.length) {
  40997. if (timeout) {
  40998. timeout = timeout * 2;
  40999. if (_this.timeoutLimit) {
  41000. timeout = Math.min(timeout, _this.timeoutLimit);
  41001. }
  41002. }
  41003. runner = _this.tryStrategy(strategies[current], minPriority, { timeout: timeout, failFast: _this.failFast }, tryNextStrategy);
  41004. }
  41005. else {
  41006. callback(true);
  41007. }
  41008. }
  41009. };
  41010. runner = this.tryStrategy(strategies[current], minPriority, { timeout: timeout, failFast: this.failFast }, tryNextStrategy);
  41011. return {
  41012. abort: function () {
  41013. runner.abort();
  41014. },
  41015. forceMinPriority: function (p) {
  41016. minPriority = p;
  41017. if (runner) {
  41018. runner.forceMinPriority(p);
  41019. }
  41020. }
  41021. };
  41022. };
  41023. SequentialStrategy.prototype.tryStrategy = function (strategy, minPriority, options, callback) {
  41024. var timer = null;
  41025. var runner = null;
  41026. if (options.timeout > 0) {
  41027. timer = new OneOffTimer(options.timeout, function () {
  41028. runner.abort();
  41029. callback(true);
  41030. });
  41031. }
  41032. runner = strategy.connect(minPriority, function (error, handshake) {
  41033. if (error && timer && timer.isRunning() && !options.failFast) {
  41034. return;
  41035. }
  41036. if (timer) {
  41037. timer.ensureAborted();
  41038. }
  41039. callback(error, handshake);
  41040. });
  41041. return {
  41042. abort: function () {
  41043. if (timer) {
  41044. timer.ensureAborted();
  41045. }
  41046. runner.abort();
  41047. },
  41048. forceMinPriority: function (p) {
  41049. runner.forceMinPriority(p);
  41050. }
  41051. };
  41052. };
  41053. return SequentialStrategy;
  41054. }());
  41055. /* harmony default export */ var sequential_strategy = (sequential_strategy_SequentialStrategy);
  41056. // CONCATENATED MODULE: ./src/core/strategies/best_connected_ever_strategy.ts
  41057. var best_connected_ever_strategy_BestConnectedEverStrategy = (function () {
  41058. function BestConnectedEverStrategy(strategies) {
  41059. this.strategies = strategies;
  41060. }
  41061. BestConnectedEverStrategy.prototype.isSupported = function () {
  41062. return any(this.strategies, util.method("isSupported"));
  41063. };
  41064. BestConnectedEverStrategy.prototype.connect = function (minPriority, callback) {
  41065. return connect(this.strategies, minPriority, function (i, runners) {
  41066. return function (error, handshake) {
  41067. runners[i].error = error;
  41068. if (error) {
  41069. if (allRunnersFailed(runners)) {
  41070. callback(true);
  41071. }
  41072. return;
  41073. }
  41074. apply(runners, function (runner) {
  41075. runner.forceMinPriority(handshake.transport.priority);
  41076. });
  41077. callback(null, handshake);
  41078. };
  41079. });
  41080. };
  41081. return BestConnectedEverStrategy;
  41082. }());
  41083. /* harmony default export */ var best_connected_ever_strategy = (best_connected_ever_strategy_BestConnectedEverStrategy);
  41084. function connect(strategies, minPriority, callbackBuilder) {
  41085. var runners = map(strategies, function (strategy, i, _, rs) {
  41086. return strategy.connect(minPriority, callbackBuilder(i, rs));
  41087. });
  41088. return {
  41089. abort: function () {
  41090. apply(runners, abortRunner);
  41091. },
  41092. forceMinPriority: function (p) {
  41093. apply(runners, function (runner) {
  41094. runner.forceMinPriority(p);
  41095. });
  41096. }
  41097. };
  41098. }
  41099. function allRunnersFailed(runners) {
  41100. return collections_all(runners, function (runner) {
  41101. return Boolean(runner.error);
  41102. });
  41103. }
  41104. function abortRunner(runner) {
  41105. if (!runner.error && !runner.aborted) {
  41106. runner.abort();
  41107. runner.aborted = true;
  41108. }
  41109. }
  41110. // CONCATENATED MODULE: ./src/core/strategies/cached_strategy.ts
  41111. var cached_strategy_CachedStrategy = (function () {
  41112. function CachedStrategy(strategy, transports, options) {
  41113. this.strategy = strategy;
  41114. this.transports = transports;
  41115. this.ttl = options.ttl || 1800 * 1000;
  41116. this.usingTLS = options.useTLS;
  41117. this.timeline = options.timeline;
  41118. }
  41119. CachedStrategy.prototype.isSupported = function () {
  41120. return this.strategy.isSupported();
  41121. };
  41122. CachedStrategy.prototype.connect = function (minPriority, callback) {
  41123. var usingTLS = this.usingTLS;
  41124. var info = fetchTransportCache(usingTLS);
  41125. var strategies = [this.strategy];
  41126. if (info && info.timestamp + this.ttl >= util.now()) {
  41127. var transport = this.transports[info.transport];
  41128. if (transport) {
  41129. this.timeline.info({
  41130. cached: true,
  41131. transport: info.transport,
  41132. latency: info.latency
  41133. });
  41134. strategies.push(new sequential_strategy([transport], {
  41135. timeout: info.latency * 2 + 1000,
  41136. failFast: true
  41137. }));
  41138. }
  41139. }
  41140. var startTimestamp = util.now();
  41141. var runner = strategies.pop().connect(minPriority, function cb(error, handshake) {
  41142. if (error) {
  41143. flushTransportCache(usingTLS);
  41144. if (strategies.length > 0) {
  41145. startTimestamp = util.now();
  41146. runner = strategies.pop().connect(minPriority, cb);
  41147. }
  41148. else {
  41149. callback(error);
  41150. }
  41151. }
  41152. else {
  41153. storeTransportCache(usingTLS, handshake.transport.name, util.now() - startTimestamp);
  41154. callback(null, handshake);
  41155. }
  41156. });
  41157. return {
  41158. abort: function () {
  41159. runner.abort();
  41160. },
  41161. forceMinPriority: function (p) {
  41162. minPriority = p;
  41163. if (runner) {
  41164. runner.forceMinPriority(p);
  41165. }
  41166. }
  41167. };
  41168. };
  41169. return CachedStrategy;
  41170. }());
  41171. /* harmony default export */ var cached_strategy = (cached_strategy_CachedStrategy);
  41172. function getTransportCacheKey(usingTLS) {
  41173. return "pusherTransport" + (usingTLS ? "TLS" : "NonTLS");
  41174. }
  41175. function fetchTransportCache(usingTLS) {
  41176. var storage = runtime.getLocalStorage();
  41177. if (storage) {
  41178. try {
  41179. var serializedCache = storage[getTransportCacheKey(usingTLS)];
  41180. if (serializedCache) {
  41181. return JSON.parse(serializedCache);
  41182. }
  41183. }
  41184. catch (e) {
  41185. flushTransportCache(usingTLS);
  41186. }
  41187. }
  41188. return null;
  41189. }
  41190. function storeTransportCache(usingTLS, transport, latency) {
  41191. var storage = runtime.getLocalStorage();
  41192. if (storage) {
  41193. try {
  41194. storage[getTransportCacheKey(usingTLS)] = safeJSONStringify({
  41195. timestamp: util.now(),
  41196. transport: transport,
  41197. latency: latency
  41198. });
  41199. }
  41200. catch (e) {
  41201. }
  41202. }
  41203. }
  41204. function flushTransportCache(usingTLS) {
  41205. var storage = runtime.getLocalStorage();
  41206. if (storage) {
  41207. try {
  41208. delete storage[getTransportCacheKey(usingTLS)];
  41209. }
  41210. catch (e) {
  41211. }
  41212. }
  41213. }
  41214. // CONCATENATED MODULE: ./src/core/strategies/delayed_strategy.ts
  41215. var delayed_strategy_DelayedStrategy = (function () {
  41216. function DelayedStrategy(strategy, _a) {
  41217. var number = _a.delay;
  41218. this.strategy = strategy;
  41219. this.options = { delay: number };
  41220. }
  41221. DelayedStrategy.prototype.isSupported = function () {
  41222. return this.strategy.isSupported();
  41223. };
  41224. DelayedStrategy.prototype.connect = function (minPriority, callback) {
  41225. var strategy = this.strategy;
  41226. var runner;
  41227. var timer = new OneOffTimer(this.options.delay, function () {
  41228. runner = strategy.connect(minPriority, callback);
  41229. });
  41230. return {
  41231. abort: function () {
  41232. timer.ensureAborted();
  41233. if (runner) {
  41234. runner.abort();
  41235. }
  41236. },
  41237. forceMinPriority: function (p) {
  41238. minPriority = p;
  41239. if (runner) {
  41240. runner.forceMinPriority(p);
  41241. }
  41242. }
  41243. };
  41244. };
  41245. return DelayedStrategy;
  41246. }());
  41247. /* harmony default export */ var delayed_strategy = (delayed_strategy_DelayedStrategy);
  41248. // CONCATENATED MODULE: ./src/core/strategies/if_strategy.ts
  41249. var IfStrategy = (function () {
  41250. function IfStrategy(test, trueBranch, falseBranch) {
  41251. this.test = test;
  41252. this.trueBranch = trueBranch;
  41253. this.falseBranch = falseBranch;
  41254. }
  41255. IfStrategy.prototype.isSupported = function () {
  41256. var branch = this.test() ? this.trueBranch : this.falseBranch;
  41257. return branch.isSupported();
  41258. };
  41259. IfStrategy.prototype.connect = function (minPriority, callback) {
  41260. var branch = this.test() ? this.trueBranch : this.falseBranch;
  41261. return branch.connect(minPriority, callback);
  41262. };
  41263. return IfStrategy;
  41264. }());
  41265. /* harmony default export */ var if_strategy = (IfStrategy);
  41266. // CONCATENATED MODULE: ./src/core/strategies/first_connected_strategy.ts
  41267. var FirstConnectedStrategy = (function () {
  41268. function FirstConnectedStrategy(strategy) {
  41269. this.strategy = strategy;
  41270. }
  41271. FirstConnectedStrategy.prototype.isSupported = function () {
  41272. return this.strategy.isSupported();
  41273. };
  41274. FirstConnectedStrategy.prototype.connect = function (minPriority, callback) {
  41275. var runner = this.strategy.connect(minPriority, function (error, handshake) {
  41276. if (handshake) {
  41277. runner.abort();
  41278. }
  41279. callback(error, handshake);
  41280. });
  41281. return runner;
  41282. };
  41283. return FirstConnectedStrategy;
  41284. }());
  41285. /* harmony default export */ var first_connected_strategy = (FirstConnectedStrategy);
  41286. // CONCATENATED MODULE: ./src/runtimes/web/default_strategy.ts
  41287. function testSupportsStrategy(strategy) {
  41288. return function () {
  41289. return strategy.isSupported();
  41290. };
  41291. }
  41292. var getDefaultStrategy = function (config, defineTransport) {
  41293. var definedTransports = {};
  41294. function defineTransportStrategy(name, type, priority, options, manager) {
  41295. var transport = defineTransport(config, name, type, priority, options, manager);
  41296. definedTransports[name] = transport;
  41297. return transport;
  41298. }
  41299. var ws_options = {
  41300. hostNonTLS: config.wsHost + ":" + config.wsPort,
  41301. hostTLS: config.wsHost + ":" + config.wssPort,
  41302. httpPath: config.wsPath
  41303. };
  41304. var wss_options = extend({}, ws_options, {
  41305. useTLS: true
  41306. });
  41307. var sockjs_options = {
  41308. hostNonTLS: config.httpHost + ":" + config.httpPort,
  41309. hostTLS: config.httpHost + ":" + config.httpsPort,
  41310. httpPath: config.httpPath
  41311. };
  41312. var timeouts = {
  41313. loop: true,
  41314. timeout: 15000,
  41315. timeoutLimit: 60000
  41316. };
  41317. var ws_manager = new transport_manager({
  41318. lives: 2,
  41319. minPingDelay: 10000,
  41320. maxPingDelay: config.activity_timeout
  41321. });
  41322. var streaming_manager = new transport_manager({
  41323. lives: 2,
  41324. minPingDelay: 10000,
  41325. maxPingDelay: config.activity_timeout
  41326. });
  41327. var ws_transport = defineTransportStrategy("ws", "ws", 3, ws_options, ws_manager);
  41328. var wss_transport = defineTransportStrategy("wss", "ws", 3, wss_options, ws_manager);
  41329. var sockjs_transport = defineTransportStrategy("sockjs", "sockjs", 1, sockjs_options);
  41330. var xhr_streaming_transport = defineTransportStrategy("xhr_streaming", "xhr_streaming", 1, sockjs_options, streaming_manager);
  41331. var xdr_streaming_transport = defineTransportStrategy("xdr_streaming", "xdr_streaming", 1, sockjs_options, streaming_manager);
  41332. var xhr_polling_transport = defineTransportStrategy("xhr_polling", "xhr_polling", 1, sockjs_options);
  41333. var xdr_polling_transport = defineTransportStrategy("xdr_polling", "xdr_polling", 1, sockjs_options);
  41334. var ws_loop = new sequential_strategy([ws_transport], timeouts);
  41335. var wss_loop = new sequential_strategy([wss_transport], timeouts);
  41336. var sockjs_loop = new sequential_strategy([sockjs_transport], timeouts);
  41337. var streaming_loop = new sequential_strategy([new if_strategy(testSupportsStrategy(xhr_streaming_transport), xhr_streaming_transport, xdr_streaming_transport)], timeouts);
  41338. var polling_loop = new sequential_strategy([new if_strategy(testSupportsStrategy(xhr_polling_transport), xhr_polling_transport, xdr_polling_transport)], timeouts);
  41339. 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);
  41340. var http_fallback_loop = new if_strategy(testSupportsStrategy(http_loop), http_loop, sockjs_loop);
  41341. var wsStrategy;
  41342. if (config.useTLS) {
  41343. wsStrategy = new best_connected_ever_strategy([ws_loop, new delayed_strategy(http_fallback_loop, { delay: 2000 })]);
  41344. }
  41345. else {
  41346. wsStrategy = new best_connected_ever_strategy([
  41347. ws_loop,
  41348. new delayed_strategy(wss_loop, { delay: 2000 }),
  41349. new delayed_strategy(http_fallback_loop, { delay: 5000 })
  41350. ]);
  41351. }
  41352. return new cached_strategy(new first_connected_strategy(new if_strategy(testSupportsStrategy(ws_transport), wsStrategy, http_fallback_loop)), definedTransports, {
  41353. ttl: 1800000,
  41354. timeline: config.timeline,
  41355. useTLS: config.useTLS
  41356. });
  41357. };
  41358. /* harmony default export */ var default_strategy = (getDefaultStrategy);
  41359. // CONCATENATED MODULE: ./src/runtimes/web/transports/transport_connection_initializer.ts
  41360. /* harmony default export */ var transport_connection_initializer = (function () {
  41361. var self = this;
  41362. self.timeline.info(self.buildTimelineMessage({
  41363. transport: self.name + (self.options.useTLS ? "s" : "")
  41364. }));
  41365. if (self.hooks.isInitialized()) {
  41366. self.changeState("initialized");
  41367. }
  41368. else if (self.hooks.file) {
  41369. self.changeState("initializing");
  41370. Dependencies.load(self.hooks.file, { useTLS: self.options.useTLS }, function (error, callback) {
  41371. if (self.hooks.isInitialized()) {
  41372. self.changeState("initialized");
  41373. callback(true);
  41374. }
  41375. else {
  41376. if (error) {
  41377. self.onError(error);
  41378. }
  41379. self.onClose();
  41380. callback(false);
  41381. }
  41382. });
  41383. }
  41384. else {
  41385. self.onClose();
  41386. }
  41387. });
  41388. // CONCATENATED MODULE: ./src/runtimes/web/http/http_xdomain_request.ts
  41389. var http_xdomain_request_hooks = {
  41390. getRequest: function (socket) {
  41391. var xdr = new window.XDomainRequest();
  41392. xdr.ontimeout = function () {
  41393. socket.emit("error", new RequestTimedOut());
  41394. socket.close();
  41395. };
  41396. xdr.onerror = function (e) {
  41397. socket.emit("error", e);
  41398. socket.close();
  41399. };
  41400. xdr.onprogress = function () {
  41401. if (xdr.responseText && xdr.responseText.length > 0) {
  41402. socket.onChunk(200, xdr.responseText);
  41403. }
  41404. };
  41405. xdr.onload = function () {
  41406. if (xdr.responseText && xdr.responseText.length > 0) {
  41407. socket.onChunk(200, xdr.responseText);
  41408. }
  41409. socket.emit("finished", 200);
  41410. socket.close();
  41411. };
  41412. return xdr;
  41413. },
  41414. abortRequest: function (xdr) {
  41415. xdr.ontimeout = xdr.onerror = xdr.onprogress = xdr.onload = null;
  41416. xdr.abort();
  41417. }
  41418. };
  41419. /* harmony default export */ var http_xdomain_request = (http_xdomain_request_hooks);
  41420. // CONCATENATED MODULE: ./src/core/http/http_request.ts
  41421. var http_request_extends = (undefined && undefined.__extends) || (function () {
  41422. var extendStatics = function (d, b) {
  41423. extendStatics = Object.setPrototypeOf ||
  41424. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  41425. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  41426. return extendStatics(d, b);
  41427. };
  41428. return function (d, b) {
  41429. extendStatics(d, b);
  41430. function __() { this.constructor = d; }
  41431. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  41432. };
  41433. })();
  41434. var MAX_BUFFER_LENGTH = 256 * 1024;
  41435. var http_request_HTTPRequest = (function (_super) {
  41436. http_request_extends(HTTPRequest, _super);
  41437. function HTTPRequest(hooks, method, url) {
  41438. var _this = _super.call(this) || this;
  41439. _this.hooks = hooks;
  41440. _this.method = method;
  41441. _this.url = url;
  41442. return _this;
  41443. }
  41444. HTTPRequest.prototype.start = function (payload) {
  41445. var _this = this;
  41446. this.position = 0;
  41447. this.xhr = this.hooks.getRequest(this);
  41448. this.unloader = function () {
  41449. _this.close();
  41450. };
  41451. runtime.addUnloadListener(this.unloader);
  41452. this.xhr.open(this.method, this.url, true);
  41453. if (this.xhr.setRequestHeader) {
  41454. this.xhr.setRequestHeader("Content-Type", "application/json");
  41455. }
  41456. this.xhr.send(payload);
  41457. };
  41458. HTTPRequest.prototype.close = function () {
  41459. if (this.unloader) {
  41460. runtime.removeUnloadListener(this.unloader);
  41461. this.unloader = null;
  41462. }
  41463. if (this.xhr) {
  41464. this.hooks.abortRequest(this.xhr);
  41465. this.xhr = null;
  41466. }
  41467. };
  41468. HTTPRequest.prototype.onChunk = function (status, data) {
  41469. while (true) {
  41470. var chunk = this.advanceBuffer(data);
  41471. if (chunk) {
  41472. this.emit("chunk", { status: status, data: chunk });
  41473. }
  41474. else {
  41475. break;
  41476. }
  41477. }
  41478. if (this.isBufferTooLong(data)) {
  41479. this.emit("buffer_too_long");
  41480. }
  41481. };
  41482. HTTPRequest.prototype.advanceBuffer = function (buffer) {
  41483. var unreadData = buffer.slice(this.position);
  41484. var endOfLinePosition = unreadData.indexOf("\n");
  41485. if (endOfLinePosition !== -1) {
  41486. this.position += endOfLinePosition + 1;
  41487. return unreadData.slice(0, endOfLinePosition);
  41488. }
  41489. else {
  41490. return null;
  41491. }
  41492. };
  41493. HTTPRequest.prototype.isBufferTooLong = function (buffer) {
  41494. return this.position === buffer.length && buffer.length > MAX_BUFFER_LENGTH;
  41495. };
  41496. return HTTPRequest;
  41497. }(dispatcher));
  41498. /* harmony default export */ var http_request = (http_request_HTTPRequest);
  41499. // CONCATENATED MODULE: ./src/core/http/state.ts
  41500. var State;
  41501. (function (State) {
  41502. State[State["CONNECTING"] = 0] = "CONNECTING";
  41503. State[State["OPEN"] = 1] = "OPEN";
  41504. State[State["CLOSED"] = 3] = "CLOSED";
  41505. })(State || (State = {}));
  41506. /* harmony default export */ var state = (State);
  41507. // CONCATENATED MODULE: ./src/core/http/http_socket.ts
  41508. var autoIncrement = 1;
  41509. var http_socket_HTTPSocket = (function () {
  41510. function HTTPSocket(hooks, url) {
  41511. this.hooks = hooks;
  41512. this.session = randomNumber(1000) + "/" + randomString(8);
  41513. this.location = getLocation(url);
  41514. this.readyState = state.CONNECTING;
  41515. this.openStream();
  41516. }
  41517. HTTPSocket.prototype.send = function (payload) {
  41518. return this.sendRaw(JSON.stringify([payload]));
  41519. };
  41520. HTTPSocket.prototype.ping = function () {
  41521. this.hooks.sendHeartbeat(this);
  41522. };
  41523. HTTPSocket.prototype.close = function (code, reason) {
  41524. this.onClose(code, reason, true);
  41525. };
  41526. HTTPSocket.prototype.sendRaw = function (payload) {
  41527. if (this.readyState === state.OPEN) {
  41528. try {
  41529. runtime.createSocketRequest("POST", getUniqueURL(getSendURL(this.location, this.session))).start(payload);
  41530. return true;
  41531. }
  41532. catch (e) {
  41533. return false;
  41534. }
  41535. }
  41536. else {
  41537. return false;
  41538. }
  41539. };
  41540. HTTPSocket.prototype.reconnect = function () {
  41541. this.closeStream();
  41542. this.openStream();
  41543. };
  41544. ;
  41545. HTTPSocket.prototype.onClose = function (code, reason, wasClean) {
  41546. this.closeStream();
  41547. this.readyState = state.CLOSED;
  41548. if (this.onclose) {
  41549. this.onclose({
  41550. code: code,
  41551. reason: reason,
  41552. wasClean: wasClean
  41553. });
  41554. }
  41555. };
  41556. HTTPSocket.prototype.onChunk = function (chunk) {
  41557. if (chunk.status !== 200) {
  41558. return;
  41559. }
  41560. if (this.readyState === state.OPEN) {
  41561. this.onActivity();
  41562. }
  41563. var payload;
  41564. var type = chunk.data.slice(0, 1);
  41565. switch (type) {
  41566. case 'o':
  41567. payload = JSON.parse(chunk.data.slice(1) || '{}');
  41568. this.onOpen(payload);
  41569. break;
  41570. case 'a':
  41571. payload = JSON.parse(chunk.data.slice(1) || '[]');
  41572. for (var i = 0; i < payload.length; i++) {
  41573. this.onEvent(payload[i]);
  41574. }
  41575. break;
  41576. case 'm':
  41577. payload = JSON.parse(chunk.data.slice(1) || 'null');
  41578. this.onEvent(payload);
  41579. break;
  41580. case 'h':
  41581. this.hooks.onHeartbeat(this);
  41582. break;
  41583. case 'c':
  41584. payload = JSON.parse(chunk.data.slice(1) || '[]');
  41585. this.onClose(payload[0], payload[1], true);
  41586. break;
  41587. }
  41588. };
  41589. HTTPSocket.prototype.onOpen = function (options) {
  41590. if (this.readyState === state.CONNECTING) {
  41591. if (options && options.hostname) {
  41592. this.location.base = replaceHost(this.location.base, options.hostname);
  41593. }
  41594. this.readyState = state.OPEN;
  41595. if (this.onopen) {
  41596. this.onopen();
  41597. }
  41598. }
  41599. else {
  41600. this.onClose(1006, "Server lost session", true);
  41601. }
  41602. };
  41603. HTTPSocket.prototype.onEvent = function (event) {
  41604. if (this.readyState === state.OPEN && this.onmessage) {
  41605. this.onmessage({ data: event });
  41606. }
  41607. };
  41608. HTTPSocket.prototype.onActivity = function () {
  41609. if (this.onactivity) {
  41610. this.onactivity();
  41611. }
  41612. };
  41613. HTTPSocket.prototype.onError = function (error) {
  41614. if (this.onerror) {
  41615. this.onerror(error);
  41616. }
  41617. };
  41618. HTTPSocket.prototype.openStream = function () {
  41619. var _this = this;
  41620. this.stream = runtime.createSocketRequest("POST", getUniqueURL(this.hooks.getReceiveURL(this.location, this.session)));
  41621. this.stream.bind("chunk", function (chunk) {
  41622. _this.onChunk(chunk);
  41623. });
  41624. this.stream.bind("finished", function (status) {
  41625. _this.hooks.onFinished(_this, status);
  41626. });
  41627. this.stream.bind("buffer_too_long", function () {
  41628. _this.reconnect();
  41629. });
  41630. try {
  41631. this.stream.start();
  41632. }
  41633. catch (error) {
  41634. util.defer(function () {
  41635. _this.onError(error);
  41636. _this.onClose(1006, "Could not start streaming", false);
  41637. });
  41638. }
  41639. };
  41640. HTTPSocket.prototype.closeStream = function () {
  41641. if (this.stream) {
  41642. this.stream.unbind_all();
  41643. this.stream.close();
  41644. this.stream = null;
  41645. }
  41646. };
  41647. return HTTPSocket;
  41648. }());
  41649. function getLocation(url) {
  41650. var parts = /([^\?]*)\/*(\??.*)/.exec(url);
  41651. return {
  41652. base: parts[1],
  41653. queryString: parts[2]
  41654. };
  41655. }
  41656. function getSendURL(url, session) {
  41657. return url.base + "/" + session + "/xhr_send";
  41658. }
  41659. function getUniqueURL(url) {
  41660. var separator = (url.indexOf('?') === -1) ? "?" : "&";
  41661. return url + separator + "t=" + (+new Date()) + "&n=" + autoIncrement++;
  41662. }
  41663. function replaceHost(url, hostname) {
  41664. var urlParts = /(https?:\/\/)([^\/:]+)((\/|:)?.*)/.exec(url);
  41665. return urlParts[1] + hostname + urlParts[3];
  41666. }
  41667. function randomNumber(max) {
  41668. return Math.floor(Math.random() * max);
  41669. }
  41670. function randomString(length) {
  41671. var result = [];
  41672. for (var i = 0; i < length; i++) {
  41673. result.push(randomNumber(32).toString(32));
  41674. }
  41675. return result.join('');
  41676. }
  41677. /* harmony default export */ var http_socket = (http_socket_HTTPSocket);
  41678. // CONCATENATED MODULE: ./src/core/http/http_streaming_socket.ts
  41679. var http_streaming_socket_hooks = {
  41680. getReceiveURL: function (url, session) {
  41681. return url.base + "/" + session + "/xhr_streaming" + url.queryString;
  41682. },
  41683. onHeartbeat: function (socket) {
  41684. socket.sendRaw("[]");
  41685. },
  41686. sendHeartbeat: function (socket) {
  41687. socket.sendRaw("[]");
  41688. },
  41689. onFinished: function (socket, status) {
  41690. socket.onClose(1006, "Connection interrupted (" + status + ")", false);
  41691. }
  41692. };
  41693. /* harmony default export */ var http_streaming_socket = (http_streaming_socket_hooks);
  41694. // CONCATENATED MODULE: ./src/core/http/http_polling_socket.ts
  41695. var http_polling_socket_hooks = {
  41696. getReceiveURL: function (url, session) {
  41697. return url.base + "/" + session + "/xhr" + url.queryString;
  41698. },
  41699. onHeartbeat: function () {
  41700. },
  41701. sendHeartbeat: function (socket) {
  41702. socket.sendRaw("[]");
  41703. },
  41704. onFinished: function (socket, status) {
  41705. if (status === 200) {
  41706. socket.reconnect();
  41707. }
  41708. else {
  41709. socket.onClose(1006, "Connection interrupted (" + status + ")", false);
  41710. }
  41711. }
  41712. };
  41713. /* harmony default export */ var http_polling_socket = (http_polling_socket_hooks);
  41714. // CONCATENATED MODULE: ./src/runtimes/isomorphic/http/http_xhr_request.ts
  41715. var http_xhr_request_hooks = {
  41716. getRequest: function (socket) {
  41717. var Constructor = runtime.getXHRAPI();
  41718. var xhr = new Constructor();
  41719. xhr.onreadystatechange = xhr.onprogress = function () {
  41720. switch (xhr.readyState) {
  41721. case 3:
  41722. if (xhr.responseText && xhr.responseText.length > 0) {
  41723. socket.onChunk(xhr.status, xhr.responseText);
  41724. }
  41725. break;
  41726. case 4:
  41727. if (xhr.responseText && xhr.responseText.length > 0) {
  41728. socket.onChunk(xhr.status, xhr.responseText);
  41729. }
  41730. socket.emit("finished", xhr.status);
  41731. socket.close();
  41732. break;
  41733. }
  41734. };
  41735. return xhr;
  41736. },
  41737. abortRequest: function (xhr) {
  41738. xhr.onreadystatechange = null;
  41739. xhr.abort();
  41740. }
  41741. };
  41742. /* harmony default export */ var http_xhr_request = (http_xhr_request_hooks);
  41743. // CONCATENATED MODULE: ./src/runtimes/isomorphic/http/http.ts
  41744. var HTTP = {
  41745. createStreamingSocket: function (url) {
  41746. return this.createSocket(http_streaming_socket, url);
  41747. },
  41748. createPollingSocket: function (url) {
  41749. return this.createSocket(http_polling_socket, url);
  41750. },
  41751. createSocket: function (hooks, url) {
  41752. return new http_socket(hooks, url);
  41753. },
  41754. createXHR: function (method, url) {
  41755. return this.createRequest(http_xhr_request, method, url);
  41756. },
  41757. createRequest: function (hooks, method, url) {
  41758. return new http_request(hooks, method, url);
  41759. }
  41760. };
  41761. /* harmony default export */ var http_http = (HTTP);
  41762. // CONCATENATED MODULE: ./src/runtimes/web/http/http.ts
  41763. http_http.createXDR = function (method, url) {
  41764. return this.createRequest(http_xdomain_request, method, url);
  41765. };
  41766. /* harmony default export */ var web_http_http = (http_http);
  41767. // CONCATENATED MODULE: ./src/runtimes/web/runtime.ts
  41768. var Runtime = {
  41769. nextAuthCallbackID: 1,
  41770. auth_callbacks: {},
  41771. ScriptReceivers: ScriptReceivers,
  41772. DependenciesReceivers: DependenciesReceivers,
  41773. getDefaultStrategy: default_strategy,
  41774. Transports: transports_transports,
  41775. transportConnectionInitializer: transport_connection_initializer,
  41776. HTTPFactory: web_http_http,
  41777. TimelineTransport: jsonp_timeline,
  41778. getXHRAPI: function () {
  41779. return window.XMLHttpRequest;
  41780. },
  41781. getWebSocketAPI: function () {
  41782. return window.WebSocket || window.MozWebSocket;
  41783. },
  41784. setup: function (PusherClass) {
  41785. var _this = this;
  41786. window.Pusher = PusherClass;
  41787. var initializeOnDocumentBody = function () {
  41788. _this.onDocumentBody(PusherClass.ready);
  41789. };
  41790. if (!window.JSON) {
  41791. Dependencies.load("json2", {}, initializeOnDocumentBody);
  41792. }
  41793. else {
  41794. initializeOnDocumentBody();
  41795. }
  41796. },
  41797. getDocument: function () {
  41798. return document;
  41799. },
  41800. getProtocol: function () {
  41801. return this.getDocument().location.protocol;
  41802. },
  41803. getAuthorizers: function () {
  41804. return { ajax: xhr_auth, jsonp: jsonp_auth };
  41805. },
  41806. onDocumentBody: function (callback) {
  41807. var _this = this;
  41808. if (document.body) {
  41809. callback();
  41810. }
  41811. else {
  41812. setTimeout(function () {
  41813. _this.onDocumentBody(callback);
  41814. }, 0);
  41815. }
  41816. },
  41817. createJSONPRequest: function (url, data) {
  41818. return new jsonp_request(url, data);
  41819. },
  41820. createScriptRequest: function (src) {
  41821. return new script_request(src);
  41822. },
  41823. getLocalStorage: function () {
  41824. try {
  41825. return window.localStorage;
  41826. }
  41827. catch (e) {
  41828. return undefined;
  41829. }
  41830. },
  41831. createXHR: function () {
  41832. if (this.getXHRAPI()) {
  41833. return this.createXMLHttpRequest();
  41834. }
  41835. else {
  41836. return this.createMicrosoftXHR();
  41837. }
  41838. },
  41839. createXMLHttpRequest: function () {
  41840. var Constructor = this.getXHRAPI();
  41841. return new Constructor();
  41842. },
  41843. createMicrosoftXHR: function () {
  41844. return new ActiveXObject("Microsoft.XMLHTTP");
  41845. },
  41846. getNetwork: function () {
  41847. return net_info_Network;
  41848. },
  41849. createWebSocket: function (url) {
  41850. var Constructor = this.getWebSocketAPI();
  41851. return new Constructor(url);
  41852. },
  41853. createSocketRequest: function (method, url) {
  41854. if (this.isXHRSupported()) {
  41855. return this.HTTPFactory.createXHR(method, url);
  41856. }
  41857. else if (this.isXDRSupported(url.indexOf("https:") === 0)) {
  41858. return this.HTTPFactory.createXDR(method, url);
  41859. }
  41860. else {
  41861. throw "Cross-origin HTTP requests are not supported";
  41862. }
  41863. },
  41864. isXHRSupported: function () {
  41865. var Constructor = this.getXHRAPI();
  41866. return Boolean(Constructor) && (new Constructor()).withCredentials !== undefined;
  41867. },
  41868. isXDRSupported: function (useTLS) {
  41869. var protocol = useTLS ? "https:" : "http:";
  41870. var documentProtocol = this.getProtocol();
  41871. return Boolean((window['XDomainRequest'])) && documentProtocol === protocol;
  41872. },
  41873. addUnloadListener: function (listener) {
  41874. if (window.addEventListener !== undefined) {
  41875. window.addEventListener("unload", listener, false);
  41876. }
  41877. else if (window.attachEvent !== undefined) {
  41878. window.attachEvent("onunload", listener);
  41879. }
  41880. },
  41881. removeUnloadListener: function (listener) {
  41882. if (window.addEventListener !== undefined) {
  41883. window.removeEventListener("unload", listener, false);
  41884. }
  41885. else if (window.detachEvent !== undefined) {
  41886. window.detachEvent("onunload", listener);
  41887. }
  41888. }
  41889. };
  41890. /* harmony default export */ var runtime = (Runtime);
  41891. // CONCATENATED MODULE: ./src/core/timeline/level.ts
  41892. var TimelineLevel;
  41893. (function (TimelineLevel) {
  41894. TimelineLevel[TimelineLevel["ERROR"] = 3] = "ERROR";
  41895. TimelineLevel[TimelineLevel["INFO"] = 6] = "INFO";
  41896. TimelineLevel[TimelineLevel["DEBUG"] = 7] = "DEBUG";
  41897. })(TimelineLevel || (TimelineLevel = {}));
  41898. /* harmony default export */ var timeline_level = (TimelineLevel);
  41899. // CONCATENATED MODULE: ./src/core/timeline/timeline.ts
  41900. var timeline_Timeline = (function () {
  41901. function Timeline(key, session, options) {
  41902. this.key = key;
  41903. this.session = session;
  41904. this.events = [];
  41905. this.options = options || {};
  41906. this.sent = 0;
  41907. this.uniqueID = 0;
  41908. }
  41909. Timeline.prototype.log = function (level, event) {
  41910. if (level <= this.options.level) {
  41911. this.events.push(extend({}, event, { timestamp: util.now() }));
  41912. if (this.options.limit && this.events.length > this.options.limit) {
  41913. this.events.shift();
  41914. }
  41915. }
  41916. };
  41917. Timeline.prototype.error = function (event) {
  41918. this.log(timeline_level.ERROR, event);
  41919. };
  41920. Timeline.prototype.info = function (event) {
  41921. this.log(timeline_level.INFO, event);
  41922. };
  41923. Timeline.prototype.debug = function (event) {
  41924. this.log(timeline_level.DEBUG, event);
  41925. };
  41926. Timeline.prototype.isEmpty = function () {
  41927. return this.events.length === 0;
  41928. };
  41929. Timeline.prototype.send = function (sendfn, callback) {
  41930. var _this = this;
  41931. var data = extend({
  41932. session: this.session,
  41933. bundle: this.sent + 1,
  41934. key: this.key,
  41935. lib: "js",
  41936. version: this.options.version,
  41937. cluster: this.options.cluster,
  41938. features: this.options.features,
  41939. timeline: this.events
  41940. }, this.options.params);
  41941. this.events = [];
  41942. sendfn(data, function (error, result) {
  41943. if (!error) {
  41944. _this.sent++;
  41945. }
  41946. if (callback) {
  41947. callback(error, result);
  41948. }
  41949. });
  41950. return true;
  41951. };
  41952. Timeline.prototype.generateUniqueID = function () {
  41953. this.uniqueID++;
  41954. return this.uniqueID;
  41955. };
  41956. return Timeline;
  41957. }());
  41958. /* harmony default export */ var timeline_timeline = (timeline_Timeline);
  41959. // CONCATENATED MODULE: ./src/core/strategies/transport_strategy.ts
  41960. var transport_strategy_TransportStrategy = (function () {
  41961. function TransportStrategy(name, priority, transport, options) {
  41962. this.name = name;
  41963. this.priority = priority;
  41964. this.transport = transport;
  41965. this.options = options || {};
  41966. }
  41967. TransportStrategy.prototype.isSupported = function () {
  41968. return this.transport.isSupported({
  41969. useTLS: this.options.useTLS
  41970. });
  41971. };
  41972. TransportStrategy.prototype.connect = function (minPriority, callback) {
  41973. var _this = this;
  41974. if (!this.isSupported()) {
  41975. return failAttempt(new UnsupportedStrategy(), callback);
  41976. }
  41977. else if (this.priority < minPriority) {
  41978. return failAttempt(new TransportPriorityTooLow(), callback);
  41979. }
  41980. var connected = false;
  41981. var transport = this.transport.createConnection(this.name, this.priority, this.options.key, this.options);
  41982. var handshake = null;
  41983. var onInitialized = function () {
  41984. transport.unbind("initialized", onInitialized);
  41985. transport.connect();
  41986. };
  41987. var onOpen = function () {
  41988. handshake = factory.createHandshake(transport, function (result) {
  41989. connected = true;
  41990. unbindListeners();
  41991. callback(null, result);
  41992. });
  41993. };
  41994. var onError = function (error) {
  41995. unbindListeners();
  41996. callback(error);
  41997. };
  41998. var onClosed = function () {
  41999. unbindListeners();
  42000. var serializedTransport;
  42001. serializedTransport = safeJSONStringify(transport);
  42002. callback(new TransportClosed(serializedTransport));
  42003. };
  42004. var unbindListeners = function () {
  42005. transport.unbind("initialized", onInitialized);
  42006. transport.unbind("open", onOpen);
  42007. transport.unbind("error", onError);
  42008. transport.unbind("closed", onClosed);
  42009. };
  42010. transport.bind("initialized", onInitialized);
  42011. transport.bind("open", onOpen);
  42012. transport.bind("error", onError);
  42013. transport.bind("closed", onClosed);
  42014. transport.initialize();
  42015. return {
  42016. abort: function () {
  42017. if (connected) {
  42018. return;
  42019. }
  42020. unbindListeners();
  42021. if (handshake) {
  42022. handshake.close();
  42023. }
  42024. else {
  42025. transport.close();
  42026. }
  42027. },
  42028. forceMinPriority: function (p) {
  42029. if (connected) {
  42030. return;
  42031. }
  42032. if (_this.priority < p) {
  42033. if (handshake) {
  42034. handshake.close();
  42035. }
  42036. else {
  42037. transport.close();
  42038. }
  42039. }
  42040. }
  42041. };
  42042. };
  42043. return TransportStrategy;
  42044. }());
  42045. /* harmony default export */ var transport_strategy = (transport_strategy_TransportStrategy);
  42046. function failAttempt(error, callback) {
  42047. util.defer(function () {
  42048. callback(error);
  42049. });
  42050. return {
  42051. abort: function () { },
  42052. forceMinPriority: function () { }
  42053. };
  42054. }
  42055. // CONCATENATED MODULE: ./src/core/strategies/strategy_builder.ts
  42056. var strategy_builder_Transports = runtime.Transports;
  42057. var strategy_builder_defineTransport = function (config, name, type, priority, options, manager) {
  42058. var transportClass = strategy_builder_Transports[type];
  42059. if (!transportClass) {
  42060. throw new UnsupportedTransport(type);
  42061. }
  42062. var enabled = (!config.enabledTransports ||
  42063. arrayIndexOf(config.enabledTransports, name) !== -1) &&
  42064. (!config.disabledTransports ||
  42065. arrayIndexOf(config.disabledTransports, name) === -1);
  42066. var transport;
  42067. if (enabled) {
  42068. transport = new transport_strategy(name, priority, manager ? manager.getAssistant(transportClass) : transportClass, extend({
  42069. key: config.key,
  42070. useTLS: config.useTLS,
  42071. timeline: config.timeline,
  42072. ignoreNullOrigin: config.ignoreNullOrigin
  42073. }, options));
  42074. }
  42075. else {
  42076. transport = strategy_builder_UnsupportedStrategy;
  42077. }
  42078. return transport;
  42079. };
  42080. var strategy_builder_UnsupportedStrategy = {
  42081. isSupported: function () {
  42082. return false;
  42083. },
  42084. connect: function (_, callback) {
  42085. var deferred = util.defer(function () {
  42086. callback(new UnsupportedStrategy());
  42087. });
  42088. return {
  42089. abort: function () {
  42090. deferred.ensureAborted();
  42091. },
  42092. forceMinPriority: function () { }
  42093. };
  42094. }
  42095. };
  42096. // CONCATENATED MODULE: ./src/core/config.ts
  42097. var getGlobalConfig = function () {
  42098. return {
  42099. wsHost: defaults.host,
  42100. wsPort: defaults.ws_port,
  42101. wssPort: defaults.wss_port,
  42102. wsPath: defaults.ws_path,
  42103. httpHost: defaults.sockjs_host,
  42104. httpPort: defaults.sockjs_http_port,
  42105. httpsPort: defaults.sockjs_https_port,
  42106. httpPath: defaults.sockjs_path,
  42107. statsHost: defaults.stats_host,
  42108. authEndpoint: defaults.channel_auth_endpoint,
  42109. authTransport: defaults.channel_auth_transport,
  42110. activity_timeout: defaults.activity_timeout,
  42111. pong_timeout: defaults.pong_timeout,
  42112. unavailable_timeout: defaults.unavailable_timeout
  42113. };
  42114. };
  42115. var getClusterConfig = function (clusterName) {
  42116. return {
  42117. wsHost: 'ws-' + clusterName + '.pusher.com',
  42118. httpHost: 'sockjs-' + clusterName + '.pusher.com'
  42119. };
  42120. };
  42121. // CONCATENATED MODULE: ./src/core/pusher.ts
  42122. var pusher_Pusher = (function () {
  42123. function Pusher(app_key, options) {
  42124. var _this = this;
  42125. checkAppKey(app_key);
  42126. options = options || {};
  42127. if (!options.cluster && !(options.wsHost || options.httpHost)) {
  42128. var suffix = url_store.buildLogSuffix('javascriptQuickStart');
  42129. logger.warn("You should always specify a cluster when connecting. " + suffix);
  42130. }
  42131. this.key = app_key;
  42132. this.config = extend(getGlobalConfig(), options.cluster ? getClusterConfig(options.cluster) : {}, options);
  42133. this.channels = factory.createChannels();
  42134. this.global_emitter = new dispatcher();
  42135. this.sessionID = Math.floor(Math.random() * 1000000000);
  42136. this.timeline = new timeline_timeline(this.key, this.sessionID, {
  42137. cluster: this.config.cluster,
  42138. features: Pusher.getClientFeatures(),
  42139. params: this.config.timelineParams || {},
  42140. limit: 50,
  42141. level: timeline_level.INFO,
  42142. version: defaults.VERSION
  42143. });
  42144. if (!this.config.disableStats) {
  42145. this.timelineSender = factory.createTimelineSender(this.timeline, {
  42146. host: this.config.statsHost,
  42147. path: '/timeline/v2/' + runtime.TimelineTransport.name
  42148. });
  42149. }
  42150. var getStrategy = function (options) {
  42151. var config = extend({}, _this.config, options);
  42152. return runtime.getDefaultStrategy(config, strategy_builder_defineTransport);
  42153. };
  42154. this.connection = factory.createConnectionManager(this.key, extend({
  42155. getStrategy: getStrategy,
  42156. timeline: this.timeline,
  42157. activityTimeout: this.config.activity_timeout,
  42158. pongTimeout: this.config.pong_timeout,
  42159. unavailableTimeout: this.config.unavailable_timeout
  42160. }, this.config, { useTLS: this.shouldUseTLS() }));
  42161. this.connection.bind('connected', function () {
  42162. _this.subscribeAll();
  42163. if (_this.timelineSender) {
  42164. _this.timelineSender.send(_this.connection.isUsingTLS());
  42165. }
  42166. });
  42167. this.connection.bind('message', function (event) {
  42168. var eventName = event.event;
  42169. var internal = eventName.indexOf('pusher_internal:') === 0;
  42170. if (event.channel) {
  42171. var channel = _this.channel(event.channel);
  42172. if (channel) {
  42173. channel.handleEvent(event);
  42174. }
  42175. }
  42176. if (!internal) {
  42177. _this.global_emitter.emit(event.event, event.data);
  42178. }
  42179. });
  42180. this.connection.bind('connecting', function () {
  42181. _this.channels.disconnect();
  42182. });
  42183. this.connection.bind('disconnected', function () {
  42184. _this.channels.disconnect();
  42185. });
  42186. this.connection.bind('error', function (err) {
  42187. logger.warn(err);
  42188. });
  42189. Pusher.instances.push(this);
  42190. this.timeline.info({ instances: Pusher.instances.length });
  42191. if (Pusher.isReady) {
  42192. this.connect();
  42193. }
  42194. }
  42195. Pusher.ready = function () {
  42196. Pusher.isReady = true;
  42197. for (var i = 0, l = Pusher.instances.length; i < l; i++) {
  42198. Pusher.instances[i].connect();
  42199. }
  42200. };
  42201. Pusher.getClientFeatures = function () {
  42202. return keys(filterObject({ ws: runtime.Transports.ws }, function (t) {
  42203. return t.isSupported({});
  42204. }));
  42205. };
  42206. Pusher.prototype.channel = function (name) {
  42207. return this.channels.find(name);
  42208. };
  42209. Pusher.prototype.allChannels = function () {
  42210. return this.channels.all();
  42211. };
  42212. Pusher.prototype.connect = function () {
  42213. this.connection.connect();
  42214. if (this.timelineSender) {
  42215. if (!this.timelineSenderTimer) {
  42216. var usingTLS = this.connection.isUsingTLS();
  42217. var timelineSender = this.timelineSender;
  42218. this.timelineSenderTimer = new PeriodicTimer(60000, function () {
  42219. timelineSender.send(usingTLS);
  42220. });
  42221. }
  42222. }
  42223. };
  42224. Pusher.prototype.disconnect = function () {
  42225. this.connection.disconnect();
  42226. if (this.timelineSenderTimer) {
  42227. this.timelineSenderTimer.ensureAborted();
  42228. this.timelineSenderTimer = null;
  42229. }
  42230. };
  42231. Pusher.prototype.bind = function (event_name, callback, context) {
  42232. this.global_emitter.bind(event_name, callback, context);
  42233. return this;
  42234. };
  42235. Pusher.prototype.unbind = function (event_name, callback, context) {
  42236. this.global_emitter.unbind(event_name, callback, context);
  42237. return this;
  42238. };
  42239. Pusher.prototype.bind_global = function (callback) {
  42240. this.global_emitter.bind_global(callback);
  42241. return this;
  42242. };
  42243. Pusher.prototype.unbind_global = function (callback) {
  42244. this.global_emitter.unbind_global(callback);
  42245. return this;
  42246. };
  42247. Pusher.prototype.unbind_all = function (callback) {
  42248. this.global_emitter.unbind_all();
  42249. return this;
  42250. };
  42251. Pusher.prototype.subscribeAll = function () {
  42252. var channelName;
  42253. for (channelName in this.channels.channels) {
  42254. if (this.channels.channels.hasOwnProperty(channelName)) {
  42255. this.subscribe(channelName);
  42256. }
  42257. }
  42258. };
  42259. Pusher.prototype.subscribe = function (channel_name) {
  42260. var channel = this.channels.add(channel_name, this);
  42261. if (channel.subscriptionPending && channel.subscriptionCancelled) {
  42262. channel.reinstateSubscription();
  42263. }
  42264. else if (!channel.subscriptionPending &&
  42265. this.connection.state === 'connected') {
  42266. channel.subscribe();
  42267. }
  42268. return channel;
  42269. };
  42270. Pusher.prototype.unsubscribe = function (channel_name) {
  42271. var channel = this.channels.find(channel_name);
  42272. if (channel && channel.subscriptionPending) {
  42273. channel.cancelSubscription();
  42274. }
  42275. else {
  42276. channel = this.channels.remove(channel_name);
  42277. if (channel && this.connection.state === 'connected') {
  42278. channel.unsubscribe();
  42279. }
  42280. }
  42281. };
  42282. Pusher.prototype.send_event = function (event_name, data, channel) {
  42283. return this.connection.send_event(event_name, data, channel);
  42284. };
  42285. Pusher.prototype.shouldUseTLS = function () {
  42286. if (runtime.getProtocol() === 'https:') {
  42287. return true;
  42288. }
  42289. else if (this.config.forceTLS === true) {
  42290. return true;
  42291. }
  42292. else {
  42293. return Boolean(this.config.encrypted);
  42294. }
  42295. };
  42296. Pusher.instances = [];
  42297. Pusher.isReady = false;
  42298. Pusher.logToConsole = false;
  42299. Pusher.Runtime = runtime;
  42300. Pusher.ScriptReceivers = runtime.ScriptReceivers;
  42301. Pusher.DependenciesReceivers = runtime.DependenciesReceivers;
  42302. Pusher.auth_callbacks = runtime.auth_callbacks;
  42303. return Pusher;
  42304. }());
  42305. /* harmony default export */ var core_pusher = __webpack_exports__["default"] = (pusher_Pusher);
  42306. function checkAppKey(key) {
  42307. if (key === null || key === undefined) {
  42308. throw 'You must pass your app key when you instantiate Pusher.';
  42309. }
  42310. }
  42311. runtime.setup(pusher_Pusher);
  42312. /***/ })
  42313. /******/ ]);
  42314. });
  42315. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../../buffer/index.js */ "./node_modules/buffer/index.js").Buffer))
  42316. /***/ }),
  42317. /***/ "./node_modules/setimmediate/setImmediate.js":
  42318. /*!***************************************************!*\
  42319. !*** ./node_modules/setimmediate/setImmediate.js ***!
  42320. \***************************************************/
  42321. /*! no static exports found */
  42322. /***/ (function(module, exports, __webpack_require__) {
  42323. /* WEBPACK VAR INJECTION */(function(global, process) {(function (global, undefined) {
  42324. "use strict";
  42325. if (global.setImmediate) {
  42326. return;
  42327. }
  42328. var nextHandle = 1; // Spec says greater than zero
  42329. var tasksByHandle = {};
  42330. var currentlyRunningATask = false;
  42331. var doc = global.document;
  42332. var registerImmediate;
  42333. function setImmediate(callback) {
  42334. // Callback can either be a function or a string
  42335. if (typeof callback !== "function") {
  42336. callback = new Function("" + callback);
  42337. }
  42338. // Copy function arguments
  42339. var args = new Array(arguments.length - 1);
  42340. for (var i = 0; i < args.length; i++) {
  42341. args[i] = arguments[i + 1];
  42342. }
  42343. // Store and register the task
  42344. var task = { callback: callback, args: args };
  42345. tasksByHandle[nextHandle] = task;
  42346. registerImmediate(nextHandle);
  42347. return nextHandle++;
  42348. }
  42349. function clearImmediate(handle) {
  42350. delete tasksByHandle[handle];
  42351. }
  42352. function run(task) {
  42353. var callback = task.callback;
  42354. var args = task.args;
  42355. switch (args.length) {
  42356. case 0:
  42357. callback();
  42358. break;
  42359. case 1:
  42360. callback(args[0]);
  42361. break;
  42362. case 2:
  42363. callback(args[0], args[1]);
  42364. break;
  42365. case 3:
  42366. callback(args[0], args[1], args[2]);
  42367. break;
  42368. default:
  42369. callback.apply(undefined, args);
  42370. break;
  42371. }
  42372. }
  42373. function runIfPresent(handle) {
  42374. // From the spec: "Wait until any invocations of this algorithm started before this one have completed."
  42375. // So if we're currently running a task, we'll need to delay this invocation.
  42376. if (currentlyRunningATask) {
  42377. // Delay by doing a setTimeout. setImmediate was tried instead, but in Firefox 7 it generated a
  42378. // "too much recursion" error.
  42379. setTimeout(runIfPresent, 0, handle);
  42380. } else {
  42381. var task = tasksByHandle[handle];
  42382. if (task) {
  42383. currentlyRunningATask = true;
  42384. try {
  42385. run(task);
  42386. } finally {
  42387. clearImmediate(handle);
  42388. currentlyRunningATask = false;
  42389. }
  42390. }
  42391. }
  42392. }
  42393. function installNextTickImplementation() {
  42394. registerImmediate = function(handle) {
  42395. process.nextTick(function () { runIfPresent(handle); });
  42396. };
  42397. }
  42398. function canUsePostMessage() {
  42399. // The test against `importScripts` prevents this implementation from being installed inside a web worker,
  42400. // where `global.postMessage` means something completely different and can't be used for this purpose.
  42401. if (global.postMessage && !global.importScripts) {
  42402. var postMessageIsAsynchronous = true;
  42403. var oldOnMessage = global.onmessage;
  42404. global.onmessage = function() {
  42405. postMessageIsAsynchronous = false;
  42406. };
  42407. global.postMessage("", "*");
  42408. global.onmessage = oldOnMessage;
  42409. return postMessageIsAsynchronous;
  42410. }
  42411. }
  42412. function installPostMessageImplementation() {
  42413. // Installs an event handler on `global` for the `message` event: see
  42414. // * https://developer.mozilla.org/en/DOM/window.postMessage
  42415. // * http://www.whatwg.org/specs/web-apps/current-work/multipage/comms.html#crossDocumentMessages
  42416. var messagePrefix = "setImmediate$" + Math.random() + "$";
  42417. var onGlobalMessage = function(event) {
  42418. if (event.source === global &&
  42419. typeof event.data === "string" &&
  42420. event.data.indexOf(messagePrefix) === 0) {
  42421. runIfPresent(+event.data.slice(messagePrefix.length));
  42422. }
  42423. };
  42424. if (global.addEventListener) {
  42425. global.addEventListener("message", onGlobalMessage, false);
  42426. } else {
  42427. global.attachEvent("onmessage", onGlobalMessage);
  42428. }
  42429. registerImmediate = function(handle) {
  42430. global.postMessage(messagePrefix + handle, "*");
  42431. };
  42432. }
  42433. function installMessageChannelImplementation() {
  42434. var channel = new MessageChannel();
  42435. channel.port1.onmessage = function(event) {
  42436. var handle = event.data;
  42437. runIfPresent(handle);
  42438. };
  42439. registerImmediate = function(handle) {
  42440. channel.port2.postMessage(handle);
  42441. };
  42442. }
  42443. function installReadyStateChangeImplementation() {
  42444. var html = doc.documentElement;
  42445. registerImmediate = function(handle) {
  42446. // Create a <script> element; its readystatechange event will be fired asynchronously once it is inserted
  42447. // into the document. Do so, thus queuing up the task. Remember to clean up once it's been called.
  42448. var script = doc.createElement("script");
  42449. script.onreadystatechange = function () {
  42450. runIfPresent(handle);
  42451. script.onreadystatechange = null;
  42452. html.removeChild(script);
  42453. script = null;
  42454. };
  42455. html.appendChild(script);
  42456. };
  42457. }
  42458. function installSetTimeoutImplementation() {
  42459. registerImmediate = function(handle) {
  42460. setTimeout(runIfPresent, 0, handle);
  42461. };
  42462. }
  42463. // If supported, we should attach to the prototype of global, since that is where setTimeout et al. live.
  42464. var attachTo = Object.getPrototypeOf && Object.getPrototypeOf(global);
  42465. attachTo = attachTo && attachTo.setTimeout ? attachTo : global;
  42466. // Don't get fooled by e.g. browserify environments.
  42467. if ({}.toString.call(global.process) === "[object process]") {
  42468. // For Node.js before 0.9
  42469. installNextTickImplementation();
  42470. } else if (canUsePostMessage()) {
  42471. // For non-IE10 modern browsers
  42472. installPostMessageImplementation();
  42473. } else if (global.MessageChannel) {
  42474. // For web workers, where supported
  42475. installMessageChannelImplementation();
  42476. } else if (doc && "onreadystatechange" in doc.createElement("script")) {
  42477. // For IE 6–8
  42478. installReadyStateChangeImplementation();
  42479. } else {
  42480. // For older browsers
  42481. installSetTimeoutImplementation();
  42482. }
  42483. attachTo.setImmediate = setImmediate;
  42484. attachTo.clearImmediate = clearImmediate;
  42485. }(typeof self === "undefined" ? typeof global === "undefined" ? this : global : self));
  42486. /* 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")))
  42487. /***/ }),
  42488. /***/ "./node_modules/timers-browserify/main.js":
  42489. /*!************************************************!*\
  42490. !*** ./node_modules/timers-browserify/main.js ***!
  42491. \************************************************/
  42492. /*! no static exports found */
  42493. /***/ (function(module, exports, __webpack_require__) {
  42494. /* WEBPACK VAR INJECTION */(function(global) {var scope = (typeof global !== "undefined" && global) ||
  42495. (typeof self !== "undefined" && self) ||
  42496. window;
  42497. var apply = Function.prototype.apply;
  42498. // DOM APIs, for completeness
  42499. exports.setTimeout = function() {
  42500. return new Timeout(apply.call(setTimeout, scope, arguments), clearTimeout);
  42501. };
  42502. exports.setInterval = function() {
  42503. return new Timeout(apply.call(setInterval, scope, arguments), clearInterval);
  42504. };
  42505. exports.clearTimeout =
  42506. exports.clearInterval = function(timeout) {
  42507. if (timeout) {
  42508. timeout.close();
  42509. }
  42510. };
  42511. function Timeout(id, clearFn) {
  42512. this._id = id;
  42513. this._clearFn = clearFn;
  42514. }
  42515. Timeout.prototype.unref = Timeout.prototype.ref = function() {};
  42516. Timeout.prototype.close = function() {
  42517. this._clearFn.call(scope, this._id);
  42518. };
  42519. // Does not start the time, just sets up the members needed.
  42520. exports.enroll = function(item, msecs) {
  42521. clearTimeout(item._idleTimeoutId);
  42522. item._idleTimeout = msecs;
  42523. };
  42524. exports.unenroll = function(item) {
  42525. clearTimeout(item._idleTimeoutId);
  42526. item._idleTimeout = -1;
  42527. };
  42528. exports._unrefActive = exports.active = function(item) {
  42529. clearTimeout(item._idleTimeoutId);
  42530. var msecs = item._idleTimeout;
  42531. if (msecs >= 0) {
  42532. item._idleTimeoutId = setTimeout(function onTimeout() {
  42533. if (item._onTimeout)
  42534. item._onTimeout();
  42535. }, msecs);
  42536. }
  42537. };
  42538. // setimmediate attaches itself to the global object
  42539. __webpack_require__(/*! setimmediate */ "./node_modules/setimmediate/setImmediate.js");
  42540. // On some exotic environments, it's not clear which object `setimmediate` was
  42541. // able to install onto. Search each possibility in the same order as the
  42542. // `setimmediate` library.
  42543. exports.setImmediate = (typeof self !== "undefined" && self.setImmediate) ||
  42544. (typeof global !== "undefined" && global.setImmediate) ||
  42545. (this && this.setImmediate);
  42546. exports.clearImmediate = (typeof self !== "undefined" && self.clearImmediate) ||
  42547. (typeof global !== "undefined" && global.clearImmediate) ||
  42548. (this && this.clearImmediate);
  42549. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../webpack/buildin/global.js */ "./node_modules/webpack/buildin/global.js")))
  42550. /***/ }),
  42551. /***/ "./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&":
  42552. /*!*******************************************************************************************************************************************************************************************************************!*\
  42553. !*** ./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& ***!
  42554. \*******************************************************************************************************************************************************************************************************************/
  42555. /*! exports provided: render, staticRenderFns */
  42556. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  42557. "use strict";
  42558. __webpack_require__.r(__webpack_exports__);
  42559. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "render", function() { return render; });
  42560. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "staticRenderFns", function() { return staticRenderFns; });
  42561. var render = function() {
  42562. var _vm = this
  42563. var _h = _vm.$createElement
  42564. var _c = _vm._self._c || _h
  42565. return _vm._m(0)
  42566. }
  42567. var staticRenderFns = [
  42568. function() {
  42569. var _vm = this
  42570. var _h = _vm.$createElement
  42571. var _c = _vm._self._c || _h
  42572. return _c("div", { staticClass: "container" }, [
  42573. _c("div", { staticClass: "row justify-content-center" }, [
  42574. _c("div", { staticClass: "col-md-8" }, [
  42575. _c("div", { staticClass: "card" }, [
  42576. _c("div", { staticClass: "card-header" }, [
  42577. _vm._v("Example Component")
  42578. ]),
  42579. _vm._v(" "),
  42580. _c("div", { staticClass: "card-body" }, [
  42581. _vm._v(
  42582. "\n I'm an example component.\n "
  42583. )
  42584. ])
  42585. ])
  42586. ])
  42587. ])
  42588. ])
  42589. }
  42590. ]
  42591. render._withStripped = true
  42592. /***/ }),
  42593. /***/ "./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&":
  42594. /*!************************************************************************************************************************************************************************************************************!*\
  42595. !*** ./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& ***!
  42596. \************************************************************************************************************************************************************************************************************/
  42597. /*! exports provided: render, staticRenderFns */
  42598. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  42599. "use strict";
  42600. __webpack_require__.r(__webpack_exports__);
  42601. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "render", function() { return render; });
  42602. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "staticRenderFns", function() { return staticRenderFns; });
  42603. var render = function() {
  42604. var _vm = this
  42605. var _h = _vm.$createElement
  42606. var _c = _vm._self._c || _h
  42607. return _c(
  42608. "div",
  42609. [
  42610. _c(
  42611. "modal",
  42612. {
  42613. attrs: {
  42614. id: "asseteditModal",
  42615. tabindex: "-1",
  42616. role: "dialog",
  42617. "aria-labelledby": "asseteditModalLabel"
  42618. }
  42619. },
  42620. [
  42621. _c(
  42622. "h5",
  42623. {
  42624. staticClass: "modal-title",
  42625. attrs: { slot: "header", id: "asseteditModalLabel" },
  42626. slot: "header"
  42627. },
  42628. [_vm._v("\n Edit Work Order Information\n ")]
  42629. ),
  42630. _vm._v(" "),
  42631. _c("div", { attrs: { slot: "body" }, slot: "body" }, [
  42632. _c("div", { staticClass: "form-group" }, [
  42633. _c("label", { attrs: { for: "manufacturer" } }, [
  42634. _vm._v("Manufacturer")
  42635. ]),
  42636. _vm._v(" "),
  42637. _c("input", {
  42638. directives: [
  42639. {
  42640. name: "model",
  42641. rawName: "v-model",
  42642. value: _vm.data.pcmanu,
  42643. expression: "data.pcmanu"
  42644. }
  42645. ],
  42646. staticClass: "form-control",
  42647. attrs: {
  42648. type: "text",
  42649. name: "manufacturer",
  42650. id: "manufacturer"
  42651. },
  42652. domProps: { value: _vm.data.pcmanu },
  42653. on: {
  42654. input: function($event) {
  42655. if ($event.target.composing) {
  42656. return
  42657. }
  42658. _vm.$set(_vm.data, "pcmanu", $event.target.value)
  42659. }
  42660. }
  42661. })
  42662. ]),
  42663. _vm._v(" "),
  42664. _c("div", { staticClass: "form-group" }, [
  42665. _c("label", { attrs: { for: "make" } }, [_vm._v("Make")]),
  42666. _vm._v(" "),
  42667. _c("input", {
  42668. directives: [
  42669. {
  42670. name: "model",
  42671. rawName: "v-model",
  42672. value: _vm.data.pcmake,
  42673. expression: "data.pcmake"
  42674. }
  42675. ],
  42676. staticClass: "form-control",
  42677. attrs: { type: "text", name: "make", id: "make" },
  42678. domProps: { value: _vm.data.pcmake },
  42679. on: {
  42680. input: function($event) {
  42681. if ($event.target.composing) {
  42682. return
  42683. }
  42684. _vm.$set(_vm.data, "pcmake", $event.target.value)
  42685. }
  42686. }
  42687. })
  42688. ]),
  42689. _vm._v(" "),
  42690. _c("div", { staticClass: "form-group" }, [
  42691. _c("label", { attrs: { for: "nickname" } }, [_vm._v("Nickname")]),
  42692. _vm._v(" "),
  42693. _c("input", {
  42694. directives: [
  42695. {
  42696. name: "model",
  42697. rawName: "v-model",
  42698. value: _vm.data.pcnickname,
  42699. expression: "data.pcnickname"
  42700. }
  42701. ],
  42702. staticClass: "form-control",
  42703. attrs: { type: "text", name: "nickname", id: "nickname" },
  42704. domProps: { value: _vm.data.pcnickname },
  42705. on: {
  42706. input: function($event) {
  42707. if ($event.target.composing) {
  42708. return
  42709. }
  42710. _vm.$set(_vm.data, "pcnickname", $event.target.value)
  42711. }
  42712. }
  42713. })
  42714. ]),
  42715. _vm._v(" "),
  42716. _c("div", { staticClass: "form-group" }, [
  42717. _c("label", { attrs: { for: "os" } }, [_vm._v("OS")]),
  42718. _vm._v(" "),
  42719. _c("input", {
  42720. directives: [
  42721. {
  42722. name: "model",
  42723. rawName: "v-model",
  42724. value: _vm.pcextra[2],
  42725. expression: "pcextra[2]"
  42726. }
  42727. ],
  42728. staticClass: "form-control",
  42729. attrs: { type: "text", name: "os", id: "os" },
  42730. domProps: { value: _vm.pcextra[2] },
  42731. on: {
  42732. input: function($event) {
  42733. if ($event.target.composing) {
  42734. return
  42735. }
  42736. _vm.$set(_vm.pcextra, 2, $event.target.value)
  42737. }
  42738. }
  42739. })
  42740. ]),
  42741. _vm._v(" "),
  42742. _c("div", { staticClass: "form-group" }, [
  42743. _c("label", { attrs: { for: "serial" } }, [
  42744. _vm._v("Serial Number")
  42745. ]),
  42746. _vm._v(" "),
  42747. _c("input", {
  42748. directives: [
  42749. {
  42750. name: "model",
  42751. rawName: "v-model",
  42752. value: _vm.pcextra[104],
  42753. expression: "pcextra[104]"
  42754. }
  42755. ],
  42756. staticClass: "form-control",
  42757. attrs: { type: "text", id: "serial", name: "serial" },
  42758. domProps: { value: _vm.pcextra[104] },
  42759. on: {
  42760. input: function($event) {
  42761. if ($event.target.composing) {
  42762. return
  42763. }
  42764. _vm.$set(_vm.pcextra, 104, $event.target.value)
  42765. }
  42766. }
  42767. })
  42768. ]),
  42769. _vm._v(" "),
  42770. _c("div", { staticClass: "form-group" }, [
  42771. _c("label", { attrs: { for: "cpu" } }, [_vm._v("CPU")]),
  42772. _vm._v(" "),
  42773. _c("input", {
  42774. directives: [
  42775. {
  42776. name: "model",
  42777. rawName: "v-model",
  42778. value: _vm.pcextra[101],
  42779. expression: "pcextra[101]"
  42780. }
  42781. ],
  42782. staticClass: "form-control",
  42783. attrs: { type: "text", id: "cpu", name: "cpu" },
  42784. domProps: { value: _vm.pcextra[101] },
  42785. on: {
  42786. input: function($event) {
  42787. if ($event.target.composing) {
  42788. return
  42789. }
  42790. _vm.$set(_vm.pcextra, 101, $event.target.value)
  42791. }
  42792. }
  42793. })
  42794. ]),
  42795. _vm._v(" "),
  42796. _c("div", { staticClass: "form-group" }, [
  42797. _c("label", { attrs: { for: "ram" } }, [_vm._v("RAM")]),
  42798. _vm._v(" "),
  42799. _c("input", {
  42800. directives: [
  42801. {
  42802. name: "model",
  42803. rawName: "v-model",
  42804. value: _vm.pcextra[100],
  42805. expression: "pcextra[100]"
  42806. }
  42807. ],
  42808. staticClass: "form-control",
  42809. attrs: { type: "text", name: "ram", id: "ram" },
  42810. domProps: { value: _vm.pcextra[100] },
  42811. on: {
  42812. input: function($event) {
  42813. if ($event.target.composing) {
  42814. return
  42815. }
  42816. _vm.$set(_vm.pcextra, 100, $event.target.value)
  42817. }
  42818. }
  42819. })
  42820. ]),
  42821. _vm._v(" "),
  42822. _c("div", { staticClass: "form-group" }, [
  42823. _c("label", { attrs: { for: "graphics" } }, [_vm._v("Graphics")]),
  42824. _vm._v(" "),
  42825. _c("input", {
  42826. directives: [
  42827. {
  42828. name: "model",
  42829. rawName: "v-model",
  42830. value: _vm.pcextra[4],
  42831. expression: "pcextra[4]"
  42832. }
  42833. ],
  42834. staticClass: "form-control",
  42835. attrs: { type: "text", name: "graphics", id: "grapics" },
  42836. domProps: { value: _vm.pcextra[4] },
  42837. on: {
  42838. input: function($event) {
  42839. if ($event.target.composing) {
  42840. return
  42841. }
  42842. _vm.$set(_vm.pcextra, 4, $event.target.value)
  42843. }
  42844. }
  42845. })
  42846. ])
  42847. ]),
  42848. _vm._v(" "),
  42849. _c("div", { attrs: { slot: "footer" }, slot: "footer" }, [
  42850. _c(
  42851. "button",
  42852. {
  42853. staticClass: "btn btn-secondary",
  42854. attrs: { type: "button", "data-dismiss": "modal" }
  42855. },
  42856. [_vm._v("Close")]
  42857. ),
  42858. _vm._v(" "),
  42859. _c(
  42860. "button",
  42861. {
  42862. staticClass: "btn btn-primary",
  42863. attrs: { type: "button" },
  42864. on: {
  42865. click: function($event) {
  42866. return _vm.updateAsset()
  42867. }
  42868. }
  42869. },
  42870. [_vm._v("Save")]
  42871. )
  42872. ])
  42873. ]
  42874. ),
  42875. _vm._v(" "),
  42876. _c("h4", { staticClass: "text-center" }, [
  42877. _vm._v(
  42878. _vm._s(this.data.pcmanu) + " " + _vm._s(this.data.pcmake) + " - "
  42879. ),
  42880. _c("small", { staticClass: "text-muted" }, [
  42881. _vm._v(_vm._s(this.data.pcnickname))
  42882. ])
  42883. ]),
  42884. _vm._v(" "),
  42885. _c("p", [_vm._v("OS: " + _vm._s(this.pcextra[2]))]),
  42886. _vm._v(" "),
  42887. _c("p", [_vm._v("S/N: " + _vm._s(this.pcextra[104]))]),
  42888. _vm._v(" "),
  42889. _c("p", [_vm._v("CPU: " + _vm._s(this.pcextra[101]))]),
  42890. _vm._v(" "),
  42891. _c("p", [_vm._v("RAM: " + _vm._s(this.pcextra[100]))]),
  42892. _vm._v(" "),
  42893. _c("p", [_vm._v("Graphics: " + _vm._s(this.pcextra[4]))]),
  42894. _vm._v(" "),
  42895. _c(
  42896. "button",
  42897. {
  42898. staticClass: "btn btn-primary",
  42899. attrs: {
  42900. type: "button",
  42901. "data-toggle": "modal",
  42902. "data-target": "#asseteditModal"
  42903. }
  42904. },
  42905. [_vm._v("Edit")]
  42906. )
  42907. ],
  42908. 1
  42909. )
  42910. }
  42911. var staticRenderFns = []
  42912. render._withStripped = true
  42913. /***/ }),
  42914. /***/ "./node_modules/vue-loader/lib/loaders/templateLoader.js?!./node_modules/vue-loader/lib/index.js?!./resources/js/components/credential.vue?vue&type=template&id=0f5cc562&":
  42915. /*!*************************************************************************************************************************************************************************************************************!*\
  42916. !*** ./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/vue-loader/lib??vue-loader-options!./resources/js/components/credential.vue?vue&type=template&id=0f5cc562& ***!
  42917. \*************************************************************************************************************************************************************************************************************/
  42918. /*! exports provided: render, staticRenderFns */
  42919. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  42920. "use strict";
  42921. __webpack_require__.r(__webpack_exports__);
  42922. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "render", function() { return render; });
  42923. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "staticRenderFns", function() { return staticRenderFns; });
  42924. var render = function() {
  42925. var _vm = this
  42926. var _h = _vm.$createElement
  42927. var _c = _vm._self._c || _h
  42928. return _c(
  42929. "div",
  42930. { staticClass: "bg-lightgray m-1 p-2 border rounded container-fluid" },
  42931. [
  42932. _c("div", { staticClass: "row no-gutters" }, [
  42933. _c("div", { staticClass: "h5 col-3 text-left" }, [
  42934. _vm._v(_vm._s(this.data.creddesc))
  42935. ]),
  42936. _vm._v(" "),
  42937. _c("div", { staticClass: "col-9 text-right" }, [
  42938. _vm._v(_vm._s(this.data.creddate))
  42939. ])
  42940. ]),
  42941. _vm._v(" "),
  42942. _c("div", { staticClass: "row" }, [
  42943. _c("div", { staticClass: "col-lg-9" }, [
  42944. _c("div", [
  42945. _vm._m(0),
  42946. _vm._v(" "),
  42947. _c("input", {
  42948. staticClass: "border-0 credential",
  42949. attrs: {
  42950. type: "text",
  42951. id: "username" + this.data.credid,
  42952. readonly: ""
  42953. },
  42954. domProps: { value: this.data.creduser }
  42955. }),
  42956. _vm._v(" "),
  42957. _c(
  42958. "button",
  42959. {
  42960. staticClass: "btn-clip btn btn-sm btn-primary rounded-pill",
  42961. attrs: {
  42962. id: "btn-username" + this.data.credid,
  42963. "data-clipboard-target": "#username" + this.data.credid
  42964. }
  42965. },
  42966. [_c("i", { staticClass: "far fa-clone" })]
  42967. )
  42968. ]),
  42969. _vm._v(" "),
  42970. _c("div", [
  42971. _vm._m(1),
  42972. _vm._v(" "),
  42973. _c("input", {
  42974. staticClass: "border-0 credential",
  42975. attrs: {
  42976. type: "text",
  42977. id: "password" + this.data.credid,
  42978. readonly: ""
  42979. },
  42980. domProps: { value: this.data.credpass }
  42981. }),
  42982. _vm._v(" "),
  42983. _c(
  42984. "button",
  42985. {
  42986. staticClass: "btn-clip btn btn-sm btn-primary rounded-pill",
  42987. attrs: {
  42988. id: "btn-password" + this.data.credid,
  42989. "data-clipboard-target": "#password" + this.data.credid
  42990. }
  42991. },
  42992. [_c("i", { staticClass: "far fa-clone" })]
  42993. )
  42994. ])
  42995. ]),
  42996. _vm._v(" "),
  42997. _vm._m(2)
  42998. ])
  42999. ]
  43000. )
  43001. }
  43002. var staticRenderFns = [
  43003. function() {
  43004. var _vm = this
  43005. var _h = _vm.$createElement
  43006. var _c = _vm._self._c || _h
  43007. return _c("label", { attrs: { for: "username" } }, [
  43008. _c("i", { staticClass: "fas fa-fw fa-user" })
  43009. ])
  43010. },
  43011. function() {
  43012. var _vm = this
  43013. var _h = _vm.$createElement
  43014. var _c = _vm._self._c || _h
  43015. return _c("label", { attrs: { for: "password" } }, [
  43016. _c("i", { staticClass: "fas fa-fw fa-key" })
  43017. ])
  43018. },
  43019. function() {
  43020. var _vm = this
  43021. var _h = _vm.$createElement
  43022. var _c = _vm._self._c || _h
  43023. return _c(
  43024. "div",
  43025. {
  43026. staticClass: "btn-group col-lg-2 align-self-end w-25 w-lg-auto",
  43027. attrs: { role: "group", "aria-label": "Edit and Delete" }
  43028. },
  43029. [
  43030. _c(
  43031. "button",
  43032. {
  43033. staticClass: "btn btn-sm btn-secondary p-lg-1",
  43034. attrs: { type: "button" }
  43035. },
  43036. [_c("i", { staticClass: "fas fa-fw fa-edit" })]
  43037. ),
  43038. _vm._v(" "),
  43039. _c(
  43040. "button",
  43041. {
  43042. staticClass: "btn btn-sm btn-danger p-lg-1",
  43043. attrs: { type: "button" }
  43044. },
  43045. [_c("i", { staticClass: "fas fa-fw fa-trash-alt" })]
  43046. )
  43047. ]
  43048. )
  43049. }
  43050. ]
  43051. render._withStripped = true
  43052. /***/ }),
  43053. /***/ "./node_modules/vue-loader/lib/loaders/templateLoader.js?!./node_modules/vue-loader/lib/index.js?!./resources/js/components/modal.vue?vue&type=template&id=478d961c&":
  43054. /*!********************************************************************************************************************************************************************************************************!*\
  43055. !*** ./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/vue-loader/lib??vue-loader-options!./resources/js/components/modal.vue?vue&type=template&id=478d961c& ***!
  43056. \********************************************************************************************************************************************************************************************************/
  43057. /*! exports provided: render, staticRenderFns */
  43058. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  43059. "use strict";
  43060. __webpack_require__.r(__webpack_exports__);
  43061. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "render", function() { return render; });
  43062. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "staticRenderFns", function() { return staticRenderFns; });
  43063. var render = function() {
  43064. var _vm = this
  43065. var _h = _vm.$createElement
  43066. var _c = _vm._self._c || _h
  43067. return _c("div", { staticClass: "modal fade" }, [
  43068. _c(
  43069. "div",
  43070. { staticClass: "modal-dialog modal-lg", attrs: { role: "document" } },
  43071. [
  43072. _c("div", { staticClass: "modal-content" }, [
  43073. _c(
  43074. "div",
  43075. { staticClass: "modal-header" },
  43076. [_vm._m(0), _vm._v(" "), _vm._t("header")],
  43077. 2
  43078. ),
  43079. _vm._v(" "),
  43080. _c("div", { staticClass: "modal-body" }, [_vm._t("body")], 2),
  43081. _vm._v(" "),
  43082. _c("div", { staticClass: "modal-footer" }, [_vm._t("footer")], 2)
  43083. ])
  43084. ]
  43085. )
  43086. ])
  43087. }
  43088. var staticRenderFns = [
  43089. function() {
  43090. var _vm = this
  43091. var _h = _vm.$createElement
  43092. var _c = _vm._self._c || _h
  43093. return _c(
  43094. "button",
  43095. {
  43096. staticClass: "close",
  43097. attrs: {
  43098. type: "button",
  43099. "data-dismiss": "modal",
  43100. "aria-label": "Close"
  43101. }
  43102. },
  43103. [_c("span", { attrs: { "aria-hidden": "true" } }, [_vm._v("×")])]
  43104. )
  43105. }
  43106. ]
  43107. render._withStripped = true
  43108. /***/ }),
  43109. /***/ "./node_modules/vue-loader/lib/loaders/templateLoader.js?!./node_modules/vue-loader/lib/index.js?!./resources/js/components/notes.vue?vue&type=template&id=73d141f4&":
  43110. /*!********************************************************************************************************************************************************************************************************!*\
  43111. !*** ./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/vue-loader/lib??vue-loader-options!./resources/js/components/notes.vue?vue&type=template&id=73d141f4& ***!
  43112. \********************************************************************************************************************************************************************************************************/
  43113. /*! exports provided: render, staticRenderFns */
  43114. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  43115. "use strict";
  43116. __webpack_require__.r(__webpack_exports__);
  43117. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "render", function() { return render; });
  43118. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "staticRenderFns", function() { return staticRenderFns; });
  43119. var render = function() {
  43120. var _vm = this
  43121. var _h = _vm.$createElement
  43122. var _c = _vm._self._c || _h
  43123. return _c(
  43124. "ul",
  43125. { staticClass: "list-unstyled" },
  43126. _vm._l(this.notes, function(note) {
  43127. return _c(
  43128. "li",
  43129. { key: note.noteid, staticClass: "row no-gutters mb-2" },
  43130. [
  43131. _c("div", { staticClass: "col-md-1 d-flex flex-column mx-md-3" }, [
  43132. _c("div", { staticClass: "text-center p-0 m-0" }, [
  43133. _vm._v(_vm._s(note.noteuser))
  43134. ]),
  43135. _vm._v(" "),
  43136. _c(
  43137. "div",
  43138. { staticClass: "text-muted text-small text-center p-0 m-0" },
  43139. [_vm._v(_vm._s(_vm.getHRDate(note.notetime)))]
  43140. ),
  43141. _vm._v(" "),
  43142. _c(
  43143. "div",
  43144. { staticClass: "btn-group justify-content-center p-0 m-0" },
  43145. [
  43146. _vm.authusername === note.noteuser ||
  43147. _vm.authusername === "admin"
  43148. ? [
  43149. _vm._m(0, true),
  43150. _vm._v(" "),
  43151. _vm._m(1, true),
  43152. _vm._v(" "),
  43153. _vm._m(2, true)
  43154. ]
  43155. : _vm._e()
  43156. ],
  43157. 2
  43158. )
  43159. ]),
  43160. _vm._v(" "),
  43161. _c("div", { staticClass: "col-md-10" }, [
  43162. _c("div", { staticClass: "card m-2" }, [
  43163. _c("div", { staticClass: "card-body p-2" }, [
  43164. _vm._v(
  43165. "\n " +
  43166. _vm._s(note.thenote) +
  43167. "\n "
  43168. )
  43169. ])
  43170. ])
  43171. ])
  43172. ]
  43173. )
  43174. }),
  43175. 0
  43176. )
  43177. }
  43178. var staticRenderFns = [
  43179. function() {
  43180. var _vm = this
  43181. var _h = _vm.$createElement
  43182. var _c = _vm._self._c || _h
  43183. return _c("button", { staticClass: "btn btn-sm btn-primary m-1" }, [
  43184. _c("i", { staticClass: "fas fa-fw fa-edit" })
  43185. ])
  43186. },
  43187. function() {
  43188. var _vm = this
  43189. var _h = _vm.$createElement
  43190. var _c = _vm._self._c || _h
  43191. return _c("button", { staticClass: "btn btn-sm btn-danger m-1" }, [
  43192. _c("i", { staticClass: "fas fa-fw fa-trash-alt" })
  43193. ])
  43194. },
  43195. function() {
  43196. var _vm = this
  43197. var _h = _vm.$createElement
  43198. var _c = _vm._self._c || _h
  43199. return _c("button", { staticClass: "btn btn-sm btn-primary m-1" }, [
  43200. _c("i", { staticClass: "fa fa-fw fa-random" })
  43201. ])
  43202. }
  43203. ]
  43204. render._withStripped = true
  43205. /***/ }),
  43206. /***/ "./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&":
  43207. /*!*********************************************************************************************************************************************************************************************************!*\
  43208. !*** ./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& ***!
  43209. \*********************************************************************************************************************************************************************************************************/
  43210. /*! exports provided: render, staticRenderFns */
  43211. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  43212. "use strict";
  43213. __webpack_require__.r(__webpack_exports__);
  43214. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "render", function() { return render; });
  43215. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "staticRenderFns", function() { return staticRenderFns; });
  43216. var render = function() {
  43217. var _vm = this
  43218. var _h = _vm.$createElement
  43219. var _c = _vm._self._c || _h
  43220. return _c(
  43221. "div",
  43222. [
  43223. _c(
  43224. "modal",
  43225. {
  43226. attrs: {
  43227. id: "workordereditModal",
  43228. tabindex: "-1",
  43229. role: "dialog",
  43230. "aria-labelledby": "workordereditModalLabel"
  43231. }
  43232. },
  43233. [
  43234. _c(
  43235. "h5",
  43236. {
  43237. staticClass: "modal-title",
  43238. attrs: { slot: "header", id: "workordereditModalLabel" },
  43239. slot: "header"
  43240. },
  43241. [_vm._v("\n Edit Work Order Information\n ")]
  43242. ),
  43243. _vm._v(" "),
  43244. _c("div", { attrs: { slot: "body" }, slot: "body" }, [
  43245. _c("div", { staticClass: "form-group" }, [
  43246. _c("label", { attrs: { for: "probdesc" } }, [
  43247. _vm._v("Problem Description")
  43248. ]),
  43249. _vm._v(" "),
  43250. _c("textarea", {
  43251. directives: [
  43252. {
  43253. name: "model",
  43254. rawName: "v-model",
  43255. value: _vm.data.probdesc,
  43256. expression: "data.probdesc"
  43257. }
  43258. ],
  43259. staticClass: "form-control",
  43260. attrs: { id: "probdesc", name: "probdesc" },
  43261. domProps: { value: _vm.data.probdesc },
  43262. on: {
  43263. input: function($event) {
  43264. if ($event.target.composing) {
  43265. return
  43266. }
  43267. _vm.$set(_vm.data, "probdesc", $event.target.value)
  43268. }
  43269. }
  43270. })
  43271. ]),
  43272. _vm._v(" "),
  43273. _c("div", { staticClass: "form-group" }, [
  43274. _c("label", { attrs: { for: "suggested" } }, [
  43275. _vm._v("Suggested Solution")
  43276. ]),
  43277. _vm._v(" "),
  43278. _c("textarea", {
  43279. directives: [
  43280. {
  43281. name: "model",
  43282. rawName: "v-model",
  43283. value: _vm.data.suggested,
  43284. expression: "data.suggested"
  43285. }
  43286. ],
  43287. staticClass: "form-control",
  43288. attrs: { id: "suggested", name: "suggested" },
  43289. domProps: { value: _vm.data.suggested },
  43290. on: {
  43291. input: function($event) {
  43292. if ($event.target.composing) {
  43293. return
  43294. }
  43295. _vm.$set(_vm.data, "suggested", $event.target.value)
  43296. }
  43297. }
  43298. })
  43299. ])
  43300. ]),
  43301. _vm._v(" "),
  43302. _c("div", { attrs: { slot: "footer" }, slot: "footer" }, [
  43303. _c(
  43304. "button",
  43305. {
  43306. staticClass: "btn btn-secondary",
  43307. attrs: { type: "button", "data-dismiss": "modal" }
  43308. },
  43309. [_vm._v("Close")]
  43310. ),
  43311. _vm._v(" "),
  43312. _c(
  43313. "button",
  43314. {
  43315. staticClass: "btn btn-primary",
  43316. attrs: { type: "button" },
  43317. on: {
  43318. click: function($event) {
  43319. return _vm.updateWorkOrder()
  43320. }
  43321. }
  43322. },
  43323. [_vm._v("Save")]
  43324. )
  43325. ])
  43326. ]
  43327. ),
  43328. _vm._v(" "),
  43329. _c("p", [
  43330. _c("i", { staticClass: "fas fa-fw fa-info-circle" }),
  43331. _vm._v(" "),
  43332. _c("span", { domProps: { textContent: _vm._s(this.data.probdesc) } })
  43333. ]),
  43334. _vm._v(" "),
  43335. _c("p", [
  43336. _c("i", { staticClass: "far fa-fw fa-lightbulb" }),
  43337. _vm._v(" "),
  43338. _c("span", { domProps: { textContent: _vm._s(this.data.suggested) } })
  43339. ]),
  43340. _vm._v(" "),
  43341. _c("p", [
  43342. _c("i", { staticClass: "fas fa-fw fa-paste" }),
  43343. _vm._v(" "),
  43344. _c("span", { domProps: { textContent: _vm._s(this.data.woid) } })
  43345. ]),
  43346. _vm._v(" "),
  43347. _c("p", [
  43348. _c("i", { staticClass: "fas fa-fw fa-building" }),
  43349. _vm._v(" "),
  43350. _c("span", { domProps: { textContent: _vm._s(this.data.storeid) } })
  43351. ]),
  43352. _vm._v(" "),
  43353. _c("p", [
  43354. _c("i", { staticClass: "fas fa-fw fa-sign-in-alt" }),
  43355. _vm._v(" "),
  43356. _c(
  43357. "span",
  43358. {
  43359. staticClass: "dashed-underline",
  43360. attrs: {
  43361. "data-toggle": "tooltip",
  43362. "data-placement": "bottom",
  43363. title: this.getHRDate(this.data.dropdate)
  43364. }
  43365. },
  43366. [
  43367. _vm._v(
  43368. "\n " +
  43369. _vm._s(Math.floor(this.daysSinceToday(this.data.dropdate))) +
  43370. " days ago\n "
  43371. )
  43372. ]
  43373. )
  43374. ]),
  43375. _vm._v(" "),
  43376. _c("p", [
  43377. _c("i", { staticClass: "fas fa-sign-out-alt" }),
  43378. _vm._v(" "),
  43379. !this.isZero(this.data.pickupdate)
  43380. ? _c(
  43381. "span",
  43382. {
  43383. staticClass: "dashed-underline",
  43384. attrs: {
  43385. "data-toggle": "tooltip",
  43386. "data-placement": "bottom",
  43387. title: this.getHRDate(this.data.pickupdate)
  43388. }
  43389. },
  43390. [
  43391. _vm._v(
  43392. "\n " +
  43393. _vm._s(
  43394. Math.floor(this.daysSinceToday(this.data.pickupdate))
  43395. ) +
  43396. " days ago\n "
  43397. )
  43398. ]
  43399. )
  43400. : _vm._e()
  43401. ]),
  43402. _vm._v(" "),
  43403. _c(
  43404. "button",
  43405. {
  43406. staticClass: "btn btn-primary",
  43407. attrs: {
  43408. type: "button",
  43409. "data-toggle": "modal",
  43410. "data-target": "#workordereditModal"
  43411. }
  43412. },
  43413. [_vm._v("Edit")]
  43414. )
  43415. ],
  43416. 1
  43417. )
  43418. }
  43419. var staticRenderFns = []
  43420. render._withStripped = true
  43421. /***/ }),
  43422. /***/ "./node_modules/vue-loader/lib/runtime/componentNormalizer.js":
  43423. /*!********************************************************************!*\
  43424. !*** ./node_modules/vue-loader/lib/runtime/componentNormalizer.js ***!
  43425. \********************************************************************/
  43426. /*! exports provided: default */
  43427. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  43428. "use strict";
  43429. __webpack_require__.r(__webpack_exports__);
  43430. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return normalizeComponent; });
  43431. /* globals __VUE_SSR_CONTEXT__ */
  43432. // IMPORTANT: Do NOT use ES2015 features in this file (except for modules).
  43433. // This module is a runtime utility for cleaner component module output and will
  43434. // be included in the final webpack user bundle.
  43435. function normalizeComponent (
  43436. scriptExports,
  43437. render,
  43438. staticRenderFns,
  43439. functionalTemplate,
  43440. injectStyles,
  43441. scopeId,
  43442. moduleIdentifier, /* server only */
  43443. shadowMode /* vue-cli only */
  43444. ) {
  43445. // Vue.extend constructor export interop
  43446. var options = typeof scriptExports === 'function'
  43447. ? scriptExports.options
  43448. : scriptExports
  43449. // render functions
  43450. if (render) {
  43451. options.render = render
  43452. options.staticRenderFns = staticRenderFns
  43453. options._compiled = true
  43454. }
  43455. // functional template
  43456. if (functionalTemplate) {
  43457. options.functional = true
  43458. }
  43459. // scopedId
  43460. if (scopeId) {
  43461. options._scopeId = 'data-v-' + scopeId
  43462. }
  43463. var hook
  43464. if (moduleIdentifier) { // server build
  43465. hook = function (context) {
  43466. // 2.3 injection
  43467. context =
  43468. context || // cached call
  43469. (this.$vnode && this.$vnode.ssrContext) || // stateful
  43470. (this.parent && this.parent.$vnode && this.parent.$vnode.ssrContext) // functional
  43471. // 2.2 with runInNewContext: true
  43472. if (!context && typeof __VUE_SSR_CONTEXT__ !== 'undefined') {
  43473. context = __VUE_SSR_CONTEXT__
  43474. }
  43475. // inject component styles
  43476. if (injectStyles) {
  43477. injectStyles.call(this, context)
  43478. }
  43479. // register component module identifier for async chunk inferrence
  43480. if (context && context._registeredComponents) {
  43481. context._registeredComponents.add(moduleIdentifier)
  43482. }
  43483. }
  43484. // used by ssr in case component is cached and beforeCreate
  43485. // never gets called
  43486. options._ssrRegister = hook
  43487. } else if (injectStyles) {
  43488. hook = shadowMode
  43489. ? function () { injectStyles.call(this, this.$root.$options.shadowRoot) }
  43490. : injectStyles
  43491. }
  43492. if (hook) {
  43493. if (options.functional) {
  43494. // for template-only hot-reload because in that case the render fn doesn't
  43495. // go through the normalizer
  43496. options._injectStyles = hook
  43497. // register for functioal component in vue file
  43498. var originalRender = options.render
  43499. options.render = function renderWithStyleInjection (h, context) {
  43500. hook.call(context)
  43501. return originalRender(h, context)
  43502. }
  43503. } else {
  43504. // inject component registration as beforeCreate hook
  43505. var existing = options.beforeCreate
  43506. options.beforeCreate = existing
  43507. ? [].concat(existing, hook)
  43508. : [hook]
  43509. }
  43510. }
  43511. return {
  43512. exports: scriptExports,
  43513. options: options
  43514. }
  43515. }
  43516. /***/ }),
  43517. /***/ "./node_modules/vue/dist/vue.common.dev.js":
  43518. /*!*************************************************!*\
  43519. !*** ./node_modules/vue/dist/vue.common.dev.js ***!
  43520. \*************************************************/
  43521. /*! no static exports found */
  43522. /***/ (function(module, exports, __webpack_require__) {
  43523. "use strict";
  43524. /* WEBPACK VAR INJECTION */(function(global, setImmediate) {/*!
  43525. * Vue.js v2.6.11
  43526. * (c) 2014-2019 Evan You
  43527. * Released under the MIT License.
  43528. */
  43529. /* */
  43530. var emptyObject = Object.freeze({});
  43531. // These helpers produce better VM code in JS engines due to their
  43532. // explicitness and function inlining.
  43533. function isUndef (v) {
  43534. return v === undefined || v === null
  43535. }
  43536. function isDef (v) {
  43537. return v !== undefined && v !== null
  43538. }
  43539. function isTrue (v) {
  43540. return v === true
  43541. }
  43542. function isFalse (v) {
  43543. return v === false
  43544. }
  43545. /**
  43546. * Check if value is primitive.
  43547. */
  43548. function isPrimitive (value) {
  43549. return (
  43550. typeof value === 'string' ||
  43551. typeof value === 'number' ||
  43552. // $flow-disable-line
  43553. typeof value === 'symbol' ||
  43554. typeof value === 'boolean'
  43555. )
  43556. }
  43557. /**
  43558. * Quick object check - this is primarily used to tell
  43559. * Objects from primitive values when we know the value
  43560. * is a JSON-compliant type.
  43561. */
  43562. function isObject (obj) {
  43563. return obj !== null && typeof obj === 'object'
  43564. }
  43565. /**
  43566. * Get the raw type string of a value, e.g., [object Object].
  43567. */
  43568. var _toString = Object.prototype.toString;
  43569. function toRawType (value) {
  43570. return _toString.call(value).slice(8, -1)
  43571. }
  43572. /**
  43573. * Strict object type check. Only returns true
  43574. * for plain JavaScript objects.
  43575. */
  43576. function isPlainObject (obj) {
  43577. return _toString.call(obj) === '[object Object]'
  43578. }
  43579. function isRegExp (v) {
  43580. return _toString.call(v) === '[object RegExp]'
  43581. }
  43582. /**
  43583. * Check if val is a valid array index.
  43584. */
  43585. function isValidArrayIndex (val) {
  43586. var n = parseFloat(String(val));
  43587. return n >= 0 && Math.floor(n) === n && isFinite(val)
  43588. }
  43589. function isPromise (val) {
  43590. return (
  43591. isDef(val) &&
  43592. typeof val.then === 'function' &&
  43593. typeof val.catch === 'function'
  43594. )
  43595. }
  43596. /**
  43597. * Convert a value to a string that is actually rendered.
  43598. */
  43599. function toString (val) {
  43600. return val == null
  43601. ? ''
  43602. : Array.isArray(val) || (isPlainObject(val) && val.toString === _toString)
  43603. ? JSON.stringify(val, null, 2)
  43604. : String(val)
  43605. }
  43606. /**
  43607. * Convert an input value to a number for persistence.
  43608. * If the conversion fails, return original string.
  43609. */
  43610. function toNumber (val) {
  43611. var n = parseFloat(val);
  43612. return isNaN(n) ? val : n
  43613. }
  43614. /**
  43615. * Make a map and return a function for checking if a key
  43616. * is in that map.
  43617. */
  43618. function makeMap (
  43619. str,
  43620. expectsLowerCase
  43621. ) {
  43622. var map = Object.create(null);
  43623. var list = str.split(',');
  43624. for (var i = 0; i < list.length; i++) {
  43625. map[list[i]] = true;
  43626. }
  43627. return expectsLowerCase
  43628. ? function (val) { return map[val.toLowerCase()]; }
  43629. : function (val) { return map[val]; }
  43630. }
  43631. /**
  43632. * Check if a tag is a built-in tag.
  43633. */
  43634. var isBuiltInTag = makeMap('slot,component', true);
  43635. /**
  43636. * Check if an attribute is a reserved attribute.
  43637. */
  43638. var isReservedAttribute = makeMap('key,ref,slot,slot-scope,is');
  43639. /**
  43640. * Remove an item from an array.
  43641. */
  43642. function remove (arr, item) {
  43643. if (arr.length) {
  43644. var index = arr.indexOf(item);
  43645. if (index > -1) {
  43646. return arr.splice(index, 1)
  43647. }
  43648. }
  43649. }
  43650. /**
  43651. * Check whether an object has the property.
  43652. */
  43653. var hasOwnProperty = Object.prototype.hasOwnProperty;
  43654. function hasOwn (obj, key) {
  43655. return hasOwnProperty.call(obj, key)
  43656. }
  43657. /**
  43658. * Create a cached version of a pure function.
  43659. */
  43660. function cached (fn) {
  43661. var cache = Object.create(null);
  43662. return (function cachedFn (str) {
  43663. var hit = cache[str];
  43664. return hit || (cache[str] = fn(str))
  43665. })
  43666. }
  43667. /**
  43668. * Camelize a hyphen-delimited string.
  43669. */
  43670. var camelizeRE = /-(\w)/g;
  43671. var camelize = cached(function (str) {
  43672. return str.replace(camelizeRE, function (_, c) { return c ? c.toUpperCase() : ''; })
  43673. });
  43674. /**
  43675. * Capitalize a string.
  43676. */
  43677. var capitalize = cached(function (str) {
  43678. return str.charAt(0).toUpperCase() + str.slice(1)
  43679. });
  43680. /**
  43681. * Hyphenate a camelCase string.
  43682. */
  43683. var hyphenateRE = /\B([A-Z])/g;
  43684. var hyphenate = cached(function (str) {
  43685. return str.replace(hyphenateRE, '-$1').toLowerCase()
  43686. });
  43687. /**
  43688. * Simple bind polyfill for environments that do not support it,
  43689. * e.g., PhantomJS 1.x. Technically, we don't need this anymore
  43690. * since native bind is now performant enough in most browsers.
  43691. * But removing it would mean breaking code that was able to run in
  43692. * PhantomJS 1.x, so this must be kept for backward compatibility.
  43693. */
  43694. /* istanbul ignore next */
  43695. function polyfillBind (fn, ctx) {
  43696. function boundFn (a) {
  43697. var l = arguments.length;
  43698. return l
  43699. ? l > 1
  43700. ? fn.apply(ctx, arguments)
  43701. : fn.call(ctx, a)
  43702. : fn.call(ctx)
  43703. }
  43704. boundFn._length = fn.length;
  43705. return boundFn
  43706. }
  43707. function nativeBind (fn, ctx) {
  43708. return fn.bind(ctx)
  43709. }
  43710. var bind = Function.prototype.bind
  43711. ? nativeBind
  43712. : polyfillBind;
  43713. /**
  43714. * Convert an Array-like object to a real Array.
  43715. */
  43716. function toArray (list, start) {
  43717. start = start || 0;
  43718. var i = list.length - start;
  43719. var ret = new Array(i);
  43720. while (i--) {
  43721. ret[i] = list[i + start];
  43722. }
  43723. return ret
  43724. }
  43725. /**
  43726. * Mix properties into target object.
  43727. */
  43728. function extend (to, _from) {
  43729. for (var key in _from) {
  43730. to[key] = _from[key];
  43731. }
  43732. return to
  43733. }
  43734. /**
  43735. * Merge an Array of Objects into a single Object.
  43736. */
  43737. function toObject (arr) {
  43738. var res = {};
  43739. for (var i = 0; i < arr.length; i++) {
  43740. if (arr[i]) {
  43741. extend(res, arr[i]);
  43742. }
  43743. }
  43744. return res
  43745. }
  43746. /* eslint-disable no-unused-vars */
  43747. /**
  43748. * Perform no operation.
  43749. * Stubbing args to make Flow happy without leaving useless transpiled code
  43750. * with ...rest (https://flow.org/blog/2017/05/07/Strict-Function-Call-Arity/).
  43751. */
  43752. function noop (a, b, c) {}
  43753. /**
  43754. * Always return false.
  43755. */
  43756. var no = function (a, b, c) { return false; };
  43757. /* eslint-enable no-unused-vars */
  43758. /**
  43759. * Return the same value.
  43760. */
  43761. var identity = function (_) { return _; };
  43762. /**
  43763. * Generate a string containing static keys from compiler modules.
  43764. */
  43765. function genStaticKeys (modules) {
  43766. return modules.reduce(function (keys, m) {
  43767. return keys.concat(m.staticKeys || [])
  43768. }, []).join(',')
  43769. }
  43770. /**
  43771. * Check if two values are loosely equal - that is,
  43772. * if they are plain objects, do they have the same shape?
  43773. */
  43774. function looseEqual (a, b) {
  43775. if (a === b) { return true }
  43776. var isObjectA = isObject(a);
  43777. var isObjectB = isObject(b);
  43778. if (isObjectA && isObjectB) {
  43779. try {
  43780. var isArrayA = Array.isArray(a);
  43781. var isArrayB = Array.isArray(b);
  43782. if (isArrayA && isArrayB) {
  43783. return a.length === b.length && a.every(function (e, i) {
  43784. return looseEqual(e, b[i])
  43785. })
  43786. } else if (a instanceof Date && b instanceof Date) {
  43787. return a.getTime() === b.getTime()
  43788. } else if (!isArrayA && !isArrayB) {
  43789. var keysA = Object.keys(a);
  43790. var keysB = Object.keys(b);
  43791. return keysA.length === keysB.length && keysA.every(function (key) {
  43792. return looseEqual(a[key], b[key])
  43793. })
  43794. } else {
  43795. /* istanbul ignore next */
  43796. return false
  43797. }
  43798. } catch (e) {
  43799. /* istanbul ignore next */
  43800. return false
  43801. }
  43802. } else if (!isObjectA && !isObjectB) {
  43803. return String(a) === String(b)
  43804. } else {
  43805. return false
  43806. }
  43807. }
  43808. /**
  43809. * Return the first index at which a loosely equal value can be
  43810. * found in the array (if value is a plain object, the array must
  43811. * contain an object of the same shape), or -1 if it is not present.
  43812. */
  43813. function looseIndexOf (arr, val) {
  43814. for (var i = 0; i < arr.length; i++) {
  43815. if (looseEqual(arr[i], val)) { return i }
  43816. }
  43817. return -1
  43818. }
  43819. /**
  43820. * Ensure a function is called only once.
  43821. */
  43822. function once (fn) {
  43823. var called = false;
  43824. return function () {
  43825. if (!called) {
  43826. called = true;
  43827. fn.apply(this, arguments);
  43828. }
  43829. }
  43830. }
  43831. var SSR_ATTR = 'data-server-rendered';
  43832. var ASSET_TYPES = [
  43833. 'component',
  43834. 'directive',
  43835. 'filter'
  43836. ];
  43837. var LIFECYCLE_HOOKS = [
  43838. 'beforeCreate',
  43839. 'created',
  43840. 'beforeMount',
  43841. 'mounted',
  43842. 'beforeUpdate',
  43843. 'updated',
  43844. 'beforeDestroy',
  43845. 'destroyed',
  43846. 'activated',
  43847. 'deactivated',
  43848. 'errorCaptured',
  43849. 'serverPrefetch'
  43850. ];
  43851. /* */
  43852. var config = ({
  43853. /**
  43854. * Option merge strategies (used in core/util/options)
  43855. */
  43856. // $flow-disable-line
  43857. optionMergeStrategies: Object.create(null),
  43858. /**
  43859. * Whether to suppress warnings.
  43860. */
  43861. silent: false,
  43862. /**
  43863. * Show production mode tip message on boot?
  43864. */
  43865. productionTip: "development" !== 'production',
  43866. /**
  43867. * Whether to enable devtools
  43868. */
  43869. devtools: "development" !== 'production',
  43870. /**
  43871. * Whether to record perf
  43872. */
  43873. performance: false,
  43874. /**
  43875. * Error handler for watcher errors
  43876. */
  43877. errorHandler: null,
  43878. /**
  43879. * Warn handler for watcher warns
  43880. */
  43881. warnHandler: null,
  43882. /**
  43883. * Ignore certain custom elements
  43884. */
  43885. ignoredElements: [],
  43886. /**
  43887. * Custom user key aliases for v-on
  43888. */
  43889. // $flow-disable-line
  43890. keyCodes: Object.create(null),
  43891. /**
  43892. * Check if a tag is reserved so that it cannot be registered as a
  43893. * component. This is platform-dependent and may be overwritten.
  43894. */
  43895. isReservedTag: no,
  43896. /**
  43897. * Check if an attribute is reserved so that it cannot be used as a component
  43898. * prop. This is platform-dependent and may be overwritten.
  43899. */
  43900. isReservedAttr: no,
  43901. /**
  43902. * Check if a tag is an unknown element.
  43903. * Platform-dependent.
  43904. */
  43905. isUnknownElement: no,
  43906. /**
  43907. * Get the namespace of an element
  43908. */
  43909. getTagNamespace: noop,
  43910. /**
  43911. * Parse the real tag name for the specific platform.
  43912. */
  43913. parsePlatformTagName: identity,
  43914. /**
  43915. * Check if an attribute must be bound using property, e.g. value
  43916. * Platform-dependent.
  43917. */
  43918. mustUseProp: no,
  43919. /**
  43920. * Perform updates asynchronously. Intended to be used by Vue Test Utils
  43921. * This will significantly reduce performance if set to false.
  43922. */
  43923. async: true,
  43924. /**
  43925. * Exposed for legacy reasons
  43926. */
  43927. _lifecycleHooks: LIFECYCLE_HOOKS
  43928. });
  43929. /* */
  43930. /**
  43931. * unicode letters used for parsing html tags, component names and property paths.
  43932. * using https://www.w3.org/TR/html53/semantics-scripting.html#potentialcustomelementname
  43933. * skipping \u10000-\uEFFFF due to it freezing up PhantomJS
  43934. */
  43935. 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/;
  43936. /**
  43937. * Check if a string starts with $ or _
  43938. */
  43939. function isReserved (str) {
  43940. var c = (str + '').charCodeAt(0);
  43941. return c === 0x24 || c === 0x5F
  43942. }
  43943. /**
  43944. * Define a property.
  43945. */
  43946. function def (obj, key, val, enumerable) {
  43947. Object.defineProperty(obj, key, {
  43948. value: val,
  43949. enumerable: !!enumerable,
  43950. writable: true,
  43951. configurable: true
  43952. });
  43953. }
  43954. /**
  43955. * Parse simple path.
  43956. */
  43957. var bailRE = new RegExp(("[^" + (unicodeRegExp.source) + ".$_\\d]"));
  43958. function parsePath (path) {
  43959. if (bailRE.test(path)) {
  43960. return
  43961. }
  43962. var segments = path.split('.');
  43963. return function (obj) {
  43964. for (var i = 0; i < segments.length; i++) {
  43965. if (!obj) { return }
  43966. obj = obj[segments[i]];
  43967. }
  43968. return obj
  43969. }
  43970. }
  43971. /* */
  43972. // can we use __proto__?
  43973. var hasProto = '__proto__' in {};
  43974. // Browser environment sniffing
  43975. var inBrowser = typeof window !== 'undefined';
  43976. var inWeex = typeof WXEnvironment !== 'undefined' && !!WXEnvironment.platform;
  43977. var weexPlatform = inWeex && WXEnvironment.platform.toLowerCase();
  43978. var UA = inBrowser && window.navigator.userAgent.toLowerCase();
  43979. var isIE = UA && /msie|trident/.test(UA);
  43980. var isIE9 = UA && UA.indexOf('msie 9.0') > 0;
  43981. var isEdge = UA && UA.indexOf('edge/') > 0;
  43982. var isAndroid = (UA && UA.indexOf('android') > 0) || (weexPlatform === 'android');
  43983. var isIOS = (UA && /iphone|ipad|ipod|ios/.test(UA)) || (weexPlatform === 'ios');
  43984. var isChrome = UA && /chrome\/\d+/.test(UA) && !isEdge;
  43985. var isPhantomJS = UA && /phantomjs/.test(UA);
  43986. var isFF = UA && UA.match(/firefox\/(\d+)/);
  43987. // Firefox has a "watch" function on Object.prototype...
  43988. var nativeWatch = ({}).watch;
  43989. var supportsPassive = false;
  43990. if (inBrowser) {
  43991. try {
  43992. var opts = {};
  43993. Object.defineProperty(opts, 'passive', ({
  43994. get: function get () {
  43995. /* istanbul ignore next */
  43996. supportsPassive = true;
  43997. }
  43998. })); // https://github.com/facebook/flow/issues/285
  43999. window.addEventListener('test-passive', null, opts);
  44000. } catch (e) {}
  44001. }
  44002. // this needs to be lazy-evaled because vue may be required before
  44003. // vue-server-renderer can set VUE_ENV
  44004. var _isServer;
  44005. var isServerRendering = function () {
  44006. if (_isServer === undefined) {
  44007. /* istanbul ignore if */
  44008. if (!inBrowser && !inWeex && typeof global !== 'undefined') {
  44009. // detect presence of vue-server-renderer and avoid
  44010. // Webpack shimming the process
  44011. _isServer = global['process'] && global['process'].env.VUE_ENV === 'server';
  44012. } else {
  44013. _isServer = false;
  44014. }
  44015. }
  44016. return _isServer
  44017. };
  44018. // detect devtools
  44019. var devtools = inBrowser && window.__VUE_DEVTOOLS_GLOBAL_HOOK__;
  44020. /* istanbul ignore next */
  44021. function isNative (Ctor) {
  44022. return typeof Ctor === 'function' && /native code/.test(Ctor.toString())
  44023. }
  44024. var hasSymbol =
  44025. typeof Symbol !== 'undefined' && isNative(Symbol) &&
  44026. typeof Reflect !== 'undefined' && isNative(Reflect.ownKeys);
  44027. var _Set;
  44028. /* istanbul ignore if */ // $flow-disable-line
  44029. if (typeof Set !== 'undefined' && isNative(Set)) {
  44030. // use native Set when available.
  44031. _Set = Set;
  44032. } else {
  44033. // a non-standard Set polyfill that only works with primitive keys.
  44034. _Set = /*@__PURE__*/(function () {
  44035. function Set () {
  44036. this.set = Object.create(null);
  44037. }
  44038. Set.prototype.has = function has (key) {
  44039. return this.set[key] === true
  44040. };
  44041. Set.prototype.add = function add (key) {
  44042. this.set[key] = true;
  44043. };
  44044. Set.prototype.clear = function clear () {
  44045. this.set = Object.create(null);
  44046. };
  44047. return Set;
  44048. }());
  44049. }
  44050. /* */
  44051. var warn = noop;
  44052. var tip = noop;
  44053. var generateComponentTrace = (noop); // work around flow check
  44054. var formatComponentName = (noop);
  44055. {
  44056. var hasConsole = typeof console !== 'undefined';
  44057. var classifyRE = /(?:^|[-_])(\w)/g;
  44058. var classify = function (str) { return str
  44059. .replace(classifyRE, function (c) { return c.toUpperCase(); })
  44060. .replace(/[-_]/g, ''); };
  44061. warn = function (msg, vm) {
  44062. var trace = vm ? generateComponentTrace(vm) : '';
  44063. if (config.warnHandler) {
  44064. config.warnHandler.call(null, msg, vm, trace);
  44065. } else if (hasConsole && (!config.silent)) {
  44066. console.error(("[Vue warn]: " + msg + trace));
  44067. }
  44068. };
  44069. tip = function (msg, vm) {
  44070. if (hasConsole && (!config.silent)) {
  44071. console.warn("[Vue tip]: " + msg + (
  44072. vm ? generateComponentTrace(vm) : ''
  44073. ));
  44074. }
  44075. };
  44076. formatComponentName = function (vm, includeFile) {
  44077. if (vm.$root === vm) {
  44078. return '<Root>'
  44079. }
  44080. var options = typeof vm === 'function' && vm.cid != null
  44081. ? vm.options
  44082. : vm._isVue
  44083. ? vm.$options || vm.constructor.options
  44084. : vm;
  44085. var name = options.name || options._componentTag;
  44086. var file = options.__file;
  44087. if (!name && file) {
  44088. var match = file.match(/([^/\\]+)\.vue$/);
  44089. name = match && match[1];
  44090. }
  44091. return (
  44092. (name ? ("<" + (classify(name)) + ">") : "<Anonymous>") +
  44093. (file && includeFile !== false ? (" at " + file) : '')
  44094. )
  44095. };
  44096. var repeat = function (str, n) {
  44097. var res = '';
  44098. while (n) {
  44099. if (n % 2 === 1) { res += str; }
  44100. if (n > 1) { str += str; }
  44101. n >>= 1;
  44102. }
  44103. return res
  44104. };
  44105. generateComponentTrace = function (vm) {
  44106. if (vm._isVue && vm.$parent) {
  44107. var tree = [];
  44108. var currentRecursiveSequence = 0;
  44109. while (vm) {
  44110. if (tree.length > 0) {
  44111. var last = tree[tree.length - 1];
  44112. if (last.constructor === vm.constructor) {
  44113. currentRecursiveSequence++;
  44114. vm = vm.$parent;
  44115. continue
  44116. } else if (currentRecursiveSequence > 0) {
  44117. tree[tree.length - 1] = [last, currentRecursiveSequence];
  44118. currentRecursiveSequence = 0;
  44119. }
  44120. }
  44121. tree.push(vm);
  44122. vm = vm.$parent;
  44123. }
  44124. return '\n\nfound in\n\n' + tree
  44125. .map(function (vm, i) { return ("" + (i === 0 ? '---> ' : repeat(' ', 5 + i * 2)) + (Array.isArray(vm)
  44126. ? ((formatComponentName(vm[0])) + "... (" + (vm[1]) + " recursive calls)")
  44127. : formatComponentName(vm))); })
  44128. .join('\n')
  44129. } else {
  44130. return ("\n\n(found in " + (formatComponentName(vm)) + ")")
  44131. }
  44132. };
  44133. }
  44134. /* */
  44135. var uid = 0;
  44136. /**
  44137. * A dep is an observable that can have multiple
  44138. * directives subscribing to it.
  44139. */
  44140. var Dep = function Dep () {
  44141. this.id = uid++;
  44142. this.subs = [];
  44143. };
  44144. Dep.prototype.addSub = function addSub (sub) {
  44145. this.subs.push(sub);
  44146. };
  44147. Dep.prototype.removeSub = function removeSub (sub) {
  44148. remove(this.subs, sub);
  44149. };
  44150. Dep.prototype.depend = function depend () {
  44151. if (Dep.target) {
  44152. Dep.target.addDep(this);
  44153. }
  44154. };
  44155. Dep.prototype.notify = function notify () {
  44156. // stabilize the subscriber list first
  44157. var subs = this.subs.slice();
  44158. if (!config.async) {
  44159. // subs aren't sorted in scheduler if not running async
  44160. // we need to sort them now to make sure they fire in correct
  44161. // order
  44162. subs.sort(function (a, b) { return a.id - b.id; });
  44163. }
  44164. for (var i = 0, l = subs.length; i < l; i++) {
  44165. subs[i].update();
  44166. }
  44167. };
  44168. // The current target watcher being evaluated.
  44169. // This is globally unique because only one watcher
  44170. // can be evaluated at a time.
  44171. Dep.target = null;
  44172. var targetStack = [];
  44173. function pushTarget (target) {
  44174. targetStack.push(target);
  44175. Dep.target = target;
  44176. }
  44177. function popTarget () {
  44178. targetStack.pop();
  44179. Dep.target = targetStack[targetStack.length - 1];
  44180. }
  44181. /* */
  44182. var VNode = function VNode (
  44183. tag,
  44184. data,
  44185. children,
  44186. text,
  44187. elm,
  44188. context,
  44189. componentOptions,
  44190. asyncFactory
  44191. ) {
  44192. this.tag = tag;
  44193. this.data = data;
  44194. this.children = children;
  44195. this.text = text;
  44196. this.elm = elm;
  44197. this.ns = undefined;
  44198. this.context = context;
  44199. this.fnContext = undefined;
  44200. this.fnOptions = undefined;
  44201. this.fnScopeId = undefined;
  44202. this.key = data && data.key;
  44203. this.componentOptions = componentOptions;
  44204. this.componentInstance = undefined;
  44205. this.parent = undefined;
  44206. this.raw = false;
  44207. this.isStatic = false;
  44208. this.isRootInsert = true;
  44209. this.isComment = false;
  44210. this.isCloned = false;
  44211. this.isOnce = false;
  44212. this.asyncFactory = asyncFactory;
  44213. this.asyncMeta = undefined;
  44214. this.isAsyncPlaceholder = false;
  44215. };
  44216. var prototypeAccessors = { child: { configurable: true } };
  44217. // DEPRECATED: alias for componentInstance for backwards compat.
  44218. /* istanbul ignore next */
  44219. prototypeAccessors.child.get = function () {
  44220. return this.componentInstance
  44221. };
  44222. Object.defineProperties( VNode.prototype, prototypeAccessors );
  44223. var createEmptyVNode = function (text) {
  44224. if ( text === void 0 ) text = '';
  44225. var node = new VNode();
  44226. node.text = text;
  44227. node.isComment = true;
  44228. return node
  44229. };
  44230. function createTextVNode (val) {
  44231. return new VNode(undefined, undefined, undefined, String(val))
  44232. }
  44233. // optimized shallow clone
  44234. // used for static nodes and slot nodes because they may be reused across
  44235. // multiple renders, cloning them avoids errors when DOM manipulations rely
  44236. // on their elm reference.
  44237. function cloneVNode (vnode) {
  44238. var cloned = new VNode(
  44239. vnode.tag,
  44240. vnode.data,
  44241. // #7975
  44242. // clone children array to avoid mutating original in case of cloning
  44243. // a child.
  44244. vnode.children && vnode.children.slice(),
  44245. vnode.text,
  44246. vnode.elm,
  44247. vnode.context,
  44248. vnode.componentOptions,
  44249. vnode.asyncFactory
  44250. );
  44251. cloned.ns = vnode.ns;
  44252. cloned.isStatic = vnode.isStatic;
  44253. cloned.key = vnode.key;
  44254. cloned.isComment = vnode.isComment;
  44255. cloned.fnContext = vnode.fnContext;
  44256. cloned.fnOptions = vnode.fnOptions;
  44257. cloned.fnScopeId = vnode.fnScopeId;
  44258. cloned.asyncMeta = vnode.asyncMeta;
  44259. cloned.isCloned = true;
  44260. return cloned
  44261. }
  44262. /*
  44263. * not type checking this file because flow doesn't play well with
  44264. * dynamically accessing methods on Array prototype
  44265. */
  44266. var arrayProto = Array.prototype;
  44267. var arrayMethods = Object.create(arrayProto);
  44268. var methodsToPatch = [
  44269. 'push',
  44270. 'pop',
  44271. 'shift',
  44272. 'unshift',
  44273. 'splice',
  44274. 'sort',
  44275. 'reverse'
  44276. ];
  44277. /**
  44278. * Intercept mutating methods and emit events
  44279. */
  44280. methodsToPatch.forEach(function (method) {
  44281. // cache original method
  44282. var original = arrayProto[method];
  44283. def(arrayMethods, method, function mutator () {
  44284. var args = [], len = arguments.length;
  44285. while ( len-- ) args[ len ] = arguments[ len ];
  44286. var result = original.apply(this, args);
  44287. var ob = this.__ob__;
  44288. var inserted;
  44289. switch (method) {
  44290. case 'push':
  44291. case 'unshift':
  44292. inserted = args;
  44293. break
  44294. case 'splice':
  44295. inserted = args.slice(2);
  44296. break
  44297. }
  44298. if (inserted) { ob.observeArray(inserted); }
  44299. // notify change
  44300. ob.dep.notify();
  44301. return result
  44302. });
  44303. });
  44304. /* */
  44305. var arrayKeys = Object.getOwnPropertyNames(arrayMethods);
  44306. /**
  44307. * In some cases we may want to disable observation inside a component's
  44308. * update computation.
  44309. */
  44310. var shouldObserve = true;
  44311. function toggleObserving (value) {
  44312. shouldObserve = value;
  44313. }
  44314. /**
  44315. * Observer class that is attached to each observed
  44316. * object. Once attached, the observer converts the target
  44317. * object's property keys into getter/setters that
  44318. * collect dependencies and dispatch updates.
  44319. */
  44320. var Observer = function Observer (value) {
  44321. this.value = value;
  44322. this.dep = new Dep();
  44323. this.vmCount = 0;
  44324. def(value, '__ob__', this);
  44325. if (Array.isArray(value)) {
  44326. if (hasProto) {
  44327. protoAugment(value, arrayMethods);
  44328. } else {
  44329. copyAugment(value, arrayMethods, arrayKeys);
  44330. }
  44331. this.observeArray(value);
  44332. } else {
  44333. this.walk(value);
  44334. }
  44335. };
  44336. /**
  44337. * Walk through all properties and convert them into
  44338. * getter/setters. This method should only be called when
  44339. * value type is Object.
  44340. */
  44341. Observer.prototype.walk = function walk (obj) {
  44342. var keys = Object.keys(obj);
  44343. for (var i = 0; i < keys.length; i++) {
  44344. defineReactive$$1(obj, keys[i]);
  44345. }
  44346. };
  44347. /**
  44348. * Observe a list of Array items.
  44349. */
  44350. Observer.prototype.observeArray = function observeArray (items) {
  44351. for (var i = 0, l = items.length; i < l; i++) {
  44352. observe(items[i]);
  44353. }
  44354. };
  44355. // helpers
  44356. /**
  44357. * Augment a target Object or Array by intercepting
  44358. * the prototype chain using __proto__
  44359. */
  44360. function protoAugment (target, src) {
  44361. /* eslint-disable no-proto */
  44362. target.__proto__ = src;
  44363. /* eslint-enable no-proto */
  44364. }
  44365. /**
  44366. * Augment a target Object or Array by defining
  44367. * hidden properties.
  44368. */
  44369. /* istanbul ignore next */
  44370. function copyAugment (target, src, keys) {
  44371. for (var i = 0, l = keys.length; i < l; i++) {
  44372. var key = keys[i];
  44373. def(target, key, src[key]);
  44374. }
  44375. }
  44376. /**
  44377. * Attempt to create an observer instance for a value,
  44378. * returns the new observer if successfully observed,
  44379. * or the existing observer if the value already has one.
  44380. */
  44381. function observe (value, asRootData) {
  44382. if (!isObject(value) || value instanceof VNode) {
  44383. return
  44384. }
  44385. var ob;
  44386. if (hasOwn(value, '__ob__') && value.__ob__ instanceof Observer) {
  44387. ob = value.__ob__;
  44388. } else if (
  44389. shouldObserve &&
  44390. !isServerRendering() &&
  44391. (Array.isArray(value) || isPlainObject(value)) &&
  44392. Object.isExtensible(value) &&
  44393. !value._isVue
  44394. ) {
  44395. ob = new Observer(value);
  44396. }
  44397. if (asRootData && ob) {
  44398. ob.vmCount++;
  44399. }
  44400. return ob
  44401. }
  44402. /**
  44403. * Define a reactive property on an Object.
  44404. */
  44405. function defineReactive$$1 (
  44406. obj,
  44407. key,
  44408. val,
  44409. customSetter,
  44410. shallow
  44411. ) {
  44412. var dep = new Dep();
  44413. var property = Object.getOwnPropertyDescriptor(obj, key);
  44414. if (property && property.configurable === false) {
  44415. return
  44416. }
  44417. // cater for pre-defined getter/setters
  44418. var getter = property && property.get;
  44419. var setter = property && property.set;
  44420. if ((!getter || setter) && arguments.length === 2) {
  44421. val = obj[key];
  44422. }
  44423. var childOb = !shallow && observe(val);
  44424. Object.defineProperty(obj, key, {
  44425. enumerable: true,
  44426. configurable: true,
  44427. get: function reactiveGetter () {
  44428. var value = getter ? getter.call(obj) : val;
  44429. if (Dep.target) {
  44430. dep.depend();
  44431. if (childOb) {
  44432. childOb.dep.depend();
  44433. if (Array.isArray(value)) {
  44434. dependArray(value);
  44435. }
  44436. }
  44437. }
  44438. return value
  44439. },
  44440. set: function reactiveSetter (newVal) {
  44441. var value = getter ? getter.call(obj) : val;
  44442. /* eslint-disable no-self-compare */
  44443. if (newVal === value || (newVal !== newVal && value !== value)) {
  44444. return
  44445. }
  44446. /* eslint-enable no-self-compare */
  44447. if (customSetter) {
  44448. customSetter();
  44449. }
  44450. // #7981: for accessor properties without setter
  44451. if (getter && !setter) { return }
  44452. if (setter) {
  44453. setter.call(obj, newVal);
  44454. } else {
  44455. val = newVal;
  44456. }
  44457. childOb = !shallow && observe(newVal);
  44458. dep.notify();
  44459. }
  44460. });
  44461. }
  44462. /**
  44463. * Set a property on an object. Adds the new property and
  44464. * triggers change notification if the property doesn't
  44465. * already exist.
  44466. */
  44467. function set (target, key, val) {
  44468. if (isUndef(target) || isPrimitive(target)
  44469. ) {
  44470. warn(("Cannot set reactive property on undefined, null, or primitive value: " + ((target))));
  44471. }
  44472. if (Array.isArray(target) && isValidArrayIndex(key)) {
  44473. target.length = Math.max(target.length, key);
  44474. target.splice(key, 1, val);
  44475. return val
  44476. }
  44477. if (key in target && !(key in Object.prototype)) {
  44478. target[key] = val;
  44479. return val
  44480. }
  44481. var ob = (target).__ob__;
  44482. if (target._isVue || (ob && ob.vmCount)) {
  44483. warn(
  44484. 'Avoid adding reactive properties to a Vue instance or its root $data ' +
  44485. 'at runtime - declare it upfront in the data option.'
  44486. );
  44487. return val
  44488. }
  44489. if (!ob) {
  44490. target[key] = val;
  44491. return val
  44492. }
  44493. defineReactive$$1(ob.value, key, val);
  44494. ob.dep.notify();
  44495. return val
  44496. }
  44497. /**
  44498. * Delete a property and trigger change if necessary.
  44499. */
  44500. function del (target, key) {
  44501. if (isUndef(target) || isPrimitive(target)
  44502. ) {
  44503. warn(("Cannot delete reactive property on undefined, null, or primitive value: " + ((target))));
  44504. }
  44505. if (Array.isArray(target) && isValidArrayIndex(key)) {
  44506. target.splice(key, 1);
  44507. return
  44508. }
  44509. var ob = (target).__ob__;
  44510. if (target._isVue || (ob && ob.vmCount)) {
  44511. warn(
  44512. 'Avoid deleting properties on a Vue instance or its root $data ' +
  44513. '- just set it to null.'
  44514. );
  44515. return
  44516. }
  44517. if (!hasOwn(target, key)) {
  44518. return
  44519. }
  44520. delete target[key];
  44521. if (!ob) {
  44522. return
  44523. }
  44524. ob.dep.notify();
  44525. }
  44526. /**
  44527. * Collect dependencies on array elements when the array is touched, since
  44528. * we cannot intercept array element access like property getters.
  44529. */
  44530. function dependArray (value) {
  44531. for (var e = (void 0), i = 0, l = value.length; i < l; i++) {
  44532. e = value[i];
  44533. e && e.__ob__ && e.__ob__.dep.depend();
  44534. if (Array.isArray(e)) {
  44535. dependArray(e);
  44536. }
  44537. }
  44538. }
  44539. /* */
  44540. /**
  44541. * Option overwriting strategies are functions that handle
  44542. * how to merge a parent option value and a child option
  44543. * value into the final value.
  44544. */
  44545. var strats = config.optionMergeStrategies;
  44546. /**
  44547. * Options with restrictions
  44548. */
  44549. {
  44550. strats.el = strats.propsData = function (parent, child, vm, key) {
  44551. if (!vm) {
  44552. warn(
  44553. "option \"" + key + "\" can only be used during instance " +
  44554. 'creation with the `new` keyword.'
  44555. );
  44556. }
  44557. return defaultStrat(parent, child)
  44558. };
  44559. }
  44560. /**
  44561. * Helper that recursively merges two data objects together.
  44562. */
  44563. function mergeData (to, from) {
  44564. if (!from) { return to }
  44565. var key, toVal, fromVal;
  44566. var keys = hasSymbol
  44567. ? Reflect.ownKeys(from)
  44568. : Object.keys(from);
  44569. for (var i = 0; i < keys.length; i++) {
  44570. key = keys[i];
  44571. // in case the object is already observed...
  44572. if (key === '__ob__') { continue }
  44573. toVal = to[key];
  44574. fromVal = from[key];
  44575. if (!hasOwn(to, key)) {
  44576. set(to, key, fromVal);
  44577. } else if (
  44578. toVal !== fromVal &&
  44579. isPlainObject(toVal) &&
  44580. isPlainObject(fromVal)
  44581. ) {
  44582. mergeData(toVal, fromVal);
  44583. }
  44584. }
  44585. return to
  44586. }
  44587. /**
  44588. * Data
  44589. */
  44590. function mergeDataOrFn (
  44591. parentVal,
  44592. childVal,
  44593. vm
  44594. ) {
  44595. if (!vm) {
  44596. // in a Vue.extend merge, both should be functions
  44597. if (!childVal) {
  44598. return parentVal
  44599. }
  44600. if (!parentVal) {
  44601. return childVal
  44602. }
  44603. // when parentVal & childVal are both present,
  44604. // we need to return a function that returns the
  44605. // merged result of both functions... no need to
  44606. // check if parentVal is a function here because
  44607. // it has to be a function to pass previous merges.
  44608. return function mergedDataFn () {
  44609. return mergeData(
  44610. typeof childVal === 'function' ? childVal.call(this, this) : childVal,
  44611. typeof parentVal === 'function' ? parentVal.call(this, this) : parentVal
  44612. )
  44613. }
  44614. } else {
  44615. return function mergedInstanceDataFn () {
  44616. // instance merge
  44617. var instanceData = typeof childVal === 'function'
  44618. ? childVal.call(vm, vm)
  44619. : childVal;
  44620. var defaultData = typeof parentVal === 'function'
  44621. ? parentVal.call(vm, vm)
  44622. : parentVal;
  44623. if (instanceData) {
  44624. return mergeData(instanceData, defaultData)
  44625. } else {
  44626. return defaultData
  44627. }
  44628. }
  44629. }
  44630. }
  44631. strats.data = function (
  44632. parentVal,
  44633. childVal,
  44634. vm
  44635. ) {
  44636. if (!vm) {
  44637. if (childVal && typeof childVal !== 'function') {
  44638. warn(
  44639. 'The "data" option should be a function ' +
  44640. 'that returns a per-instance value in component ' +
  44641. 'definitions.',
  44642. vm
  44643. );
  44644. return parentVal
  44645. }
  44646. return mergeDataOrFn(parentVal, childVal)
  44647. }
  44648. return mergeDataOrFn(parentVal, childVal, vm)
  44649. };
  44650. /**
  44651. * Hooks and props are merged as arrays.
  44652. */
  44653. function mergeHook (
  44654. parentVal,
  44655. childVal
  44656. ) {
  44657. var res = childVal
  44658. ? parentVal
  44659. ? parentVal.concat(childVal)
  44660. : Array.isArray(childVal)
  44661. ? childVal
  44662. : [childVal]
  44663. : parentVal;
  44664. return res
  44665. ? dedupeHooks(res)
  44666. : res
  44667. }
  44668. function dedupeHooks (hooks) {
  44669. var res = [];
  44670. for (var i = 0; i < hooks.length; i++) {
  44671. if (res.indexOf(hooks[i]) === -1) {
  44672. res.push(hooks[i]);
  44673. }
  44674. }
  44675. return res
  44676. }
  44677. LIFECYCLE_HOOKS.forEach(function (hook) {
  44678. strats[hook] = mergeHook;
  44679. });
  44680. /**
  44681. * Assets
  44682. *
  44683. * When a vm is present (instance creation), we need to do
  44684. * a three-way merge between constructor options, instance
  44685. * options and parent options.
  44686. */
  44687. function mergeAssets (
  44688. parentVal,
  44689. childVal,
  44690. vm,
  44691. key
  44692. ) {
  44693. var res = Object.create(parentVal || null);
  44694. if (childVal) {
  44695. assertObjectType(key, childVal, vm);
  44696. return extend(res, childVal)
  44697. } else {
  44698. return res
  44699. }
  44700. }
  44701. ASSET_TYPES.forEach(function (type) {
  44702. strats[type + 's'] = mergeAssets;
  44703. });
  44704. /**
  44705. * Watchers.
  44706. *
  44707. * Watchers hashes should not overwrite one
  44708. * another, so we merge them as arrays.
  44709. */
  44710. strats.watch = function (
  44711. parentVal,
  44712. childVal,
  44713. vm,
  44714. key
  44715. ) {
  44716. // work around Firefox's Object.prototype.watch...
  44717. if (parentVal === nativeWatch) { parentVal = undefined; }
  44718. if (childVal === nativeWatch) { childVal = undefined; }
  44719. /* istanbul ignore if */
  44720. if (!childVal) { return Object.create(parentVal || null) }
  44721. {
  44722. assertObjectType(key, childVal, vm);
  44723. }
  44724. if (!parentVal) { return childVal }
  44725. var ret = {};
  44726. extend(ret, parentVal);
  44727. for (var key$1 in childVal) {
  44728. var parent = ret[key$1];
  44729. var child = childVal[key$1];
  44730. if (parent && !Array.isArray(parent)) {
  44731. parent = [parent];
  44732. }
  44733. ret[key$1] = parent
  44734. ? parent.concat(child)
  44735. : Array.isArray(child) ? child : [child];
  44736. }
  44737. return ret
  44738. };
  44739. /**
  44740. * Other object hashes.
  44741. */
  44742. strats.props =
  44743. strats.methods =
  44744. strats.inject =
  44745. strats.computed = function (
  44746. parentVal,
  44747. childVal,
  44748. vm,
  44749. key
  44750. ) {
  44751. if (childVal && "development" !== 'production') {
  44752. assertObjectType(key, childVal, vm);
  44753. }
  44754. if (!parentVal) { return childVal }
  44755. var ret = Object.create(null);
  44756. extend(ret, parentVal);
  44757. if (childVal) { extend(ret, childVal); }
  44758. return ret
  44759. };
  44760. strats.provide = mergeDataOrFn;
  44761. /**
  44762. * Default strategy.
  44763. */
  44764. var defaultStrat = function (parentVal, childVal) {
  44765. return childVal === undefined
  44766. ? parentVal
  44767. : childVal
  44768. };
  44769. /**
  44770. * Validate component names
  44771. */
  44772. function checkComponents (options) {
  44773. for (var key in options.components) {
  44774. validateComponentName(key);
  44775. }
  44776. }
  44777. function validateComponentName (name) {
  44778. if (!new RegExp(("^[a-zA-Z][\\-\\.0-9_" + (unicodeRegExp.source) + "]*$")).test(name)) {
  44779. warn(
  44780. 'Invalid component name: "' + name + '". Component names ' +
  44781. 'should conform to valid custom element name in html5 specification.'
  44782. );
  44783. }
  44784. if (isBuiltInTag(name) || config.isReservedTag(name)) {
  44785. warn(
  44786. 'Do not use built-in or reserved HTML elements as component ' +
  44787. 'id: ' + name
  44788. );
  44789. }
  44790. }
  44791. /**
  44792. * Ensure all props option syntax are normalized into the
  44793. * Object-based format.
  44794. */
  44795. function normalizeProps (options, vm) {
  44796. var props = options.props;
  44797. if (!props) { return }
  44798. var res = {};
  44799. var i, val, name;
  44800. if (Array.isArray(props)) {
  44801. i = props.length;
  44802. while (i--) {
  44803. val = props[i];
  44804. if (typeof val === 'string') {
  44805. name = camelize(val);
  44806. res[name] = { type: null };
  44807. } else {
  44808. warn('props must be strings when using array syntax.');
  44809. }
  44810. }
  44811. } else if (isPlainObject(props)) {
  44812. for (var key in props) {
  44813. val = props[key];
  44814. name = camelize(key);
  44815. res[name] = isPlainObject(val)
  44816. ? val
  44817. : { type: val };
  44818. }
  44819. } else {
  44820. warn(
  44821. "Invalid value for option \"props\": expected an Array or an Object, " +
  44822. "but got " + (toRawType(props)) + ".",
  44823. vm
  44824. );
  44825. }
  44826. options.props = res;
  44827. }
  44828. /**
  44829. * Normalize all injections into Object-based format
  44830. */
  44831. function normalizeInject (options, vm) {
  44832. var inject = options.inject;
  44833. if (!inject) { return }
  44834. var normalized = options.inject = {};
  44835. if (Array.isArray(inject)) {
  44836. for (var i = 0; i < inject.length; i++) {
  44837. normalized[inject[i]] = { from: inject[i] };
  44838. }
  44839. } else if (isPlainObject(inject)) {
  44840. for (var key in inject) {
  44841. var val = inject[key];
  44842. normalized[key] = isPlainObject(val)
  44843. ? extend({ from: key }, val)
  44844. : { from: val };
  44845. }
  44846. } else {
  44847. warn(
  44848. "Invalid value for option \"inject\": expected an Array or an Object, " +
  44849. "but got " + (toRawType(inject)) + ".",
  44850. vm
  44851. );
  44852. }
  44853. }
  44854. /**
  44855. * Normalize raw function directives into object format.
  44856. */
  44857. function normalizeDirectives (options) {
  44858. var dirs = options.directives;
  44859. if (dirs) {
  44860. for (var key in dirs) {
  44861. var def$$1 = dirs[key];
  44862. if (typeof def$$1 === 'function') {
  44863. dirs[key] = { bind: def$$1, update: def$$1 };
  44864. }
  44865. }
  44866. }
  44867. }
  44868. function assertObjectType (name, value, vm) {
  44869. if (!isPlainObject(value)) {
  44870. warn(
  44871. "Invalid value for option \"" + name + "\": expected an Object, " +
  44872. "but got " + (toRawType(value)) + ".",
  44873. vm
  44874. );
  44875. }
  44876. }
  44877. /**
  44878. * Merge two option objects into a new one.
  44879. * Core utility used in both instantiation and inheritance.
  44880. */
  44881. function mergeOptions (
  44882. parent,
  44883. child,
  44884. vm
  44885. ) {
  44886. {
  44887. checkComponents(child);
  44888. }
  44889. if (typeof child === 'function') {
  44890. child = child.options;
  44891. }
  44892. normalizeProps(child, vm);
  44893. normalizeInject(child, vm);
  44894. normalizeDirectives(child);
  44895. // Apply extends and mixins on the child options,
  44896. // but only if it is a raw options object that isn't
  44897. // the result of another mergeOptions call.
  44898. // Only merged options has the _base property.
  44899. if (!child._base) {
  44900. if (child.extends) {
  44901. parent = mergeOptions(parent, child.extends, vm);
  44902. }
  44903. if (child.mixins) {
  44904. for (var i = 0, l = child.mixins.length; i < l; i++) {
  44905. parent = mergeOptions(parent, child.mixins[i], vm);
  44906. }
  44907. }
  44908. }
  44909. var options = {};
  44910. var key;
  44911. for (key in parent) {
  44912. mergeField(key);
  44913. }
  44914. for (key in child) {
  44915. if (!hasOwn(parent, key)) {
  44916. mergeField(key);
  44917. }
  44918. }
  44919. function mergeField (key) {
  44920. var strat = strats[key] || defaultStrat;
  44921. options[key] = strat(parent[key], child[key], vm, key);
  44922. }
  44923. return options
  44924. }
  44925. /**
  44926. * Resolve an asset.
  44927. * This function is used because child instances need access
  44928. * to assets defined in its ancestor chain.
  44929. */
  44930. function resolveAsset (
  44931. options,
  44932. type,
  44933. id,
  44934. warnMissing
  44935. ) {
  44936. /* istanbul ignore if */
  44937. if (typeof id !== 'string') {
  44938. return
  44939. }
  44940. var assets = options[type];
  44941. // check local registration variations first
  44942. if (hasOwn(assets, id)) { return assets[id] }
  44943. var camelizedId = camelize(id);
  44944. if (hasOwn(assets, camelizedId)) { return assets[camelizedId] }
  44945. var PascalCaseId = capitalize(camelizedId);
  44946. if (hasOwn(assets, PascalCaseId)) { return assets[PascalCaseId] }
  44947. // fallback to prototype chain
  44948. var res = assets[id] || assets[camelizedId] || assets[PascalCaseId];
  44949. if (warnMissing && !res) {
  44950. warn(
  44951. 'Failed to resolve ' + type.slice(0, -1) + ': ' + id,
  44952. options
  44953. );
  44954. }
  44955. return res
  44956. }
  44957. /* */
  44958. function validateProp (
  44959. key,
  44960. propOptions,
  44961. propsData,
  44962. vm
  44963. ) {
  44964. var prop = propOptions[key];
  44965. var absent = !hasOwn(propsData, key);
  44966. var value = propsData[key];
  44967. // boolean casting
  44968. var booleanIndex = getTypeIndex(Boolean, prop.type);
  44969. if (booleanIndex > -1) {
  44970. if (absent && !hasOwn(prop, 'default')) {
  44971. value = false;
  44972. } else if (value === '' || value === hyphenate(key)) {
  44973. // only cast empty string / same name to boolean if
  44974. // boolean has higher priority
  44975. var stringIndex = getTypeIndex(String, prop.type);
  44976. if (stringIndex < 0 || booleanIndex < stringIndex) {
  44977. value = true;
  44978. }
  44979. }
  44980. }
  44981. // check default value
  44982. if (value === undefined) {
  44983. value = getPropDefaultValue(vm, prop, key);
  44984. // since the default value is a fresh copy,
  44985. // make sure to observe it.
  44986. var prevShouldObserve = shouldObserve;
  44987. toggleObserving(true);
  44988. observe(value);
  44989. toggleObserving(prevShouldObserve);
  44990. }
  44991. {
  44992. assertProp(prop, key, value, vm, absent);
  44993. }
  44994. return value
  44995. }
  44996. /**
  44997. * Get the default value of a prop.
  44998. */
  44999. function getPropDefaultValue (vm, prop, key) {
  45000. // no default, return undefined
  45001. if (!hasOwn(prop, 'default')) {
  45002. return undefined
  45003. }
  45004. var def = prop.default;
  45005. // warn against non-factory defaults for Object & Array
  45006. if (isObject(def)) {
  45007. warn(
  45008. 'Invalid default value for prop "' + key + '": ' +
  45009. 'Props with type Object/Array must use a factory function ' +
  45010. 'to return the default value.',
  45011. vm
  45012. );
  45013. }
  45014. // the raw prop value was also undefined from previous render,
  45015. // return previous default value to avoid unnecessary watcher trigger
  45016. if (vm && vm.$options.propsData &&
  45017. vm.$options.propsData[key] === undefined &&
  45018. vm._props[key] !== undefined
  45019. ) {
  45020. return vm._props[key]
  45021. }
  45022. // call factory function for non-Function types
  45023. // a value is Function if its prototype is function even across different execution context
  45024. return typeof def === 'function' && getType(prop.type) !== 'Function'
  45025. ? def.call(vm)
  45026. : def
  45027. }
  45028. /**
  45029. * Assert whether a prop is valid.
  45030. */
  45031. function assertProp (
  45032. prop,
  45033. name,
  45034. value,
  45035. vm,
  45036. absent
  45037. ) {
  45038. if (prop.required && absent) {
  45039. warn(
  45040. 'Missing required prop: "' + name + '"',
  45041. vm
  45042. );
  45043. return
  45044. }
  45045. if (value == null && !prop.required) {
  45046. return
  45047. }
  45048. var type = prop.type;
  45049. var valid = !type || type === true;
  45050. var expectedTypes = [];
  45051. if (type) {
  45052. if (!Array.isArray(type)) {
  45053. type = [type];
  45054. }
  45055. for (var i = 0; i < type.length && !valid; i++) {
  45056. var assertedType = assertType(value, type[i]);
  45057. expectedTypes.push(assertedType.expectedType || '');
  45058. valid = assertedType.valid;
  45059. }
  45060. }
  45061. if (!valid) {
  45062. warn(
  45063. getInvalidTypeMessage(name, value, expectedTypes),
  45064. vm
  45065. );
  45066. return
  45067. }
  45068. var validator = prop.validator;
  45069. if (validator) {
  45070. if (!validator(value)) {
  45071. warn(
  45072. 'Invalid prop: custom validator check failed for prop "' + name + '".',
  45073. vm
  45074. );
  45075. }
  45076. }
  45077. }
  45078. var simpleCheckRE = /^(String|Number|Boolean|Function|Symbol)$/;
  45079. function assertType (value, type) {
  45080. var valid;
  45081. var expectedType = getType(type);
  45082. if (simpleCheckRE.test(expectedType)) {
  45083. var t = typeof value;
  45084. valid = t === expectedType.toLowerCase();
  45085. // for primitive wrapper objects
  45086. if (!valid && t === 'object') {
  45087. valid = value instanceof type;
  45088. }
  45089. } else if (expectedType === 'Object') {
  45090. valid = isPlainObject(value);
  45091. } else if (expectedType === 'Array') {
  45092. valid = Array.isArray(value);
  45093. } else {
  45094. valid = value instanceof type;
  45095. }
  45096. return {
  45097. valid: valid,
  45098. expectedType: expectedType
  45099. }
  45100. }
  45101. /**
  45102. * Use function string name to check built-in types,
  45103. * because a simple equality check will fail when running
  45104. * across different vms / iframes.
  45105. */
  45106. function getType (fn) {
  45107. var match = fn && fn.toString().match(/^\s*function (\w+)/);
  45108. return match ? match[1] : ''
  45109. }
  45110. function isSameType (a, b) {
  45111. return getType(a) === getType(b)
  45112. }
  45113. function getTypeIndex (type, expectedTypes) {
  45114. if (!Array.isArray(expectedTypes)) {
  45115. return isSameType(expectedTypes, type) ? 0 : -1
  45116. }
  45117. for (var i = 0, len = expectedTypes.length; i < len; i++) {
  45118. if (isSameType(expectedTypes[i], type)) {
  45119. return i
  45120. }
  45121. }
  45122. return -1
  45123. }
  45124. function getInvalidTypeMessage (name, value, expectedTypes) {
  45125. var message = "Invalid prop: type check failed for prop \"" + name + "\"." +
  45126. " Expected " + (expectedTypes.map(capitalize).join(', '));
  45127. var expectedType = expectedTypes[0];
  45128. var receivedType = toRawType(value);
  45129. var expectedValue = styleValue(value, expectedType);
  45130. var receivedValue = styleValue(value, receivedType);
  45131. // check if we need to specify expected value
  45132. if (expectedTypes.length === 1 &&
  45133. isExplicable(expectedType) &&
  45134. !isBoolean(expectedType, receivedType)) {
  45135. message += " with value " + expectedValue;
  45136. }
  45137. message += ", got " + receivedType + " ";
  45138. // check if we need to specify received value
  45139. if (isExplicable(receivedType)) {
  45140. message += "with value " + receivedValue + ".";
  45141. }
  45142. return message
  45143. }
  45144. function styleValue (value, type) {
  45145. if (type === 'String') {
  45146. return ("\"" + value + "\"")
  45147. } else if (type === 'Number') {
  45148. return ("" + (Number(value)))
  45149. } else {
  45150. return ("" + value)
  45151. }
  45152. }
  45153. function isExplicable (value) {
  45154. var explicitTypes = ['string', 'number', 'boolean'];
  45155. return explicitTypes.some(function (elem) { return value.toLowerCase() === elem; })
  45156. }
  45157. function isBoolean () {
  45158. var args = [], len = arguments.length;
  45159. while ( len-- ) args[ len ] = arguments[ len ];
  45160. return args.some(function (elem) { return elem.toLowerCase() === 'boolean'; })
  45161. }
  45162. /* */
  45163. function handleError (err, vm, info) {
  45164. // Deactivate deps tracking while processing error handler to avoid possible infinite rendering.
  45165. // See: https://github.com/vuejs/vuex/issues/1505
  45166. pushTarget();
  45167. try {
  45168. if (vm) {
  45169. var cur = vm;
  45170. while ((cur = cur.$parent)) {
  45171. var hooks = cur.$options.errorCaptured;
  45172. if (hooks) {
  45173. for (var i = 0; i < hooks.length; i++) {
  45174. try {
  45175. var capture = hooks[i].call(cur, err, vm, info) === false;
  45176. if (capture) { return }
  45177. } catch (e) {
  45178. globalHandleError(e, cur, 'errorCaptured hook');
  45179. }
  45180. }
  45181. }
  45182. }
  45183. }
  45184. globalHandleError(err, vm, info);
  45185. } finally {
  45186. popTarget();
  45187. }
  45188. }
  45189. function invokeWithErrorHandling (
  45190. handler,
  45191. context,
  45192. args,
  45193. vm,
  45194. info
  45195. ) {
  45196. var res;
  45197. try {
  45198. res = args ? handler.apply(context, args) : handler.call(context);
  45199. if (res && !res._isVue && isPromise(res) && !res._handled) {
  45200. res.catch(function (e) { return handleError(e, vm, info + " (Promise/async)"); });
  45201. // issue #9511
  45202. // avoid catch triggering multiple times when nested calls
  45203. res._handled = true;
  45204. }
  45205. } catch (e) {
  45206. handleError(e, vm, info);
  45207. }
  45208. return res
  45209. }
  45210. function globalHandleError (err, vm, info) {
  45211. if (config.errorHandler) {
  45212. try {
  45213. return config.errorHandler.call(null, err, vm, info)
  45214. } catch (e) {
  45215. // if the user intentionally throws the original error in the handler,
  45216. // do not log it twice
  45217. if (e !== err) {
  45218. logError(e, null, 'config.errorHandler');
  45219. }
  45220. }
  45221. }
  45222. logError(err, vm, info);
  45223. }
  45224. function logError (err, vm, info) {
  45225. {
  45226. warn(("Error in " + info + ": \"" + (err.toString()) + "\""), vm);
  45227. }
  45228. /* istanbul ignore else */
  45229. if ((inBrowser || inWeex) && typeof console !== 'undefined') {
  45230. console.error(err);
  45231. } else {
  45232. throw err
  45233. }
  45234. }
  45235. /* */
  45236. var isUsingMicroTask = false;
  45237. var callbacks = [];
  45238. var pending = false;
  45239. function flushCallbacks () {
  45240. pending = false;
  45241. var copies = callbacks.slice(0);
  45242. callbacks.length = 0;
  45243. for (var i = 0; i < copies.length; i++) {
  45244. copies[i]();
  45245. }
  45246. }
  45247. // Here we have async deferring wrappers using microtasks.
  45248. // In 2.5 we used (macro) tasks (in combination with microtasks).
  45249. // However, it has subtle problems when state is changed right before repaint
  45250. // (e.g. #6813, out-in transitions).
  45251. // Also, using (macro) tasks in event handler would cause some weird behaviors
  45252. // that cannot be circumvented (e.g. #7109, #7153, #7546, #7834, #8109).
  45253. // So we now use microtasks everywhere, again.
  45254. // A major drawback of this tradeoff is that there are some scenarios
  45255. // where microtasks have too high a priority and fire in between supposedly
  45256. // sequential events (e.g. #4521, #6690, which have workarounds)
  45257. // or even between bubbling of the same event (#6566).
  45258. var timerFunc;
  45259. // The nextTick behavior leverages the microtask queue, which can be accessed
  45260. // via either native Promise.then or MutationObserver.
  45261. // MutationObserver has wider support, however it is seriously bugged in
  45262. // UIWebView in iOS >= 9.3.3 when triggered in touch event handlers. It
  45263. // completely stops working after triggering a few times... so, if native
  45264. // Promise is available, we will use it:
  45265. /* istanbul ignore next, $flow-disable-line */
  45266. if (typeof Promise !== 'undefined' && isNative(Promise)) {
  45267. var p = Promise.resolve();
  45268. timerFunc = function () {
  45269. p.then(flushCallbacks);
  45270. // In problematic UIWebViews, Promise.then doesn't completely break, but
  45271. // it can get stuck in a weird state where callbacks are pushed into the
  45272. // microtask queue but the queue isn't being flushed, until the browser
  45273. // needs to do some other work, e.g. handle a timer. Therefore we can
  45274. // "force" the microtask queue to be flushed by adding an empty timer.
  45275. if (isIOS) { setTimeout(noop); }
  45276. };
  45277. isUsingMicroTask = true;
  45278. } else if (!isIE && typeof MutationObserver !== 'undefined' && (
  45279. isNative(MutationObserver) ||
  45280. // PhantomJS and iOS 7.x
  45281. MutationObserver.toString() === '[object MutationObserverConstructor]'
  45282. )) {
  45283. // Use MutationObserver where native Promise is not available,
  45284. // e.g. PhantomJS, iOS7, Android 4.4
  45285. // (#6466 MutationObserver is unreliable in IE11)
  45286. var counter = 1;
  45287. var observer = new MutationObserver(flushCallbacks);
  45288. var textNode = document.createTextNode(String(counter));
  45289. observer.observe(textNode, {
  45290. characterData: true
  45291. });
  45292. timerFunc = function () {
  45293. counter = (counter + 1) % 2;
  45294. textNode.data = String(counter);
  45295. };
  45296. isUsingMicroTask = true;
  45297. } else if (typeof setImmediate !== 'undefined' && isNative(setImmediate)) {
  45298. // Fallback to setImmediate.
  45299. // Technically it leverages the (macro) task queue,
  45300. // but it is still a better choice than setTimeout.
  45301. timerFunc = function () {
  45302. setImmediate(flushCallbacks);
  45303. };
  45304. } else {
  45305. // Fallback to setTimeout.
  45306. timerFunc = function () {
  45307. setTimeout(flushCallbacks, 0);
  45308. };
  45309. }
  45310. function nextTick (cb, ctx) {
  45311. var _resolve;
  45312. callbacks.push(function () {
  45313. if (cb) {
  45314. try {
  45315. cb.call(ctx);
  45316. } catch (e) {
  45317. handleError(e, ctx, 'nextTick');
  45318. }
  45319. } else if (_resolve) {
  45320. _resolve(ctx);
  45321. }
  45322. });
  45323. if (!pending) {
  45324. pending = true;
  45325. timerFunc();
  45326. }
  45327. // $flow-disable-line
  45328. if (!cb && typeof Promise !== 'undefined') {
  45329. return new Promise(function (resolve) {
  45330. _resolve = resolve;
  45331. })
  45332. }
  45333. }
  45334. /* */
  45335. var mark;
  45336. var measure;
  45337. {
  45338. var perf = inBrowser && window.performance;
  45339. /* istanbul ignore if */
  45340. if (
  45341. perf &&
  45342. perf.mark &&
  45343. perf.measure &&
  45344. perf.clearMarks &&
  45345. perf.clearMeasures
  45346. ) {
  45347. mark = function (tag) { return perf.mark(tag); };
  45348. measure = function (name, startTag, endTag) {
  45349. perf.measure(name, startTag, endTag);
  45350. perf.clearMarks(startTag);
  45351. perf.clearMarks(endTag);
  45352. // perf.clearMeasures(name)
  45353. };
  45354. }
  45355. }
  45356. /* not type checking this file because flow doesn't play well with Proxy */
  45357. var initProxy;
  45358. {
  45359. var allowedGlobals = makeMap(
  45360. 'Infinity,undefined,NaN,isFinite,isNaN,' +
  45361. 'parseFloat,parseInt,decodeURI,decodeURIComponent,encodeURI,encodeURIComponent,' +
  45362. 'Math,Number,Date,Array,Object,Boolean,String,RegExp,Map,Set,JSON,Intl,' +
  45363. 'require' // for Webpack/Browserify
  45364. );
  45365. var warnNonPresent = function (target, key) {
  45366. warn(
  45367. "Property or method \"" + key + "\" is not defined on the instance but " +
  45368. 'referenced during render. Make sure that this property is reactive, ' +
  45369. 'either in the data option, or for class-based components, by ' +
  45370. 'initializing the property. ' +
  45371. 'See: https://vuejs.org/v2/guide/reactivity.html#Declaring-Reactive-Properties.',
  45372. target
  45373. );
  45374. };
  45375. var warnReservedPrefix = function (target, key) {
  45376. warn(
  45377. "Property \"" + key + "\" must be accessed with \"$data." + key + "\" because " +
  45378. 'properties starting with "$" or "_" are not proxied in the Vue instance to ' +
  45379. 'prevent conflicts with Vue internals. ' +
  45380. 'See: https://vuejs.org/v2/api/#data',
  45381. target
  45382. );
  45383. };
  45384. var hasProxy =
  45385. typeof Proxy !== 'undefined' && isNative(Proxy);
  45386. if (hasProxy) {
  45387. var isBuiltInModifier = makeMap('stop,prevent,self,ctrl,shift,alt,meta,exact');
  45388. config.keyCodes = new Proxy(config.keyCodes, {
  45389. set: function set (target, key, value) {
  45390. if (isBuiltInModifier(key)) {
  45391. warn(("Avoid overwriting built-in modifier in config.keyCodes: ." + key));
  45392. return false
  45393. } else {
  45394. target[key] = value;
  45395. return true
  45396. }
  45397. }
  45398. });
  45399. }
  45400. var hasHandler = {
  45401. has: function has (target, key) {
  45402. var has = key in target;
  45403. var isAllowed = allowedGlobals(key) ||
  45404. (typeof key === 'string' && key.charAt(0) === '_' && !(key in target.$data));
  45405. if (!has && !isAllowed) {
  45406. if (key in target.$data) { warnReservedPrefix(target, key); }
  45407. else { warnNonPresent(target, key); }
  45408. }
  45409. return has || !isAllowed
  45410. }
  45411. };
  45412. var getHandler = {
  45413. get: function get (target, key) {
  45414. if (typeof key === 'string' && !(key in target)) {
  45415. if (key in target.$data) { warnReservedPrefix(target, key); }
  45416. else { warnNonPresent(target, key); }
  45417. }
  45418. return target[key]
  45419. }
  45420. };
  45421. initProxy = function initProxy (vm) {
  45422. if (hasProxy) {
  45423. // determine which proxy handler to use
  45424. var options = vm.$options;
  45425. var handlers = options.render && options.render._withStripped
  45426. ? getHandler
  45427. : hasHandler;
  45428. vm._renderProxy = new Proxy(vm, handlers);
  45429. } else {
  45430. vm._renderProxy = vm;
  45431. }
  45432. };
  45433. }
  45434. /* */
  45435. var seenObjects = new _Set();
  45436. /**
  45437. * Recursively traverse an object to evoke all converted
  45438. * getters, so that every nested property inside the object
  45439. * is collected as a "deep" dependency.
  45440. */
  45441. function traverse (val) {
  45442. _traverse(val, seenObjects);
  45443. seenObjects.clear();
  45444. }
  45445. function _traverse (val, seen) {
  45446. var i, keys;
  45447. var isA = Array.isArray(val);
  45448. if ((!isA && !isObject(val)) || Object.isFrozen(val) || val instanceof VNode) {
  45449. return
  45450. }
  45451. if (val.__ob__) {
  45452. var depId = val.__ob__.dep.id;
  45453. if (seen.has(depId)) {
  45454. return
  45455. }
  45456. seen.add(depId);
  45457. }
  45458. if (isA) {
  45459. i = val.length;
  45460. while (i--) { _traverse(val[i], seen); }
  45461. } else {
  45462. keys = Object.keys(val);
  45463. i = keys.length;
  45464. while (i--) { _traverse(val[keys[i]], seen); }
  45465. }
  45466. }
  45467. /* */
  45468. var normalizeEvent = cached(function (name) {
  45469. var passive = name.charAt(0) === '&';
  45470. name = passive ? name.slice(1) : name;
  45471. var once$$1 = name.charAt(0) === '~'; // Prefixed last, checked first
  45472. name = once$$1 ? name.slice(1) : name;
  45473. var capture = name.charAt(0) === '!';
  45474. name = capture ? name.slice(1) : name;
  45475. return {
  45476. name: name,
  45477. once: once$$1,
  45478. capture: capture,
  45479. passive: passive
  45480. }
  45481. });
  45482. function createFnInvoker (fns, vm) {
  45483. function invoker () {
  45484. var arguments$1 = arguments;
  45485. var fns = invoker.fns;
  45486. if (Array.isArray(fns)) {
  45487. var cloned = fns.slice();
  45488. for (var i = 0; i < cloned.length; i++) {
  45489. invokeWithErrorHandling(cloned[i], null, arguments$1, vm, "v-on handler");
  45490. }
  45491. } else {
  45492. // return handler return value for single handlers
  45493. return invokeWithErrorHandling(fns, null, arguments, vm, "v-on handler")
  45494. }
  45495. }
  45496. invoker.fns = fns;
  45497. return invoker
  45498. }
  45499. function updateListeners (
  45500. on,
  45501. oldOn,
  45502. add,
  45503. remove$$1,
  45504. createOnceHandler,
  45505. vm
  45506. ) {
  45507. var name, def$$1, cur, old, event;
  45508. for (name in on) {
  45509. def$$1 = cur = on[name];
  45510. old = oldOn[name];
  45511. event = normalizeEvent(name);
  45512. if (isUndef(cur)) {
  45513. warn(
  45514. "Invalid handler for event \"" + (event.name) + "\": got " + String(cur),
  45515. vm
  45516. );
  45517. } else if (isUndef(old)) {
  45518. if (isUndef(cur.fns)) {
  45519. cur = on[name] = createFnInvoker(cur, vm);
  45520. }
  45521. if (isTrue(event.once)) {
  45522. cur = on[name] = createOnceHandler(event.name, cur, event.capture);
  45523. }
  45524. add(event.name, cur, event.capture, event.passive, event.params);
  45525. } else if (cur !== old) {
  45526. old.fns = cur;
  45527. on[name] = old;
  45528. }
  45529. }
  45530. for (name in oldOn) {
  45531. if (isUndef(on[name])) {
  45532. event = normalizeEvent(name);
  45533. remove$$1(event.name, oldOn[name], event.capture);
  45534. }
  45535. }
  45536. }
  45537. /* */
  45538. function mergeVNodeHook (def, hookKey, hook) {
  45539. if (def instanceof VNode) {
  45540. def = def.data.hook || (def.data.hook = {});
  45541. }
  45542. var invoker;
  45543. var oldHook = def[hookKey];
  45544. function wrappedHook () {
  45545. hook.apply(this, arguments);
  45546. // important: remove merged hook to ensure it's called only once
  45547. // and prevent memory leak
  45548. remove(invoker.fns, wrappedHook);
  45549. }
  45550. if (isUndef(oldHook)) {
  45551. // no existing hook
  45552. invoker = createFnInvoker([wrappedHook]);
  45553. } else {
  45554. /* istanbul ignore if */
  45555. if (isDef(oldHook.fns) && isTrue(oldHook.merged)) {
  45556. // already a merged invoker
  45557. invoker = oldHook;
  45558. invoker.fns.push(wrappedHook);
  45559. } else {
  45560. // existing plain hook
  45561. invoker = createFnInvoker([oldHook, wrappedHook]);
  45562. }
  45563. }
  45564. invoker.merged = true;
  45565. def[hookKey] = invoker;
  45566. }
  45567. /* */
  45568. function extractPropsFromVNodeData (
  45569. data,
  45570. Ctor,
  45571. tag
  45572. ) {
  45573. // we are only extracting raw values here.
  45574. // validation and default values are handled in the child
  45575. // component itself.
  45576. var propOptions = Ctor.options.props;
  45577. if (isUndef(propOptions)) {
  45578. return
  45579. }
  45580. var res = {};
  45581. var attrs = data.attrs;
  45582. var props = data.props;
  45583. if (isDef(attrs) || isDef(props)) {
  45584. for (var key in propOptions) {
  45585. var altKey = hyphenate(key);
  45586. {
  45587. var keyInLowerCase = key.toLowerCase();
  45588. if (
  45589. key !== keyInLowerCase &&
  45590. attrs && hasOwn(attrs, keyInLowerCase)
  45591. ) {
  45592. tip(
  45593. "Prop \"" + keyInLowerCase + "\" is passed to component " +
  45594. (formatComponentName(tag || Ctor)) + ", but the declared prop name is" +
  45595. " \"" + key + "\". " +
  45596. "Note that HTML attributes are case-insensitive and camelCased " +
  45597. "props need to use their kebab-case equivalents when using in-DOM " +
  45598. "templates. You should probably use \"" + altKey + "\" instead of \"" + key + "\"."
  45599. );
  45600. }
  45601. }
  45602. checkProp(res, props, key, altKey, true) ||
  45603. checkProp(res, attrs, key, altKey, false);
  45604. }
  45605. }
  45606. return res
  45607. }
  45608. function checkProp (
  45609. res,
  45610. hash,
  45611. key,
  45612. altKey,
  45613. preserve
  45614. ) {
  45615. if (isDef(hash)) {
  45616. if (hasOwn(hash, key)) {
  45617. res[key] = hash[key];
  45618. if (!preserve) {
  45619. delete hash[key];
  45620. }
  45621. return true
  45622. } else if (hasOwn(hash, altKey)) {
  45623. res[key] = hash[altKey];
  45624. if (!preserve) {
  45625. delete hash[altKey];
  45626. }
  45627. return true
  45628. }
  45629. }
  45630. return false
  45631. }
  45632. /* */
  45633. // The template compiler attempts to minimize the need for normalization by
  45634. // statically analyzing the template at compile time.
  45635. //
  45636. // For plain HTML markup, normalization can be completely skipped because the
  45637. // generated render function is guaranteed to return Array<VNode>. There are
  45638. // two cases where extra normalization is needed:
  45639. // 1. When the children contains components - because a functional component
  45640. // may return an Array instead of a single root. In this case, just a simple
  45641. // normalization is needed - if any child is an Array, we flatten the whole
  45642. // thing with Array.prototype.concat. It is guaranteed to be only 1-level deep
  45643. // because functional components already normalize their own children.
  45644. function simpleNormalizeChildren (children) {
  45645. for (var i = 0; i < children.length; i++) {
  45646. if (Array.isArray(children[i])) {
  45647. return Array.prototype.concat.apply([], children)
  45648. }
  45649. }
  45650. return children
  45651. }
  45652. // 2. When the children contains constructs that always generated nested Arrays,
  45653. // e.g. <template>, <slot>, v-for, or when the children is provided by user
  45654. // with hand-written render functions / JSX. In such cases a full normalization
  45655. // is needed to cater to all possible types of children values.
  45656. function normalizeChildren (children) {
  45657. return isPrimitive(children)
  45658. ? [createTextVNode(children)]
  45659. : Array.isArray(children)
  45660. ? normalizeArrayChildren(children)
  45661. : undefined
  45662. }
  45663. function isTextNode (node) {
  45664. return isDef(node) && isDef(node.text) && isFalse(node.isComment)
  45665. }
  45666. function normalizeArrayChildren (children, nestedIndex) {
  45667. var res = [];
  45668. var i, c, lastIndex, last;
  45669. for (i = 0; i < children.length; i++) {
  45670. c = children[i];
  45671. if (isUndef(c) || typeof c === 'boolean') { continue }
  45672. lastIndex = res.length - 1;
  45673. last = res[lastIndex];
  45674. // nested
  45675. if (Array.isArray(c)) {
  45676. if (c.length > 0) {
  45677. c = normalizeArrayChildren(c, ((nestedIndex || '') + "_" + i));
  45678. // merge adjacent text nodes
  45679. if (isTextNode(c[0]) && isTextNode(last)) {
  45680. res[lastIndex] = createTextVNode(last.text + (c[0]).text);
  45681. c.shift();
  45682. }
  45683. res.push.apply(res, c);
  45684. }
  45685. } else if (isPrimitive(c)) {
  45686. if (isTextNode(last)) {
  45687. // merge adjacent text nodes
  45688. // this is necessary for SSR hydration because text nodes are
  45689. // essentially merged when rendered to HTML strings
  45690. res[lastIndex] = createTextVNode(last.text + c);
  45691. } else if (c !== '') {
  45692. // convert primitive to vnode
  45693. res.push(createTextVNode(c));
  45694. }
  45695. } else {
  45696. if (isTextNode(c) && isTextNode(last)) {
  45697. // merge adjacent text nodes
  45698. res[lastIndex] = createTextVNode(last.text + c.text);
  45699. } else {
  45700. // default key for nested array children (likely generated by v-for)
  45701. if (isTrue(children._isVList) &&
  45702. isDef(c.tag) &&
  45703. isUndef(c.key) &&
  45704. isDef(nestedIndex)) {
  45705. c.key = "__vlist" + nestedIndex + "_" + i + "__";
  45706. }
  45707. res.push(c);
  45708. }
  45709. }
  45710. }
  45711. return res
  45712. }
  45713. /* */
  45714. function initProvide (vm) {
  45715. var provide = vm.$options.provide;
  45716. if (provide) {
  45717. vm._provided = typeof provide === 'function'
  45718. ? provide.call(vm)
  45719. : provide;
  45720. }
  45721. }
  45722. function initInjections (vm) {
  45723. var result = resolveInject(vm.$options.inject, vm);
  45724. if (result) {
  45725. toggleObserving(false);
  45726. Object.keys(result).forEach(function (key) {
  45727. /* istanbul ignore else */
  45728. {
  45729. defineReactive$$1(vm, key, result[key], function () {
  45730. warn(
  45731. "Avoid mutating an injected value directly since the changes will be " +
  45732. "overwritten whenever the provided component re-renders. " +
  45733. "injection being mutated: \"" + key + "\"",
  45734. vm
  45735. );
  45736. });
  45737. }
  45738. });
  45739. toggleObserving(true);
  45740. }
  45741. }
  45742. function resolveInject (inject, vm) {
  45743. if (inject) {
  45744. // inject is :any because flow is not smart enough to figure out cached
  45745. var result = Object.create(null);
  45746. var keys = hasSymbol
  45747. ? Reflect.ownKeys(inject)
  45748. : Object.keys(inject);
  45749. for (var i = 0; i < keys.length; i++) {
  45750. var key = keys[i];
  45751. // #6574 in case the inject object is observed...
  45752. if (key === '__ob__') { continue }
  45753. var provideKey = inject[key].from;
  45754. var source = vm;
  45755. while (source) {
  45756. if (source._provided && hasOwn(source._provided, provideKey)) {
  45757. result[key] = source._provided[provideKey];
  45758. break
  45759. }
  45760. source = source.$parent;
  45761. }
  45762. if (!source) {
  45763. if ('default' in inject[key]) {
  45764. var provideDefault = inject[key].default;
  45765. result[key] = typeof provideDefault === 'function'
  45766. ? provideDefault.call(vm)
  45767. : provideDefault;
  45768. } else {
  45769. warn(("Injection \"" + key + "\" not found"), vm);
  45770. }
  45771. }
  45772. }
  45773. return result
  45774. }
  45775. }
  45776. /* */
  45777. /**
  45778. * Runtime helper for resolving raw children VNodes into a slot object.
  45779. */
  45780. function resolveSlots (
  45781. children,
  45782. context
  45783. ) {
  45784. if (!children || !children.length) {
  45785. return {}
  45786. }
  45787. var slots = {};
  45788. for (var i = 0, l = children.length; i < l; i++) {
  45789. var child = children[i];
  45790. var data = child.data;
  45791. // remove slot attribute if the node is resolved as a Vue slot node
  45792. if (data && data.attrs && data.attrs.slot) {
  45793. delete data.attrs.slot;
  45794. }
  45795. // named slots should only be respected if the vnode was rendered in the
  45796. // same context.
  45797. if ((child.context === context || child.fnContext === context) &&
  45798. data && data.slot != null
  45799. ) {
  45800. var name = data.slot;
  45801. var slot = (slots[name] || (slots[name] = []));
  45802. if (child.tag === 'template') {
  45803. slot.push.apply(slot, child.children || []);
  45804. } else {
  45805. slot.push(child);
  45806. }
  45807. } else {
  45808. (slots.default || (slots.default = [])).push(child);
  45809. }
  45810. }
  45811. // ignore slots that contains only whitespace
  45812. for (var name$1 in slots) {
  45813. if (slots[name$1].every(isWhitespace)) {
  45814. delete slots[name$1];
  45815. }
  45816. }
  45817. return slots
  45818. }
  45819. function isWhitespace (node) {
  45820. return (node.isComment && !node.asyncFactory) || node.text === ' '
  45821. }
  45822. /* */
  45823. function normalizeScopedSlots (
  45824. slots,
  45825. normalSlots,
  45826. prevSlots
  45827. ) {
  45828. var res;
  45829. var hasNormalSlots = Object.keys(normalSlots).length > 0;
  45830. var isStable = slots ? !!slots.$stable : !hasNormalSlots;
  45831. var key = slots && slots.$key;
  45832. if (!slots) {
  45833. res = {};
  45834. } else if (slots._normalized) {
  45835. // fast path 1: child component re-render only, parent did not change
  45836. return slots._normalized
  45837. } else if (
  45838. isStable &&
  45839. prevSlots &&
  45840. prevSlots !== emptyObject &&
  45841. key === prevSlots.$key &&
  45842. !hasNormalSlots &&
  45843. !prevSlots.$hasNormal
  45844. ) {
  45845. // fast path 2: stable scoped slots w/ no normal slots to proxy,
  45846. // only need to normalize once
  45847. return prevSlots
  45848. } else {
  45849. res = {};
  45850. for (var key$1 in slots) {
  45851. if (slots[key$1] && key$1[0] !== '$') {
  45852. res[key$1] = normalizeScopedSlot(normalSlots, key$1, slots[key$1]);
  45853. }
  45854. }
  45855. }
  45856. // expose normal slots on scopedSlots
  45857. for (var key$2 in normalSlots) {
  45858. if (!(key$2 in res)) {
  45859. res[key$2] = proxyNormalSlot(normalSlots, key$2);
  45860. }
  45861. }
  45862. // avoriaz seems to mock a non-extensible $scopedSlots object
  45863. // and when that is passed down this would cause an error
  45864. if (slots && Object.isExtensible(slots)) {
  45865. (slots)._normalized = res;
  45866. }
  45867. def(res, '$stable', isStable);
  45868. def(res, '$key', key);
  45869. def(res, '$hasNormal', hasNormalSlots);
  45870. return res
  45871. }
  45872. function normalizeScopedSlot(normalSlots, key, fn) {
  45873. var normalized = function () {
  45874. var res = arguments.length ? fn.apply(null, arguments) : fn({});
  45875. res = res && typeof res === 'object' && !Array.isArray(res)
  45876. ? [res] // single vnode
  45877. : normalizeChildren(res);
  45878. return res && (
  45879. res.length === 0 ||
  45880. (res.length === 1 && res[0].isComment) // #9658
  45881. ) ? undefined
  45882. : res
  45883. };
  45884. // this is a slot using the new v-slot syntax without scope. although it is
  45885. // compiled as a scoped slot, render fn users would expect it to be present
  45886. // on this.$slots because the usage is semantically a normal slot.
  45887. if (fn.proxy) {
  45888. Object.defineProperty(normalSlots, key, {
  45889. get: normalized,
  45890. enumerable: true,
  45891. configurable: true
  45892. });
  45893. }
  45894. return normalized
  45895. }
  45896. function proxyNormalSlot(slots, key) {
  45897. return function () { return slots[key]; }
  45898. }
  45899. /* */
  45900. /**
  45901. * Runtime helper for rendering v-for lists.
  45902. */
  45903. function renderList (
  45904. val,
  45905. render
  45906. ) {
  45907. var ret, i, l, keys, key;
  45908. if (Array.isArray(val) || typeof val === 'string') {
  45909. ret = new Array(val.length);
  45910. for (i = 0, l = val.length; i < l; i++) {
  45911. ret[i] = render(val[i], i);
  45912. }
  45913. } else if (typeof val === 'number') {
  45914. ret = new Array(val);
  45915. for (i = 0; i < val; i++) {
  45916. ret[i] = render(i + 1, i);
  45917. }
  45918. } else if (isObject(val)) {
  45919. if (hasSymbol && val[Symbol.iterator]) {
  45920. ret = [];
  45921. var iterator = val[Symbol.iterator]();
  45922. var result = iterator.next();
  45923. while (!result.done) {
  45924. ret.push(render(result.value, ret.length));
  45925. result = iterator.next();
  45926. }
  45927. } else {
  45928. keys = Object.keys(val);
  45929. ret = new Array(keys.length);
  45930. for (i = 0, l = keys.length; i < l; i++) {
  45931. key = keys[i];
  45932. ret[i] = render(val[key], key, i);
  45933. }
  45934. }
  45935. }
  45936. if (!isDef(ret)) {
  45937. ret = [];
  45938. }
  45939. (ret)._isVList = true;
  45940. return ret
  45941. }
  45942. /* */
  45943. /**
  45944. * Runtime helper for rendering <slot>
  45945. */
  45946. function renderSlot (
  45947. name,
  45948. fallback,
  45949. props,
  45950. bindObject
  45951. ) {
  45952. var scopedSlotFn = this.$scopedSlots[name];
  45953. var nodes;
  45954. if (scopedSlotFn) { // scoped slot
  45955. props = props || {};
  45956. if (bindObject) {
  45957. if (!isObject(bindObject)) {
  45958. warn(
  45959. 'slot v-bind without argument expects an Object',
  45960. this
  45961. );
  45962. }
  45963. props = extend(extend({}, bindObject), props);
  45964. }
  45965. nodes = scopedSlotFn(props) || fallback;
  45966. } else {
  45967. nodes = this.$slots[name] || fallback;
  45968. }
  45969. var target = props && props.slot;
  45970. if (target) {
  45971. return this.$createElement('template', { slot: target }, nodes)
  45972. } else {
  45973. return nodes
  45974. }
  45975. }
  45976. /* */
  45977. /**
  45978. * Runtime helper for resolving filters
  45979. */
  45980. function resolveFilter (id) {
  45981. return resolveAsset(this.$options, 'filters', id, true) || identity
  45982. }
  45983. /* */
  45984. function isKeyNotMatch (expect, actual) {
  45985. if (Array.isArray(expect)) {
  45986. return expect.indexOf(actual) === -1
  45987. } else {
  45988. return expect !== actual
  45989. }
  45990. }
  45991. /**
  45992. * Runtime helper for checking keyCodes from config.
  45993. * exposed as Vue.prototype._k
  45994. * passing in eventKeyName as last argument separately for backwards compat
  45995. */
  45996. function checkKeyCodes (
  45997. eventKeyCode,
  45998. key,
  45999. builtInKeyCode,
  46000. eventKeyName,
  46001. builtInKeyName
  46002. ) {
  46003. var mappedKeyCode = config.keyCodes[key] || builtInKeyCode;
  46004. if (builtInKeyName && eventKeyName && !config.keyCodes[key]) {
  46005. return isKeyNotMatch(builtInKeyName, eventKeyName)
  46006. } else if (mappedKeyCode) {
  46007. return isKeyNotMatch(mappedKeyCode, eventKeyCode)
  46008. } else if (eventKeyName) {
  46009. return hyphenate(eventKeyName) !== key
  46010. }
  46011. }
  46012. /* */
  46013. /**
  46014. * Runtime helper for merging v-bind="object" into a VNode's data.
  46015. */
  46016. function bindObjectProps (
  46017. data,
  46018. tag,
  46019. value,
  46020. asProp,
  46021. isSync
  46022. ) {
  46023. if (value) {
  46024. if (!isObject(value)) {
  46025. warn(
  46026. 'v-bind without argument expects an Object or Array value',
  46027. this
  46028. );
  46029. } else {
  46030. if (Array.isArray(value)) {
  46031. value = toObject(value);
  46032. }
  46033. var hash;
  46034. var loop = function ( key ) {
  46035. if (
  46036. key === 'class' ||
  46037. key === 'style' ||
  46038. isReservedAttribute(key)
  46039. ) {
  46040. hash = data;
  46041. } else {
  46042. var type = data.attrs && data.attrs.type;
  46043. hash = asProp || config.mustUseProp(tag, type, key)
  46044. ? data.domProps || (data.domProps = {})
  46045. : data.attrs || (data.attrs = {});
  46046. }
  46047. var camelizedKey = camelize(key);
  46048. var hyphenatedKey = hyphenate(key);
  46049. if (!(camelizedKey in hash) && !(hyphenatedKey in hash)) {
  46050. hash[key] = value[key];
  46051. if (isSync) {
  46052. var on = data.on || (data.on = {});
  46053. on[("update:" + key)] = function ($event) {
  46054. value[key] = $event;
  46055. };
  46056. }
  46057. }
  46058. };
  46059. for (var key in value) loop( key );
  46060. }
  46061. }
  46062. return data
  46063. }
  46064. /* */
  46065. /**
  46066. * Runtime helper for rendering static trees.
  46067. */
  46068. function renderStatic (
  46069. index,
  46070. isInFor
  46071. ) {
  46072. var cached = this._staticTrees || (this._staticTrees = []);
  46073. var tree = cached[index];
  46074. // if has already-rendered static tree and not inside v-for,
  46075. // we can reuse the same tree.
  46076. if (tree && !isInFor) {
  46077. return tree
  46078. }
  46079. // otherwise, render a fresh tree.
  46080. tree = cached[index] = this.$options.staticRenderFns[index].call(
  46081. this._renderProxy,
  46082. null,
  46083. this // for render fns generated for functional component templates
  46084. );
  46085. markStatic(tree, ("__static__" + index), false);
  46086. return tree
  46087. }
  46088. /**
  46089. * Runtime helper for v-once.
  46090. * Effectively it means marking the node as static with a unique key.
  46091. */
  46092. function markOnce (
  46093. tree,
  46094. index,
  46095. key
  46096. ) {
  46097. markStatic(tree, ("__once__" + index + (key ? ("_" + key) : "")), true);
  46098. return tree
  46099. }
  46100. function markStatic (
  46101. tree,
  46102. key,
  46103. isOnce
  46104. ) {
  46105. if (Array.isArray(tree)) {
  46106. for (var i = 0; i < tree.length; i++) {
  46107. if (tree[i] && typeof tree[i] !== 'string') {
  46108. markStaticNode(tree[i], (key + "_" + i), isOnce);
  46109. }
  46110. }
  46111. } else {
  46112. markStaticNode(tree, key, isOnce);
  46113. }
  46114. }
  46115. function markStaticNode (node, key, isOnce) {
  46116. node.isStatic = true;
  46117. node.key = key;
  46118. node.isOnce = isOnce;
  46119. }
  46120. /* */
  46121. function bindObjectListeners (data, value) {
  46122. if (value) {
  46123. if (!isPlainObject(value)) {
  46124. warn(
  46125. 'v-on without argument expects an Object value',
  46126. this
  46127. );
  46128. } else {
  46129. var on = data.on = data.on ? extend({}, data.on) : {};
  46130. for (var key in value) {
  46131. var existing = on[key];
  46132. var ours = value[key];
  46133. on[key] = existing ? [].concat(existing, ours) : ours;
  46134. }
  46135. }
  46136. }
  46137. return data
  46138. }
  46139. /* */
  46140. function resolveScopedSlots (
  46141. fns, // see flow/vnode
  46142. res,
  46143. // the following are added in 2.6
  46144. hasDynamicKeys,
  46145. contentHashKey
  46146. ) {
  46147. res = res || { $stable: !hasDynamicKeys };
  46148. for (var i = 0; i < fns.length; i++) {
  46149. var slot = fns[i];
  46150. if (Array.isArray(slot)) {
  46151. resolveScopedSlots(slot, res, hasDynamicKeys);
  46152. } else if (slot) {
  46153. // marker for reverse proxying v-slot without scope on this.$slots
  46154. if (slot.proxy) {
  46155. slot.fn.proxy = true;
  46156. }
  46157. res[slot.key] = slot.fn;
  46158. }
  46159. }
  46160. if (contentHashKey) {
  46161. (res).$key = contentHashKey;
  46162. }
  46163. return res
  46164. }
  46165. /* */
  46166. function bindDynamicKeys (baseObj, values) {
  46167. for (var i = 0; i < values.length; i += 2) {
  46168. var key = values[i];
  46169. if (typeof key === 'string' && key) {
  46170. baseObj[values[i]] = values[i + 1];
  46171. } else if (key !== '' && key !== null) {
  46172. // null is a special value for explicitly removing a binding
  46173. warn(
  46174. ("Invalid value for dynamic directive argument (expected string or null): " + key),
  46175. this
  46176. );
  46177. }
  46178. }
  46179. return baseObj
  46180. }
  46181. // helper to dynamically append modifier runtime markers to event names.
  46182. // ensure only append when value is already string, otherwise it will be cast
  46183. // to string and cause the type check to miss.
  46184. function prependModifier (value, symbol) {
  46185. return typeof value === 'string' ? symbol + value : value
  46186. }
  46187. /* */
  46188. function installRenderHelpers (target) {
  46189. target._o = markOnce;
  46190. target._n = toNumber;
  46191. target._s = toString;
  46192. target._l = renderList;
  46193. target._t = renderSlot;
  46194. target._q = looseEqual;
  46195. target._i = looseIndexOf;
  46196. target._m = renderStatic;
  46197. target._f = resolveFilter;
  46198. target._k = checkKeyCodes;
  46199. target._b = bindObjectProps;
  46200. target._v = createTextVNode;
  46201. target._e = createEmptyVNode;
  46202. target._u = resolveScopedSlots;
  46203. target._g = bindObjectListeners;
  46204. target._d = bindDynamicKeys;
  46205. target._p = prependModifier;
  46206. }
  46207. /* */
  46208. function FunctionalRenderContext (
  46209. data,
  46210. props,
  46211. children,
  46212. parent,
  46213. Ctor
  46214. ) {
  46215. var this$1 = this;
  46216. var options = Ctor.options;
  46217. // ensure the createElement function in functional components
  46218. // gets a unique context - this is necessary for correct named slot check
  46219. var contextVm;
  46220. if (hasOwn(parent, '_uid')) {
  46221. contextVm = Object.create(parent);
  46222. // $flow-disable-line
  46223. contextVm._original = parent;
  46224. } else {
  46225. // the context vm passed in is a functional context as well.
  46226. // in this case we want to make sure we are able to get a hold to the
  46227. // real context instance.
  46228. contextVm = parent;
  46229. // $flow-disable-line
  46230. parent = parent._original;
  46231. }
  46232. var isCompiled = isTrue(options._compiled);
  46233. var needNormalization = !isCompiled;
  46234. this.data = data;
  46235. this.props = props;
  46236. this.children = children;
  46237. this.parent = parent;
  46238. this.listeners = data.on || emptyObject;
  46239. this.injections = resolveInject(options.inject, parent);
  46240. this.slots = function () {
  46241. if (!this$1.$slots) {
  46242. normalizeScopedSlots(
  46243. data.scopedSlots,
  46244. this$1.$slots = resolveSlots(children, parent)
  46245. );
  46246. }
  46247. return this$1.$slots
  46248. };
  46249. Object.defineProperty(this, 'scopedSlots', ({
  46250. enumerable: true,
  46251. get: function get () {
  46252. return normalizeScopedSlots(data.scopedSlots, this.slots())
  46253. }
  46254. }));
  46255. // support for compiled functional template
  46256. if (isCompiled) {
  46257. // exposing $options for renderStatic()
  46258. this.$options = options;
  46259. // pre-resolve slots for renderSlot()
  46260. this.$slots = this.slots();
  46261. this.$scopedSlots = normalizeScopedSlots(data.scopedSlots, this.$slots);
  46262. }
  46263. if (options._scopeId) {
  46264. this._c = function (a, b, c, d) {
  46265. var vnode = createElement(contextVm, a, b, c, d, needNormalization);
  46266. if (vnode && !Array.isArray(vnode)) {
  46267. vnode.fnScopeId = options._scopeId;
  46268. vnode.fnContext = parent;
  46269. }
  46270. return vnode
  46271. };
  46272. } else {
  46273. this._c = function (a, b, c, d) { return createElement(contextVm, a, b, c, d, needNormalization); };
  46274. }
  46275. }
  46276. installRenderHelpers(FunctionalRenderContext.prototype);
  46277. function createFunctionalComponent (
  46278. Ctor,
  46279. propsData,
  46280. data,
  46281. contextVm,
  46282. children
  46283. ) {
  46284. var options = Ctor.options;
  46285. var props = {};
  46286. var propOptions = options.props;
  46287. if (isDef(propOptions)) {
  46288. for (var key in propOptions) {
  46289. props[key] = validateProp(key, propOptions, propsData || emptyObject);
  46290. }
  46291. } else {
  46292. if (isDef(data.attrs)) { mergeProps(props, data.attrs); }
  46293. if (isDef(data.props)) { mergeProps(props, data.props); }
  46294. }
  46295. var renderContext = new FunctionalRenderContext(
  46296. data,
  46297. props,
  46298. children,
  46299. contextVm,
  46300. Ctor
  46301. );
  46302. var vnode = options.render.call(null, renderContext._c, renderContext);
  46303. if (vnode instanceof VNode) {
  46304. return cloneAndMarkFunctionalResult(vnode, data, renderContext.parent, options, renderContext)
  46305. } else if (Array.isArray(vnode)) {
  46306. var vnodes = normalizeChildren(vnode) || [];
  46307. var res = new Array(vnodes.length);
  46308. for (var i = 0; i < vnodes.length; i++) {
  46309. res[i] = cloneAndMarkFunctionalResult(vnodes[i], data, renderContext.parent, options, renderContext);
  46310. }
  46311. return res
  46312. }
  46313. }
  46314. function cloneAndMarkFunctionalResult (vnode, data, contextVm, options, renderContext) {
  46315. // #7817 clone node before setting fnContext, otherwise if the node is reused
  46316. // (e.g. it was from a cached normal slot) the fnContext causes named slots
  46317. // that should not be matched to match.
  46318. var clone = cloneVNode(vnode);
  46319. clone.fnContext = contextVm;
  46320. clone.fnOptions = options;
  46321. {
  46322. (clone.devtoolsMeta = clone.devtoolsMeta || {}).renderContext = renderContext;
  46323. }
  46324. if (data.slot) {
  46325. (clone.data || (clone.data = {})).slot = data.slot;
  46326. }
  46327. return clone
  46328. }
  46329. function mergeProps (to, from) {
  46330. for (var key in from) {
  46331. to[camelize(key)] = from[key];
  46332. }
  46333. }
  46334. /* */
  46335. /* */
  46336. /* */
  46337. /* */
  46338. // inline hooks to be invoked on component VNodes during patch
  46339. var componentVNodeHooks = {
  46340. init: function init (vnode, hydrating) {
  46341. if (
  46342. vnode.componentInstance &&
  46343. !vnode.componentInstance._isDestroyed &&
  46344. vnode.data.keepAlive
  46345. ) {
  46346. // kept-alive components, treat as a patch
  46347. var mountedNode = vnode; // work around flow
  46348. componentVNodeHooks.prepatch(mountedNode, mountedNode);
  46349. } else {
  46350. var child = vnode.componentInstance = createComponentInstanceForVnode(
  46351. vnode,
  46352. activeInstance
  46353. );
  46354. child.$mount(hydrating ? vnode.elm : undefined, hydrating);
  46355. }
  46356. },
  46357. prepatch: function prepatch (oldVnode, vnode) {
  46358. var options = vnode.componentOptions;
  46359. var child = vnode.componentInstance = oldVnode.componentInstance;
  46360. updateChildComponent(
  46361. child,
  46362. options.propsData, // updated props
  46363. options.listeners, // updated listeners
  46364. vnode, // new parent vnode
  46365. options.children // new children
  46366. );
  46367. },
  46368. insert: function insert (vnode) {
  46369. var context = vnode.context;
  46370. var componentInstance = vnode.componentInstance;
  46371. if (!componentInstance._isMounted) {
  46372. componentInstance._isMounted = true;
  46373. callHook(componentInstance, 'mounted');
  46374. }
  46375. if (vnode.data.keepAlive) {
  46376. if (context._isMounted) {
  46377. // vue-router#1212
  46378. // During updates, a kept-alive component's child components may
  46379. // change, so directly walking the tree here may call activated hooks
  46380. // on incorrect children. Instead we push them into a queue which will
  46381. // be processed after the whole patch process ended.
  46382. queueActivatedComponent(componentInstance);
  46383. } else {
  46384. activateChildComponent(componentInstance, true /* direct */);
  46385. }
  46386. }
  46387. },
  46388. destroy: function destroy (vnode) {
  46389. var componentInstance = vnode.componentInstance;
  46390. if (!componentInstance._isDestroyed) {
  46391. if (!vnode.data.keepAlive) {
  46392. componentInstance.$destroy();
  46393. } else {
  46394. deactivateChildComponent(componentInstance, true /* direct */);
  46395. }
  46396. }
  46397. }
  46398. };
  46399. var hooksToMerge = Object.keys(componentVNodeHooks);
  46400. function createComponent (
  46401. Ctor,
  46402. data,
  46403. context,
  46404. children,
  46405. tag
  46406. ) {
  46407. if (isUndef(Ctor)) {
  46408. return
  46409. }
  46410. var baseCtor = context.$options._base;
  46411. // plain options object: turn it into a constructor
  46412. if (isObject(Ctor)) {
  46413. Ctor = baseCtor.extend(Ctor);
  46414. }
  46415. // if at this stage it's not a constructor or an async component factory,
  46416. // reject.
  46417. if (typeof Ctor !== 'function') {
  46418. {
  46419. warn(("Invalid Component definition: " + (String(Ctor))), context);
  46420. }
  46421. return
  46422. }
  46423. // async component
  46424. var asyncFactory;
  46425. if (isUndef(Ctor.cid)) {
  46426. asyncFactory = Ctor;
  46427. Ctor = resolveAsyncComponent(asyncFactory, baseCtor);
  46428. if (Ctor === undefined) {
  46429. // return a placeholder node for async component, which is rendered
  46430. // as a comment node but preserves all the raw information for the node.
  46431. // the information will be used for async server-rendering and hydration.
  46432. return createAsyncPlaceholder(
  46433. asyncFactory,
  46434. data,
  46435. context,
  46436. children,
  46437. tag
  46438. )
  46439. }
  46440. }
  46441. data = data || {};
  46442. // resolve constructor options in case global mixins are applied after
  46443. // component constructor creation
  46444. resolveConstructorOptions(Ctor);
  46445. // transform component v-model data into props & events
  46446. if (isDef(data.model)) {
  46447. transformModel(Ctor.options, data);
  46448. }
  46449. // extract props
  46450. var propsData = extractPropsFromVNodeData(data, Ctor, tag);
  46451. // functional component
  46452. if (isTrue(Ctor.options.functional)) {
  46453. return createFunctionalComponent(Ctor, propsData, data, context, children)
  46454. }
  46455. // extract listeners, since these needs to be treated as
  46456. // child component listeners instead of DOM listeners
  46457. var listeners = data.on;
  46458. // replace with listeners with .native modifier
  46459. // so it gets processed during parent component patch.
  46460. data.on = data.nativeOn;
  46461. if (isTrue(Ctor.options.abstract)) {
  46462. // abstract components do not keep anything
  46463. // other than props & listeners & slot
  46464. // work around flow
  46465. var slot = data.slot;
  46466. data = {};
  46467. if (slot) {
  46468. data.slot = slot;
  46469. }
  46470. }
  46471. // install component management hooks onto the placeholder node
  46472. installComponentHooks(data);
  46473. // return a placeholder vnode
  46474. var name = Ctor.options.name || tag;
  46475. var vnode = new VNode(
  46476. ("vue-component-" + (Ctor.cid) + (name ? ("-" + name) : '')),
  46477. data, undefined, undefined, undefined, context,
  46478. { Ctor: Ctor, propsData: propsData, listeners: listeners, tag: tag, children: children },
  46479. asyncFactory
  46480. );
  46481. return vnode
  46482. }
  46483. function createComponentInstanceForVnode (
  46484. vnode, // we know it's MountedComponentVNode but flow doesn't
  46485. parent // activeInstance in lifecycle state
  46486. ) {
  46487. var options = {
  46488. _isComponent: true,
  46489. _parentVnode: vnode,
  46490. parent: parent
  46491. };
  46492. // check inline-template render functions
  46493. var inlineTemplate = vnode.data.inlineTemplate;
  46494. if (isDef(inlineTemplate)) {
  46495. options.render = inlineTemplate.render;
  46496. options.staticRenderFns = inlineTemplate.staticRenderFns;
  46497. }
  46498. return new vnode.componentOptions.Ctor(options)
  46499. }
  46500. function installComponentHooks (data) {
  46501. var hooks = data.hook || (data.hook = {});
  46502. for (var i = 0; i < hooksToMerge.length; i++) {
  46503. var key = hooksToMerge[i];
  46504. var existing = hooks[key];
  46505. var toMerge = componentVNodeHooks[key];
  46506. if (existing !== toMerge && !(existing && existing._merged)) {
  46507. hooks[key] = existing ? mergeHook$1(toMerge, existing) : toMerge;
  46508. }
  46509. }
  46510. }
  46511. function mergeHook$1 (f1, f2) {
  46512. var merged = function (a, b) {
  46513. // flow complains about extra args which is why we use any
  46514. f1(a, b);
  46515. f2(a, b);
  46516. };
  46517. merged._merged = true;
  46518. return merged
  46519. }
  46520. // transform component v-model info (value and callback) into
  46521. // prop and event handler respectively.
  46522. function transformModel (options, data) {
  46523. var prop = (options.model && options.model.prop) || 'value';
  46524. var event = (options.model && options.model.event) || 'input'
  46525. ;(data.attrs || (data.attrs = {}))[prop] = data.model.value;
  46526. var on = data.on || (data.on = {});
  46527. var existing = on[event];
  46528. var callback = data.model.callback;
  46529. if (isDef(existing)) {
  46530. if (
  46531. Array.isArray(existing)
  46532. ? existing.indexOf(callback) === -1
  46533. : existing !== callback
  46534. ) {
  46535. on[event] = [callback].concat(existing);
  46536. }
  46537. } else {
  46538. on[event] = callback;
  46539. }
  46540. }
  46541. /* */
  46542. var SIMPLE_NORMALIZE = 1;
  46543. var ALWAYS_NORMALIZE = 2;
  46544. // wrapper function for providing a more flexible interface
  46545. // without getting yelled at by flow
  46546. function createElement (
  46547. context,
  46548. tag,
  46549. data,
  46550. children,
  46551. normalizationType,
  46552. alwaysNormalize
  46553. ) {
  46554. if (Array.isArray(data) || isPrimitive(data)) {
  46555. normalizationType = children;
  46556. children = data;
  46557. data = undefined;
  46558. }
  46559. if (isTrue(alwaysNormalize)) {
  46560. normalizationType = ALWAYS_NORMALIZE;
  46561. }
  46562. return _createElement(context, tag, data, children, normalizationType)
  46563. }
  46564. function _createElement (
  46565. context,
  46566. tag,
  46567. data,
  46568. children,
  46569. normalizationType
  46570. ) {
  46571. if (isDef(data) && isDef((data).__ob__)) {
  46572. warn(
  46573. "Avoid using observed data object as vnode data: " + (JSON.stringify(data)) + "\n" +
  46574. 'Always create fresh vnode data objects in each render!',
  46575. context
  46576. );
  46577. return createEmptyVNode()
  46578. }
  46579. // object syntax in v-bind
  46580. if (isDef(data) && isDef(data.is)) {
  46581. tag = data.is;
  46582. }
  46583. if (!tag) {
  46584. // in case of component :is set to falsy value
  46585. return createEmptyVNode()
  46586. }
  46587. // warn against non-primitive key
  46588. if (isDef(data) && isDef(data.key) && !isPrimitive(data.key)
  46589. ) {
  46590. {
  46591. warn(
  46592. 'Avoid using non-primitive value as key, ' +
  46593. 'use string/number value instead.',
  46594. context
  46595. );
  46596. }
  46597. }
  46598. // support single function children as default scoped slot
  46599. if (Array.isArray(children) &&
  46600. typeof children[0] === 'function'
  46601. ) {
  46602. data = data || {};
  46603. data.scopedSlots = { default: children[0] };
  46604. children.length = 0;
  46605. }
  46606. if (normalizationType === ALWAYS_NORMALIZE) {
  46607. children = normalizeChildren(children);
  46608. } else if (normalizationType === SIMPLE_NORMALIZE) {
  46609. children = simpleNormalizeChildren(children);
  46610. }
  46611. var vnode, ns;
  46612. if (typeof tag === 'string') {
  46613. var Ctor;
  46614. ns = (context.$vnode && context.$vnode.ns) || config.getTagNamespace(tag);
  46615. if (config.isReservedTag(tag)) {
  46616. // platform built-in elements
  46617. if (isDef(data) && isDef(data.nativeOn)) {
  46618. warn(
  46619. ("The .native modifier for v-on is only valid on components but it was used on <" + tag + ">."),
  46620. context
  46621. );
  46622. }
  46623. vnode = new VNode(
  46624. config.parsePlatformTagName(tag), data, children,
  46625. undefined, undefined, context
  46626. );
  46627. } else if ((!data || !data.pre) && isDef(Ctor = resolveAsset(context.$options, 'components', tag))) {
  46628. // component
  46629. vnode = createComponent(Ctor, data, context, children, tag);
  46630. } else {
  46631. // unknown or unlisted namespaced elements
  46632. // check at runtime because it may get assigned a namespace when its
  46633. // parent normalizes children
  46634. vnode = new VNode(
  46635. tag, data, children,
  46636. undefined, undefined, context
  46637. );
  46638. }
  46639. } else {
  46640. // direct component options / constructor
  46641. vnode = createComponent(tag, data, context, children);
  46642. }
  46643. if (Array.isArray(vnode)) {
  46644. return vnode
  46645. } else if (isDef(vnode)) {
  46646. if (isDef(ns)) { applyNS(vnode, ns); }
  46647. if (isDef(data)) { registerDeepBindings(data); }
  46648. return vnode
  46649. } else {
  46650. return createEmptyVNode()
  46651. }
  46652. }
  46653. function applyNS (vnode, ns, force) {
  46654. vnode.ns = ns;
  46655. if (vnode.tag === 'foreignObject') {
  46656. // use default namespace inside foreignObject
  46657. ns = undefined;
  46658. force = true;
  46659. }
  46660. if (isDef(vnode.children)) {
  46661. for (var i = 0, l = vnode.children.length; i < l; i++) {
  46662. var child = vnode.children[i];
  46663. if (isDef(child.tag) && (
  46664. isUndef(child.ns) || (isTrue(force) && child.tag !== 'svg'))) {
  46665. applyNS(child, ns, force);
  46666. }
  46667. }
  46668. }
  46669. }
  46670. // ref #5318
  46671. // necessary to ensure parent re-render when deep bindings like :style and
  46672. // :class are used on slot nodes
  46673. function registerDeepBindings (data) {
  46674. if (isObject(data.style)) {
  46675. traverse(data.style);
  46676. }
  46677. if (isObject(data.class)) {
  46678. traverse(data.class);
  46679. }
  46680. }
  46681. /* */
  46682. function initRender (vm) {
  46683. vm._vnode = null; // the root of the child tree
  46684. vm._staticTrees = null; // v-once cached trees
  46685. var options = vm.$options;
  46686. var parentVnode = vm.$vnode = options._parentVnode; // the placeholder node in parent tree
  46687. var renderContext = parentVnode && parentVnode.context;
  46688. vm.$slots = resolveSlots(options._renderChildren, renderContext);
  46689. vm.$scopedSlots = emptyObject;
  46690. // bind the createElement fn to this instance
  46691. // so that we get proper render context inside it.
  46692. // args order: tag, data, children, normalizationType, alwaysNormalize
  46693. // internal version is used by render functions compiled from templates
  46694. vm._c = function (a, b, c, d) { return createElement(vm, a, b, c, d, false); };
  46695. // normalization is always applied for the public version, used in
  46696. // user-written render functions.
  46697. vm.$createElement = function (a, b, c, d) { return createElement(vm, a, b, c, d, true); };
  46698. // $attrs & $listeners are exposed for easier HOC creation.
  46699. // they need to be reactive so that HOCs using them are always updated
  46700. var parentData = parentVnode && parentVnode.data;
  46701. /* istanbul ignore else */
  46702. {
  46703. defineReactive$$1(vm, '$attrs', parentData && parentData.attrs || emptyObject, function () {
  46704. !isUpdatingChildComponent && warn("$attrs is readonly.", vm);
  46705. }, true);
  46706. defineReactive$$1(vm, '$listeners', options._parentListeners || emptyObject, function () {
  46707. !isUpdatingChildComponent && warn("$listeners is readonly.", vm);
  46708. }, true);
  46709. }
  46710. }
  46711. var currentRenderingInstance = null;
  46712. function renderMixin (Vue) {
  46713. // install runtime convenience helpers
  46714. installRenderHelpers(Vue.prototype);
  46715. Vue.prototype.$nextTick = function (fn) {
  46716. return nextTick(fn, this)
  46717. };
  46718. Vue.prototype._render = function () {
  46719. var vm = this;
  46720. var ref = vm.$options;
  46721. var render = ref.render;
  46722. var _parentVnode = ref._parentVnode;
  46723. if (_parentVnode) {
  46724. vm.$scopedSlots = normalizeScopedSlots(
  46725. _parentVnode.data.scopedSlots,
  46726. vm.$slots,
  46727. vm.$scopedSlots
  46728. );
  46729. }
  46730. // set parent vnode. this allows render functions to have access
  46731. // to the data on the placeholder node.
  46732. vm.$vnode = _parentVnode;
  46733. // render self
  46734. var vnode;
  46735. try {
  46736. // There's no need to maintain a stack because all render fns are called
  46737. // separately from one another. Nested component's render fns are called
  46738. // when parent component is patched.
  46739. currentRenderingInstance = vm;
  46740. vnode = render.call(vm._renderProxy, vm.$createElement);
  46741. } catch (e) {
  46742. handleError(e, vm, "render");
  46743. // return error render result,
  46744. // or previous vnode to prevent render error causing blank component
  46745. /* istanbul ignore else */
  46746. if (vm.$options.renderError) {
  46747. try {
  46748. vnode = vm.$options.renderError.call(vm._renderProxy, vm.$createElement, e);
  46749. } catch (e) {
  46750. handleError(e, vm, "renderError");
  46751. vnode = vm._vnode;
  46752. }
  46753. } else {
  46754. vnode = vm._vnode;
  46755. }
  46756. } finally {
  46757. currentRenderingInstance = null;
  46758. }
  46759. // if the returned array contains only a single node, allow it
  46760. if (Array.isArray(vnode) && vnode.length === 1) {
  46761. vnode = vnode[0];
  46762. }
  46763. // return empty vnode in case the render function errored out
  46764. if (!(vnode instanceof VNode)) {
  46765. if (Array.isArray(vnode)) {
  46766. warn(
  46767. 'Multiple root nodes returned from render function. Render function ' +
  46768. 'should return a single root node.',
  46769. vm
  46770. );
  46771. }
  46772. vnode = createEmptyVNode();
  46773. }
  46774. // set parent
  46775. vnode.parent = _parentVnode;
  46776. return vnode
  46777. };
  46778. }
  46779. /* */
  46780. function ensureCtor (comp, base) {
  46781. if (
  46782. comp.__esModule ||
  46783. (hasSymbol && comp[Symbol.toStringTag] === 'Module')
  46784. ) {
  46785. comp = comp.default;
  46786. }
  46787. return isObject(comp)
  46788. ? base.extend(comp)
  46789. : comp
  46790. }
  46791. function createAsyncPlaceholder (
  46792. factory,
  46793. data,
  46794. context,
  46795. children,
  46796. tag
  46797. ) {
  46798. var node = createEmptyVNode();
  46799. node.asyncFactory = factory;
  46800. node.asyncMeta = { data: data, context: context, children: children, tag: tag };
  46801. return node
  46802. }
  46803. function resolveAsyncComponent (
  46804. factory,
  46805. baseCtor
  46806. ) {
  46807. if (isTrue(factory.error) && isDef(factory.errorComp)) {
  46808. return factory.errorComp
  46809. }
  46810. if (isDef(factory.resolved)) {
  46811. return factory.resolved
  46812. }
  46813. var owner = currentRenderingInstance;
  46814. if (owner && isDef(factory.owners) && factory.owners.indexOf(owner) === -1) {
  46815. // already pending
  46816. factory.owners.push(owner);
  46817. }
  46818. if (isTrue(factory.loading) && isDef(factory.loadingComp)) {
  46819. return factory.loadingComp
  46820. }
  46821. if (owner && !isDef(factory.owners)) {
  46822. var owners = factory.owners = [owner];
  46823. var sync = true;
  46824. var timerLoading = null;
  46825. var timerTimeout = null
  46826. ;(owner).$on('hook:destroyed', function () { return remove(owners, owner); });
  46827. var forceRender = function (renderCompleted) {
  46828. for (var i = 0, l = owners.length; i < l; i++) {
  46829. (owners[i]).$forceUpdate();
  46830. }
  46831. if (renderCompleted) {
  46832. owners.length = 0;
  46833. if (timerLoading !== null) {
  46834. clearTimeout(timerLoading);
  46835. timerLoading = null;
  46836. }
  46837. if (timerTimeout !== null) {
  46838. clearTimeout(timerTimeout);
  46839. timerTimeout = null;
  46840. }
  46841. }
  46842. };
  46843. var resolve = once(function (res) {
  46844. // cache resolved
  46845. factory.resolved = ensureCtor(res, baseCtor);
  46846. // invoke callbacks only if this is not a synchronous resolve
  46847. // (async resolves are shimmed as synchronous during SSR)
  46848. if (!sync) {
  46849. forceRender(true);
  46850. } else {
  46851. owners.length = 0;
  46852. }
  46853. });
  46854. var reject = once(function (reason) {
  46855. warn(
  46856. "Failed to resolve async component: " + (String(factory)) +
  46857. (reason ? ("\nReason: " + reason) : '')
  46858. );
  46859. if (isDef(factory.errorComp)) {
  46860. factory.error = true;
  46861. forceRender(true);
  46862. }
  46863. });
  46864. var res = factory(resolve, reject);
  46865. if (isObject(res)) {
  46866. if (isPromise(res)) {
  46867. // () => Promise
  46868. if (isUndef(factory.resolved)) {
  46869. res.then(resolve, reject);
  46870. }
  46871. } else if (isPromise(res.component)) {
  46872. res.component.then(resolve, reject);
  46873. if (isDef(res.error)) {
  46874. factory.errorComp = ensureCtor(res.error, baseCtor);
  46875. }
  46876. if (isDef(res.loading)) {
  46877. factory.loadingComp = ensureCtor(res.loading, baseCtor);
  46878. if (res.delay === 0) {
  46879. factory.loading = true;
  46880. } else {
  46881. timerLoading = setTimeout(function () {
  46882. timerLoading = null;
  46883. if (isUndef(factory.resolved) && isUndef(factory.error)) {
  46884. factory.loading = true;
  46885. forceRender(false);
  46886. }
  46887. }, res.delay || 200);
  46888. }
  46889. }
  46890. if (isDef(res.timeout)) {
  46891. timerTimeout = setTimeout(function () {
  46892. timerTimeout = null;
  46893. if (isUndef(factory.resolved)) {
  46894. reject(
  46895. "timeout (" + (res.timeout) + "ms)"
  46896. );
  46897. }
  46898. }, res.timeout);
  46899. }
  46900. }
  46901. }
  46902. sync = false;
  46903. // return in case resolved synchronously
  46904. return factory.loading
  46905. ? factory.loadingComp
  46906. : factory.resolved
  46907. }
  46908. }
  46909. /* */
  46910. function isAsyncPlaceholder (node) {
  46911. return node.isComment && node.asyncFactory
  46912. }
  46913. /* */
  46914. function getFirstComponentChild (children) {
  46915. if (Array.isArray(children)) {
  46916. for (var i = 0; i < children.length; i++) {
  46917. var c = children[i];
  46918. if (isDef(c) && (isDef(c.componentOptions) || isAsyncPlaceholder(c))) {
  46919. return c
  46920. }
  46921. }
  46922. }
  46923. }
  46924. /* */
  46925. /* */
  46926. function initEvents (vm) {
  46927. vm._events = Object.create(null);
  46928. vm._hasHookEvent = false;
  46929. // init parent attached events
  46930. var listeners = vm.$options._parentListeners;
  46931. if (listeners) {
  46932. updateComponentListeners(vm, listeners);
  46933. }
  46934. }
  46935. var target;
  46936. function add (event, fn) {
  46937. target.$on(event, fn);
  46938. }
  46939. function remove$1 (event, fn) {
  46940. target.$off(event, fn);
  46941. }
  46942. function createOnceHandler (event, fn) {
  46943. var _target = target;
  46944. return function onceHandler () {
  46945. var res = fn.apply(null, arguments);
  46946. if (res !== null) {
  46947. _target.$off(event, onceHandler);
  46948. }
  46949. }
  46950. }
  46951. function updateComponentListeners (
  46952. vm,
  46953. listeners,
  46954. oldListeners
  46955. ) {
  46956. target = vm;
  46957. updateListeners(listeners, oldListeners || {}, add, remove$1, createOnceHandler, vm);
  46958. target = undefined;
  46959. }
  46960. function eventsMixin (Vue) {
  46961. var hookRE = /^hook:/;
  46962. Vue.prototype.$on = function (event, fn) {
  46963. var vm = this;
  46964. if (Array.isArray(event)) {
  46965. for (var i = 0, l = event.length; i < l; i++) {
  46966. vm.$on(event[i], fn);
  46967. }
  46968. } else {
  46969. (vm._events[event] || (vm._events[event] = [])).push(fn);
  46970. // optimize hook:event cost by using a boolean flag marked at registration
  46971. // instead of a hash lookup
  46972. if (hookRE.test(event)) {
  46973. vm._hasHookEvent = true;
  46974. }
  46975. }
  46976. return vm
  46977. };
  46978. Vue.prototype.$once = function (event, fn) {
  46979. var vm = this;
  46980. function on () {
  46981. vm.$off(event, on);
  46982. fn.apply(vm, arguments);
  46983. }
  46984. on.fn = fn;
  46985. vm.$on(event, on);
  46986. return vm
  46987. };
  46988. Vue.prototype.$off = function (event, fn) {
  46989. var vm = this;
  46990. // all
  46991. if (!arguments.length) {
  46992. vm._events = Object.create(null);
  46993. return vm
  46994. }
  46995. // array of events
  46996. if (Array.isArray(event)) {
  46997. for (var i$1 = 0, l = event.length; i$1 < l; i$1++) {
  46998. vm.$off(event[i$1], fn);
  46999. }
  47000. return vm
  47001. }
  47002. // specific event
  47003. var cbs = vm._events[event];
  47004. if (!cbs) {
  47005. return vm
  47006. }
  47007. if (!fn) {
  47008. vm._events[event] = null;
  47009. return vm
  47010. }
  47011. // specific handler
  47012. var cb;
  47013. var i = cbs.length;
  47014. while (i--) {
  47015. cb = cbs[i];
  47016. if (cb === fn || cb.fn === fn) {
  47017. cbs.splice(i, 1);
  47018. break
  47019. }
  47020. }
  47021. return vm
  47022. };
  47023. Vue.prototype.$emit = function (event) {
  47024. var vm = this;
  47025. {
  47026. var lowerCaseEvent = event.toLowerCase();
  47027. if (lowerCaseEvent !== event && vm._events[lowerCaseEvent]) {
  47028. tip(
  47029. "Event \"" + lowerCaseEvent + "\" is emitted in component " +
  47030. (formatComponentName(vm)) + " but the handler is registered for \"" + event + "\". " +
  47031. "Note that HTML attributes are case-insensitive and you cannot use " +
  47032. "v-on to listen to camelCase events when using in-DOM templates. " +
  47033. "You should probably use \"" + (hyphenate(event)) + "\" instead of \"" + event + "\"."
  47034. );
  47035. }
  47036. }
  47037. var cbs = vm._events[event];
  47038. if (cbs) {
  47039. cbs = cbs.length > 1 ? toArray(cbs) : cbs;
  47040. var args = toArray(arguments, 1);
  47041. var info = "event handler for \"" + event + "\"";
  47042. for (var i = 0, l = cbs.length; i < l; i++) {
  47043. invokeWithErrorHandling(cbs[i], vm, args, vm, info);
  47044. }
  47045. }
  47046. return vm
  47047. };
  47048. }
  47049. /* */
  47050. var activeInstance = null;
  47051. var isUpdatingChildComponent = false;
  47052. function setActiveInstance(vm) {
  47053. var prevActiveInstance = activeInstance;
  47054. activeInstance = vm;
  47055. return function () {
  47056. activeInstance = prevActiveInstance;
  47057. }
  47058. }
  47059. function initLifecycle (vm) {
  47060. var options = vm.$options;
  47061. // locate first non-abstract parent
  47062. var parent = options.parent;
  47063. if (parent && !options.abstract) {
  47064. while (parent.$options.abstract && parent.$parent) {
  47065. parent = parent.$parent;
  47066. }
  47067. parent.$children.push(vm);
  47068. }
  47069. vm.$parent = parent;
  47070. vm.$root = parent ? parent.$root : vm;
  47071. vm.$children = [];
  47072. vm.$refs = {};
  47073. vm._watcher = null;
  47074. vm._inactive = null;
  47075. vm._directInactive = false;
  47076. vm._isMounted = false;
  47077. vm._isDestroyed = false;
  47078. vm._isBeingDestroyed = false;
  47079. }
  47080. function lifecycleMixin (Vue) {
  47081. Vue.prototype._update = function (vnode, hydrating) {
  47082. var vm = this;
  47083. var prevEl = vm.$el;
  47084. var prevVnode = vm._vnode;
  47085. var restoreActiveInstance = setActiveInstance(vm);
  47086. vm._vnode = vnode;
  47087. // Vue.prototype.__patch__ is injected in entry points
  47088. // based on the rendering backend used.
  47089. if (!prevVnode) {
  47090. // initial render
  47091. vm.$el = vm.__patch__(vm.$el, vnode, hydrating, false /* removeOnly */);
  47092. } else {
  47093. // updates
  47094. vm.$el = vm.__patch__(prevVnode, vnode);
  47095. }
  47096. restoreActiveInstance();
  47097. // update __vue__ reference
  47098. if (prevEl) {
  47099. prevEl.__vue__ = null;
  47100. }
  47101. if (vm.$el) {
  47102. vm.$el.__vue__ = vm;
  47103. }
  47104. // if parent is an HOC, update its $el as well
  47105. if (vm.$vnode && vm.$parent && vm.$vnode === vm.$parent._vnode) {
  47106. vm.$parent.$el = vm.$el;
  47107. }
  47108. // updated hook is called by the scheduler to ensure that children are
  47109. // updated in a parent's updated hook.
  47110. };
  47111. Vue.prototype.$forceUpdate = function () {
  47112. var vm = this;
  47113. if (vm._watcher) {
  47114. vm._watcher.update();
  47115. }
  47116. };
  47117. Vue.prototype.$destroy = function () {
  47118. var vm = this;
  47119. if (vm._isBeingDestroyed) {
  47120. return
  47121. }
  47122. callHook(vm, 'beforeDestroy');
  47123. vm._isBeingDestroyed = true;
  47124. // remove self from parent
  47125. var parent = vm.$parent;
  47126. if (parent && !parent._isBeingDestroyed && !vm.$options.abstract) {
  47127. remove(parent.$children, vm);
  47128. }
  47129. // teardown watchers
  47130. if (vm._watcher) {
  47131. vm._watcher.teardown();
  47132. }
  47133. var i = vm._watchers.length;
  47134. while (i--) {
  47135. vm._watchers[i].teardown();
  47136. }
  47137. // remove reference from data ob
  47138. // frozen object may not have observer.
  47139. if (vm._data.__ob__) {
  47140. vm._data.__ob__.vmCount--;
  47141. }
  47142. // call the last hook...
  47143. vm._isDestroyed = true;
  47144. // invoke destroy hooks on current rendered tree
  47145. vm.__patch__(vm._vnode, null);
  47146. // fire destroyed hook
  47147. callHook(vm, 'destroyed');
  47148. // turn off all instance listeners.
  47149. vm.$off();
  47150. // remove __vue__ reference
  47151. if (vm.$el) {
  47152. vm.$el.__vue__ = null;
  47153. }
  47154. // release circular reference (#6759)
  47155. if (vm.$vnode) {
  47156. vm.$vnode.parent = null;
  47157. }
  47158. };
  47159. }
  47160. function mountComponent (
  47161. vm,
  47162. el,
  47163. hydrating
  47164. ) {
  47165. vm.$el = el;
  47166. if (!vm.$options.render) {
  47167. vm.$options.render = createEmptyVNode;
  47168. {
  47169. /* istanbul ignore if */
  47170. if ((vm.$options.template && vm.$options.template.charAt(0) !== '#') ||
  47171. vm.$options.el || el) {
  47172. warn(
  47173. 'You are using the runtime-only build of Vue where the template ' +
  47174. 'compiler is not available. Either pre-compile the templates into ' +
  47175. 'render functions, or use the compiler-included build.',
  47176. vm
  47177. );
  47178. } else {
  47179. warn(
  47180. 'Failed to mount component: template or render function not defined.',
  47181. vm
  47182. );
  47183. }
  47184. }
  47185. }
  47186. callHook(vm, 'beforeMount');
  47187. var updateComponent;
  47188. /* istanbul ignore if */
  47189. if (config.performance && mark) {
  47190. updateComponent = function () {
  47191. var name = vm._name;
  47192. var id = vm._uid;
  47193. var startTag = "vue-perf-start:" + id;
  47194. var endTag = "vue-perf-end:" + id;
  47195. mark(startTag);
  47196. var vnode = vm._render();
  47197. mark(endTag);
  47198. measure(("vue " + name + " render"), startTag, endTag);
  47199. mark(startTag);
  47200. vm._update(vnode, hydrating);
  47201. mark(endTag);
  47202. measure(("vue " + name + " patch"), startTag, endTag);
  47203. };
  47204. } else {
  47205. updateComponent = function () {
  47206. vm._update(vm._render(), hydrating);
  47207. };
  47208. }
  47209. // we set this to vm._watcher inside the watcher's constructor
  47210. // since the watcher's initial patch may call $forceUpdate (e.g. inside child
  47211. // component's mounted hook), which relies on vm._watcher being already defined
  47212. new Watcher(vm, updateComponent, noop, {
  47213. before: function before () {
  47214. if (vm._isMounted && !vm._isDestroyed) {
  47215. callHook(vm, 'beforeUpdate');
  47216. }
  47217. }
  47218. }, true /* isRenderWatcher */);
  47219. hydrating = false;
  47220. // manually mounted instance, call mounted on self
  47221. // mounted is called for render-created child components in its inserted hook
  47222. if (vm.$vnode == null) {
  47223. vm._isMounted = true;
  47224. callHook(vm, 'mounted');
  47225. }
  47226. return vm
  47227. }
  47228. function updateChildComponent (
  47229. vm,
  47230. propsData,
  47231. listeners,
  47232. parentVnode,
  47233. renderChildren
  47234. ) {
  47235. {
  47236. isUpdatingChildComponent = true;
  47237. }
  47238. // determine whether component has slot children
  47239. // we need to do this before overwriting $options._renderChildren.
  47240. // check if there are dynamic scopedSlots (hand-written or compiled but with
  47241. // dynamic slot names). Static scoped slots compiled from template has the
  47242. // "$stable" marker.
  47243. var newScopedSlots = parentVnode.data.scopedSlots;
  47244. var oldScopedSlots = vm.$scopedSlots;
  47245. var hasDynamicScopedSlot = !!(
  47246. (newScopedSlots && !newScopedSlots.$stable) ||
  47247. (oldScopedSlots !== emptyObject && !oldScopedSlots.$stable) ||
  47248. (newScopedSlots && vm.$scopedSlots.$key !== newScopedSlots.$key)
  47249. );
  47250. // Any static slot children from the parent may have changed during parent's
  47251. // update. Dynamic scoped slots may also have changed. In such cases, a forced
  47252. // update is necessary to ensure correctness.
  47253. var needsForceUpdate = !!(
  47254. renderChildren || // has new static slots
  47255. vm.$options._renderChildren || // has old static slots
  47256. hasDynamicScopedSlot
  47257. );
  47258. vm.$options._parentVnode = parentVnode;
  47259. vm.$vnode = parentVnode; // update vm's placeholder node without re-render
  47260. if (vm._vnode) { // update child tree's parent
  47261. vm._vnode.parent = parentVnode;
  47262. }
  47263. vm.$options._renderChildren = renderChildren;
  47264. // update $attrs and $listeners hash
  47265. // these are also reactive so they may trigger child update if the child
  47266. // used them during render
  47267. vm.$attrs = parentVnode.data.attrs || emptyObject;
  47268. vm.$listeners = listeners || emptyObject;
  47269. // update props
  47270. if (propsData && vm.$options.props) {
  47271. toggleObserving(false);
  47272. var props = vm._props;
  47273. var propKeys = vm.$options._propKeys || [];
  47274. for (var i = 0; i < propKeys.length; i++) {
  47275. var key = propKeys[i];
  47276. var propOptions = vm.$options.props; // wtf flow?
  47277. props[key] = validateProp(key, propOptions, propsData, vm);
  47278. }
  47279. toggleObserving(true);
  47280. // keep a copy of raw propsData
  47281. vm.$options.propsData = propsData;
  47282. }
  47283. // update listeners
  47284. listeners = listeners || emptyObject;
  47285. var oldListeners = vm.$options._parentListeners;
  47286. vm.$options._parentListeners = listeners;
  47287. updateComponentListeners(vm, listeners, oldListeners);
  47288. // resolve slots + force update if has children
  47289. if (needsForceUpdate) {
  47290. vm.$slots = resolveSlots(renderChildren, parentVnode.context);
  47291. vm.$forceUpdate();
  47292. }
  47293. {
  47294. isUpdatingChildComponent = false;
  47295. }
  47296. }
  47297. function isInInactiveTree (vm) {
  47298. while (vm && (vm = vm.$parent)) {
  47299. if (vm._inactive) { return true }
  47300. }
  47301. return false
  47302. }
  47303. function activateChildComponent (vm, direct) {
  47304. if (direct) {
  47305. vm._directInactive = false;
  47306. if (isInInactiveTree(vm)) {
  47307. return
  47308. }
  47309. } else if (vm._directInactive) {
  47310. return
  47311. }
  47312. if (vm._inactive || vm._inactive === null) {
  47313. vm._inactive = false;
  47314. for (var i = 0; i < vm.$children.length; i++) {
  47315. activateChildComponent(vm.$children[i]);
  47316. }
  47317. callHook(vm, 'activated');
  47318. }
  47319. }
  47320. function deactivateChildComponent (vm, direct) {
  47321. if (direct) {
  47322. vm._directInactive = true;
  47323. if (isInInactiveTree(vm)) {
  47324. return
  47325. }
  47326. }
  47327. if (!vm._inactive) {
  47328. vm._inactive = true;
  47329. for (var i = 0; i < vm.$children.length; i++) {
  47330. deactivateChildComponent(vm.$children[i]);
  47331. }
  47332. callHook(vm, 'deactivated');
  47333. }
  47334. }
  47335. function callHook (vm, hook) {
  47336. // #7573 disable dep collection when invoking lifecycle hooks
  47337. pushTarget();
  47338. var handlers = vm.$options[hook];
  47339. var info = hook + " hook";
  47340. if (handlers) {
  47341. for (var i = 0, j = handlers.length; i < j; i++) {
  47342. invokeWithErrorHandling(handlers[i], vm, null, vm, info);
  47343. }
  47344. }
  47345. if (vm._hasHookEvent) {
  47346. vm.$emit('hook:' + hook);
  47347. }
  47348. popTarget();
  47349. }
  47350. /* */
  47351. var MAX_UPDATE_COUNT = 100;
  47352. var queue = [];
  47353. var activatedChildren = [];
  47354. var has = {};
  47355. var circular = {};
  47356. var waiting = false;
  47357. var flushing = false;
  47358. var index = 0;
  47359. /**
  47360. * Reset the scheduler's state.
  47361. */
  47362. function resetSchedulerState () {
  47363. index = queue.length = activatedChildren.length = 0;
  47364. has = {};
  47365. {
  47366. circular = {};
  47367. }
  47368. waiting = flushing = false;
  47369. }
  47370. // Async edge case #6566 requires saving the timestamp when event listeners are
  47371. // attached. However, calling performance.now() has a perf overhead especially
  47372. // if the page has thousands of event listeners. Instead, we take a timestamp
  47373. // every time the scheduler flushes and use that for all event listeners
  47374. // attached during that flush.
  47375. var currentFlushTimestamp = 0;
  47376. // Async edge case fix requires storing an event listener's attach timestamp.
  47377. var getNow = Date.now;
  47378. // Determine what event timestamp the browser is using. Annoyingly, the
  47379. // timestamp can either be hi-res (relative to page load) or low-res
  47380. // (relative to UNIX epoch), so in order to compare time we have to use the
  47381. // same timestamp type when saving the flush timestamp.
  47382. // All IE versions use low-res event timestamps, and have problematic clock
  47383. // implementations (#9632)
  47384. if (inBrowser && !isIE) {
  47385. var performance = window.performance;
  47386. if (
  47387. performance &&
  47388. typeof performance.now === 'function' &&
  47389. getNow() > document.createEvent('Event').timeStamp
  47390. ) {
  47391. // if the event timestamp, although evaluated AFTER the Date.now(), is
  47392. // smaller than it, it means the event is using a hi-res timestamp,
  47393. // and we need to use the hi-res version for event listener timestamps as
  47394. // well.
  47395. getNow = function () { return performance.now(); };
  47396. }
  47397. }
  47398. /**
  47399. * Flush both queues and run the watchers.
  47400. */
  47401. function flushSchedulerQueue () {
  47402. currentFlushTimestamp = getNow();
  47403. flushing = true;
  47404. var watcher, id;
  47405. // Sort queue before flush.
  47406. // This ensures that:
  47407. // 1. Components are updated from parent to child. (because parent is always
  47408. // created before the child)
  47409. // 2. A component's user watchers are run before its render watcher (because
  47410. // user watchers are created before the render watcher)
  47411. // 3. If a component is destroyed during a parent component's watcher run,
  47412. // its watchers can be skipped.
  47413. queue.sort(function (a, b) { return a.id - b.id; });
  47414. // do not cache length because more watchers might be pushed
  47415. // as we run existing watchers
  47416. for (index = 0; index < queue.length; index++) {
  47417. watcher = queue[index];
  47418. if (watcher.before) {
  47419. watcher.before();
  47420. }
  47421. id = watcher.id;
  47422. has[id] = null;
  47423. watcher.run();
  47424. // in dev build, check and stop circular updates.
  47425. if (has[id] != null) {
  47426. circular[id] = (circular[id] || 0) + 1;
  47427. if (circular[id] > MAX_UPDATE_COUNT) {
  47428. warn(
  47429. 'You may have an infinite update loop ' + (
  47430. watcher.user
  47431. ? ("in watcher with expression \"" + (watcher.expression) + "\"")
  47432. : "in a component render function."
  47433. ),
  47434. watcher.vm
  47435. );
  47436. break
  47437. }
  47438. }
  47439. }
  47440. // keep copies of post queues before resetting state
  47441. var activatedQueue = activatedChildren.slice();
  47442. var updatedQueue = queue.slice();
  47443. resetSchedulerState();
  47444. // call component updated and activated hooks
  47445. callActivatedHooks(activatedQueue);
  47446. callUpdatedHooks(updatedQueue);
  47447. // devtool hook
  47448. /* istanbul ignore if */
  47449. if (devtools && config.devtools) {
  47450. devtools.emit('flush');
  47451. }
  47452. }
  47453. function callUpdatedHooks (queue) {
  47454. var i = queue.length;
  47455. while (i--) {
  47456. var watcher = queue[i];
  47457. var vm = watcher.vm;
  47458. if (vm._watcher === watcher && vm._isMounted && !vm._isDestroyed) {
  47459. callHook(vm, 'updated');
  47460. }
  47461. }
  47462. }
  47463. /**
  47464. * Queue a kept-alive component that was activated during patch.
  47465. * The queue will be processed after the entire tree has been patched.
  47466. */
  47467. function queueActivatedComponent (vm) {
  47468. // setting _inactive to false here so that a render function can
  47469. // rely on checking whether it's in an inactive tree (e.g. router-view)
  47470. vm._inactive = false;
  47471. activatedChildren.push(vm);
  47472. }
  47473. function callActivatedHooks (queue) {
  47474. for (var i = 0; i < queue.length; i++) {
  47475. queue[i]._inactive = true;
  47476. activateChildComponent(queue[i], true /* true */);
  47477. }
  47478. }
  47479. /**
  47480. * Push a watcher into the watcher queue.
  47481. * Jobs with duplicate IDs will be skipped unless it's
  47482. * pushed when the queue is being flushed.
  47483. */
  47484. function queueWatcher (watcher) {
  47485. var id = watcher.id;
  47486. if (has[id] == null) {
  47487. has[id] = true;
  47488. if (!flushing) {
  47489. queue.push(watcher);
  47490. } else {
  47491. // if already flushing, splice the watcher based on its id
  47492. // if already past its id, it will be run next immediately.
  47493. var i = queue.length - 1;
  47494. while (i > index && queue[i].id > watcher.id) {
  47495. i--;
  47496. }
  47497. queue.splice(i + 1, 0, watcher);
  47498. }
  47499. // queue the flush
  47500. if (!waiting) {
  47501. waiting = true;
  47502. if (!config.async) {
  47503. flushSchedulerQueue();
  47504. return
  47505. }
  47506. nextTick(flushSchedulerQueue);
  47507. }
  47508. }
  47509. }
  47510. /* */
  47511. var uid$2 = 0;
  47512. /**
  47513. * A watcher parses an expression, collects dependencies,
  47514. * and fires callback when the expression value changes.
  47515. * This is used for both the $watch() api and directives.
  47516. */
  47517. var Watcher = function Watcher (
  47518. vm,
  47519. expOrFn,
  47520. cb,
  47521. options,
  47522. isRenderWatcher
  47523. ) {
  47524. this.vm = vm;
  47525. if (isRenderWatcher) {
  47526. vm._watcher = this;
  47527. }
  47528. vm._watchers.push(this);
  47529. // options
  47530. if (options) {
  47531. this.deep = !!options.deep;
  47532. this.user = !!options.user;
  47533. this.lazy = !!options.lazy;
  47534. this.sync = !!options.sync;
  47535. this.before = options.before;
  47536. } else {
  47537. this.deep = this.user = this.lazy = this.sync = false;
  47538. }
  47539. this.cb = cb;
  47540. this.id = ++uid$2; // uid for batching
  47541. this.active = true;
  47542. this.dirty = this.lazy; // for lazy watchers
  47543. this.deps = [];
  47544. this.newDeps = [];
  47545. this.depIds = new _Set();
  47546. this.newDepIds = new _Set();
  47547. this.expression = expOrFn.toString();
  47548. // parse expression for getter
  47549. if (typeof expOrFn === 'function') {
  47550. this.getter = expOrFn;
  47551. } else {
  47552. this.getter = parsePath(expOrFn);
  47553. if (!this.getter) {
  47554. this.getter = noop;
  47555. warn(
  47556. "Failed watching path: \"" + expOrFn + "\" " +
  47557. 'Watcher only accepts simple dot-delimited paths. ' +
  47558. 'For full control, use a function instead.',
  47559. vm
  47560. );
  47561. }
  47562. }
  47563. this.value = this.lazy
  47564. ? undefined
  47565. : this.get();
  47566. };
  47567. /**
  47568. * Evaluate the getter, and re-collect dependencies.
  47569. */
  47570. Watcher.prototype.get = function get () {
  47571. pushTarget(this);
  47572. var value;
  47573. var vm = this.vm;
  47574. try {
  47575. value = this.getter.call(vm, vm);
  47576. } catch (e) {
  47577. if (this.user) {
  47578. handleError(e, vm, ("getter for watcher \"" + (this.expression) + "\""));
  47579. } else {
  47580. throw e
  47581. }
  47582. } finally {
  47583. // "touch" every property so they are all tracked as
  47584. // dependencies for deep watching
  47585. if (this.deep) {
  47586. traverse(value);
  47587. }
  47588. popTarget();
  47589. this.cleanupDeps();
  47590. }
  47591. return value
  47592. };
  47593. /**
  47594. * Add a dependency to this directive.
  47595. */
  47596. Watcher.prototype.addDep = function addDep (dep) {
  47597. var id = dep.id;
  47598. if (!this.newDepIds.has(id)) {
  47599. this.newDepIds.add(id);
  47600. this.newDeps.push(dep);
  47601. if (!this.depIds.has(id)) {
  47602. dep.addSub(this);
  47603. }
  47604. }
  47605. };
  47606. /**
  47607. * Clean up for dependency collection.
  47608. */
  47609. Watcher.prototype.cleanupDeps = function cleanupDeps () {
  47610. var i = this.deps.length;
  47611. while (i--) {
  47612. var dep = this.deps[i];
  47613. if (!this.newDepIds.has(dep.id)) {
  47614. dep.removeSub(this);
  47615. }
  47616. }
  47617. var tmp = this.depIds;
  47618. this.depIds = this.newDepIds;
  47619. this.newDepIds = tmp;
  47620. this.newDepIds.clear();
  47621. tmp = this.deps;
  47622. this.deps = this.newDeps;
  47623. this.newDeps = tmp;
  47624. this.newDeps.length = 0;
  47625. };
  47626. /**
  47627. * Subscriber interface.
  47628. * Will be called when a dependency changes.
  47629. */
  47630. Watcher.prototype.update = function update () {
  47631. /* istanbul ignore else */
  47632. if (this.lazy) {
  47633. this.dirty = true;
  47634. } else if (this.sync) {
  47635. this.run();
  47636. } else {
  47637. queueWatcher(this);
  47638. }
  47639. };
  47640. /**
  47641. * Scheduler job interface.
  47642. * Will be called by the scheduler.
  47643. */
  47644. Watcher.prototype.run = function run () {
  47645. if (this.active) {
  47646. var value = this.get();
  47647. if (
  47648. value !== this.value ||
  47649. // Deep watchers and watchers on Object/Arrays should fire even
  47650. // when the value is the same, because the value may
  47651. // have mutated.
  47652. isObject(value) ||
  47653. this.deep
  47654. ) {
  47655. // set new value
  47656. var oldValue = this.value;
  47657. this.value = value;
  47658. if (this.user) {
  47659. try {
  47660. this.cb.call(this.vm, value, oldValue);
  47661. } catch (e) {
  47662. handleError(e, this.vm, ("callback for watcher \"" + (this.expression) + "\""));
  47663. }
  47664. } else {
  47665. this.cb.call(this.vm, value, oldValue);
  47666. }
  47667. }
  47668. }
  47669. };
  47670. /**
  47671. * Evaluate the value of the watcher.
  47672. * This only gets called for lazy watchers.
  47673. */
  47674. Watcher.prototype.evaluate = function evaluate () {
  47675. this.value = this.get();
  47676. this.dirty = false;
  47677. };
  47678. /**
  47679. * Depend on all deps collected by this watcher.
  47680. */
  47681. Watcher.prototype.depend = function depend () {
  47682. var i = this.deps.length;
  47683. while (i--) {
  47684. this.deps[i].depend();
  47685. }
  47686. };
  47687. /**
  47688. * Remove self from all dependencies' subscriber list.
  47689. */
  47690. Watcher.prototype.teardown = function teardown () {
  47691. if (this.active) {
  47692. // remove self from vm's watcher list
  47693. // this is a somewhat expensive operation so we skip it
  47694. // if the vm is being destroyed.
  47695. if (!this.vm._isBeingDestroyed) {
  47696. remove(this.vm._watchers, this);
  47697. }
  47698. var i = this.deps.length;
  47699. while (i--) {
  47700. this.deps[i].removeSub(this);
  47701. }
  47702. this.active = false;
  47703. }
  47704. };
  47705. /* */
  47706. var sharedPropertyDefinition = {
  47707. enumerable: true,
  47708. configurable: true,
  47709. get: noop,
  47710. set: noop
  47711. };
  47712. function proxy (target, sourceKey, key) {
  47713. sharedPropertyDefinition.get = function proxyGetter () {
  47714. return this[sourceKey][key]
  47715. };
  47716. sharedPropertyDefinition.set = function proxySetter (val) {
  47717. this[sourceKey][key] = val;
  47718. };
  47719. Object.defineProperty(target, key, sharedPropertyDefinition);
  47720. }
  47721. function initState (vm) {
  47722. vm._watchers = [];
  47723. var opts = vm.$options;
  47724. if (opts.props) { initProps(vm, opts.props); }
  47725. if (opts.methods) { initMethods(vm, opts.methods); }
  47726. if (opts.data) {
  47727. initData(vm);
  47728. } else {
  47729. observe(vm._data = {}, true /* asRootData */);
  47730. }
  47731. if (opts.computed) { initComputed(vm, opts.computed); }
  47732. if (opts.watch && opts.watch !== nativeWatch) {
  47733. initWatch(vm, opts.watch);
  47734. }
  47735. }
  47736. function initProps (vm, propsOptions) {
  47737. var propsData = vm.$options.propsData || {};
  47738. var props = vm._props = {};
  47739. // cache prop keys so that future props updates can iterate using Array
  47740. // instead of dynamic object key enumeration.
  47741. var keys = vm.$options._propKeys = [];
  47742. var isRoot = !vm.$parent;
  47743. // root instance props should be converted
  47744. if (!isRoot) {
  47745. toggleObserving(false);
  47746. }
  47747. var loop = function ( key ) {
  47748. keys.push(key);
  47749. var value = validateProp(key, propsOptions, propsData, vm);
  47750. /* istanbul ignore else */
  47751. {
  47752. var hyphenatedKey = hyphenate(key);
  47753. if (isReservedAttribute(hyphenatedKey) ||
  47754. config.isReservedAttr(hyphenatedKey)) {
  47755. warn(
  47756. ("\"" + hyphenatedKey + "\" is a reserved attribute and cannot be used as component prop."),
  47757. vm
  47758. );
  47759. }
  47760. defineReactive$$1(props, key, value, function () {
  47761. if (!isRoot && !isUpdatingChildComponent) {
  47762. warn(
  47763. "Avoid mutating a prop directly since the value will be " +
  47764. "overwritten whenever the parent component re-renders. " +
  47765. "Instead, use a data or computed property based on the prop's " +
  47766. "value. Prop being mutated: \"" + key + "\"",
  47767. vm
  47768. );
  47769. }
  47770. });
  47771. }
  47772. // static props are already proxied on the component's prototype
  47773. // during Vue.extend(). We only need to proxy props defined at
  47774. // instantiation here.
  47775. if (!(key in vm)) {
  47776. proxy(vm, "_props", key);
  47777. }
  47778. };
  47779. for (var key in propsOptions) loop( key );
  47780. toggleObserving(true);
  47781. }
  47782. function initData (vm) {
  47783. var data = vm.$options.data;
  47784. data = vm._data = typeof data === 'function'
  47785. ? getData(data, vm)
  47786. : data || {};
  47787. if (!isPlainObject(data)) {
  47788. data = {};
  47789. warn(
  47790. 'data functions should return an object:\n' +
  47791. 'https://vuejs.org/v2/guide/components.html#data-Must-Be-a-Function',
  47792. vm
  47793. );
  47794. }
  47795. // proxy data on instance
  47796. var keys = Object.keys(data);
  47797. var props = vm.$options.props;
  47798. var methods = vm.$options.methods;
  47799. var i = keys.length;
  47800. while (i--) {
  47801. var key = keys[i];
  47802. {
  47803. if (methods && hasOwn(methods, key)) {
  47804. warn(
  47805. ("Method \"" + key + "\" has already been defined as a data property."),
  47806. vm
  47807. );
  47808. }
  47809. }
  47810. if (props && hasOwn(props, key)) {
  47811. warn(
  47812. "The data property \"" + key + "\" is already declared as a prop. " +
  47813. "Use prop default value instead.",
  47814. vm
  47815. );
  47816. } else if (!isReserved(key)) {
  47817. proxy(vm, "_data", key);
  47818. }
  47819. }
  47820. // observe data
  47821. observe(data, true /* asRootData */);
  47822. }
  47823. function getData (data, vm) {
  47824. // #7573 disable dep collection when invoking data getters
  47825. pushTarget();
  47826. try {
  47827. return data.call(vm, vm)
  47828. } catch (e) {
  47829. handleError(e, vm, "data()");
  47830. return {}
  47831. } finally {
  47832. popTarget();
  47833. }
  47834. }
  47835. var computedWatcherOptions = { lazy: true };
  47836. function initComputed (vm, computed) {
  47837. // $flow-disable-line
  47838. var watchers = vm._computedWatchers = Object.create(null);
  47839. // computed properties are just getters during SSR
  47840. var isSSR = isServerRendering();
  47841. for (var key in computed) {
  47842. var userDef = computed[key];
  47843. var getter = typeof userDef === 'function' ? userDef : userDef.get;
  47844. if (getter == null) {
  47845. warn(
  47846. ("Getter is missing for computed property \"" + key + "\"."),
  47847. vm
  47848. );
  47849. }
  47850. if (!isSSR) {
  47851. // create internal watcher for the computed property.
  47852. watchers[key] = new Watcher(
  47853. vm,
  47854. getter || noop,
  47855. noop,
  47856. computedWatcherOptions
  47857. );
  47858. }
  47859. // component-defined computed properties are already defined on the
  47860. // component prototype. We only need to define computed properties defined
  47861. // at instantiation here.
  47862. if (!(key in vm)) {
  47863. defineComputed(vm, key, userDef);
  47864. } else {
  47865. if (key in vm.$data) {
  47866. warn(("The computed property \"" + key + "\" is already defined in data."), vm);
  47867. } else if (vm.$options.props && key in vm.$options.props) {
  47868. warn(("The computed property \"" + key + "\" is already defined as a prop."), vm);
  47869. }
  47870. }
  47871. }
  47872. }
  47873. function defineComputed (
  47874. target,
  47875. key,
  47876. userDef
  47877. ) {
  47878. var shouldCache = !isServerRendering();
  47879. if (typeof userDef === 'function') {
  47880. sharedPropertyDefinition.get = shouldCache
  47881. ? createComputedGetter(key)
  47882. : createGetterInvoker(userDef);
  47883. sharedPropertyDefinition.set = noop;
  47884. } else {
  47885. sharedPropertyDefinition.get = userDef.get
  47886. ? shouldCache && userDef.cache !== false
  47887. ? createComputedGetter(key)
  47888. : createGetterInvoker(userDef.get)
  47889. : noop;
  47890. sharedPropertyDefinition.set = userDef.set || noop;
  47891. }
  47892. if (sharedPropertyDefinition.set === noop) {
  47893. sharedPropertyDefinition.set = function () {
  47894. warn(
  47895. ("Computed property \"" + key + "\" was assigned to but it has no setter."),
  47896. this
  47897. );
  47898. };
  47899. }
  47900. Object.defineProperty(target, key, sharedPropertyDefinition);
  47901. }
  47902. function createComputedGetter (key) {
  47903. return function computedGetter () {
  47904. var watcher = this._computedWatchers && this._computedWatchers[key];
  47905. if (watcher) {
  47906. if (watcher.dirty) {
  47907. watcher.evaluate();
  47908. }
  47909. if (Dep.target) {
  47910. watcher.depend();
  47911. }
  47912. return watcher.value
  47913. }
  47914. }
  47915. }
  47916. function createGetterInvoker(fn) {
  47917. return function computedGetter () {
  47918. return fn.call(this, this)
  47919. }
  47920. }
  47921. function initMethods (vm, methods) {
  47922. var props = vm.$options.props;
  47923. for (var key in methods) {
  47924. {
  47925. if (typeof methods[key] !== 'function') {
  47926. warn(
  47927. "Method \"" + key + "\" has type \"" + (typeof methods[key]) + "\" in the component definition. " +
  47928. "Did you reference the function correctly?",
  47929. vm
  47930. );
  47931. }
  47932. if (props && hasOwn(props, key)) {
  47933. warn(
  47934. ("Method \"" + key + "\" has already been defined as a prop."),
  47935. vm
  47936. );
  47937. }
  47938. if ((key in vm) && isReserved(key)) {
  47939. warn(
  47940. "Method \"" + key + "\" conflicts with an existing Vue instance method. " +
  47941. "Avoid defining component methods that start with _ or $."
  47942. );
  47943. }
  47944. }
  47945. vm[key] = typeof methods[key] !== 'function' ? noop : bind(methods[key], vm);
  47946. }
  47947. }
  47948. function initWatch (vm, watch) {
  47949. for (var key in watch) {
  47950. var handler = watch[key];
  47951. if (Array.isArray(handler)) {
  47952. for (var i = 0; i < handler.length; i++) {
  47953. createWatcher(vm, key, handler[i]);
  47954. }
  47955. } else {
  47956. createWatcher(vm, key, handler);
  47957. }
  47958. }
  47959. }
  47960. function createWatcher (
  47961. vm,
  47962. expOrFn,
  47963. handler,
  47964. options
  47965. ) {
  47966. if (isPlainObject(handler)) {
  47967. options = handler;
  47968. handler = handler.handler;
  47969. }
  47970. if (typeof handler === 'string') {
  47971. handler = vm[handler];
  47972. }
  47973. return vm.$watch(expOrFn, handler, options)
  47974. }
  47975. function stateMixin (Vue) {
  47976. // flow somehow has problems with directly declared definition object
  47977. // when using Object.defineProperty, so we have to procedurally build up
  47978. // the object here.
  47979. var dataDef = {};
  47980. dataDef.get = function () { return this._data };
  47981. var propsDef = {};
  47982. propsDef.get = function () { return this._props };
  47983. {
  47984. dataDef.set = function () {
  47985. warn(
  47986. 'Avoid replacing instance root $data. ' +
  47987. 'Use nested data properties instead.',
  47988. this
  47989. );
  47990. };
  47991. propsDef.set = function () {
  47992. warn("$props is readonly.", this);
  47993. };
  47994. }
  47995. Object.defineProperty(Vue.prototype, '$data', dataDef);
  47996. Object.defineProperty(Vue.prototype, '$props', propsDef);
  47997. Vue.prototype.$set = set;
  47998. Vue.prototype.$delete = del;
  47999. Vue.prototype.$watch = function (
  48000. expOrFn,
  48001. cb,
  48002. options
  48003. ) {
  48004. var vm = this;
  48005. if (isPlainObject(cb)) {
  48006. return createWatcher(vm, expOrFn, cb, options)
  48007. }
  48008. options = options || {};
  48009. options.user = true;
  48010. var watcher = new Watcher(vm, expOrFn, cb, options);
  48011. if (options.immediate) {
  48012. try {
  48013. cb.call(vm, watcher.value);
  48014. } catch (error) {
  48015. handleError(error, vm, ("callback for immediate watcher \"" + (watcher.expression) + "\""));
  48016. }
  48017. }
  48018. return function unwatchFn () {
  48019. watcher.teardown();
  48020. }
  48021. };
  48022. }
  48023. /* */
  48024. var uid$3 = 0;
  48025. function initMixin (Vue) {
  48026. Vue.prototype._init = function (options) {
  48027. var vm = this;
  48028. // a uid
  48029. vm._uid = uid$3++;
  48030. var startTag, endTag;
  48031. /* istanbul ignore if */
  48032. if (config.performance && mark) {
  48033. startTag = "vue-perf-start:" + (vm._uid);
  48034. endTag = "vue-perf-end:" + (vm._uid);
  48035. mark(startTag);
  48036. }
  48037. // a flag to avoid this being observed
  48038. vm._isVue = true;
  48039. // merge options
  48040. if (options && options._isComponent) {
  48041. // optimize internal component instantiation
  48042. // since dynamic options merging is pretty slow, and none of the
  48043. // internal component options needs special treatment.
  48044. initInternalComponent(vm, options);
  48045. } else {
  48046. vm.$options = mergeOptions(
  48047. resolveConstructorOptions(vm.constructor),
  48048. options || {},
  48049. vm
  48050. );
  48051. }
  48052. /* istanbul ignore else */
  48053. {
  48054. initProxy(vm);
  48055. }
  48056. // expose real self
  48057. vm._self = vm;
  48058. initLifecycle(vm);
  48059. initEvents(vm);
  48060. initRender(vm);
  48061. callHook(vm, 'beforeCreate');
  48062. initInjections(vm); // resolve injections before data/props
  48063. initState(vm);
  48064. initProvide(vm); // resolve provide after data/props
  48065. callHook(vm, 'created');
  48066. /* istanbul ignore if */
  48067. if (config.performance && mark) {
  48068. vm._name = formatComponentName(vm, false);
  48069. mark(endTag);
  48070. measure(("vue " + (vm._name) + " init"), startTag, endTag);
  48071. }
  48072. if (vm.$options.el) {
  48073. vm.$mount(vm.$options.el);
  48074. }
  48075. };
  48076. }
  48077. function initInternalComponent (vm, options) {
  48078. var opts = vm.$options = Object.create(vm.constructor.options);
  48079. // doing this because it's faster than dynamic enumeration.
  48080. var parentVnode = options._parentVnode;
  48081. opts.parent = options.parent;
  48082. opts._parentVnode = parentVnode;
  48083. var vnodeComponentOptions = parentVnode.componentOptions;
  48084. opts.propsData = vnodeComponentOptions.propsData;
  48085. opts._parentListeners = vnodeComponentOptions.listeners;
  48086. opts._renderChildren = vnodeComponentOptions.children;
  48087. opts._componentTag = vnodeComponentOptions.tag;
  48088. if (options.render) {
  48089. opts.render = options.render;
  48090. opts.staticRenderFns = options.staticRenderFns;
  48091. }
  48092. }
  48093. function resolveConstructorOptions (Ctor) {
  48094. var options = Ctor.options;
  48095. if (Ctor.super) {
  48096. var superOptions = resolveConstructorOptions(Ctor.super);
  48097. var cachedSuperOptions = Ctor.superOptions;
  48098. if (superOptions !== cachedSuperOptions) {
  48099. // super option changed,
  48100. // need to resolve new options.
  48101. Ctor.superOptions = superOptions;
  48102. // check if there are any late-modified/attached options (#4976)
  48103. var modifiedOptions = resolveModifiedOptions(Ctor);
  48104. // update base extend options
  48105. if (modifiedOptions) {
  48106. extend(Ctor.extendOptions, modifiedOptions);
  48107. }
  48108. options = Ctor.options = mergeOptions(superOptions, Ctor.extendOptions);
  48109. if (options.name) {
  48110. options.components[options.name] = Ctor;
  48111. }
  48112. }
  48113. }
  48114. return options
  48115. }
  48116. function resolveModifiedOptions (Ctor) {
  48117. var modified;
  48118. var latest = Ctor.options;
  48119. var sealed = Ctor.sealedOptions;
  48120. for (var key in latest) {
  48121. if (latest[key] !== sealed[key]) {
  48122. if (!modified) { modified = {}; }
  48123. modified[key] = latest[key];
  48124. }
  48125. }
  48126. return modified
  48127. }
  48128. function Vue (options) {
  48129. if (!(this instanceof Vue)
  48130. ) {
  48131. warn('Vue is a constructor and should be called with the `new` keyword');
  48132. }
  48133. this._init(options);
  48134. }
  48135. initMixin(Vue);
  48136. stateMixin(Vue);
  48137. eventsMixin(Vue);
  48138. lifecycleMixin(Vue);
  48139. renderMixin(Vue);
  48140. /* */
  48141. function initUse (Vue) {
  48142. Vue.use = function (plugin) {
  48143. var installedPlugins = (this._installedPlugins || (this._installedPlugins = []));
  48144. if (installedPlugins.indexOf(plugin) > -1) {
  48145. return this
  48146. }
  48147. // additional parameters
  48148. var args = toArray(arguments, 1);
  48149. args.unshift(this);
  48150. if (typeof plugin.install === 'function') {
  48151. plugin.install.apply(plugin, args);
  48152. } else if (typeof plugin === 'function') {
  48153. plugin.apply(null, args);
  48154. }
  48155. installedPlugins.push(plugin);
  48156. return this
  48157. };
  48158. }
  48159. /* */
  48160. function initMixin$1 (Vue) {
  48161. Vue.mixin = function (mixin) {
  48162. this.options = mergeOptions(this.options, mixin);
  48163. return this
  48164. };
  48165. }
  48166. /* */
  48167. function initExtend (Vue) {
  48168. /**
  48169. * Each instance constructor, including Vue, has a unique
  48170. * cid. This enables us to create wrapped "child
  48171. * constructors" for prototypal inheritance and cache them.
  48172. */
  48173. Vue.cid = 0;
  48174. var cid = 1;
  48175. /**
  48176. * Class inheritance
  48177. */
  48178. Vue.extend = function (extendOptions) {
  48179. extendOptions = extendOptions || {};
  48180. var Super = this;
  48181. var SuperId = Super.cid;
  48182. var cachedCtors = extendOptions._Ctor || (extendOptions._Ctor = {});
  48183. if (cachedCtors[SuperId]) {
  48184. return cachedCtors[SuperId]
  48185. }
  48186. var name = extendOptions.name || Super.options.name;
  48187. if (name) {
  48188. validateComponentName(name);
  48189. }
  48190. var Sub = function VueComponent (options) {
  48191. this._init(options);
  48192. };
  48193. Sub.prototype = Object.create(Super.prototype);
  48194. Sub.prototype.constructor = Sub;
  48195. Sub.cid = cid++;
  48196. Sub.options = mergeOptions(
  48197. Super.options,
  48198. extendOptions
  48199. );
  48200. Sub['super'] = Super;
  48201. // For props and computed properties, we define the proxy getters on
  48202. // the Vue instances at extension time, on the extended prototype. This
  48203. // avoids Object.defineProperty calls for each instance created.
  48204. if (Sub.options.props) {
  48205. initProps$1(Sub);
  48206. }
  48207. if (Sub.options.computed) {
  48208. initComputed$1(Sub);
  48209. }
  48210. // allow further extension/mixin/plugin usage
  48211. Sub.extend = Super.extend;
  48212. Sub.mixin = Super.mixin;
  48213. Sub.use = Super.use;
  48214. // create asset registers, so extended classes
  48215. // can have their private assets too.
  48216. ASSET_TYPES.forEach(function (type) {
  48217. Sub[type] = Super[type];
  48218. });
  48219. // enable recursive self-lookup
  48220. if (name) {
  48221. Sub.options.components[name] = Sub;
  48222. }
  48223. // keep a reference to the super options at extension time.
  48224. // later at instantiation we can check if Super's options have
  48225. // been updated.
  48226. Sub.superOptions = Super.options;
  48227. Sub.extendOptions = extendOptions;
  48228. Sub.sealedOptions = extend({}, Sub.options);
  48229. // cache constructor
  48230. cachedCtors[SuperId] = Sub;
  48231. return Sub
  48232. };
  48233. }
  48234. function initProps$1 (Comp) {
  48235. var props = Comp.options.props;
  48236. for (var key in props) {
  48237. proxy(Comp.prototype, "_props", key);
  48238. }
  48239. }
  48240. function initComputed$1 (Comp) {
  48241. var computed = Comp.options.computed;
  48242. for (var key in computed) {
  48243. defineComputed(Comp.prototype, key, computed[key]);
  48244. }
  48245. }
  48246. /* */
  48247. function initAssetRegisters (Vue) {
  48248. /**
  48249. * Create asset registration methods.
  48250. */
  48251. ASSET_TYPES.forEach(function (type) {
  48252. Vue[type] = function (
  48253. id,
  48254. definition
  48255. ) {
  48256. if (!definition) {
  48257. return this.options[type + 's'][id]
  48258. } else {
  48259. /* istanbul ignore if */
  48260. if (type === 'component') {
  48261. validateComponentName(id);
  48262. }
  48263. if (type === 'component' && isPlainObject(definition)) {
  48264. definition.name = definition.name || id;
  48265. definition = this.options._base.extend(definition);
  48266. }
  48267. if (type === 'directive' && typeof definition === 'function') {
  48268. definition = { bind: definition, update: definition };
  48269. }
  48270. this.options[type + 's'][id] = definition;
  48271. return definition
  48272. }
  48273. };
  48274. });
  48275. }
  48276. /* */
  48277. function getComponentName (opts) {
  48278. return opts && (opts.Ctor.options.name || opts.tag)
  48279. }
  48280. function matches (pattern, name) {
  48281. if (Array.isArray(pattern)) {
  48282. return pattern.indexOf(name) > -1
  48283. } else if (typeof pattern === 'string') {
  48284. return pattern.split(',').indexOf(name) > -1
  48285. } else if (isRegExp(pattern)) {
  48286. return pattern.test(name)
  48287. }
  48288. /* istanbul ignore next */
  48289. return false
  48290. }
  48291. function pruneCache (keepAliveInstance, filter) {
  48292. var cache = keepAliveInstance.cache;
  48293. var keys = keepAliveInstance.keys;
  48294. var _vnode = keepAliveInstance._vnode;
  48295. for (var key in cache) {
  48296. var cachedNode = cache[key];
  48297. if (cachedNode) {
  48298. var name = getComponentName(cachedNode.componentOptions);
  48299. if (name && !filter(name)) {
  48300. pruneCacheEntry(cache, key, keys, _vnode);
  48301. }
  48302. }
  48303. }
  48304. }
  48305. function pruneCacheEntry (
  48306. cache,
  48307. key,
  48308. keys,
  48309. current
  48310. ) {
  48311. var cached$$1 = cache[key];
  48312. if (cached$$1 && (!current || cached$$1.tag !== current.tag)) {
  48313. cached$$1.componentInstance.$destroy();
  48314. }
  48315. cache[key] = null;
  48316. remove(keys, key);
  48317. }
  48318. var patternTypes = [String, RegExp, Array];
  48319. var KeepAlive = {
  48320. name: 'keep-alive',
  48321. abstract: true,
  48322. props: {
  48323. include: patternTypes,
  48324. exclude: patternTypes,
  48325. max: [String, Number]
  48326. },
  48327. created: function created () {
  48328. this.cache = Object.create(null);
  48329. this.keys = [];
  48330. },
  48331. destroyed: function destroyed () {
  48332. for (var key in this.cache) {
  48333. pruneCacheEntry(this.cache, key, this.keys);
  48334. }
  48335. },
  48336. mounted: function mounted () {
  48337. var this$1 = this;
  48338. this.$watch('include', function (val) {
  48339. pruneCache(this$1, function (name) { return matches(val, name); });
  48340. });
  48341. this.$watch('exclude', function (val) {
  48342. pruneCache(this$1, function (name) { return !matches(val, name); });
  48343. });
  48344. },
  48345. render: function render () {
  48346. var slot = this.$slots.default;
  48347. var vnode = getFirstComponentChild(slot);
  48348. var componentOptions = vnode && vnode.componentOptions;
  48349. if (componentOptions) {
  48350. // check pattern
  48351. var name = getComponentName(componentOptions);
  48352. var ref = this;
  48353. var include = ref.include;
  48354. var exclude = ref.exclude;
  48355. if (
  48356. // not included
  48357. (include && (!name || !matches(include, name))) ||
  48358. // excluded
  48359. (exclude && name && matches(exclude, name))
  48360. ) {
  48361. return vnode
  48362. }
  48363. var ref$1 = this;
  48364. var cache = ref$1.cache;
  48365. var keys = ref$1.keys;
  48366. var key = vnode.key == null
  48367. // same constructor may get registered as different local components
  48368. // so cid alone is not enough (#3269)
  48369. ? componentOptions.Ctor.cid + (componentOptions.tag ? ("::" + (componentOptions.tag)) : '')
  48370. : vnode.key;
  48371. if (cache[key]) {
  48372. vnode.componentInstance = cache[key].componentInstance;
  48373. // make current key freshest
  48374. remove(keys, key);
  48375. keys.push(key);
  48376. } else {
  48377. cache[key] = vnode;
  48378. keys.push(key);
  48379. // prune oldest entry
  48380. if (this.max && keys.length > parseInt(this.max)) {
  48381. pruneCacheEntry(cache, keys[0], keys, this._vnode);
  48382. }
  48383. }
  48384. vnode.data.keepAlive = true;
  48385. }
  48386. return vnode || (slot && slot[0])
  48387. }
  48388. };
  48389. var builtInComponents = {
  48390. KeepAlive: KeepAlive
  48391. };
  48392. /* */
  48393. function initGlobalAPI (Vue) {
  48394. // config
  48395. var configDef = {};
  48396. configDef.get = function () { return config; };
  48397. {
  48398. configDef.set = function () {
  48399. warn(
  48400. 'Do not replace the Vue.config object, set individual fields instead.'
  48401. );
  48402. };
  48403. }
  48404. Object.defineProperty(Vue, 'config', configDef);
  48405. // exposed util methods.
  48406. // NOTE: these are not considered part of the public API - avoid relying on
  48407. // them unless you are aware of the risk.
  48408. Vue.util = {
  48409. warn: warn,
  48410. extend: extend,
  48411. mergeOptions: mergeOptions,
  48412. defineReactive: defineReactive$$1
  48413. };
  48414. Vue.set = set;
  48415. Vue.delete = del;
  48416. Vue.nextTick = nextTick;
  48417. // 2.6 explicit observable API
  48418. Vue.observable = function (obj) {
  48419. observe(obj);
  48420. return obj
  48421. };
  48422. Vue.options = Object.create(null);
  48423. ASSET_TYPES.forEach(function (type) {
  48424. Vue.options[type + 's'] = Object.create(null);
  48425. });
  48426. // this is used to identify the "base" constructor to extend all plain-object
  48427. // components with in Weex's multi-instance scenarios.
  48428. Vue.options._base = Vue;
  48429. extend(Vue.options.components, builtInComponents);
  48430. initUse(Vue);
  48431. initMixin$1(Vue);
  48432. initExtend(Vue);
  48433. initAssetRegisters(Vue);
  48434. }
  48435. initGlobalAPI(Vue);
  48436. Object.defineProperty(Vue.prototype, '$isServer', {
  48437. get: isServerRendering
  48438. });
  48439. Object.defineProperty(Vue.prototype, '$ssrContext', {
  48440. get: function get () {
  48441. /* istanbul ignore next */
  48442. return this.$vnode && this.$vnode.ssrContext
  48443. }
  48444. });
  48445. // expose FunctionalRenderContext for ssr runtime helper installation
  48446. Object.defineProperty(Vue, 'FunctionalRenderContext', {
  48447. value: FunctionalRenderContext
  48448. });
  48449. Vue.version = '2.6.11';
  48450. /* */
  48451. // these are reserved for web because they are directly compiled away
  48452. // during template compilation
  48453. var isReservedAttr = makeMap('style,class');
  48454. // attributes that should be using props for binding
  48455. var acceptValue = makeMap('input,textarea,option,select,progress');
  48456. var mustUseProp = function (tag, type, attr) {
  48457. return (
  48458. (attr === 'value' && acceptValue(tag)) && type !== 'button' ||
  48459. (attr === 'selected' && tag === 'option') ||
  48460. (attr === 'checked' && tag === 'input') ||
  48461. (attr === 'muted' && tag === 'video')
  48462. )
  48463. };
  48464. var isEnumeratedAttr = makeMap('contenteditable,draggable,spellcheck');
  48465. var isValidContentEditableValue = makeMap('events,caret,typing,plaintext-only');
  48466. var convertEnumeratedValue = function (key, value) {
  48467. return isFalsyAttrValue(value) || value === 'false'
  48468. ? 'false'
  48469. // allow arbitrary string value for contenteditable
  48470. : key === 'contenteditable' && isValidContentEditableValue(value)
  48471. ? value
  48472. : 'true'
  48473. };
  48474. var isBooleanAttr = makeMap(
  48475. 'allowfullscreen,async,autofocus,autoplay,checked,compact,controls,declare,' +
  48476. 'default,defaultchecked,defaultmuted,defaultselected,defer,disabled,' +
  48477. 'enabled,formnovalidate,hidden,indeterminate,inert,ismap,itemscope,loop,multiple,' +
  48478. 'muted,nohref,noresize,noshade,novalidate,nowrap,open,pauseonexit,readonly,' +
  48479. 'required,reversed,scoped,seamless,selected,sortable,translate,' +
  48480. 'truespeed,typemustmatch,visible'
  48481. );
  48482. var xlinkNS = 'http://www.w3.org/1999/xlink';
  48483. var isXlink = function (name) {
  48484. return name.charAt(5) === ':' && name.slice(0, 5) === 'xlink'
  48485. };
  48486. var getXlinkProp = function (name) {
  48487. return isXlink(name) ? name.slice(6, name.length) : ''
  48488. };
  48489. var isFalsyAttrValue = function (val) {
  48490. return val == null || val === false
  48491. };
  48492. /* */
  48493. function genClassForVnode (vnode) {
  48494. var data = vnode.data;
  48495. var parentNode = vnode;
  48496. var childNode = vnode;
  48497. while (isDef(childNode.componentInstance)) {
  48498. childNode = childNode.componentInstance._vnode;
  48499. if (childNode && childNode.data) {
  48500. data = mergeClassData(childNode.data, data);
  48501. }
  48502. }
  48503. while (isDef(parentNode = parentNode.parent)) {
  48504. if (parentNode && parentNode.data) {
  48505. data = mergeClassData(data, parentNode.data);
  48506. }
  48507. }
  48508. return renderClass(data.staticClass, data.class)
  48509. }
  48510. function mergeClassData (child, parent) {
  48511. return {
  48512. staticClass: concat(child.staticClass, parent.staticClass),
  48513. class: isDef(child.class)
  48514. ? [child.class, parent.class]
  48515. : parent.class
  48516. }
  48517. }
  48518. function renderClass (
  48519. staticClass,
  48520. dynamicClass
  48521. ) {
  48522. if (isDef(staticClass) || isDef(dynamicClass)) {
  48523. return concat(staticClass, stringifyClass(dynamicClass))
  48524. }
  48525. /* istanbul ignore next */
  48526. return ''
  48527. }
  48528. function concat (a, b) {
  48529. return a ? b ? (a + ' ' + b) : a : (b || '')
  48530. }
  48531. function stringifyClass (value) {
  48532. if (Array.isArray(value)) {
  48533. return stringifyArray(value)
  48534. }
  48535. if (isObject(value)) {
  48536. return stringifyObject(value)
  48537. }
  48538. if (typeof value === 'string') {
  48539. return value
  48540. }
  48541. /* istanbul ignore next */
  48542. return ''
  48543. }
  48544. function stringifyArray (value) {
  48545. var res = '';
  48546. var stringified;
  48547. for (var i = 0, l = value.length; i < l; i++) {
  48548. if (isDef(stringified = stringifyClass(value[i])) && stringified !== '') {
  48549. if (res) { res += ' '; }
  48550. res += stringified;
  48551. }
  48552. }
  48553. return res
  48554. }
  48555. function stringifyObject (value) {
  48556. var res = '';
  48557. for (var key in value) {
  48558. if (value[key]) {
  48559. if (res) { res += ' '; }
  48560. res += key;
  48561. }
  48562. }
  48563. return res
  48564. }
  48565. /* */
  48566. var namespaceMap = {
  48567. svg: 'http://www.w3.org/2000/svg',
  48568. math: 'http://www.w3.org/1998/Math/MathML'
  48569. };
  48570. var isHTMLTag = makeMap(
  48571. 'html,body,base,head,link,meta,style,title,' +
  48572. 'address,article,aside,footer,header,h1,h2,h3,h4,h5,h6,hgroup,nav,section,' +
  48573. 'div,dd,dl,dt,figcaption,figure,picture,hr,img,li,main,ol,p,pre,ul,' +
  48574. 'a,b,abbr,bdi,bdo,br,cite,code,data,dfn,em,i,kbd,mark,q,rp,rt,rtc,ruby,' +
  48575. 's,samp,small,span,strong,sub,sup,time,u,var,wbr,area,audio,map,track,video,' +
  48576. 'embed,object,param,source,canvas,script,noscript,del,ins,' +
  48577. 'caption,col,colgroup,table,thead,tbody,td,th,tr,' +
  48578. 'button,datalist,fieldset,form,input,label,legend,meter,optgroup,option,' +
  48579. 'output,progress,select,textarea,' +
  48580. 'details,dialog,menu,menuitem,summary,' +
  48581. 'content,element,shadow,template,blockquote,iframe,tfoot'
  48582. );
  48583. // this map is intentionally selective, only covering SVG elements that may
  48584. // contain child elements.
  48585. var isSVG = makeMap(
  48586. 'svg,animate,circle,clippath,cursor,defs,desc,ellipse,filter,font-face,' +
  48587. 'foreignObject,g,glyph,image,line,marker,mask,missing-glyph,path,pattern,' +
  48588. 'polygon,polyline,rect,switch,symbol,text,textpath,tspan,use,view',
  48589. true
  48590. );
  48591. var isPreTag = function (tag) { return tag === 'pre'; };
  48592. var isReservedTag = function (tag) {
  48593. return isHTMLTag(tag) || isSVG(tag)
  48594. };
  48595. function getTagNamespace (tag) {
  48596. if (isSVG(tag)) {
  48597. return 'svg'
  48598. }
  48599. // basic support for MathML
  48600. // note it doesn't support other MathML elements being component roots
  48601. if (tag === 'math') {
  48602. return 'math'
  48603. }
  48604. }
  48605. var unknownElementCache = Object.create(null);
  48606. function isUnknownElement (tag) {
  48607. /* istanbul ignore if */
  48608. if (!inBrowser) {
  48609. return true
  48610. }
  48611. if (isReservedTag(tag)) {
  48612. return false
  48613. }
  48614. tag = tag.toLowerCase();
  48615. /* istanbul ignore if */
  48616. if (unknownElementCache[tag] != null) {
  48617. return unknownElementCache[tag]
  48618. }
  48619. var el = document.createElement(tag);
  48620. if (tag.indexOf('-') > -1) {
  48621. // http://stackoverflow.com/a/28210364/1070244
  48622. return (unknownElementCache[tag] = (
  48623. el.constructor === window.HTMLUnknownElement ||
  48624. el.constructor === window.HTMLElement
  48625. ))
  48626. } else {
  48627. return (unknownElementCache[tag] = /HTMLUnknownElement/.test(el.toString()))
  48628. }
  48629. }
  48630. var isTextInputType = makeMap('text,number,password,search,email,tel,url');
  48631. /* */
  48632. /**
  48633. * Query an element selector if it's not an element already.
  48634. */
  48635. function query (el) {
  48636. if (typeof el === 'string') {
  48637. var selected = document.querySelector(el);
  48638. if (!selected) {
  48639. warn(
  48640. 'Cannot find element: ' + el
  48641. );
  48642. return document.createElement('div')
  48643. }
  48644. return selected
  48645. } else {
  48646. return el
  48647. }
  48648. }
  48649. /* */
  48650. function createElement$1 (tagName, vnode) {
  48651. var elm = document.createElement(tagName);
  48652. if (tagName !== 'select') {
  48653. return elm
  48654. }
  48655. // false or null will remove the attribute but undefined will not
  48656. if (vnode.data && vnode.data.attrs && vnode.data.attrs.multiple !== undefined) {
  48657. elm.setAttribute('multiple', 'multiple');
  48658. }
  48659. return elm
  48660. }
  48661. function createElementNS (namespace, tagName) {
  48662. return document.createElementNS(namespaceMap[namespace], tagName)
  48663. }
  48664. function createTextNode (text) {
  48665. return document.createTextNode(text)
  48666. }
  48667. function createComment (text) {
  48668. return document.createComment(text)
  48669. }
  48670. function insertBefore (parentNode, newNode, referenceNode) {
  48671. parentNode.insertBefore(newNode, referenceNode);
  48672. }
  48673. function removeChild (node, child) {
  48674. node.removeChild(child);
  48675. }
  48676. function appendChild (node, child) {
  48677. node.appendChild(child);
  48678. }
  48679. function parentNode (node) {
  48680. return node.parentNode
  48681. }
  48682. function nextSibling (node) {
  48683. return node.nextSibling
  48684. }
  48685. function tagName (node) {
  48686. return node.tagName
  48687. }
  48688. function setTextContent (node, text) {
  48689. node.textContent = text;
  48690. }
  48691. function setStyleScope (node, scopeId) {
  48692. node.setAttribute(scopeId, '');
  48693. }
  48694. var nodeOps = /*#__PURE__*/Object.freeze({
  48695. createElement: createElement$1,
  48696. createElementNS: createElementNS,
  48697. createTextNode: createTextNode,
  48698. createComment: createComment,
  48699. insertBefore: insertBefore,
  48700. removeChild: removeChild,
  48701. appendChild: appendChild,
  48702. parentNode: parentNode,
  48703. nextSibling: nextSibling,
  48704. tagName: tagName,
  48705. setTextContent: setTextContent,
  48706. setStyleScope: setStyleScope
  48707. });
  48708. /* */
  48709. var ref = {
  48710. create: function create (_, vnode) {
  48711. registerRef(vnode);
  48712. },
  48713. update: function update (oldVnode, vnode) {
  48714. if (oldVnode.data.ref !== vnode.data.ref) {
  48715. registerRef(oldVnode, true);
  48716. registerRef(vnode);
  48717. }
  48718. },
  48719. destroy: function destroy (vnode) {
  48720. registerRef(vnode, true);
  48721. }
  48722. };
  48723. function registerRef (vnode, isRemoval) {
  48724. var key = vnode.data.ref;
  48725. if (!isDef(key)) { return }
  48726. var vm = vnode.context;
  48727. var ref = vnode.componentInstance || vnode.elm;
  48728. var refs = vm.$refs;
  48729. if (isRemoval) {
  48730. if (Array.isArray(refs[key])) {
  48731. remove(refs[key], ref);
  48732. } else if (refs[key] === ref) {
  48733. refs[key] = undefined;
  48734. }
  48735. } else {
  48736. if (vnode.data.refInFor) {
  48737. if (!Array.isArray(refs[key])) {
  48738. refs[key] = [ref];
  48739. } else if (refs[key].indexOf(ref) < 0) {
  48740. // $flow-disable-line
  48741. refs[key].push(ref);
  48742. }
  48743. } else {
  48744. refs[key] = ref;
  48745. }
  48746. }
  48747. }
  48748. /**
  48749. * Virtual DOM patching algorithm based on Snabbdom by
  48750. * Simon Friis Vindum (@paldepind)
  48751. * Licensed under the MIT License
  48752. * https://github.com/paldepind/snabbdom/blob/master/LICENSE
  48753. *
  48754. * modified by Evan You (@yyx990803)
  48755. *
  48756. * Not type-checking this because this file is perf-critical and the cost
  48757. * of making flow understand it is not worth it.
  48758. */
  48759. var emptyNode = new VNode('', {}, []);
  48760. var hooks = ['create', 'activate', 'update', 'remove', 'destroy'];
  48761. function sameVnode (a, b) {
  48762. return (
  48763. a.key === b.key && (
  48764. (
  48765. a.tag === b.tag &&
  48766. a.isComment === b.isComment &&
  48767. isDef(a.data) === isDef(b.data) &&
  48768. sameInputType(a, b)
  48769. ) || (
  48770. isTrue(a.isAsyncPlaceholder) &&
  48771. a.asyncFactory === b.asyncFactory &&
  48772. isUndef(b.asyncFactory.error)
  48773. )
  48774. )
  48775. )
  48776. }
  48777. function sameInputType (a, b) {
  48778. if (a.tag !== 'input') { return true }
  48779. var i;
  48780. var typeA = isDef(i = a.data) && isDef(i = i.attrs) && i.type;
  48781. var typeB = isDef(i = b.data) && isDef(i = i.attrs) && i.type;
  48782. return typeA === typeB || isTextInputType(typeA) && isTextInputType(typeB)
  48783. }
  48784. function createKeyToOldIdx (children, beginIdx, endIdx) {
  48785. var i, key;
  48786. var map = {};
  48787. for (i = beginIdx; i <= endIdx; ++i) {
  48788. key = children[i].key;
  48789. if (isDef(key)) { map[key] = i; }
  48790. }
  48791. return map
  48792. }
  48793. function createPatchFunction (backend) {
  48794. var i, j;
  48795. var cbs = {};
  48796. var modules = backend.modules;
  48797. var nodeOps = backend.nodeOps;
  48798. for (i = 0; i < hooks.length; ++i) {
  48799. cbs[hooks[i]] = [];
  48800. for (j = 0; j < modules.length; ++j) {
  48801. if (isDef(modules[j][hooks[i]])) {
  48802. cbs[hooks[i]].push(modules[j][hooks[i]]);
  48803. }
  48804. }
  48805. }
  48806. function emptyNodeAt (elm) {
  48807. return new VNode(nodeOps.tagName(elm).toLowerCase(), {}, [], undefined, elm)
  48808. }
  48809. function createRmCb (childElm, listeners) {
  48810. function remove$$1 () {
  48811. if (--remove$$1.listeners === 0) {
  48812. removeNode(childElm);
  48813. }
  48814. }
  48815. remove$$1.listeners = listeners;
  48816. return remove$$1
  48817. }
  48818. function removeNode (el) {
  48819. var parent = nodeOps.parentNode(el);
  48820. // element may have already been removed due to v-html / v-text
  48821. if (isDef(parent)) {
  48822. nodeOps.removeChild(parent, el);
  48823. }
  48824. }
  48825. function isUnknownElement$$1 (vnode, inVPre) {
  48826. return (
  48827. !inVPre &&
  48828. !vnode.ns &&
  48829. !(
  48830. config.ignoredElements.length &&
  48831. config.ignoredElements.some(function (ignore) {
  48832. return isRegExp(ignore)
  48833. ? ignore.test(vnode.tag)
  48834. : ignore === vnode.tag
  48835. })
  48836. ) &&
  48837. config.isUnknownElement(vnode.tag)
  48838. )
  48839. }
  48840. var creatingElmInVPre = 0;
  48841. function createElm (
  48842. vnode,
  48843. insertedVnodeQueue,
  48844. parentElm,
  48845. refElm,
  48846. nested,
  48847. ownerArray,
  48848. index
  48849. ) {
  48850. if (isDef(vnode.elm) && isDef(ownerArray)) {
  48851. // This vnode was used in a previous render!
  48852. // now it's used as a new node, overwriting its elm would cause
  48853. // potential patch errors down the road when it's used as an insertion
  48854. // reference node. Instead, we clone the node on-demand before creating
  48855. // associated DOM element for it.
  48856. vnode = ownerArray[index] = cloneVNode(vnode);
  48857. }
  48858. vnode.isRootInsert = !nested; // for transition enter check
  48859. if (createComponent(vnode, insertedVnodeQueue, parentElm, refElm)) {
  48860. return
  48861. }
  48862. var data = vnode.data;
  48863. var children = vnode.children;
  48864. var tag = vnode.tag;
  48865. if (isDef(tag)) {
  48866. {
  48867. if (data && data.pre) {
  48868. creatingElmInVPre++;
  48869. }
  48870. if (isUnknownElement$$1(vnode, creatingElmInVPre)) {
  48871. warn(
  48872. 'Unknown custom element: <' + tag + '> - did you ' +
  48873. 'register the component correctly? For recursive components, ' +
  48874. 'make sure to provide the "name" option.',
  48875. vnode.context
  48876. );
  48877. }
  48878. }
  48879. vnode.elm = vnode.ns
  48880. ? nodeOps.createElementNS(vnode.ns, tag)
  48881. : nodeOps.createElement(tag, vnode);
  48882. setScope(vnode);
  48883. /* istanbul ignore if */
  48884. {
  48885. createChildren(vnode, children, insertedVnodeQueue);
  48886. if (isDef(data)) {
  48887. invokeCreateHooks(vnode, insertedVnodeQueue);
  48888. }
  48889. insert(parentElm, vnode.elm, refElm);
  48890. }
  48891. if (data && data.pre) {
  48892. creatingElmInVPre--;
  48893. }
  48894. } else if (isTrue(vnode.isComment)) {
  48895. vnode.elm = nodeOps.createComment(vnode.text);
  48896. insert(parentElm, vnode.elm, refElm);
  48897. } else {
  48898. vnode.elm = nodeOps.createTextNode(vnode.text);
  48899. insert(parentElm, vnode.elm, refElm);
  48900. }
  48901. }
  48902. function createComponent (vnode, insertedVnodeQueue, parentElm, refElm) {
  48903. var i = vnode.data;
  48904. if (isDef(i)) {
  48905. var isReactivated = isDef(vnode.componentInstance) && i.keepAlive;
  48906. if (isDef(i = i.hook) && isDef(i = i.init)) {
  48907. i(vnode, false /* hydrating */);
  48908. }
  48909. // after calling the init hook, if the vnode is a child component
  48910. // it should've created a child instance and mounted it. the child
  48911. // component also has set the placeholder vnode's elm.
  48912. // in that case we can just return the element and be done.
  48913. if (isDef(vnode.componentInstance)) {
  48914. initComponent(vnode, insertedVnodeQueue);
  48915. insert(parentElm, vnode.elm, refElm);
  48916. if (isTrue(isReactivated)) {
  48917. reactivateComponent(vnode, insertedVnodeQueue, parentElm, refElm);
  48918. }
  48919. return true
  48920. }
  48921. }
  48922. }
  48923. function initComponent (vnode, insertedVnodeQueue) {
  48924. if (isDef(vnode.data.pendingInsert)) {
  48925. insertedVnodeQueue.push.apply(insertedVnodeQueue, vnode.data.pendingInsert);
  48926. vnode.data.pendingInsert = null;
  48927. }
  48928. vnode.elm = vnode.componentInstance.$el;
  48929. if (isPatchable(vnode)) {
  48930. invokeCreateHooks(vnode, insertedVnodeQueue);
  48931. setScope(vnode);
  48932. } else {
  48933. // empty component root.
  48934. // skip all element-related modules except for ref (#3455)
  48935. registerRef(vnode);
  48936. // make sure to invoke the insert hook
  48937. insertedVnodeQueue.push(vnode);
  48938. }
  48939. }
  48940. function reactivateComponent (vnode, insertedVnodeQueue, parentElm, refElm) {
  48941. var i;
  48942. // hack for #4339: a reactivated component with inner transition
  48943. // does not trigger because the inner node's created hooks are not called
  48944. // again. It's not ideal to involve module-specific logic in here but
  48945. // there doesn't seem to be a better way to do it.
  48946. var innerNode = vnode;
  48947. while (innerNode.componentInstance) {
  48948. innerNode = innerNode.componentInstance._vnode;
  48949. if (isDef(i = innerNode.data) && isDef(i = i.transition)) {
  48950. for (i = 0; i < cbs.activate.length; ++i) {
  48951. cbs.activate[i](emptyNode, innerNode);
  48952. }
  48953. insertedVnodeQueue.push(innerNode);
  48954. break
  48955. }
  48956. }
  48957. // unlike a newly created component,
  48958. // a reactivated keep-alive component doesn't insert itself
  48959. insert(parentElm, vnode.elm, refElm);
  48960. }
  48961. function insert (parent, elm, ref$$1) {
  48962. if (isDef(parent)) {
  48963. if (isDef(ref$$1)) {
  48964. if (nodeOps.parentNode(ref$$1) === parent) {
  48965. nodeOps.insertBefore(parent, elm, ref$$1);
  48966. }
  48967. } else {
  48968. nodeOps.appendChild(parent, elm);
  48969. }
  48970. }
  48971. }
  48972. function createChildren (vnode, children, insertedVnodeQueue) {
  48973. if (Array.isArray(children)) {
  48974. {
  48975. checkDuplicateKeys(children);
  48976. }
  48977. for (var i = 0; i < children.length; ++i) {
  48978. createElm(children[i], insertedVnodeQueue, vnode.elm, null, true, children, i);
  48979. }
  48980. } else if (isPrimitive(vnode.text)) {
  48981. nodeOps.appendChild(vnode.elm, nodeOps.createTextNode(String(vnode.text)));
  48982. }
  48983. }
  48984. function isPatchable (vnode) {
  48985. while (vnode.componentInstance) {
  48986. vnode = vnode.componentInstance._vnode;
  48987. }
  48988. return isDef(vnode.tag)
  48989. }
  48990. function invokeCreateHooks (vnode, insertedVnodeQueue) {
  48991. for (var i$1 = 0; i$1 < cbs.create.length; ++i$1) {
  48992. cbs.create[i$1](emptyNode, vnode);
  48993. }
  48994. i = vnode.data.hook; // Reuse variable
  48995. if (isDef(i)) {
  48996. if (isDef(i.create)) { i.create(emptyNode, vnode); }
  48997. if (isDef(i.insert)) { insertedVnodeQueue.push(vnode); }
  48998. }
  48999. }
  49000. // set scope id attribute for scoped CSS.
  49001. // this is implemented as a special case to avoid the overhead
  49002. // of going through the normal attribute patching process.
  49003. function setScope (vnode) {
  49004. var i;
  49005. if (isDef(i = vnode.fnScopeId)) {
  49006. nodeOps.setStyleScope(vnode.elm, i);
  49007. } else {
  49008. var ancestor = vnode;
  49009. while (ancestor) {
  49010. if (isDef(i = ancestor.context) && isDef(i = i.$options._scopeId)) {
  49011. nodeOps.setStyleScope(vnode.elm, i);
  49012. }
  49013. ancestor = ancestor.parent;
  49014. }
  49015. }
  49016. // for slot content they should also get the scopeId from the host instance.
  49017. if (isDef(i = activeInstance) &&
  49018. i !== vnode.context &&
  49019. i !== vnode.fnContext &&
  49020. isDef(i = i.$options._scopeId)
  49021. ) {
  49022. nodeOps.setStyleScope(vnode.elm, i);
  49023. }
  49024. }
  49025. function addVnodes (parentElm, refElm, vnodes, startIdx, endIdx, insertedVnodeQueue) {
  49026. for (; startIdx <= endIdx; ++startIdx) {
  49027. createElm(vnodes[startIdx], insertedVnodeQueue, parentElm, refElm, false, vnodes, startIdx);
  49028. }
  49029. }
  49030. function invokeDestroyHook (vnode) {
  49031. var i, j;
  49032. var data = vnode.data;
  49033. if (isDef(data)) {
  49034. if (isDef(i = data.hook) && isDef(i = i.destroy)) { i(vnode); }
  49035. for (i = 0; i < cbs.destroy.length; ++i) { cbs.destroy[i](vnode); }
  49036. }
  49037. if (isDef(i = vnode.children)) {
  49038. for (j = 0; j < vnode.children.length; ++j) {
  49039. invokeDestroyHook(vnode.children[j]);
  49040. }
  49041. }
  49042. }
  49043. function removeVnodes (vnodes, startIdx, endIdx) {
  49044. for (; startIdx <= endIdx; ++startIdx) {
  49045. var ch = vnodes[startIdx];
  49046. if (isDef(ch)) {
  49047. if (isDef(ch.tag)) {
  49048. removeAndInvokeRemoveHook(ch);
  49049. invokeDestroyHook(ch);
  49050. } else { // Text node
  49051. removeNode(ch.elm);
  49052. }
  49053. }
  49054. }
  49055. }
  49056. function removeAndInvokeRemoveHook (vnode, rm) {
  49057. if (isDef(rm) || isDef(vnode.data)) {
  49058. var i;
  49059. var listeners = cbs.remove.length + 1;
  49060. if (isDef(rm)) {
  49061. // we have a recursively passed down rm callback
  49062. // increase the listeners count
  49063. rm.listeners += listeners;
  49064. } else {
  49065. // directly removing
  49066. rm = createRmCb(vnode.elm, listeners);
  49067. }
  49068. // recursively invoke hooks on child component root node
  49069. if (isDef(i = vnode.componentInstance) && isDef(i = i._vnode) && isDef(i.data)) {
  49070. removeAndInvokeRemoveHook(i, rm);
  49071. }
  49072. for (i = 0; i < cbs.remove.length; ++i) {
  49073. cbs.remove[i](vnode, rm);
  49074. }
  49075. if (isDef(i = vnode.data.hook) && isDef(i = i.remove)) {
  49076. i(vnode, rm);
  49077. } else {
  49078. rm();
  49079. }
  49080. } else {
  49081. removeNode(vnode.elm);
  49082. }
  49083. }
  49084. function updateChildren (parentElm, oldCh, newCh, insertedVnodeQueue, removeOnly) {
  49085. var oldStartIdx = 0;
  49086. var newStartIdx = 0;
  49087. var oldEndIdx = oldCh.length - 1;
  49088. var oldStartVnode = oldCh[0];
  49089. var oldEndVnode = oldCh[oldEndIdx];
  49090. var newEndIdx = newCh.length - 1;
  49091. var newStartVnode = newCh[0];
  49092. var newEndVnode = newCh[newEndIdx];
  49093. var oldKeyToIdx, idxInOld, vnodeToMove, refElm;
  49094. // removeOnly is a special flag used only by <transition-group>
  49095. // to ensure removed elements stay in correct relative positions
  49096. // during leaving transitions
  49097. var canMove = !removeOnly;
  49098. {
  49099. checkDuplicateKeys(newCh);
  49100. }
  49101. while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
  49102. if (isUndef(oldStartVnode)) {
  49103. oldStartVnode = oldCh[++oldStartIdx]; // Vnode has been moved left
  49104. } else if (isUndef(oldEndVnode)) {
  49105. oldEndVnode = oldCh[--oldEndIdx];
  49106. } else if (sameVnode(oldStartVnode, newStartVnode)) {
  49107. patchVnode(oldStartVnode, newStartVnode, insertedVnodeQueue, newCh, newStartIdx);
  49108. oldStartVnode = oldCh[++oldStartIdx];
  49109. newStartVnode = newCh[++newStartIdx];
  49110. } else if (sameVnode(oldEndVnode, newEndVnode)) {
  49111. patchVnode(oldEndVnode, newEndVnode, insertedVnodeQueue, newCh, newEndIdx);
  49112. oldEndVnode = oldCh[--oldEndIdx];
  49113. newEndVnode = newCh[--newEndIdx];
  49114. } else if (sameVnode(oldStartVnode, newEndVnode)) { // Vnode moved right
  49115. patchVnode(oldStartVnode, newEndVnode, insertedVnodeQueue, newCh, newEndIdx);
  49116. canMove && nodeOps.insertBefore(parentElm, oldStartVnode.elm, nodeOps.nextSibling(oldEndVnode.elm));
  49117. oldStartVnode = oldCh[++oldStartIdx];
  49118. newEndVnode = newCh[--newEndIdx];
  49119. } else if (sameVnode(oldEndVnode, newStartVnode)) { // Vnode moved left
  49120. patchVnode(oldEndVnode, newStartVnode, insertedVnodeQueue, newCh, newStartIdx);
  49121. canMove && nodeOps.insertBefore(parentElm, oldEndVnode.elm, oldStartVnode.elm);
  49122. oldEndVnode = oldCh[--oldEndIdx];
  49123. newStartVnode = newCh[++newStartIdx];
  49124. } else {
  49125. if (isUndef(oldKeyToIdx)) { oldKeyToIdx = createKeyToOldIdx(oldCh, oldStartIdx, oldEndIdx); }
  49126. idxInOld = isDef(newStartVnode.key)
  49127. ? oldKeyToIdx[newStartVnode.key]
  49128. : findIdxInOld(newStartVnode, oldCh, oldStartIdx, oldEndIdx);
  49129. if (isUndef(idxInOld)) { // New element
  49130. createElm(newStartVnode, insertedVnodeQueue, parentElm, oldStartVnode.elm, false, newCh, newStartIdx);
  49131. } else {
  49132. vnodeToMove = oldCh[idxInOld];
  49133. if (sameVnode(vnodeToMove, newStartVnode)) {
  49134. patchVnode(vnodeToMove, newStartVnode, insertedVnodeQueue, newCh, newStartIdx);
  49135. oldCh[idxInOld] = undefined;
  49136. canMove && nodeOps.insertBefore(parentElm, vnodeToMove.elm, oldStartVnode.elm);
  49137. } else {
  49138. // same key but different element. treat as new element
  49139. createElm(newStartVnode, insertedVnodeQueue, parentElm, oldStartVnode.elm, false, newCh, newStartIdx);
  49140. }
  49141. }
  49142. newStartVnode = newCh[++newStartIdx];
  49143. }
  49144. }
  49145. if (oldStartIdx > oldEndIdx) {
  49146. refElm = isUndef(newCh[newEndIdx + 1]) ? null : newCh[newEndIdx + 1].elm;
  49147. addVnodes(parentElm, refElm, newCh, newStartIdx, newEndIdx, insertedVnodeQueue);
  49148. } else if (newStartIdx > newEndIdx) {
  49149. removeVnodes(oldCh, oldStartIdx, oldEndIdx);
  49150. }
  49151. }
  49152. function checkDuplicateKeys (children) {
  49153. var seenKeys = {};
  49154. for (var i = 0; i < children.length; i++) {
  49155. var vnode = children[i];
  49156. var key = vnode.key;
  49157. if (isDef(key)) {
  49158. if (seenKeys[key]) {
  49159. warn(
  49160. ("Duplicate keys detected: '" + key + "'. This may cause an update error."),
  49161. vnode.context
  49162. );
  49163. } else {
  49164. seenKeys[key] = true;
  49165. }
  49166. }
  49167. }
  49168. }
  49169. function findIdxInOld (node, oldCh, start, end) {
  49170. for (var i = start; i < end; i++) {
  49171. var c = oldCh[i];
  49172. if (isDef(c) && sameVnode(node, c)) { return i }
  49173. }
  49174. }
  49175. function patchVnode (
  49176. oldVnode,
  49177. vnode,
  49178. insertedVnodeQueue,
  49179. ownerArray,
  49180. index,
  49181. removeOnly
  49182. ) {
  49183. if (oldVnode === vnode) {
  49184. return
  49185. }
  49186. if (isDef(vnode.elm) && isDef(ownerArray)) {
  49187. // clone reused vnode
  49188. vnode = ownerArray[index] = cloneVNode(vnode);
  49189. }
  49190. var elm = vnode.elm = oldVnode.elm;
  49191. if (isTrue(oldVnode.isAsyncPlaceholder)) {
  49192. if (isDef(vnode.asyncFactory.resolved)) {
  49193. hydrate(oldVnode.elm, vnode, insertedVnodeQueue);
  49194. } else {
  49195. vnode.isAsyncPlaceholder = true;
  49196. }
  49197. return
  49198. }
  49199. // reuse element for static trees.
  49200. // note we only do this if the vnode is cloned -
  49201. // if the new node is not cloned it means the render functions have been
  49202. // reset by the hot-reload-api and we need to do a proper re-render.
  49203. if (isTrue(vnode.isStatic) &&
  49204. isTrue(oldVnode.isStatic) &&
  49205. vnode.key === oldVnode.key &&
  49206. (isTrue(vnode.isCloned) || isTrue(vnode.isOnce))
  49207. ) {
  49208. vnode.componentInstance = oldVnode.componentInstance;
  49209. return
  49210. }
  49211. var i;
  49212. var data = vnode.data;
  49213. if (isDef(data) && isDef(i = data.hook) && isDef(i = i.prepatch)) {
  49214. i(oldVnode, vnode);
  49215. }
  49216. var oldCh = oldVnode.children;
  49217. var ch = vnode.children;
  49218. if (isDef(data) && isPatchable(vnode)) {
  49219. for (i = 0; i < cbs.update.length; ++i) { cbs.update[i](oldVnode, vnode); }
  49220. if (isDef(i = data.hook) && isDef(i = i.update)) { i(oldVnode, vnode); }
  49221. }
  49222. if (isUndef(vnode.text)) {
  49223. if (isDef(oldCh) && isDef(ch)) {
  49224. if (oldCh !== ch) { updateChildren(elm, oldCh, ch, insertedVnodeQueue, removeOnly); }
  49225. } else if (isDef(ch)) {
  49226. {
  49227. checkDuplicateKeys(ch);
  49228. }
  49229. if (isDef(oldVnode.text)) { nodeOps.setTextContent(elm, ''); }
  49230. addVnodes(elm, null, ch, 0, ch.length - 1, insertedVnodeQueue);
  49231. } else if (isDef(oldCh)) {
  49232. removeVnodes(oldCh, 0, oldCh.length - 1);
  49233. } else if (isDef(oldVnode.text)) {
  49234. nodeOps.setTextContent(elm, '');
  49235. }
  49236. } else if (oldVnode.text !== vnode.text) {
  49237. nodeOps.setTextContent(elm, vnode.text);
  49238. }
  49239. if (isDef(data)) {
  49240. if (isDef(i = data.hook) && isDef(i = i.postpatch)) { i(oldVnode, vnode); }
  49241. }
  49242. }
  49243. function invokeInsertHook (vnode, queue, initial) {
  49244. // delay insert hooks for component root nodes, invoke them after the
  49245. // element is really inserted
  49246. if (isTrue(initial) && isDef(vnode.parent)) {
  49247. vnode.parent.data.pendingInsert = queue;
  49248. } else {
  49249. for (var i = 0; i < queue.length; ++i) {
  49250. queue[i].data.hook.insert(queue[i]);
  49251. }
  49252. }
  49253. }
  49254. var hydrationBailed = false;
  49255. // list of modules that can skip create hook during hydration because they
  49256. // are already rendered on the client or has no need for initialization
  49257. // Note: style is excluded because it relies on initial clone for future
  49258. // deep updates (#7063).
  49259. var isRenderedModule = makeMap('attrs,class,staticClass,staticStyle,key');
  49260. // Note: this is a browser-only function so we can assume elms are DOM nodes.
  49261. function hydrate (elm, vnode, insertedVnodeQueue, inVPre) {
  49262. var i;
  49263. var tag = vnode.tag;
  49264. var data = vnode.data;
  49265. var children = vnode.children;
  49266. inVPre = inVPre || (data && data.pre);
  49267. vnode.elm = elm;
  49268. if (isTrue(vnode.isComment) && isDef(vnode.asyncFactory)) {
  49269. vnode.isAsyncPlaceholder = true;
  49270. return true
  49271. }
  49272. // assert node match
  49273. {
  49274. if (!assertNodeMatch(elm, vnode, inVPre)) {
  49275. return false
  49276. }
  49277. }
  49278. if (isDef(data)) {
  49279. if (isDef(i = data.hook) && isDef(i = i.init)) { i(vnode, true /* hydrating */); }
  49280. if (isDef(i = vnode.componentInstance)) {
  49281. // child component. it should have hydrated its own tree.
  49282. initComponent(vnode, insertedVnodeQueue);
  49283. return true
  49284. }
  49285. }
  49286. if (isDef(tag)) {
  49287. if (isDef(children)) {
  49288. // empty element, allow client to pick up and populate children
  49289. if (!elm.hasChildNodes()) {
  49290. createChildren(vnode, children, insertedVnodeQueue);
  49291. } else {
  49292. // v-html and domProps: innerHTML
  49293. if (isDef(i = data) && isDef(i = i.domProps) && isDef(i = i.innerHTML)) {
  49294. if (i !== elm.innerHTML) {
  49295. /* istanbul ignore if */
  49296. if (typeof console !== 'undefined' &&
  49297. !hydrationBailed
  49298. ) {
  49299. hydrationBailed = true;
  49300. console.warn('Parent: ', elm);
  49301. console.warn('server innerHTML: ', i);
  49302. console.warn('client innerHTML: ', elm.innerHTML);
  49303. }
  49304. return false
  49305. }
  49306. } else {
  49307. // iterate and compare children lists
  49308. var childrenMatch = true;
  49309. var childNode = elm.firstChild;
  49310. for (var i$1 = 0; i$1 < children.length; i$1++) {
  49311. if (!childNode || !hydrate(childNode, children[i$1], insertedVnodeQueue, inVPre)) {
  49312. childrenMatch = false;
  49313. break
  49314. }
  49315. childNode = childNode.nextSibling;
  49316. }
  49317. // if childNode is not null, it means the actual childNodes list is
  49318. // longer than the virtual children list.
  49319. if (!childrenMatch || childNode) {
  49320. /* istanbul ignore if */
  49321. if (typeof console !== 'undefined' &&
  49322. !hydrationBailed
  49323. ) {
  49324. hydrationBailed = true;
  49325. console.warn('Parent: ', elm);
  49326. console.warn('Mismatching childNodes vs. VNodes: ', elm.childNodes, children);
  49327. }
  49328. return false
  49329. }
  49330. }
  49331. }
  49332. }
  49333. if (isDef(data)) {
  49334. var fullInvoke = false;
  49335. for (var key in data) {
  49336. if (!isRenderedModule(key)) {
  49337. fullInvoke = true;
  49338. invokeCreateHooks(vnode, insertedVnodeQueue);
  49339. break
  49340. }
  49341. }
  49342. if (!fullInvoke && data['class']) {
  49343. // ensure collecting deps for deep class bindings for future updates
  49344. traverse(data['class']);
  49345. }
  49346. }
  49347. } else if (elm.data !== vnode.text) {
  49348. elm.data = vnode.text;
  49349. }
  49350. return true
  49351. }
  49352. function assertNodeMatch (node, vnode, inVPre) {
  49353. if (isDef(vnode.tag)) {
  49354. return vnode.tag.indexOf('vue-component') === 0 || (
  49355. !isUnknownElement$$1(vnode, inVPre) &&
  49356. vnode.tag.toLowerCase() === (node.tagName && node.tagName.toLowerCase())
  49357. )
  49358. } else {
  49359. return node.nodeType === (vnode.isComment ? 8 : 3)
  49360. }
  49361. }
  49362. return function patch (oldVnode, vnode, hydrating, removeOnly) {
  49363. if (isUndef(vnode)) {
  49364. if (isDef(oldVnode)) { invokeDestroyHook(oldVnode); }
  49365. return
  49366. }
  49367. var isInitialPatch = false;
  49368. var insertedVnodeQueue = [];
  49369. if (isUndef(oldVnode)) {
  49370. // empty mount (likely as component), create new root element
  49371. isInitialPatch = true;
  49372. createElm(vnode, insertedVnodeQueue);
  49373. } else {
  49374. var isRealElement = isDef(oldVnode.nodeType);
  49375. if (!isRealElement && sameVnode(oldVnode, vnode)) {
  49376. // patch existing root node
  49377. patchVnode(oldVnode, vnode, insertedVnodeQueue, null, null, removeOnly);
  49378. } else {
  49379. if (isRealElement) {
  49380. // mounting to a real element
  49381. // check if this is server-rendered content and if we can perform
  49382. // a successful hydration.
  49383. if (oldVnode.nodeType === 1 && oldVnode.hasAttribute(SSR_ATTR)) {
  49384. oldVnode.removeAttribute(SSR_ATTR);
  49385. hydrating = true;
  49386. }
  49387. if (isTrue(hydrating)) {
  49388. if (hydrate(oldVnode, vnode, insertedVnodeQueue)) {
  49389. invokeInsertHook(vnode, insertedVnodeQueue, true);
  49390. return oldVnode
  49391. } else {
  49392. warn(
  49393. 'The client-side rendered virtual DOM tree is not matching ' +
  49394. 'server-rendered content. This is likely caused by incorrect ' +
  49395. 'HTML markup, for example nesting block-level elements inside ' +
  49396. '<p>, or missing <tbody>. Bailing hydration and performing ' +
  49397. 'full client-side render.'
  49398. );
  49399. }
  49400. }
  49401. // either not server-rendered, or hydration failed.
  49402. // create an empty node and replace it
  49403. oldVnode = emptyNodeAt(oldVnode);
  49404. }
  49405. // replacing existing element
  49406. var oldElm = oldVnode.elm;
  49407. var parentElm = nodeOps.parentNode(oldElm);
  49408. // create new node
  49409. createElm(
  49410. vnode,
  49411. insertedVnodeQueue,
  49412. // extremely rare edge case: do not insert if old element is in a
  49413. // leaving transition. Only happens when combining transition +
  49414. // keep-alive + HOCs. (#4590)
  49415. oldElm._leaveCb ? null : parentElm,
  49416. nodeOps.nextSibling(oldElm)
  49417. );
  49418. // update parent placeholder node element, recursively
  49419. if (isDef(vnode.parent)) {
  49420. var ancestor = vnode.parent;
  49421. var patchable = isPatchable(vnode);
  49422. while (ancestor) {
  49423. for (var i = 0; i < cbs.destroy.length; ++i) {
  49424. cbs.destroy[i](ancestor);
  49425. }
  49426. ancestor.elm = vnode.elm;
  49427. if (patchable) {
  49428. for (var i$1 = 0; i$1 < cbs.create.length; ++i$1) {
  49429. cbs.create[i$1](emptyNode, ancestor);
  49430. }
  49431. // #6513
  49432. // invoke insert hooks that may have been merged by create hooks.
  49433. // e.g. for directives that uses the "inserted" hook.
  49434. var insert = ancestor.data.hook.insert;
  49435. if (insert.merged) {
  49436. // start at index 1 to avoid re-invoking component mounted hook
  49437. for (var i$2 = 1; i$2 < insert.fns.length; i$2++) {
  49438. insert.fns[i$2]();
  49439. }
  49440. }
  49441. } else {
  49442. registerRef(ancestor);
  49443. }
  49444. ancestor = ancestor.parent;
  49445. }
  49446. }
  49447. // destroy old node
  49448. if (isDef(parentElm)) {
  49449. removeVnodes([oldVnode], 0, 0);
  49450. } else if (isDef(oldVnode.tag)) {
  49451. invokeDestroyHook(oldVnode);
  49452. }
  49453. }
  49454. }
  49455. invokeInsertHook(vnode, insertedVnodeQueue, isInitialPatch);
  49456. return vnode.elm
  49457. }
  49458. }
  49459. /* */
  49460. var directives = {
  49461. create: updateDirectives,
  49462. update: updateDirectives,
  49463. destroy: function unbindDirectives (vnode) {
  49464. updateDirectives(vnode, emptyNode);
  49465. }
  49466. };
  49467. function updateDirectives (oldVnode, vnode) {
  49468. if (oldVnode.data.directives || vnode.data.directives) {
  49469. _update(oldVnode, vnode);
  49470. }
  49471. }
  49472. function _update (oldVnode, vnode) {
  49473. var isCreate = oldVnode === emptyNode;
  49474. var isDestroy = vnode === emptyNode;
  49475. var oldDirs = normalizeDirectives$1(oldVnode.data.directives, oldVnode.context);
  49476. var newDirs = normalizeDirectives$1(vnode.data.directives, vnode.context);
  49477. var dirsWithInsert = [];
  49478. var dirsWithPostpatch = [];
  49479. var key, oldDir, dir;
  49480. for (key in newDirs) {
  49481. oldDir = oldDirs[key];
  49482. dir = newDirs[key];
  49483. if (!oldDir) {
  49484. // new directive, bind
  49485. callHook$1(dir, 'bind', vnode, oldVnode);
  49486. if (dir.def && dir.def.inserted) {
  49487. dirsWithInsert.push(dir);
  49488. }
  49489. } else {
  49490. // existing directive, update
  49491. dir.oldValue = oldDir.value;
  49492. dir.oldArg = oldDir.arg;
  49493. callHook$1(dir, 'update', vnode, oldVnode);
  49494. if (dir.def && dir.def.componentUpdated) {
  49495. dirsWithPostpatch.push(dir);
  49496. }
  49497. }
  49498. }
  49499. if (dirsWithInsert.length) {
  49500. var callInsert = function () {
  49501. for (var i = 0; i < dirsWithInsert.length; i++) {
  49502. callHook$1(dirsWithInsert[i], 'inserted', vnode, oldVnode);
  49503. }
  49504. };
  49505. if (isCreate) {
  49506. mergeVNodeHook(vnode, 'insert', callInsert);
  49507. } else {
  49508. callInsert();
  49509. }
  49510. }
  49511. if (dirsWithPostpatch.length) {
  49512. mergeVNodeHook(vnode, 'postpatch', function () {
  49513. for (var i = 0; i < dirsWithPostpatch.length; i++) {
  49514. callHook$1(dirsWithPostpatch[i], 'componentUpdated', vnode, oldVnode);
  49515. }
  49516. });
  49517. }
  49518. if (!isCreate) {
  49519. for (key in oldDirs) {
  49520. if (!newDirs[key]) {
  49521. // no longer present, unbind
  49522. callHook$1(oldDirs[key], 'unbind', oldVnode, oldVnode, isDestroy);
  49523. }
  49524. }
  49525. }
  49526. }
  49527. var emptyModifiers = Object.create(null);
  49528. function normalizeDirectives$1 (
  49529. dirs,
  49530. vm
  49531. ) {
  49532. var res = Object.create(null);
  49533. if (!dirs) {
  49534. // $flow-disable-line
  49535. return res
  49536. }
  49537. var i, dir;
  49538. for (i = 0; i < dirs.length; i++) {
  49539. dir = dirs[i];
  49540. if (!dir.modifiers) {
  49541. // $flow-disable-line
  49542. dir.modifiers = emptyModifiers;
  49543. }
  49544. res[getRawDirName(dir)] = dir;
  49545. dir.def = resolveAsset(vm.$options, 'directives', dir.name, true);
  49546. }
  49547. // $flow-disable-line
  49548. return res
  49549. }
  49550. function getRawDirName (dir) {
  49551. return dir.rawName || ((dir.name) + "." + (Object.keys(dir.modifiers || {}).join('.')))
  49552. }
  49553. function callHook$1 (dir, hook, vnode, oldVnode, isDestroy) {
  49554. var fn = dir.def && dir.def[hook];
  49555. if (fn) {
  49556. try {
  49557. fn(vnode.elm, dir, vnode, oldVnode, isDestroy);
  49558. } catch (e) {
  49559. handleError(e, vnode.context, ("directive " + (dir.name) + " " + hook + " hook"));
  49560. }
  49561. }
  49562. }
  49563. var baseModules = [
  49564. ref,
  49565. directives
  49566. ];
  49567. /* */
  49568. function updateAttrs (oldVnode, vnode) {
  49569. var opts = vnode.componentOptions;
  49570. if (isDef(opts) && opts.Ctor.options.inheritAttrs === false) {
  49571. return
  49572. }
  49573. if (isUndef(oldVnode.data.attrs) && isUndef(vnode.data.attrs)) {
  49574. return
  49575. }
  49576. var key, cur, old;
  49577. var elm = vnode.elm;
  49578. var oldAttrs = oldVnode.data.attrs || {};
  49579. var attrs = vnode.data.attrs || {};
  49580. // clone observed objects, as the user probably wants to mutate it
  49581. if (isDef(attrs.__ob__)) {
  49582. attrs = vnode.data.attrs = extend({}, attrs);
  49583. }
  49584. for (key in attrs) {
  49585. cur = attrs[key];
  49586. old = oldAttrs[key];
  49587. if (old !== cur) {
  49588. setAttr(elm, key, cur);
  49589. }
  49590. }
  49591. // #4391: in IE9, setting type can reset value for input[type=radio]
  49592. // #6666: IE/Edge forces progress value down to 1 before setting a max
  49593. /* istanbul ignore if */
  49594. if ((isIE || isEdge) && attrs.value !== oldAttrs.value) {
  49595. setAttr(elm, 'value', attrs.value);
  49596. }
  49597. for (key in oldAttrs) {
  49598. if (isUndef(attrs[key])) {
  49599. if (isXlink(key)) {
  49600. elm.removeAttributeNS(xlinkNS, getXlinkProp(key));
  49601. } else if (!isEnumeratedAttr(key)) {
  49602. elm.removeAttribute(key);
  49603. }
  49604. }
  49605. }
  49606. }
  49607. function setAttr (el, key, value) {
  49608. if (el.tagName.indexOf('-') > -1) {
  49609. baseSetAttr(el, key, value);
  49610. } else if (isBooleanAttr(key)) {
  49611. // set attribute for blank value
  49612. // e.g. <option disabled>Select one</option>
  49613. if (isFalsyAttrValue(value)) {
  49614. el.removeAttribute(key);
  49615. } else {
  49616. // technically allowfullscreen is a boolean attribute for <iframe>,
  49617. // but Flash expects a value of "true" when used on <embed> tag
  49618. value = key === 'allowfullscreen' && el.tagName === 'EMBED'
  49619. ? 'true'
  49620. : key;
  49621. el.setAttribute(key, value);
  49622. }
  49623. } else if (isEnumeratedAttr(key)) {
  49624. el.setAttribute(key, convertEnumeratedValue(key, value));
  49625. } else if (isXlink(key)) {
  49626. if (isFalsyAttrValue(value)) {
  49627. el.removeAttributeNS(xlinkNS, getXlinkProp(key));
  49628. } else {
  49629. el.setAttributeNS(xlinkNS, key, value);
  49630. }
  49631. } else {
  49632. baseSetAttr(el, key, value);
  49633. }
  49634. }
  49635. function baseSetAttr (el, key, value) {
  49636. if (isFalsyAttrValue(value)) {
  49637. el.removeAttribute(key);
  49638. } else {
  49639. // #7138: IE10 & 11 fires input event when setting placeholder on
  49640. // <textarea>... block the first input event and remove the blocker
  49641. // immediately.
  49642. /* istanbul ignore if */
  49643. if (
  49644. isIE && !isIE9 &&
  49645. el.tagName === 'TEXTAREA' &&
  49646. key === 'placeholder' && value !== '' && !el.__ieph
  49647. ) {
  49648. var blocker = function (e) {
  49649. e.stopImmediatePropagation();
  49650. el.removeEventListener('input', blocker);
  49651. };
  49652. el.addEventListener('input', blocker);
  49653. // $flow-disable-line
  49654. el.__ieph = true; /* IE placeholder patched */
  49655. }
  49656. el.setAttribute(key, value);
  49657. }
  49658. }
  49659. var attrs = {
  49660. create: updateAttrs,
  49661. update: updateAttrs
  49662. };
  49663. /* */
  49664. function updateClass (oldVnode, vnode) {
  49665. var el = vnode.elm;
  49666. var data = vnode.data;
  49667. var oldData = oldVnode.data;
  49668. if (
  49669. isUndef(data.staticClass) &&
  49670. isUndef(data.class) && (
  49671. isUndef(oldData) || (
  49672. isUndef(oldData.staticClass) &&
  49673. isUndef(oldData.class)
  49674. )
  49675. )
  49676. ) {
  49677. return
  49678. }
  49679. var cls = genClassForVnode(vnode);
  49680. // handle transition classes
  49681. var transitionClass = el._transitionClasses;
  49682. if (isDef(transitionClass)) {
  49683. cls = concat(cls, stringifyClass(transitionClass));
  49684. }
  49685. // set the class
  49686. if (cls !== el._prevClass) {
  49687. el.setAttribute('class', cls);
  49688. el._prevClass = cls;
  49689. }
  49690. }
  49691. var klass = {
  49692. create: updateClass,
  49693. update: updateClass
  49694. };
  49695. /* */
  49696. var validDivisionCharRE = /[\w).+\-_$\]]/;
  49697. function parseFilters (exp) {
  49698. var inSingle = false;
  49699. var inDouble = false;
  49700. var inTemplateString = false;
  49701. var inRegex = false;
  49702. var curly = 0;
  49703. var square = 0;
  49704. var paren = 0;
  49705. var lastFilterIndex = 0;
  49706. var c, prev, i, expression, filters;
  49707. for (i = 0; i < exp.length; i++) {
  49708. prev = c;
  49709. c = exp.charCodeAt(i);
  49710. if (inSingle) {
  49711. if (c === 0x27 && prev !== 0x5C) { inSingle = false; }
  49712. } else if (inDouble) {
  49713. if (c === 0x22 && prev !== 0x5C) { inDouble = false; }
  49714. } else if (inTemplateString) {
  49715. if (c === 0x60 && prev !== 0x5C) { inTemplateString = false; }
  49716. } else if (inRegex) {
  49717. if (c === 0x2f && prev !== 0x5C) { inRegex = false; }
  49718. } else if (
  49719. c === 0x7C && // pipe
  49720. exp.charCodeAt(i + 1) !== 0x7C &&
  49721. exp.charCodeAt(i - 1) !== 0x7C &&
  49722. !curly && !square && !paren
  49723. ) {
  49724. if (expression === undefined) {
  49725. // first filter, end of expression
  49726. lastFilterIndex = i + 1;
  49727. expression = exp.slice(0, i).trim();
  49728. } else {
  49729. pushFilter();
  49730. }
  49731. } else {
  49732. switch (c) {
  49733. case 0x22: inDouble = true; break // "
  49734. case 0x27: inSingle = true; break // '
  49735. case 0x60: inTemplateString = true; break // `
  49736. case 0x28: paren++; break // (
  49737. case 0x29: paren--; break // )
  49738. case 0x5B: square++; break // [
  49739. case 0x5D: square--; break // ]
  49740. case 0x7B: curly++; break // {
  49741. case 0x7D: curly--; break // }
  49742. }
  49743. if (c === 0x2f) { // /
  49744. var j = i - 1;
  49745. var p = (void 0);
  49746. // find first non-whitespace prev char
  49747. for (; j >= 0; j--) {
  49748. p = exp.charAt(j);
  49749. if (p !== ' ') { break }
  49750. }
  49751. if (!p || !validDivisionCharRE.test(p)) {
  49752. inRegex = true;
  49753. }
  49754. }
  49755. }
  49756. }
  49757. if (expression === undefined) {
  49758. expression = exp.slice(0, i).trim();
  49759. } else if (lastFilterIndex !== 0) {
  49760. pushFilter();
  49761. }
  49762. function pushFilter () {
  49763. (filters || (filters = [])).push(exp.slice(lastFilterIndex, i).trim());
  49764. lastFilterIndex = i + 1;
  49765. }
  49766. if (filters) {
  49767. for (i = 0; i < filters.length; i++) {
  49768. expression = wrapFilter(expression, filters[i]);
  49769. }
  49770. }
  49771. return expression
  49772. }
  49773. function wrapFilter (exp, filter) {
  49774. var i = filter.indexOf('(');
  49775. if (i < 0) {
  49776. // _f: resolveFilter
  49777. return ("_f(\"" + filter + "\")(" + exp + ")")
  49778. } else {
  49779. var name = filter.slice(0, i);
  49780. var args = filter.slice(i + 1);
  49781. return ("_f(\"" + name + "\")(" + exp + (args !== ')' ? ',' + args : args))
  49782. }
  49783. }
  49784. /* */
  49785. /* eslint-disable no-unused-vars */
  49786. function baseWarn (msg, range) {
  49787. console.error(("[Vue compiler]: " + msg));
  49788. }
  49789. /* eslint-enable no-unused-vars */
  49790. function pluckModuleFunction (
  49791. modules,
  49792. key
  49793. ) {
  49794. return modules
  49795. ? modules.map(function (m) { return m[key]; }).filter(function (_) { return _; })
  49796. : []
  49797. }
  49798. function addProp (el, name, value, range, dynamic) {
  49799. (el.props || (el.props = [])).push(rangeSetItem({ name: name, value: value, dynamic: dynamic }, range));
  49800. el.plain = false;
  49801. }
  49802. function addAttr (el, name, value, range, dynamic) {
  49803. var attrs = dynamic
  49804. ? (el.dynamicAttrs || (el.dynamicAttrs = []))
  49805. : (el.attrs || (el.attrs = []));
  49806. attrs.push(rangeSetItem({ name: name, value: value, dynamic: dynamic }, range));
  49807. el.plain = false;
  49808. }
  49809. // add a raw attr (use this in preTransforms)
  49810. function addRawAttr (el, name, value, range) {
  49811. el.attrsMap[name] = value;
  49812. el.attrsList.push(rangeSetItem({ name: name, value: value }, range));
  49813. }
  49814. function addDirective (
  49815. el,
  49816. name,
  49817. rawName,
  49818. value,
  49819. arg,
  49820. isDynamicArg,
  49821. modifiers,
  49822. range
  49823. ) {
  49824. (el.directives || (el.directives = [])).push(rangeSetItem({
  49825. name: name,
  49826. rawName: rawName,
  49827. value: value,
  49828. arg: arg,
  49829. isDynamicArg: isDynamicArg,
  49830. modifiers: modifiers
  49831. }, range));
  49832. el.plain = false;
  49833. }
  49834. function prependModifierMarker (symbol, name, dynamic) {
  49835. return dynamic
  49836. ? ("_p(" + name + ",\"" + symbol + "\")")
  49837. : symbol + name // mark the event as captured
  49838. }
  49839. function addHandler (
  49840. el,
  49841. name,
  49842. value,
  49843. modifiers,
  49844. important,
  49845. warn,
  49846. range,
  49847. dynamic
  49848. ) {
  49849. modifiers = modifiers || emptyObject;
  49850. // warn prevent and passive modifier
  49851. /* istanbul ignore if */
  49852. if (
  49853. warn &&
  49854. modifiers.prevent && modifiers.passive
  49855. ) {
  49856. warn(
  49857. 'passive and prevent can\'t be used together. ' +
  49858. 'Passive handler can\'t prevent default event.',
  49859. range
  49860. );
  49861. }
  49862. // normalize click.right and click.middle since they don't actually fire
  49863. // this is technically browser-specific, but at least for now browsers are
  49864. // the only target envs that have right/middle clicks.
  49865. if (modifiers.right) {
  49866. if (dynamic) {
  49867. name = "(" + name + ")==='click'?'contextmenu':(" + name + ")";
  49868. } else if (name === 'click') {
  49869. name = 'contextmenu';
  49870. delete modifiers.right;
  49871. }
  49872. } else if (modifiers.middle) {
  49873. if (dynamic) {
  49874. name = "(" + name + ")==='click'?'mouseup':(" + name + ")";
  49875. } else if (name === 'click') {
  49876. name = 'mouseup';
  49877. }
  49878. }
  49879. // check capture modifier
  49880. if (modifiers.capture) {
  49881. delete modifiers.capture;
  49882. name = prependModifierMarker('!', name, dynamic);
  49883. }
  49884. if (modifiers.once) {
  49885. delete modifiers.once;
  49886. name = prependModifierMarker('~', name, dynamic);
  49887. }
  49888. /* istanbul ignore if */
  49889. if (modifiers.passive) {
  49890. delete modifiers.passive;
  49891. name = prependModifierMarker('&', name, dynamic);
  49892. }
  49893. var events;
  49894. if (modifiers.native) {
  49895. delete modifiers.native;
  49896. events = el.nativeEvents || (el.nativeEvents = {});
  49897. } else {
  49898. events = el.events || (el.events = {});
  49899. }
  49900. var newHandler = rangeSetItem({ value: value.trim(), dynamic: dynamic }, range);
  49901. if (modifiers !== emptyObject) {
  49902. newHandler.modifiers = modifiers;
  49903. }
  49904. var handlers = events[name];
  49905. /* istanbul ignore if */
  49906. if (Array.isArray(handlers)) {
  49907. important ? handlers.unshift(newHandler) : handlers.push(newHandler);
  49908. } else if (handlers) {
  49909. events[name] = important ? [newHandler, handlers] : [handlers, newHandler];
  49910. } else {
  49911. events[name] = newHandler;
  49912. }
  49913. el.plain = false;
  49914. }
  49915. function getRawBindingAttr (
  49916. el,
  49917. name
  49918. ) {
  49919. return el.rawAttrsMap[':' + name] ||
  49920. el.rawAttrsMap['v-bind:' + name] ||
  49921. el.rawAttrsMap[name]
  49922. }
  49923. function getBindingAttr (
  49924. el,
  49925. name,
  49926. getStatic
  49927. ) {
  49928. var dynamicValue =
  49929. getAndRemoveAttr(el, ':' + name) ||
  49930. getAndRemoveAttr(el, 'v-bind:' + name);
  49931. if (dynamicValue != null) {
  49932. return parseFilters(dynamicValue)
  49933. } else if (getStatic !== false) {
  49934. var staticValue = getAndRemoveAttr(el, name);
  49935. if (staticValue != null) {
  49936. return JSON.stringify(staticValue)
  49937. }
  49938. }
  49939. }
  49940. // note: this only removes the attr from the Array (attrsList) so that it
  49941. // doesn't get processed by processAttrs.
  49942. // By default it does NOT remove it from the map (attrsMap) because the map is
  49943. // needed during codegen.
  49944. function getAndRemoveAttr (
  49945. el,
  49946. name,
  49947. removeFromMap
  49948. ) {
  49949. var val;
  49950. if ((val = el.attrsMap[name]) != null) {
  49951. var list = el.attrsList;
  49952. for (var i = 0, l = list.length; i < l; i++) {
  49953. if (list[i].name === name) {
  49954. list.splice(i, 1);
  49955. break
  49956. }
  49957. }
  49958. }
  49959. if (removeFromMap) {
  49960. delete el.attrsMap[name];
  49961. }
  49962. return val
  49963. }
  49964. function getAndRemoveAttrByRegex (
  49965. el,
  49966. name
  49967. ) {
  49968. var list = el.attrsList;
  49969. for (var i = 0, l = list.length; i < l; i++) {
  49970. var attr = list[i];
  49971. if (name.test(attr.name)) {
  49972. list.splice(i, 1);
  49973. return attr
  49974. }
  49975. }
  49976. }
  49977. function rangeSetItem (
  49978. item,
  49979. range
  49980. ) {
  49981. if (range) {
  49982. if (range.start != null) {
  49983. item.start = range.start;
  49984. }
  49985. if (range.end != null) {
  49986. item.end = range.end;
  49987. }
  49988. }
  49989. return item
  49990. }
  49991. /* */
  49992. /**
  49993. * Cross-platform code generation for component v-model
  49994. */
  49995. function genComponentModel (
  49996. el,
  49997. value,
  49998. modifiers
  49999. ) {
  50000. var ref = modifiers || {};
  50001. var number = ref.number;
  50002. var trim = ref.trim;
  50003. var baseValueExpression = '$$v';
  50004. var valueExpression = baseValueExpression;
  50005. if (trim) {
  50006. valueExpression =
  50007. "(typeof " + baseValueExpression + " === 'string'" +
  50008. "? " + baseValueExpression + ".trim()" +
  50009. ": " + baseValueExpression + ")";
  50010. }
  50011. if (number) {
  50012. valueExpression = "_n(" + valueExpression + ")";
  50013. }
  50014. var assignment = genAssignmentCode(value, valueExpression);
  50015. el.model = {
  50016. value: ("(" + value + ")"),
  50017. expression: JSON.stringify(value),
  50018. callback: ("function (" + baseValueExpression + ") {" + assignment + "}")
  50019. };
  50020. }
  50021. /**
  50022. * Cross-platform codegen helper for generating v-model value assignment code.
  50023. */
  50024. function genAssignmentCode (
  50025. value,
  50026. assignment
  50027. ) {
  50028. var res = parseModel(value);
  50029. if (res.key === null) {
  50030. return (value + "=" + assignment)
  50031. } else {
  50032. return ("$set(" + (res.exp) + ", " + (res.key) + ", " + assignment + ")")
  50033. }
  50034. }
  50035. /**
  50036. * Parse a v-model expression into a base path and a final key segment.
  50037. * Handles both dot-path and possible square brackets.
  50038. *
  50039. * Possible cases:
  50040. *
  50041. * - test
  50042. * - test[key]
  50043. * - test[test1[key]]
  50044. * - test["a"][key]
  50045. * - xxx.test[a[a].test1[key]]
  50046. * - test.xxx.a["asa"][test1[key]]
  50047. *
  50048. */
  50049. var len, str, chr, index$1, expressionPos, expressionEndPos;
  50050. function parseModel (val) {
  50051. // Fix https://github.com/vuejs/vue/pull/7730
  50052. // allow v-model="obj.val " (trailing whitespace)
  50053. val = val.trim();
  50054. len = val.length;
  50055. if (val.indexOf('[') < 0 || val.lastIndexOf(']') < len - 1) {
  50056. index$1 = val.lastIndexOf('.');
  50057. if (index$1 > -1) {
  50058. return {
  50059. exp: val.slice(0, index$1),
  50060. key: '"' + val.slice(index$1 + 1) + '"'
  50061. }
  50062. } else {
  50063. return {
  50064. exp: val,
  50065. key: null
  50066. }
  50067. }
  50068. }
  50069. str = val;
  50070. index$1 = expressionPos = expressionEndPos = 0;
  50071. while (!eof()) {
  50072. chr = next();
  50073. /* istanbul ignore if */
  50074. if (isStringStart(chr)) {
  50075. parseString(chr);
  50076. } else if (chr === 0x5B) {
  50077. parseBracket(chr);
  50078. }
  50079. }
  50080. return {
  50081. exp: val.slice(0, expressionPos),
  50082. key: val.slice(expressionPos + 1, expressionEndPos)
  50083. }
  50084. }
  50085. function next () {
  50086. return str.charCodeAt(++index$1)
  50087. }
  50088. function eof () {
  50089. return index$1 >= len
  50090. }
  50091. function isStringStart (chr) {
  50092. return chr === 0x22 || chr === 0x27
  50093. }
  50094. function parseBracket (chr) {
  50095. var inBracket = 1;
  50096. expressionPos = index$1;
  50097. while (!eof()) {
  50098. chr = next();
  50099. if (isStringStart(chr)) {
  50100. parseString(chr);
  50101. continue
  50102. }
  50103. if (chr === 0x5B) { inBracket++; }
  50104. if (chr === 0x5D) { inBracket--; }
  50105. if (inBracket === 0) {
  50106. expressionEndPos = index$1;
  50107. break
  50108. }
  50109. }
  50110. }
  50111. function parseString (chr) {
  50112. var stringQuote = chr;
  50113. while (!eof()) {
  50114. chr = next();
  50115. if (chr === stringQuote) {
  50116. break
  50117. }
  50118. }
  50119. }
  50120. /* */
  50121. var warn$1;
  50122. // in some cases, the event used has to be determined at runtime
  50123. // so we used some reserved tokens during compile.
  50124. var RANGE_TOKEN = '__r';
  50125. var CHECKBOX_RADIO_TOKEN = '__c';
  50126. function model (
  50127. el,
  50128. dir,
  50129. _warn
  50130. ) {
  50131. warn$1 = _warn;
  50132. var value = dir.value;
  50133. var modifiers = dir.modifiers;
  50134. var tag = el.tag;
  50135. var type = el.attrsMap.type;
  50136. {
  50137. // inputs with type="file" are read only and setting the input's
  50138. // value will throw an error.
  50139. if (tag === 'input' && type === 'file') {
  50140. warn$1(
  50141. "<" + (el.tag) + " v-model=\"" + value + "\" type=\"file\">:\n" +
  50142. "File inputs are read only. Use a v-on:change listener instead.",
  50143. el.rawAttrsMap['v-model']
  50144. );
  50145. }
  50146. }
  50147. if (el.component) {
  50148. genComponentModel(el, value, modifiers);
  50149. // component v-model doesn't need extra runtime
  50150. return false
  50151. } else if (tag === 'select') {
  50152. genSelect(el, value, modifiers);
  50153. } else if (tag === 'input' && type === 'checkbox') {
  50154. genCheckboxModel(el, value, modifiers);
  50155. } else if (tag === 'input' && type === 'radio') {
  50156. genRadioModel(el, value, modifiers);
  50157. } else if (tag === 'input' || tag === 'textarea') {
  50158. genDefaultModel(el, value, modifiers);
  50159. } else if (!config.isReservedTag(tag)) {
  50160. genComponentModel(el, value, modifiers);
  50161. // component v-model doesn't need extra runtime
  50162. return false
  50163. } else {
  50164. warn$1(
  50165. "<" + (el.tag) + " v-model=\"" + value + "\">: " +
  50166. "v-model is not supported on this element type. " +
  50167. 'If you are working with contenteditable, it\'s recommended to ' +
  50168. 'wrap a library dedicated for that purpose inside a custom component.',
  50169. el.rawAttrsMap['v-model']
  50170. );
  50171. }
  50172. // ensure runtime directive metadata
  50173. return true
  50174. }
  50175. function genCheckboxModel (
  50176. el,
  50177. value,
  50178. modifiers
  50179. ) {
  50180. var number = modifiers && modifiers.number;
  50181. var valueBinding = getBindingAttr(el, 'value') || 'null';
  50182. var trueValueBinding = getBindingAttr(el, 'true-value') || 'true';
  50183. var falseValueBinding = getBindingAttr(el, 'false-value') || 'false';
  50184. addProp(el, 'checked',
  50185. "Array.isArray(" + value + ")" +
  50186. "?_i(" + value + "," + valueBinding + ")>-1" + (
  50187. trueValueBinding === 'true'
  50188. ? (":(" + value + ")")
  50189. : (":_q(" + value + "," + trueValueBinding + ")")
  50190. )
  50191. );
  50192. addHandler(el, 'change',
  50193. "var $$a=" + value + "," +
  50194. '$$el=$event.target,' +
  50195. "$$c=$$el.checked?(" + trueValueBinding + "):(" + falseValueBinding + ");" +
  50196. 'if(Array.isArray($$a)){' +
  50197. "var $$v=" + (number ? '_n(' + valueBinding + ')' : valueBinding) + "," +
  50198. '$$i=_i($$a,$$v);' +
  50199. "if($$el.checked){$$i<0&&(" + (genAssignmentCode(value, '$$a.concat([$$v])')) + ")}" +
  50200. "else{$$i>-1&&(" + (genAssignmentCode(value, '$$a.slice(0,$$i).concat($$a.slice($$i+1))')) + ")}" +
  50201. "}else{" + (genAssignmentCode(value, '$$c')) + "}",
  50202. null, true
  50203. );
  50204. }
  50205. function genRadioModel (
  50206. el,
  50207. value,
  50208. modifiers
  50209. ) {
  50210. var number = modifiers && modifiers.number;
  50211. var valueBinding = getBindingAttr(el, 'value') || 'null';
  50212. valueBinding = number ? ("_n(" + valueBinding + ")") : valueBinding;
  50213. addProp(el, 'checked', ("_q(" + value + "," + valueBinding + ")"));
  50214. addHandler(el, 'change', genAssignmentCode(value, valueBinding), null, true);
  50215. }
  50216. function genSelect (
  50217. el,
  50218. value,
  50219. modifiers
  50220. ) {
  50221. var number = modifiers && modifiers.number;
  50222. var selectedVal = "Array.prototype.filter" +
  50223. ".call($event.target.options,function(o){return o.selected})" +
  50224. ".map(function(o){var val = \"_value\" in o ? o._value : o.value;" +
  50225. "return " + (number ? '_n(val)' : 'val') + "})";
  50226. var assignment = '$event.target.multiple ? $$selectedVal : $$selectedVal[0]';
  50227. var code = "var $$selectedVal = " + selectedVal + ";";
  50228. code = code + " " + (genAssignmentCode(value, assignment));
  50229. addHandler(el, 'change', code, null, true);
  50230. }
  50231. function genDefaultModel (
  50232. el,
  50233. value,
  50234. modifiers
  50235. ) {
  50236. var type = el.attrsMap.type;
  50237. // warn if v-bind:value conflicts with v-model
  50238. // except for inputs with v-bind:type
  50239. {
  50240. var value$1 = el.attrsMap['v-bind:value'] || el.attrsMap[':value'];
  50241. var typeBinding = el.attrsMap['v-bind:type'] || el.attrsMap[':type'];
  50242. if (value$1 && !typeBinding) {
  50243. var binding = el.attrsMap['v-bind:value'] ? 'v-bind:value' : ':value';
  50244. warn$1(
  50245. binding + "=\"" + value$1 + "\" conflicts with v-model on the same element " +
  50246. 'because the latter already expands to a value binding internally',
  50247. el.rawAttrsMap[binding]
  50248. );
  50249. }
  50250. }
  50251. var ref = modifiers || {};
  50252. var lazy = ref.lazy;
  50253. var number = ref.number;
  50254. var trim = ref.trim;
  50255. var needCompositionGuard = !lazy && type !== 'range';
  50256. var event = lazy
  50257. ? 'change'
  50258. : type === 'range'
  50259. ? RANGE_TOKEN
  50260. : 'input';
  50261. var valueExpression = '$event.target.value';
  50262. if (trim) {
  50263. valueExpression = "$event.target.value.trim()";
  50264. }
  50265. if (number) {
  50266. valueExpression = "_n(" + valueExpression + ")";
  50267. }
  50268. var code = genAssignmentCode(value, valueExpression);
  50269. if (needCompositionGuard) {
  50270. code = "if($event.target.composing)return;" + code;
  50271. }
  50272. addProp(el, 'value', ("(" + value + ")"));
  50273. addHandler(el, event, code, null, true);
  50274. if (trim || number) {
  50275. addHandler(el, 'blur', '$forceUpdate()');
  50276. }
  50277. }
  50278. /* */
  50279. // normalize v-model event tokens that can only be determined at runtime.
  50280. // it's important to place the event as the first in the array because
  50281. // the whole point is ensuring the v-model callback gets called before
  50282. // user-attached handlers.
  50283. function normalizeEvents (on) {
  50284. /* istanbul ignore if */
  50285. if (isDef(on[RANGE_TOKEN])) {
  50286. // IE input[type=range] only supports `change` event
  50287. var event = isIE ? 'change' : 'input';
  50288. on[event] = [].concat(on[RANGE_TOKEN], on[event] || []);
  50289. delete on[RANGE_TOKEN];
  50290. }
  50291. // This was originally intended to fix #4521 but no longer necessary
  50292. // after 2.5. Keeping it for backwards compat with generated code from < 2.4
  50293. /* istanbul ignore if */
  50294. if (isDef(on[CHECKBOX_RADIO_TOKEN])) {
  50295. on.change = [].concat(on[CHECKBOX_RADIO_TOKEN], on.change || []);
  50296. delete on[CHECKBOX_RADIO_TOKEN];
  50297. }
  50298. }
  50299. var target$1;
  50300. function createOnceHandler$1 (event, handler, capture) {
  50301. var _target = target$1; // save current target element in closure
  50302. return function onceHandler () {
  50303. var res = handler.apply(null, arguments);
  50304. if (res !== null) {
  50305. remove$2(event, onceHandler, capture, _target);
  50306. }
  50307. }
  50308. }
  50309. // #9446: Firefox <= 53 (in particular, ESR 52) has incorrect Event.timeStamp
  50310. // implementation and does not fire microtasks in between event propagation, so
  50311. // safe to exclude.
  50312. var useMicrotaskFix = isUsingMicroTask && !(isFF && Number(isFF[1]) <= 53);
  50313. function add$1 (
  50314. name,
  50315. handler,
  50316. capture,
  50317. passive
  50318. ) {
  50319. // async edge case #6566: inner click event triggers patch, event handler
  50320. // attached to outer element during patch, and triggered again. This
  50321. // happens because browsers fire microtask ticks between event propagation.
  50322. // the solution is simple: we save the timestamp when a handler is attached,
  50323. // and the handler would only fire if the event passed to it was fired
  50324. // AFTER it was attached.
  50325. if (useMicrotaskFix) {
  50326. var attachedTimestamp = currentFlushTimestamp;
  50327. var original = handler;
  50328. handler = original._wrapper = function (e) {
  50329. if (
  50330. // no bubbling, should always fire.
  50331. // this is just a safety net in case event.timeStamp is unreliable in
  50332. // certain weird environments...
  50333. e.target === e.currentTarget ||
  50334. // event is fired after handler attachment
  50335. e.timeStamp >= attachedTimestamp ||
  50336. // bail for environments that have buggy event.timeStamp implementations
  50337. // #9462 iOS 9 bug: event.timeStamp is 0 after history.pushState
  50338. // #9681 QtWebEngine event.timeStamp is negative value
  50339. e.timeStamp <= 0 ||
  50340. // #9448 bail if event is fired in another document in a multi-page
  50341. // electron/nw.js app, since event.timeStamp will be using a different
  50342. // starting reference
  50343. e.target.ownerDocument !== document
  50344. ) {
  50345. return original.apply(this, arguments)
  50346. }
  50347. };
  50348. }
  50349. target$1.addEventListener(
  50350. name,
  50351. handler,
  50352. supportsPassive
  50353. ? { capture: capture, passive: passive }
  50354. : capture
  50355. );
  50356. }
  50357. function remove$2 (
  50358. name,
  50359. handler,
  50360. capture,
  50361. _target
  50362. ) {
  50363. (_target || target$1).removeEventListener(
  50364. name,
  50365. handler._wrapper || handler,
  50366. capture
  50367. );
  50368. }
  50369. function updateDOMListeners (oldVnode, vnode) {
  50370. if (isUndef(oldVnode.data.on) && isUndef(vnode.data.on)) {
  50371. return
  50372. }
  50373. var on = vnode.data.on || {};
  50374. var oldOn = oldVnode.data.on || {};
  50375. target$1 = vnode.elm;
  50376. normalizeEvents(on);
  50377. updateListeners(on, oldOn, add$1, remove$2, createOnceHandler$1, vnode.context);
  50378. target$1 = undefined;
  50379. }
  50380. var events = {
  50381. create: updateDOMListeners,
  50382. update: updateDOMListeners
  50383. };
  50384. /* */
  50385. var svgContainer;
  50386. function updateDOMProps (oldVnode, vnode) {
  50387. if (isUndef(oldVnode.data.domProps) && isUndef(vnode.data.domProps)) {
  50388. return
  50389. }
  50390. var key, cur;
  50391. var elm = vnode.elm;
  50392. var oldProps = oldVnode.data.domProps || {};
  50393. var props = vnode.data.domProps || {};
  50394. // clone observed objects, as the user probably wants to mutate it
  50395. if (isDef(props.__ob__)) {
  50396. props = vnode.data.domProps = extend({}, props);
  50397. }
  50398. for (key in oldProps) {
  50399. if (!(key in props)) {
  50400. elm[key] = '';
  50401. }
  50402. }
  50403. for (key in props) {
  50404. cur = props[key];
  50405. // ignore children if the node has textContent or innerHTML,
  50406. // as these will throw away existing DOM nodes and cause removal errors
  50407. // on subsequent patches (#3360)
  50408. if (key === 'textContent' || key === 'innerHTML') {
  50409. if (vnode.children) { vnode.children.length = 0; }
  50410. if (cur === oldProps[key]) { continue }
  50411. // #6601 work around Chrome version <= 55 bug where single textNode
  50412. // replaced by innerHTML/textContent retains its parentNode property
  50413. if (elm.childNodes.length === 1) {
  50414. elm.removeChild(elm.childNodes[0]);
  50415. }
  50416. }
  50417. if (key === 'value' && elm.tagName !== 'PROGRESS') {
  50418. // store value as _value as well since
  50419. // non-string values will be stringified
  50420. elm._value = cur;
  50421. // avoid resetting cursor position when value is the same
  50422. var strCur = isUndef(cur) ? '' : String(cur);
  50423. if (shouldUpdateValue(elm, strCur)) {
  50424. elm.value = strCur;
  50425. }
  50426. } else if (key === 'innerHTML' && isSVG(elm.tagName) && isUndef(elm.innerHTML)) {
  50427. // IE doesn't support innerHTML for SVG elements
  50428. svgContainer = svgContainer || document.createElement('div');
  50429. svgContainer.innerHTML = "<svg>" + cur + "</svg>";
  50430. var svg = svgContainer.firstChild;
  50431. while (elm.firstChild) {
  50432. elm.removeChild(elm.firstChild);
  50433. }
  50434. while (svg.firstChild) {
  50435. elm.appendChild(svg.firstChild);
  50436. }
  50437. } else if (
  50438. // skip the update if old and new VDOM state is the same.
  50439. // `value` is handled separately because the DOM value may be temporarily
  50440. // out of sync with VDOM state due to focus, composition and modifiers.
  50441. // This #4521 by skipping the unnecesarry `checked` update.
  50442. cur !== oldProps[key]
  50443. ) {
  50444. // some property updates can throw
  50445. // e.g. `value` on <progress> w/ non-finite value
  50446. try {
  50447. elm[key] = cur;
  50448. } catch (e) {}
  50449. }
  50450. }
  50451. }
  50452. // check platforms/web/util/attrs.js acceptValue
  50453. function shouldUpdateValue (elm, checkVal) {
  50454. return (!elm.composing && (
  50455. elm.tagName === 'OPTION' ||
  50456. isNotInFocusAndDirty(elm, checkVal) ||
  50457. isDirtyWithModifiers(elm, checkVal)
  50458. ))
  50459. }
  50460. function isNotInFocusAndDirty (elm, checkVal) {
  50461. // return true when textbox (.number and .trim) loses focus and its value is
  50462. // not equal to the updated value
  50463. var notInFocus = true;
  50464. // #6157
  50465. // work around IE bug when accessing document.activeElement in an iframe
  50466. try { notInFocus = document.activeElement !== elm; } catch (e) {}
  50467. return notInFocus && elm.value !== checkVal
  50468. }
  50469. function isDirtyWithModifiers (elm, newVal) {
  50470. var value = elm.value;
  50471. var modifiers = elm._vModifiers; // injected by v-model runtime
  50472. if (isDef(modifiers)) {
  50473. if (modifiers.number) {
  50474. return toNumber(value) !== toNumber(newVal)
  50475. }
  50476. if (modifiers.trim) {
  50477. return value.trim() !== newVal.trim()
  50478. }
  50479. }
  50480. return value !== newVal
  50481. }
  50482. var domProps = {
  50483. create: updateDOMProps,
  50484. update: updateDOMProps
  50485. };
  50486. /* */
  50487. var parseStyleText = cached(function (cssText) {
  50488. var res = {};
  50489. var listDelimiter = /;(?![^(]*\))/g;
  50490. var propertyDelimiter = /:(.+)/;
  50491. cssText.split(listDelimiter).forEach(function (item) {
  50492. if (item) {
  50493. var tmp = item.split(propertyDelimiter);
  50494. tmp.length > 1 && (res[tmp[0].trim()] = tmp[1].trim());
  50495. }
  50496. });
  50497. return res
  50498. });
  50499. // merge static and dynamic style data on the same vnode
  50500. function normalizeStyleData (data) {
  50501. var style = normalizeStyleBinding(data.style);
  50502. // static style is pre-processed into an object during compilation
  50503. // and is always a fresh object, so it's safe to merge into it
  50504. return data.staticStyle
  50505. ? extend(data.staticStyle, style)
  50506. : style
  50507. }
  50508. // normalize possible array / string values into Object
  50509. function normalizeStyleBinding (bindingStyle) {
  50510. if (Array.isArray(bindingStyle)) {
  50511. return toObject(bindingStyle)
  50512. }
  50513. if (typeof bindingStyle === 'string') {
  50514. return parseStyleText(bindingStyle)
  50515. }
  50516. return bindingStyle
  50517. }
  50518. /**
  50519. * parent component style should be after child's
  50520. * so that parent component's style could override it
  50521. */
  50522. function getStyle (vnode, checkChild) {
  50523. var res = {};
  50524. var styleData;
  50525. if (checkChild) {
  50526. var childNode = vnode;
  50527. while (childNode.componentInstance) {
  50528. childNode = childNode.componentInstance._vnode;
  50529. if (
  50530. childNode && childNode.data &&
  50531. (styleData = normalizeStyleData(childNode.data))
  50532. ) {
  50533. extend(res, styleData);
  50534. }
  50535. }
  50536. }
  50537. if ((styleData = normalizeStyleData(vnode.data))) {
  50538. extend(res, styleData);
  50539. }
  50540. var parentNode = vnode;
  50541. while ((parentNode = parentNode.parent)) {
  50542. if (parentNode.data && (styleData = normalizeStyleData(parentNode.data))) {
  50543. extend(res, styleData);
  50544. }
  50545. }
  50546. return res
  50547. }
  50548. /* */
  50549. var cssVarRE = /^--/;
  50550. var importantRE = /\s*!important$/;
  50551. var setProp = function (el, name, val) {
  50552. /* istanbul ignore if */
  50553. if (cssVarRE.test(name)) {
  50554. el.style.setProperty(name, val);
  50555. } else if (importantRE.test(val)) {
  50556. el.style.setProperty(hyphenate(name), val.replace(importantRE, ''), 'important');
  50557. } else {
  50558. var normalizedName = normalize(name);
  50559. if (Array.isArray(val)) {
  50560. // Support values array created by autoprefixer, e.g.
  50561. // {display: ["-webkit-box", "-ms-flexbox", "flex"]}
  50562. // Set them one by one, and the browser will only set those it can recognize
  50563. for (var i = 0, len = val.length; i < len; i++) {
  50564. el.style[normalizedName] = val[i];
  50565. }
  50566. } else {
  50567. el.style[normalizedName] = val;
  50568. }
  50569. }
  50570. };
  50571. var vendorNames = ['Webkit', 'Moz', 'ms'];
  50572. var emptyStyle;
  50573. var normalize = cached(function (prop) {
  50574. emptyStyle = emptyStyle || document.createElement('div').style;
  50575. prop = camelize(prop);
  50576. if (prop !== 'filter' && (prop in emptyStyle)) {
  50577. return prop
  50578. }
  50579. var capName = prop.charAt(0).toUpperCase() + prop.slice(1);
  50580. for (var i = 0; i < vendorNames.length; i++) {
  50581. var name = vendorNames[i] + capName;
  50582. if (name in emptyStyle) {
  50583. return name
  50584. }
  50585. }
  50586. });
  50587. function updateStyle (oldVnode, vnode) {
  50588. var data = vnode.data;
  50589. var oldData = oldVnode.data;
  50590. if (isUndef(data.staticStyle) && isUndef(data.style) &&
  50591. isUndef(oldData.staticStyle) && isUndef(oldData.style)
  50592. ) {
  50593. return
  50594. }
  50595. var cur, name;
  50596. var el = vnode.elm;
  50597. var oldStaticStyle = oldData.staticStyle;
  50598. var oldStyleBinding = oldData.normalizedStyle || oldData.style || {};
  50599. // if static style exists, stylebinding already merged into it when doing normalizeStyleData
  50600. var oldStyle = oldStaticStyle || oldStyleBinding;
  50601. var style = normalizeStyleBinding(vnode.data.style) || {};
  50602. // store normalized style under a different key for next diff
  50603. // make sure to clone it if it's reactive, since the user likely wants
  50604. // to mutate it.
  50605. vnode.data.normalizedStyle = isDef(style.__ob__)
  50606. ? extend({}, style)
  50607. : style;
  50608. var newStyle = getStyle(vnode, true);
  50609. for (name in oldStyle) {
  50610. if (isUndef(newStyle[name])) {
  50611. setProp(el, name, '');
  50612. }
  50613. }
  50614. for (name in newStyle) {
  50615. cur = newStyle[name];
  50616. if (cur !== oldStyle[name]) {
  50617. // ie9 setting to null has no effect, must use empty string
  50618. setProp(el, name, cur == null ? '' : cur);
  50619. }
  50620. }
  50621. }
  50622. var style = {
  50623. create: updateStyle,
  50624. update: updateStyle
  50625. };
  50626. /* */
  50627. var whitespaceRE = /\s+/;
  50628. /**
  50629. * Add class with compatibility for SVG since classList is not supported on
  50630. * SVG elements in IE
  50631. */
  50632. function addClass (el, cls) {
  50633. /* istanbul ignore if */
  50634. if (!cls || !(cls = cls.trim())) {
  50635. return
  50636. }
  50637. /* istanbul ignore else */
  50638. if (el.classList) {
  50639. if (cls.indexOf(' ') > -1) {
  50640. cls.split(whitespaceRE).forEach(function (c) { return el.classList.add(c); });
  50641. } else {
  50642. el.classList.add(cls);
  50643. }
  50644. } else {
  50645. var cur = " " + (el.getAttribute('class') || '') + " ";
  50646. if (cur.indexOf(' ' + cls + ' ') < 0) {
  50647. el.setAttribute('class', (cur + cls).trim());
  50648. }
  50649. }
  50650. }
  50651. /**
  50652. * Remove class with compatibility for SVG since classList is not supported on
  50653. * SVG elements in IE
  50654. */
  50655. function removeClass (el, cls) {
  50656. /* istanbul ignore if */
  50657. if (!cls || !(cls = cls.trim())) {
  50658. return
  50659. }
  50660. /* istanbul ignore else */
  50661. if (el.classList) {
  50662. if (cls.indexOf(' ') > -1) {
  50663. cls.split(whitespaceRE).forEach(function (c) { return el.classList.remove(c); });
  50664. } else {
  50665. el.classList.remove(cls);
  50666. }
  50667. if (!el.classList.length) {
  50668. el.removeAttribute('class');
  50669. }
  50670. } else {
  50671. var cur = " " + (el.getAttribute('class') || '') + " ";
  50672. var tar = ' ' + cls + ' ';
  50673. while (cur.indexOf(tar) >= 0) {
  50674. cur = cur.replace(tar, ' ');
  50675. }
  50676. cur = cur.trim();
  50677. if (cur) {
  50678. el.setAttribute('class', cur);
  50679. } else {
  50680. el.removeAttribute('class');
  50681. }
  50682. }
  50683. }
  50684. /* */
  50685. function resolveTransition (def$$1) {
  50686. if (!def$$1) {
  50687. return
  50688. }
  50689. /* istanbul ignore else */
  50690. if (typeof def$$1 === 'object') {
  50691. var res = {};
  50692. if (def$$1.css !== false) {
  50693. extend(res, autoCssTransition(def$$1.name || 'v'));
  50694. }
  50695. extend(res, def$$1);
  50696. return res
  50697. } else if (typeof def$$1 === 'string') {
  50698. return autoCssTransition(def$$1)
  50699. }
  50700. }
  50701. var autoCssTransition = cached(function (name) {
  50702. return {
  50703. enterClass: (name + "-enter"),
  50704. enterToClass: (name + "-enter-to"),
  50705. enterActiveClass: (name + "-enter-active"),
  50706. leaveClass: (name + "-leave"),
  50707. leaveToClass: (name + "-leave-to"),
  50708. leaveActiveClass: (name + "-leave-active")
  50709. }
  50710. });
  50711. var hasTransition = inBrowser && !isIE9;
  50712. var TRANSITION = 'transition';
  50713. var ANIMATION = 'animation';
  50714. // Transition property/event sniffing
  50715. var transitionProp = 'transition';
  50716. var transitionEndEvent = 'transitionend';
  50717. var animationProp = 'animation';
  50718. var animationEndEvent = 'animationend';
  50719. if (hasTransition) {
  50720. /* istanbul ignore if */
  50721. if (window.ontransitionend === undefined &&
  50722. window.onwebkittransitionend !== undefined
  50723. ) {
  50724. transitionProp = 'WebkitTransition';
  50725. transitionEndEvent = 'webkitTransitionEnd';
  50726. }
  50727. if (window.onanimationend === undefined &&
  50728. window.onwebkitanimationend !== undefined
  50729. ) {
  50730. animationProp = 'WebkitAnimation';
  50731. animationEndEvent = 'webkitAnimationEnd';
  50732. }
  50733. }
  50734. // binding to window is necessary to make hot reload work in IE in strict mode
  50735. var raf = inBrowser
  50736. ? window.requestAnimationFrame
  50737. ? window.requestAnimationFrame.bind(window)
  50738. : setTimeout
  50739. : /* istanbul ignore next */ function (fn) { return fn(); };
  50740. function nextFrame (fn) {
  50741. raf(function () {
  50742. raf(fn);
  50743. });
  50744. }
  50745. function addTransitionClass (el, cls) {
  50746. var transitionClasses = el._transitionClasses || (el._transitionClasses = []);
  50747. if (transitionClasses.indexOf(cls) < 0) {
  50748. transitionClasses.push(cls);
  50749. addClass(el, cls);
  50750. }
  50751. }
  50752. function removeTransitionClass (el, cls) {
  50753. if (el._transitionClasses) {
  50754. remove(el._transitionClasses, cls);
  50755. }
  50756. removeClass(el, cls);
  50757. }
  50758. function whenTransitionEnds (
  50759. el,
  50760. expectedType,
  50761. cb
  50762. ) {
  50763. var ref = getTransitionInfo(el, expectedType);
  50764. var type = ref.type;
  50765. var timeout = ref.timeout;
  50766. var propCount = ref.propCount;
  50767. if (!type) { return cb() }
  50768. var event = type === TRANSITION ? transitionEndEvent : animationEndEvent;
  50769. var ended = 0;
  50770. var end = function () {
  50771. el.removeEventListener(event, onEnd);
  50772. cb();
  50773. };
  50774. var onEnd = function (e) {
  50775. if (e.target === el) {
  50776. if (++ended >= propCount) {
  50777. end();
  50778. }
  50779. }
  50780. };
  50781. setTimeout(function () {
  50782. if (ended < propCount) {
  50783. end();
  50784. }
  50785. }, timeout + 1);
  50786. el.addEventListener(event, onEnd);
  50787. }
  50788. var transformRE = /\b(transform|all)(,|$)/;
  50789. function getTransitionInfo (el, expectedType) {
  50790. var styles = window.getComputedStyle(el);
  50791. // JSDOM may return undefined for transition properties
  50792. var transitionDelays = (styles[transitionProp + 'Delay'] || '').split(', ');
  50793. var transitionDurations = (styles[transitionProp + 'Duration'] || '').split(', ');
  50794. var transitionTimeout = getTimeout(transitionDelays, transitionDurations);
  50795. var animationDelays = (styles[animationProp + 'Delay'] || '').split(', ');
  50796. var animationDurations = (styles[animationProp + 'Duration'] || '').split(', ');
  50797. var animationTimeout = getTimeout(animationDelays, animationDurations);
  50798. var type;
  50799. var timeout = 0;
  50800. var propCount = 0;
  50801. /* istanbul ignore if */
  50802. if (expectedType === TRANSITION) {
  50803. if (transitionTimeout > 0) {
  50804. type = TRANSITION;
  50805. timeout = transitionTimeout;
  50806. propCount = transitionDurations.length;
  50807. }
  50808. } else if (expectedType === ANIMATION) {
  50809. if (animationTimeout > 0) {
  50810. type = ANIMATION;
  50811. timeout = animationTimeout;
  50812. propCount = animationDurations.length;
  50813. }
  50814. } else {
  50815. timeout = Math.max(transitionTimeout, animationTimeout);
  50816. type = timeout > 0
  50817. ? transitionTimeout > animationTimeout
  50818. ? TRANSITION
  50819. : ANIMATION
  50820. : null;
  50821. propCount = type
  50822. ? type === TRANSITION
  50823. ? transitionDurations.length
  50824. : animationDurations.length
  50825. : 0;
  50826. }
  50827. var hasTransform =
  50828. type === TRANSITION &&
  50829. transformRE.test(styles[transitionProp + 'Property']);
  50830. return {
  50831. type: type,
  50832. timeout: timeout,
  50833. propCount: propCount,
  50834. hasTransform: hasTransform
  50835. }
  50836. }
  50837. function getTimeout (delays, durations) {
  50838. /* istanbul ignore next */
  50839. while (delays.length < durations.length) {
  50840. delays = delays.concat(delays);
  50841. }
  50842. return Math.max.apply(null, durations.map(function (d, i) {
  50843. return toMs(d) + toMs(delays[i])
  50844. }))
  50845. }
  50846. // Old versions of Chromium (below 61.0.3163.100) formats floating pointer numbers
  50847. // in a locale-dependent way, using a comma instead of a dot.
  50848. // If comma is not replaced with a dot, the input will be rounded down (i.e. acting
  50849. // as a floor function) causing unexpected behaviors
  50850. function toMs (s) {
  50851. return Number(s.slice(0, -1).replace(',', '.')) * 1000
  50852. }
  50853. /* */
  50854. function enter (vnode, toggleDisplay) {
  50855. var el = vnode.elm;
  50856. // call leave callback now
  50857. if (isDef(el._leaveCb)) {
  50858. el._leaveCb.cancelled = true;
  50859. el._leaveCb();
  50860. }
  50861. var data = resolveTransition(vnode.data.transition);
  50862. if (isUndef(data)) {
  50863. return
  50864. }
  50865. /* istanbul ignore if */
  50866. if (isDef(el._enterCb) || el.nodeType !== 1) {
  50867. return
  50868. }
  50869. var css = data.css;
  50870. var type = data.type;
  50871. var enterClass = data.enterClass;
  50872. var enterToClass = data.enterToClass;
  50873. var enterActiveClass = data.enterActiveClass;
  50874. var appearClass = data.appearClass;
  50875. var appearToClass = data.appearToClass;
  50876. var appearActiveClass = data.appearActiveClass;
  50877. var beforeEnter = data.beforeEnter;
  50878. var enter = data.enter;
  50879. var afterEnter = data.afterEnter;
  50880. var enterCancelled = data.enterCancelled;
  50881. var beforeAppear = data.beforeAppear;
  50882. var appear = data.appear;
  50883. var afterAppear = data.afterAppear;
  50884. var appearCancelled = data.appearCancelled;
  50885. var duration = data.duration;
  50886. // activeInstance will always be the <transition> component managing this
  50887. // transition. One edge case to check is when the <transition> is placed
  50888. // as the root node of a child component. In that case we need to check
  50889. // <transition>'s parent for appear check.
  50890. var context = activeInstance;
  50891. var transitionNode = activeInstance.$vnode;
  50892. while (transitionNode && transitionNode.parent) {
  50893. context = transitionNode.context;
  50894. transitionNode = transitionNode.parent;
  50895. }
  50896. var isAppear = !context._isMounted || !vnode.isRootInsert;
  50897. if (isAppear && !appear && appear !== '') {
  50898. return
  50899. }
  50900. var startClass = isAppear && appearClass
  50901. ? appearClass
  50902. : enterClass;
  50903. var activeClass = isAppear && appearActiveClass
  50904. ? appearActiveClass
  50905. : enterActiveClass;
  50906. var toClass = isAppear && appearToClass
  50907. ? appearToClass
  50908. : enterToClass;
  50909. var beforeEnterHook = isAppear
  50910. ? (beforeAppear || beforeEnter)
  50911. : beforeEnter;
  50912. var enterHook = isAppear
  50913. ? (typeof appear === 'function' ? appear : enter)
  50914. : enter;
  50915. var afterEnterHook = isAppear
  50916. ? (afterAppear || afterEnter)
  50917. : afterEnter;
  50918. var enterCancelledHook = isAppear
  50919. ? (appearCancelled || enterCancelled)
  50920. : enterCancelled;
  50921. var explicitEnterDuration = toNumber(
  50922. isObject(duration)
  50923. ? duration.enter
  50924. : duration
  50925. );
  50926. if (explicitEnterDuration != null) {
  50927. checkDuration(explicitEnterDuration, 'enter', vnode);
  50928. }
  50929. var expectsCSS = css !== false && !isIE9;
  50930. var userWantsControl = getHookArgumentsLength(enterHook);
  50931. var cb = el._enterCb = once(function () {
  50932. if (expectsCSS) {
  50933. removeTransitionClass(el, toClass);
  50934. removeTransitionClass(el, activeClass);
  50935. }
  50936. if (cb.cancelled) {
  50937. if (expectsCSS) {
  50938. removeTransitionClass(el, startClass);
  50939. }
  50940. enterCancelledHook && enterCancelledHook(el);
  50941. } else {
  50942. afterEnterHook && afterEnterHook(el);
  50943. }
  50944. el._enterCb = null;
  50945. });
  50946. if (!vnode.data.show) {
  50947. // remove pending leave element on enter by injecting an insert hook
  50948. mergeVNodeHook(vnode, 'insert', function () {
  50949. var parent = el.parentNode;
  50950. var pendingNode = parent && parent._pending && parent._pending[vnode.key];
  50951. if (pendingNode &&
  50952. pendingNode.tag === vnode.tag &&
  50953. pendingNode.elm._leaveCb
  50954. ) {
  50955. pendingNode.elm._leaveCb();
  50956. }
  50957. enterHook && enterHook(el, cb);
  50958. });
  50959. }
  50960. // start enter transition
  50961. beforeEnterHook && beforeEnterHook(el);
  50962. if (expectsCSS) {
  50963. addTransitionClass(el, startClass);
  50964. addTransitionClass(el, activeClass);
  50965. nextFrame(function () {
  50966. removeTransitionClass(el, startClass);
  50967. if (!cb.cancelled) {
  50968. addTransitionClass(el, toClass);
  50969. if (!userWantsControl) {
  50970. if (isValidDuration(explicitEnterDuration)) {
  50971. setTimeout(cb, explicitEnterDuration);
  50972. } else {
  50973. whenTransitionEnds(el, type, cb);
  50974. }
  50975. }
  50976. }
  50977. });
  50978. }
  50979. if (vnode.data.show) {
  50980. toggleDisplay && toggleDisplay();
  50981. enterHook && enterHook(el, cb);
  50982. }
  50983. if (!expectsCSS && !userWantsControl) {
  50984. cb();
  50985. }
  50986. }
  50987. function leave (vnode, rm) {
  50988. var el = vnode.elm;
  50989. // call enter callback now
  50990. if (isDef(el._enterCb)) {
  50991. el._enterCb.cancelled = true;
  50992. el._enterCb();
  50993. }
  50994. var data = resolveTransition(vnode.data.transition);
  50995. if (isUndef(data) || el.nodeType !== 1) {
  50996. return rm()
  50997. }
  50998. /* istanbul ignore if */
  50999. if (isDef(el._leaveCb)) {
  51000. return
  51001. }
  51002. var css = data.css;
  51003. var type = data.type;
  51004. var leaveClass = data.leaveClass;
  51005. var leaveToClass = data.leaveToClass;
  51006. var leaveActiveClass = data.leaveActiveClass;
  51007. var beforeLeave = data.beforeLeave;
  51008. var leave = data.leave;
  51009. var afterLeave = data.afterLeave;
  51010. var leaveCancelled = data.leaveCancelled;
  51011. var delayLeave = data.delayLeave;
  51012. var duration = data.duration;
  51013. var expectsCSS = css !== false && !isIE9;
  51014. var userWantsControl = getHookArgumentsLength(leave);
  51015. var explicitLeaveDuration = toNumber(
  51016. isObject(duration)
  51017. ? duration.leave
  51018. : duration
  51019. );
  51020. if (isDef(explicitLeaveDuration)) {
  51021. checkDuration(explicitLeaveDuration, 'leave', vnode);
  51022. }
  51023. var cb = el._leaveCb = once(function () {
  51024. if (el.parentNode && el.parentNode._pending) {
  51025. el.parentNode._pending[vnode.key] = null;
  51026. }
  51027. if (expectsCSS) {
  51028. removeTransitionClass(el, leaveToClass);
  51029. removeTransitionClass(el, leaveActiveClass);
  51030. }
  51031. if (cb.cancelled) {
  51032. if (expectsCSS) {
  51033. removeTransitionClass(el, leaveClass);
  51034. }
  51035. leaveCancelled && leaveCancelled(el);
  51036. } else {
  51037. rm();
  51038. afterLeave && afterLeave(el);
  51039. }
  51040. el._leaveCb = null;
  51041. });
  51042. if (delayLeave) {
  51043. delayLeave(performLeave);
  51044. } else {
  51045. performLeave();
  51046. }
  51047. function performLeave () {
  51048. // the delayed leave may have already been cancelled
  51049. if (cb.cancelled) {
  51050. return
  51051. }
  51052. // record leaving element
  51053. if (!vnode.data.show && el.parentNode) {
  51054. (el.parentNode._pending || (el.parentNode._pending = {}))[(vnode.key)] = vnode;
  51055. }
  51056. beforeLeave && beforeLeave(el);
  51057. if (expectsCSS) {
  51058. addTransitionClass(el, leaveClass);
  51059. addTransitionClass(el, leaveActiveClass);
  51060. nextFrame(function () {
  51061. removeTransitionClass(el, leaveClass);
  51062. if (!cb.cancelled) {
  51063. addTransitionClass(el, leaveToClass);
  51064. if (!userWantsControl) {
  51065. if (isValidDuration(explicitLeaveDuration)) {
  51066. setTimeout(cb, explicitLeaveDuration);
  51067. } else {
  51068. whenTransitionEnds(el, type, cb);
  51069. }
  51070. }
  51071. }
  51072. });
  51073. }
  51074. leave && leave(el, cb);
  51075. if (!expectsCSS && !userWantsControl) {
  51076. cb();
  51077. }
  51078. }
  51079. }
  51080. // only used in dev mode
  51081. function checkDuration (val, name, vnode) {
  51082. if (typeof val !== 'number') {
  51083. warn(
  51084. "<transition> explicit " + name + " duration is not a valid number - " +
  51085. "got " + (JSON.stringify(val)) + ".",
  51086. vnode.context
  51087. );
  51088. } else if (isNaN(val)) {
  51089. warn(
  51090. "<transition> explicit " + name + " duration is NaN - " +
  51091. 'the duration expression might be incorrect.',
  51092. vnode.context
  51093. );
  51094. }
  51095. }
  51096. function isValidDuration (val) {
  51097. return typeof val === 'number' && !isNaN(val)
  51098. }
  51099. /**
  51100. * Normalize a transition hook's argument length. The hook may be:
  51101. * - a merged hook (invoker) with the original in .fns
  51102. * - a wrapped component method (check ._length)
  51103. * - a plain function (.length)
  51104. */
  51105. function getHookArgumentsLength (fn) {
  51106. if (isUndef(fn)) {
  51107. return false
  51108. }
  51109. var invokerFns = fn.fns;
  51110. if (isDef(invokerFns)) {
  51111. // invoker
  51112. return getHookArgumentsLength(
  51113. Array.isArray(invokerFns)
  51114. ? invokerFns[0]
  51115. : invokerFns
  51116. )
  51117. } else {
  51118. return (fn._length || fn.length) > 1
  51119. }
  51120. }
  51121. function _enter (_, vnode) {
  51122. if (vnode.data.show !== true) {
  51123. enter(vnode);
  51124. }
  51125. }
  51126. var transition = inBrowser ? {
  51127. create: _enter,
  51128. activate: _enter,
  51129. remove: function remove$$1 (vnode, rm) {
  51130. /* istanbul ignore else */
  51131. if (vnode.data.show !== true) {
  51132. leave(vnode, rm);
  51133. } else {
  51134. rm();
  51135. }
  51136. }
  51137. } : {};
  51138. var platformModules = [
  51139. attrs,
  51140. klass,
  51141. events,
  51142. domProps,
  51143. style,
  51144. transition
  51145. ];
  51146. /* */
  51147. // the directive module should be applied last, after all
  51148. // built-in modules have been applied.
  51149. var modules = platformModules.concat(baseModules);
  51150. var patch = createPatchFunction({ nodeOps: nodeOps, modules: modules });
  51151. /**
  51152. * Not type checking this file because flow doesn't like attaching
  51153. * properties to Elements.
  51154. */
  51155. /* istanbul ignore if */
  51156. if (isIE9) {
  51157. // http://www.matts411.com/post/internet-explorer-9-oninput/
  51158. document.addEventListener('selectionchange', function () {
  51159. var el = document.activeElement;
  51160. if (el && el.vmodel) {
  51161. trigger(el, 'input');
  51162. }
  51163. });
  51164. }
  51165. var directive = {
  51166. inserted: function inserted (el, binding, vnode, oldVnode) {
  51167. if (vnode.tag === 'select') {
  51168. // #6903
  51169. if (oldVnode.elm && !oldVnode.elm._vOptions) {
  51170. mergeVNodeHook(vnode, 'postpatch', function () {
  51171. directive.componentUpdated(el, binding, vnode);
  51172. });
  51173. } else {
  51174. setSelected(el, binding, vnode.context);
  51175. }
  51176. el._vOptions = [].map.call(el.options, getValue);
  51177. } else if (vnode.tag === 'textarea' || isTextInputType(el.type)) {
  51178. el._vModifiers = binding.modifiers;
  51179. if (!binding.modifiers.lazy) {
  51180. el.addEventListener('compositionstart', onCompositionStart);
  51181. el.addEventListener('compositionend', onCompositionEnd);
  51182. // Safari < 10.2 & UIWebView doesn't fire compositionend when
  51183. // switching focus before confirming composition choice
  51184. // this also fixes the issue where some browsers e.g. iOS Chrome
  51185. // fires "change" instead of "input" on autocomplete.
  51186. el.addEventListener('change', onCompositionEnd);
  51187. /* istanbul ignore if */
  51188. if (isIE9) {
  51189. el.vmodel = true;
  51190. }
  51191. }
  51192. }
  51193. },
  51194. componentUpdated: function componentUpdated (el, binding, vnode) {
  51195. if (vnode.tag === 'select') {
  51196. setSelected(el, binding, vnode.context);
  51197. // in case the options rendered by v-for have changed,
  51198. // it's possible that the value is out-of-sync with the rendered options.
  51199. // detect such cases and filter out values that no longer has a matching
  51200. // option in the DOM.
  51201. var prevOptions = el._vOptions;
  51202. var curOptions = el._vOptions = [].map.call(el.options, getValue);
  51203. if (curOptions.some(function (o, i) { return !looseEqual(o, prevOptions[i]); })) {
  51204. // trigger change event if
  51205. // no matching option found for at least one value
  51206. var needReset = el.multiple
  51207. ? binding.value.some(function (v) { return hasNoMatchingOption(v, curOptions); })
  51208. : binding.value !== binding.oldValue && hasNoMatchingOption(binding.value, curOptions);
  51209. if (needReset) {
  51210. trigger(el, 'change');
  51211. }
  51212. }
  51213. }
  51214. }
  51215. };
  51216. function setSelected (el, binding, vm) {
  51217. actuallySetSelected(el, binding, vm);
  51218. /* istanbul ignore if */
  51219. if (isIE || isEdge) {
  51220. setTimeout(function () {
  51221. actuallySetSelected(el, binding, vm);
  51222. }, 0);
  51223. }
  51224. }
  51225. function actuallySetSelected (el, binding, vm) {
  51226. var value = binding.value;
  51227. var isMultiple = el.multiple;
  51228. if (isMultiple && !Array.isArray(value)) {
  51229. warn(
  51230. "<select multiple v-model=\"" + (binding.expression) + "\"> " +
  51231. "expects an Array value for its binding, but got " + (Object.prototype.toString.call(value).slice(8, -1)),
  51232. vm
  51233. );
  51234. return
  51235. }
  51236. var selected, option;
  51237. for (var i = 0, l = el.options.length; i < l; i++) {
  51238. option = el.options[i];
  51239. if (isMultiple) {
  51240. selected = looseIndexOf(value, getValue(option)) > -1;
  51241. if (option.selected !== selected) {
  51242. option.selected = selected;
  51243. }
  51244. } else {
  51245. if (looseEqual(getValue(option), value)) {
  51246. if (el.selectedIndex !== i) {
  51247. el.selectedIndex = i;
  51248. }
  51249. return
  51250. }
  51251. }
  51252. }
  51253. if (!isMultiple) {
  51254. el.selectedIndex = -1;
  51255. }
  51256. }
  51257. function hasNoMatchingOption (value, options) {
  51258. return options.every(function (o) { return !looseEqual(o, value); })
  51259. }
  51260. function getValue (option) {
  51261. return '_value' in option
  51262. ? option._value
  51263. : option.value
  51264. }
  51265. function onCompositionStart (e) {
  51266. e.target.composing = true;
  51267. }
  51268. function onCompositionEnd (e) {
  51269. // prevent triggering an input event for no reason
  51270. if (!e.target.composing) { return }
  51271. e.target.composing = false;
  51272. trigger(e.target, 'input');
  51273. }
  51274. function trigger (el, type) {
  51275. var e = document.createEvent('HTMLEvents');
  51276. e.initEvent(type, true, true);
  51277. el.dispatchEvent(e);
  51278. }
  51279. /* */
  51280. // recursively search for possible transition defined inside the component root
  51281. function locateNode (vnode) {
  51282. return vnode.componentInstance && (!vnode.data || !vnode.data.transition)
  51283. ? locateNode(vnode.componentInstance._vnode)
  51284. : vnode
  51285. }
  51286. var show = {
  51287. bind: function bind (el, ref, vnode) {
  51288. var value = ref.value;
  51289. vnode = locateNode(vnode);
  51290. var transition$$1 = vnode.data && vnode.data.transition;
  51291. var originalDisplay = el.__vOriginalDisplay =
  51292. el.style.display === 'none' ? '' : el.style.display;
  51293. if (value && transition$$1) {
  51294. vnode.data.show = true;
  51295. enter(vnode, function () {
  51296. el.style.display = originalDisplay;
  51297. });
  51298. } else {
  51299. el.style.display = value ? originalDisplay : 'none';
  51300. }
  51301. },
  51302. update: function update (el, ref, vnode) {
  51303. var value = ref.value;
  51304. var oldValue = ref.oldValue;
  51305. /* istanbul ignore if */
  51306. if (!value === !oldValue) { return }
  51307. vnode = locateNode(vnode);
  51308. var transition$$1 = vnode.data && vnode.data.transition;
  51309. if (transition$$1) {
  51310. vnode.data.show = true;
  51311. if (value) {
  51312. enter(vnode, function () {
  51313. el.style.display = el.__vOriginalDisplay;
  51314. });
  51315. } else {
  51316. leave(vnode, function () {
  51317. el.style.display = 'none';
  51318. });
  51319. }
  51320. } else {
  51321. el.style.display = value ? el.__vOriginalDisplay : 'none';
  51322. }
  51323. },
  51324. unbind: function unbind (
  51325. el,
  51326. binding,
  51327. vnode,
  51328. oldVnode,
  51329. isDestroy
  51330. ) {
  51331. if (!isDestroy) {
  51332. el.style.display = el.__vOriginalDisplay;
  51333. }
  51334. }
  51335. };
  51336. var platformDirectives = {
  51337. model: directive,
  51338. show: show
  51339. };
  51340. /* */
  51341. var transitionProps = {
  51342. name: String,
  51343. appear: Boolean,
  51344. css: Boolean,
  51345. mode: String,
  51346. type: String,
  51347. enterClass: String,
  51348. leaveClass: String,
  51349. enterToClass: String,
  51350. leaveToClass: String,
  51351. enterActiveClass: String,
  51352. leaveActiveClass: String,
  51353. appearClass: String,
  51354. appearActiveClass: String,
  51355. appearToClass: String,
  51356. duration: [Number, String, Object]
  51357. };
  51358. // in case the child is also an abstract component, e.g. <keep-alive>
  51359. // we want to recursively retrieve the real component to be rendered
  51360. function getRealChild (vnode) {
  51361. var compOptions = vnode && vnode.componentOptions;
  51362. if (compOptions && compOptions.Ctor.options.abstract) {
  51363. return getRealChild(getFirstComponentChild(compOptions.children))
  51364. } else {
  51365. return vnode
  51366. }
  51367. }
  51368. function extractTransitionData (comp) {
  51369. var data = {};
  51370. var options = comp.$options;
  51371. // props
  51372. for (var key in options.propsData) {
  51373. data[key] = comp[key];
  51374. }
  51375. // events.
  51376. // extract listeners and pass them directly to the transition methods
  51377. var listeners = options._parentListeners;
  51378. for (var key$1 in listeners) {
  51379. data[camelize(key$1)] = listeners[key$1];
  51380. }
  51381. return data
  51382. }
  51383. function placeholder (h, rawChild) {
  51384. if (/\d-keep-alive$/.test(rawChild.tag)) {
  51385. return h('keep-alive', {
  51386. props: rawChild.componentOptions.propsData
  51387. })
  51388. }
  51389. }
  51390. function hasParentTransition (vnode) {
  51391. while ((vnode = vnode.parent)) {
  51392. if (vnode.data.transition) {
  51393. return true
  51394. }
  51395. }
  51396. }
  51397. function isSameChild (child, oldChild) {
  51398. return oldChild.key === child.key && oldChild.tag === child.tag
  51399. }
  51400. var isNotTextNode = function (c) { return c.tag || isAsyncPlaceholder(c); };
  51401. var isVShowDirective = function (d) { return d.name === 'show'; };
  51402. var Transition = {
  51403. name: 'transition',
  51404. props: transitionProps,
  51405. abstract: true,
  51406. render: function render (h) {
  51407. var this$1 = this;
  51408. var children = this.$slots.default;
  51409. if (!children) {
  51410. return
  51411. }
  51412. // filter out text nodes (possible whitespaces)
  51413. children = children.filter(isNotTextNode);
  51414. /* istanbul ignore if */
  51415. if (!children.length) {
  51416. return
  51417. }
  51418. // warn multiple elements
  51419. if (children.length > 1) {
  51420. warn(
  51421. '<transition> can only be used on a single element. Use ' +
  51422. '<transition-group> for lists.',
  51423. this.$parent
  51424. );
  51425. }
  51426. var mode = this.mode;
  51427. // warn invalid mode
  51428. if (mode && mode !== 'in-out' && mode !== 'out-in'
  51429. ) {
  51430. warn(
  51431. 'invalid <transition> mode: ' + mode,
  51432. this.$parent
  51433. );
  51434. }
  51435. var rawChild = children[0];
  51436. // if this is a component root node and the component's
  51437. // parent container node also has transition, skip.
  51438. if (hasParentTransition(this.$vnode)) {
  51439. return rawChild
  51440. }
  51441. // apply transition data to child
  51442. // use getRealChild() to ignore abstract components e.g. keep-alive
  51443. var child = getRealChild(rawChild);
  51444. /* istanbul ignore if */
  51445. if (!child) {
  51446. return rawChild
  51447. }
  51448. if (this._leaving) {
  51449. return placeholder(h, rawChild)
  51450. }
  51451. // ensure a key that is unique to the vnode type and to this transition
  51452. // component instance. This key will be used to remove pending leaving nodes
  51453. // during entering.
  51454. var id = "__transition-" + (this._uid) + "-";
  51455. child.key = child.key == null
  51456. ? child.isComment
  51457. ? id + 'comment'
  51458. : id + child.tag
  51459. : isPrimitive(child.key)
  51460. ? (String(child.key).indexOf(id) === 0 ? child.key : id + child.key)
  51461. : child.key;
  51462. var data = (child.data || (child.data = {})).transition = extractTransitionData(this);
  51463. var oldRawChild = this._vnode;
  51464. var oldChild = getRealChild(oldRawChild);
  51465. // mark v-show
  51466. // so that the transition module can hand over the control to the directive
  51467. if (child.data.directives && child.data.directives.some(isVShowDirective)) {
  51468. child.data.show = true;
  51469. }
  51470. if (
  51471. oldChild &&
  51472. oldChild.data &&
  51473. !isSameChild(child, oldChild) &&
  51474. !isAsyncPlaceholder(oldChild) &&
  51475. // #6687 component root is a comment node
  51476. !(oldChild.componentInstance && oldChild.componentInstance._vnode.isComment)
  51477. ) {
  51478. // replace old child transition data with fresh one
  51479. // important for dynamic transitions!
  51480. var oldData = oldChild.data.transition = extend({}, data);
  51481. // handle transition mode
  51482. if (mode === 'out-in') {
  51483. // return placeholder node and queue update when leave finishes
  51484. this._leaving = true;
  51485. mergeVNodeHook(oldData, 'afterLeave', function () {
  51486. this$1._leaving = false;
  51487. this$1.$forceUpdate();
  51488. });
  51489. return placeholder(h, rawChild)
  51490. } else if (mode === 'in-out') {
  51491. if (isAsyncPlaceholder(child)) {
  51492. return oldRawChild
  51493. }
  51494. var delayedLeave;
  51495. var performLeave = function () { delayedLeave(); };
  51496. mergeVNodeHook(data, 'afterEnter', performLeave);
  51497. mergeVNodeHook(data, 'enterCancelled', performLeave);
  51498. mergeVNodeHook(oldData, 'delayLeave', function (leave) { delayedLeave = leave; });
  51499. }
  51500. }
  51501. return rawChild
  51502. }
  51503. };
  51504. /* */
  51505. var props = extend({
  51506. tag: String,
  51507. moveClass: String
  51508. }, transitionProps);
  51509. delete props.mode;
  51510. var TransitionGroup = {
  51511. props: props,
  51512. beforeMount: function beforeMount () {
  51513. var this$1 = this;
  51514. var update = this._update;
  51515. this._update = function (vnode, hydrating) {
  51516. var restoreActiveInstance = setActiveInstance(this$1);
  51517. // force removing pass
  51518. this$1.__patch__(
  51519. this$1._vnode,
  51520. this$1.kept,
  51521. false, // hydrating
  51522. true // removeOnly (!important, avoids unnecessary moves)
  51523. );
  51524. this$1._vnode = this$1.kept;
  51525. restoreActiveInstance();
  51526. update.call(this$1, vnode, hydrating);
  51527. };
  51528. },
  51529. render: function render (h) {
  51530. var tag = this.tag || this.$vnode.data.tag || 'span';
  51531. var map = Object.create(null);
  51532. var prevChildren = this.prevChildren = this.children;
  51533. var rawChildren = this.$slots.default || [];
  51534. var children = this.children = [];
  51535. var transitionData = extractTransitionData(this);
  51536. for (var i = 0; i < rawChildren.length; i++) {
  51537. var c = rawChildren[i];
  51538. if (c.tag) {
  51539. if (c.key != null && String(c.key).indexOf('__vlist') !== 0) {
  51540. children.push(c);
  51541. map[c.key] = c
  51542. ;(c.data || (c.data = {})).transition = transitionData;
  51543. } else {
  51544. var opts = c.componentOptions;
  51545. var name = opts ? (opts.Ctor.options.name || opts.tag || '') : c.tag;
  51546. warn(("<transition-group> children must be keyed: <" + name + ">"));
  51547. }
  51548. }
  51549. }
  51550. if (prevChildren) {
  51551. var kept = [];
  51552. var removed = [];
  51553. for (var i$1 = 0; i$1 < prevChildren.length; i$1++) {
  51554. var c$1 = prevChildren[i$1];
  51555. c$1.data.transition = transitionData;
  51556. c$1.data.pos = c$1.elm.getBoundingClientRect();
  51557. if (map[c$1.key]) {
  51558. kept.push(c$1);
  51559. } else {
  51560. removed.push(c$1);
  51561. }
  51562. }
  51563. this.kept = h(tag, null, kept);
  51564. this.removed = removed;
  51565. }
  51566. return h(tag, null, children)
  51567. },
  51568. updated: function updated () {
  51569. var children = this.prevChildren;
  51570. var moveClass = this.moveClass || ((this.name || 'v') + '-move');
  51571. if (!children.length || !this.hasMove(children[0].elm, moveClass)) {
  51572. return
  51573. }
  51574. // we divide the work into three loops to avoid mixing DOM reads and writes
  51575. // in each iteration - which helps prevent layout thrashing.
  51576. children.forEach(callPendingCbs);
  51577. children.forEach(recordPosition);
  51578. children.forEach(applyTranslation);
  51579. // force reflow to put everything in position
  51580. // assign to this to avoid being removed in tree-shaking
  51581. // $flow-disable-line
  51582. this._reflow = document.body.offsetHeight;
  51583. children.forEach(function (c) {
  51584. if (c.data.moved) {
  51585. var el = c.elm;
  51586. var s = el.style;
  51587. addTransitionClass(el, moveClass);
  51588. s.transform = s.WebkitTransform = s.transitionDuration = '';
  51589. el.addEventListener(transitionEndEvent, el._moveCb = function cb (e) {
  51590. if (e && e.target !== el) {
  51591. return
  51592. }
  51593. if (!e || /transform$/.test(e.propertyName)) {
  51594. el.removeEventListener(transitionEndEvent, cb);
  51595. el._moveCb = null;
  51596. removeTransitionClass(el, moveClass);
  51597. }
  51598. });
  51599. }
  51600. });
  51601. },
  51602. methods: {
  51603. hasMove: function hasMove (el, moveClass) {
  51604. /* istanbul ignore if */
  51605. if (!hasTransition) {
  51606. return false
  51607. }
  51608. /* istanbul ignore if */
  51609. if (this._hasMove) {
  51610. return this._hasMove
  51611. }
  51612. // Detect whether an element with the move class applied has
  51613. // CSS transitions. Since the element may be inside an entering
  51614. // transition at this very moment, we make a clone of it and remove
  51615. // all other transition classes applied to ensure only the move class
  51616. // is applied.
  51617. var clone = el.cloneNode();
  51618. if (el._transitionClasses) {
  51619. el._transitionClasses.forEach(function (cls) { removeClass(clone, cls); });
  51620. }
  51621. addClass(clone, moveClass);
  51622. clone.style.display = 'none';
  51623. this.$el.appendChild(clone);
  51624. var info = getTransitionInfo(clone);
  51625. this.$el.removeChild(clone);
  51626. return (this._hasMove = info.hasTransform)
  51627. }
  51628. }
  51629. };
  51630. function callPendingCbs (c) {
  51631. /* istanbul ignore if */
  51632. if (c.elm._moveCb) {
  51633. c.elm._moveCb();
  51634. }
  51635. /* istanbul ignore if */
  51636. if (c.elm._enterCb) {
  51637. c.elm._enterCb();
  51638. }
  51639. }
  51640. function recordPosition (c) {
  51641. c.data.newPos = c.elm.getBoundingClientRect();
  51642. }
  51643. function applyTranslation (c) {
  51644. var oldPos = c.data.pos;
  51645. var newPos = c.data.newPos;
  51646. var dx = oldPos.left - newPos.left;
  51647. var dy = oldPos.top - newPos.top;
  51648. if (dx || dy) {
  51649. c.data.moved = true;
  51650. var s = c.elm.style;
  51651. s.transform = s.WebkitTransform = "translate(" + dx + "px," + dy + "px)";
  51652. s.transitionDuration = '0s';
  51653. }
  51654. }
  51655. var platformComponents = {
  51656. Transition: Transition,
  51657. TransitionGroup: TransitionGroup
  51658. };
  51659. /* */
  51660. // install platform specific utils
  51661. Vue.config.mustUseProp = mustUseProp;
  51662. Vue.config.isReservedTag = isReservedTag;
  51663. Vue.config.isReservedAttr = isReservedAttr;
  51664. Vue.config.getTagNamespace = getTagNamespace;
  51665. Vue.config.isUnknownElement = isUnknownElement;
  51666. // install platform runtime directives & components
  51667. extend(Vue.options.directives, platformDirectives);
  51668. extend(Vue.options.components, platformComponents);
  51669. // install platform patch function
  51670. Vue.prototype.__patch__ = inBrowser ? patch : noop;
  51671. // public mount method
  51672. Vue.prototype.$mount = function (
  51673. el,
  51674. hydrating
  51675. ) {
  51676. el = el && inBrowser ? query(el) : undefined;
  51677. return mountComponent(this, el, hydrating)
  51678. };
  51679. // devtools global hook
  51680. /* istanbul ignore next */
  51681. if (inBrowser) {
  51682. setTimeout(function () {
  51683. if (config.devtools) {
  51684. if (devtools) {
  51685. devtools.emit('init', Vue);
  51686. } else {
  51687. console[console.info ? 'info' : 'log'](
  51688. 'Download the Vue Devtools extension for a better development experience:\n' +
  51689. 'https://github.com/vuejs/vue-devtools'
  51690. );
  51691. }
  51692. }
  51693. if (config.productionTip !== false &&
  51694. typeof console !== 'undefined'
  51695. ) {
  51696. console[console.info ? 'info' : 'log'](
  51697. "You are running Vue in development mode.\n" +
  51698. "Make sure to turn on production mode when deploying for production.\n" +
  51699. "See more tips at https://vuejs.org/guide/deployment.html"
  51700. );
  51701. }
  51702. }, 0);
  51703. }
  51704. /* */
  51705. var defaultTagRE = /\{\{((?:.|\r?\n)+?)\}\}/g;
  51706. var regexEscapeRE = /[-.*+?^${}()|[\]\/\\]/g;
  51707. var buildRegex = cached(function (delimiters) {
  51708. var open = delimiters[0].replace(regexEscapeRE, '\\$&');
  51709. var close = delimiters[1].replace(regexEscapeRE, '\\$&');
  51710. return new RegExp(open + '((?:.|\\n)+?)' + close, 'g')
  51711. });
  51712. function parseText (
  51713. text,
  51714. delimiters
  51715. ) {
  51716. var tagRE = delimiters ? buildRegex(delimiters) : defaultTagRE;
  51717. if (!tagRE.test(text)) {
  51718. return
  51719. }
  51720. var tokens = [];
  51721. var rawTokens = [];
  51722. var lastIndex = tagRE.lastIndex = 0;
  51723. var match, index, tokenValue;
  51724. while ((match = tagRE.exec(text))) {
  51725. index = match.index;
  51726. // push text token
  51727. if (index > lastIndex) {
  51728. rawTokens.push(tokenValue = text.slice(lastIndex, index));
  51729. tokens.push(JSON.stringify(tokenValue));
  51730. }
  51731. // tag token
  51732. var exp = parseFilters(match[1].trim());
  51733. tokens.push(("_s(" + exp + ")"));
  51734. rawTokens.push({ '@binding': exp });
  51735. lastIndex = index + match[0].length;
  51736. }
  51737. if (lastIndex < text.length) {
  51738. rawTokens.push(tokenValue = text.slice(lastIndex));
  51739. tokens.push(JSON.stringify(tokenValue));
  51740. }
  51741. return {
  51742. expression: tokens.join('+'),
  51743. tokens: rawTokens
  51744. }
  51745. }
  51746. /* */
  51747. function transformNode (el, options) {
  51748. var warn = options.warn || baseWarn;
  51749. var staticClass = getAndRemoveAttr(el, 'class');
  51750. if (staticClass) {
  51751. var res = parseText(staticClass, options.delimiters);
  51752. if (res) {
  51753. warn(
  51754. "class=\"" + staticClass + "\": " +
  51755. 'Interpolation inside attributes has been removed. ' +
  51756. 'Use v-bind or the colon shorthand instead. For example, ' +
  51757. 'instead of <div class="{{ val }}">, use <div :class="val">.',
  51758. el.rawAttrsMap['class']
  51759. );
  51760. }
  51761. }
  51762. if (staticClass) {
  51763. el.staticClass = JSON.stringify(staticClass);
  51764. }
  51765. var classBinding = getBindingAttr(el, 'class', false /* getStatic */);
  51766. if (classBinding) {
  51767. el.classBinding = classBinding;
  51768. }
  51769. }
  51770. function genData (el) {
  51771. var data = '';
  51772. if (el.staticClass) {
  51773. data += "staticClass:" + (el.staticClass) + ",";
  51774. }
  51775. if (el.classBinding) {
  51776. data += "class:" + (el.classBinding) + ",";
  51777. }
  51778. return data
  51779. }
  51780. var klass$1 = {
  51781. staticKeys: ['staticClass'],
  51782. transformNode: transformNode,
  51783. genData: genData
  51784. };
  51785. /* */
  51786. function transformNode$1 (el, options) {
  51787. var warn = options.warn || baseWarn;
  51788. var staticStyle = getAndRemoveAttr(el, 'style');
  51789. if (staticStyle) {
  51790. /* istanbul ignore if */
  51791. {
  51792. var res = parseText(staticStyle, options.delimiters);
  51793. if (res) {
  51794. warn(
  51795. "style=\"" + staticStyle + "\": " +
  51796. 'Interpolation inside attributes has been removed. ' +
  51797. 'Use v-bind or the colon shorthand instead. For example, ' +
  51798. 'instead of <div style="{{ val }}">, use <div :style="val">.',
  51799. el.rawAttrsMap['style']
  51800. );
  51801. }
  51802. }
  51803. el.staticStyle = JSON.stringify(parseStyleText(staticStyle));
  51804. }
  51805. var styleBinding = getBindingAttr(el, 'style', false /* getStatic */);
  51806. if (styleBinding) {
  51807. el.styleBinding = styleBinding;
  51808. }
  51809. }
  51810. function genData$1 (el) {
  51811. var data = '';
  51812. if (el.staticStyle) {
  51813. data += "staticStyle:" + (el.staticStyle) + ",";
  51814. }
  51815. if (el.styleBinding) {
  51816. data += "style:(" + (el.styleBinding) + "),";
  51817. }
  51818. return data
  51819. }
  51820. var style$1 = {
  51821. staticKeys: ['staticStyle'],
  51822. transformNode: transformNode$1,
  51823. genData: genData$1
  51824. };
  51825. /* */
  51826. var decoder;
  51827. var he = {
  51828. decode: function decode (html) {
  51829. decoder = decoder || document.createElement('div');
  51830. decoder.innerHTML = html;
  51831. return decoder.textContent
  51832. }
  51833. };
  51834. /* */
  51835. var isUnaryTag = makeMap(
  51836. 'area,base,br,col,embed,frame,hr,img,input,isindex,keygen,' +
  51837. 'link,meta,param,source,track,wbr'
  51838. );
  51839. // Elements that you can, intentionally, leave open
  51840. // (and which close themselves)
  51841. var canBeLeftOpenTag = makeMap(
  51842. 'colgroup,dd,dt,li,options,p,td,tfoot,th,thead,tr,source'
  51843. );
  51844. // HTML5 tags https://html.spec.whatwg.org/multipage/indices.html#elements-3
  51845. // Phrasing Content https://html.spec.whatwg.org/multipage/dom.html#phrasing-content
  51846. var isNonPhrasingTag = makeMap(
  51847. 'address,article,aside,base,blockquote,body,caption,col,colgroup,dd,' +
  51848. 'details,dialog,div,dl,dt,fieldset,figcaption,figure,footer,form,' +
  51849. 'h1,h2,h3,h4,h5,h6,head,header,hgroup,hr,html,legend,li,menuitem,meta,' +
  51850. 'optgroup,option,param,rp,rt,source,style,summary,tbody,td,tfoot,th,thead,' +
  51851. 'title,tr,track'
  51852. );
  51853. /**
  51854. * Not type-checking this file because it's mostly vendor code.
  51855. */
  51856. // Regular Expressions for parsing tags and attributes
  51857. var attribute = /^\s*([^\s"'<>\/=]+)(?:\s*(=)\s*(?:"([^"]*)"+|'([^']*)'+|([^\s"'=<>`]+)))?/;
  51858. var dynamicArgAttribute = /^\s*((?:v-[\w-]+:|@|:|#)\[[^=]+\][^\s"'<>\/=]*)(?:\s*(=)\s*(?:"([^"]*)"+|'([^']*)'+|([^\s"'=<>`]+)))?/;
  51859. var ncname = "[a-zA-Z_][\\-\\.0-9_a-zA-Z" + (unicodeRegExp.source) + "]*";
  51860. var qnameCapture = "((?:" + ncname + "\\:)?" + ncname + ")";
  51861. var startTagOpen = new RegExp(("^<" + qnameCapture));
  51862. var startTagClose = /^\s*(\/?)>/;
  51863. var endTag = new RegExp(("^<\\/" + qnameCapture + "[^>]*>"));
  51864. var doctype = /^<!DOCTYPE [^>]+>/i;
  51865. // #7298: escape - to avoid being passed as HTML comment when inlined in page
  51866. var comment = /^<!\--/;
  51867. var conditionalComment = /^<!\[/;
  51868. // Special Elements (can contain anything)
  51869. var isPlainTextElement = makeMap('script,style,textarea', true);
  51870. var reCache = {};
  51871. var decodingMap = {
  51872. '&lt;': '<',
  51873. '&gt;': '>',
  51874. '&quot;': '"',
  51875. '&amp;': '&',
  51876. '&#10;': '\n',
  51877. '&#9;': '\t',
  51878. '&#39;': "'"
  51879. };
  51880. var encodedAttr = /&(?:lt|gt|quot|amp|#39);/g;
  51881. var encodedAttrWithNewLines = /&(?:lt|gt|quot|amp|#39|#10|#9);/g;
  51882. // #5992
  51883. var isIgnoreNewlineTag = makeMap('pre,textarea', true);
  51884. var shouldIgnoreFirstNewline = function (tag, html) { return tag && isIgnoreNewlineTag(tag) && html[0] === '\n'; };
  51885. function decodeAttr (value, shouldDecodeNewlines) {
  51886. var re = shouldDecodeNewlines ? encodedAttrWithNewLines : encodedAttr;
  51887. return value.replace(re, function (match) { return decodingMap[match]; })
  51888. }
  51889. function parseHTML (html, options) {
  51890. var stack = [];
  51891. var expectHTML = options.expectHTML;
  51892. var isUnaryTag$$1 = options.isUnaryTag || no;
  51893. var canBeLeftOpenTag$$1 = options.canBeLeftOpenTag || no;
  51894. var index = 0;
  51895. var last, lastTag;
  51896. while (html) {
  51897. last = html;
  51898. // Make sure we're not in a plaintext content element like script/style
  51899. if (!lastTag || !isPlainTextElement(lastTag)) {
  51900. var textEnd = html.indexOf('<');
  51901. if (textEnd === 0) {
  51902. // Comment:
  51903. if (comment.test(html)) {
  51904. var commentEnd = html.indexOf('-->');
  51905. if (commentEnd >= 0) {
  51906. if (options.shouldKeepComment) {
  51907. options.comment(html.substring(4, commentEnd), index, index + commentEnd + 3);
  51908. }
  51909. advance(commentEnd + 3);
  51910. continue
  51911. }
  51912. }
  51913. // http://en.wikipedia.org/wiki/Conditional_comment#Downlevel-revealed_conditional_comment
  51914. if (conditionalComment.test(html)) {
  51915. var conditionalEnd = html.indexOf(']>');
  51916. if (conditionalEnd >= 0) {
  51917. advance(conditionalEnd + 2);
  51918. continue
  51919. }
  51920. }
  51921. // Doctype:
  51922. var doctypeMatch = html.match(doctype);
  51923. if (doctypeMatch) {
  51924. advance(doctypeMatch[0].length);
  51925. continue
  51926. }
  51927. // End tag:
  51928. var endTagMatch = html.match(endTag);
  51929. if (endTagMatch) {
  51930. var curIndex = index;
  51931. advance(endTagMatch[0].length);
  51932. parseEndTag(endTagMatch[1], curIndex, index);
  51933. continue
  51934. }
  51935. // Start tag:
  51936. var startTagMatch = parseStartTag();
  51937. if (startTagMatch) {
  51938. handleStartTag(startTagMatch);
  51939. if (shouldIgnoreFirstNewline(startTagMatch.tagName, html)) {
  51940. advance(1);
  51941. }
  51942. continue
  51943. }
  51944. }
  51945. var text = (void 0), rest = (void 0), next = (void 0);
  51946. if (textEnd >= 0) {
  51947. rest = html.slice(textEnd);
  51948. while (
  51949. !endTag.test(rest) &&
  51950. !startTagOpen.test(rest) &&
  51951. !comment.test(rest) &&
  51952. !conditionalComment.test(rest)
  51953. ) {
  51954. // < in plain text, be forgiving and treat it as text
  51955. next = rest.indexOf('<', 1);
  51956. if (next < 0) { break }
  51957. textEnd += next;
  51958. rest = html.slice(textEnd);
  51959. }
  51960. text = html.substring(0, textEnd);
  51961. }
  51962. if (textEnd < 0) {
  51963. text = html;
  51964. }
  51965. if (text) {
  51966. advance(text.length);
  51967. }
  51968. if (options.chars && text) {
  51969. options.chars(text, index - text.length, index);
  51970. }
  51971. } else {
  51972. var endTagLength = 0;
  51973. var stackedTag = lastTag.toLowerCase();
  51974. var reStackedTag = reCache[stackedTag] || (reCache[stackedTag] = new RegExp('([\\s\\S]*?)(</' + stackedTag + '[^>]*>)', 'i'));
  51975. var rest$1 = html.replace(reStackedTag, function (all, text, endTag) {
  51976. endTagLength = endTag.length;
  51977. if (!isPlainTextElement(stackedTag) && stackedTag !== 'noscript') {
  51978. text = text
  51979. .replace(/<!\--([\s\S]*?)-->/g, '$1') // #7298
  51980. .replace(/<!\[CDATA\[([\s\S]*?)]]>/g, '$1');
  51981. }
  51982. if (shouldIgnoreFirstNewline(stackedTag, text)) {
  51983. text = text.slice(1);
  51984. }
  51985. if (options.chars) {
  51986. options.chars(text);
  51987. }
  51988. return ''
  51989. });
  51990. index += html.length - rest$1.length;
  51991. html = rest$1;
  51992. parseEndTag(stackedTag, index - endTagLength, index);
  51993. }
  51994. if (html === last) {
  51995. options.chars && options.chars(html);
  51996. if (!stack.length && options.warn) {
  51997. options.warn(("Mal-formatted tag at end of template: \"" + html + "\""), { start: index + html.length });
  51998. }
  51999. break
  52000. }
  52001. }
  52002. // Clean up any remaining tags
  52003. parseEndTag();
  52004. function advance (n) {
  52005. index += n;
  52006. html = html.substring(n);
  52007. }
  52008. function parseStartTag () {
  52009. var start = html.match(startTagOpen);
  52010. if (start) {
  52011. var match = {
  52012. tagName: start[1],
  52013. attrs: [],
  52014. start: index
  52015. };
  52016. advance(start[0].length);
  52017. var end, attr;
  52018. while (!(end = html.match(startTagClose)) && (attr = html.match(dynamicArgAttribute) || html.match(attribute))) {
  52019. attr.start = index;
  52020. advance(attr[0].length);
  52021. attr.end = index;
  52022. match.attrs.push(attr);
  52023. }
  52024. if (end) {
  52025. match.unarySlash = end[1];
  52026. advance(end[0].length);
  52027. match.end = index;
  52028. return match
  52029. }
  52030. }
  52031. }
  52032. function handleStartTag (match) {
  52033. var tagName = match.tagName;
  52034. var unarySlash = match.unarySlash;
  52035. if (expectHTML) {
  52036. if (lastTag === 'p' && isNonPhrasingTag(tagName)) {
  52037. parseEndTag(lastTag);
  52038. }
  52039. if (canBeLeftOpenTag$$1(tagName) && lastTag === tagName) {
  52040. parseEndTag(tagName);
  52041. }
  52042. }
  52043. var unary = isUnaryTag$$1(tagName) || !!unarySlash;
  52044. var l = match.attrs.length;
  52045. var attrs = new Array(l);
  52046. for (var i = 0; i < l; i++) {
  52047. var args = match.attrs[i];
  52048. var value = args[3] || args[4] || args[5] || '';
  52049. var shouldDecodeNewlines = tagName === 'a' && args[1] === 'href'
  52050. ? options.shouldDecodeNewlinesForHref
  52051. : options.shouldDecodeNewlines;
  52052. attrs[i] = {
  52053. name: args[1],
  52054. value: decodeAttr(value, shouldDecodeNewlines)
  52055. };
  52056. if (options.outputSourceRange) {
  52057. attrs[i].start = args.start + args[0].match(/^\s*/).length;
  52058. attrs[i].end = args.end;
  52059. }
  52060. }
  52061. if (!unary) {
  52062. stack.push({ tag: tagName, lowerCasedTag: tagName.toLowerCase(), attrs: attrs, start: match.start, end: match.end });
  52063. lastTag = tagName;
  52064. }
  52065. if (options.start) {
  52066. options.start(tagName, attrs, unary, match.start, match.end);
  52067. }
  52068. }
  52069. function parseEndTag (tagName, start, end) {
  52070. var pos, lowerCasedTagName;
  52071. if (start == null) { start = index; }
  52072. if (end == null) { end = index; }
  52073. // Find the closest opened tag of the same type
  52074. if (tagName) {
  52075. lowerCasedTagName = tagName.toLowerCase();
  52076. for (pos = stack.length - 1; pos >= 0; pos--) {
  52077. if (stack[pos].lowerCasedTag === lowerCasedTagName) {
  52078. break
  52079. }
  52080. }
  52081. } else {
  52082. // If no tag name is provided, clean shop
  52083. pos = 0;
  52084. }
  52085. if (pos >= 0) {
  52086. // Close all the open elements, up the stack
  52087. for (var i = stack.length - 1; i >= pos; i--) {
  52088. if (i > pos || !tagName &&
  52089. options.warn
  52090. ) {
  52091. options.warn(
  52092. ("tag <" + (stack[i].tag) + "> has no matching end tag."),
  52093. { start: stack[i].start, end: stack[i].end }
  52094. );
  52095. }
  52096. if (options.end) {
  52097. options.end(stack[i].tag, start, end);
  52098. }
  52099. }
  52100. // Remove the open elements from the stack
  52101. stack.length = pos;
  52102. lastTag = pos && stack[pos - 1].tag;
  52103. } else if (lowerCasedTagName === 'br') {
  52104. if (options.start) {
  52105. options.start(tagName, [], true, start, end);
  52106. }
  52107. } else if (lowerCasedTagName === 'p') {
  52108. if (options.start) {
  52109. options.start(tagName, [], false, start, end);
  52110. }
  52111. if (options.end) {
  52112. options.end(tagName, start, end);
  52113. }
  52114. }
  52115. }
  52116. }
  52117. /* */
  52118. var onRE = /^@|^v-on:/;
  52119. var dirRE = /^v-|^@|^:|^#/;
  52120. var forAliasRE = /([\s\S]*?)\s+(?:in|of)\s+([\s\S]*)/;
  52121. var forIteratorRE = /,([^,\}\]]*)(?:,([^,\}\]]*))?$/;
  52122. var stripParensRE = /^\(|\)$/g;
  52123. var dynamicArgRE = /^\[.*\]$/;
  52124. var argRE = /:(.*)$/;
  52125. var bindRE = /^:|^\.|^v-bind:/;
  52126. var modifierRE = /\.[^.\]]+(?=[^\]]*$)/g;
  52127. var slotRE = /^v-slot(:|$)|^#/;
  52128. var lineBreakRE = /[\r\n]/;
  52129. var whitespaceRE$1 = /\s+/g;
  52130. var invalidAttributeRE = /[\s"'<>\/=]/;
  52131. var decodeHTMLCached = cached(he.decode);
  52132. var emptySlotScopeToken = "_empty_";
  52133. // configurable state
  52134. var warn$2;
  52135. var delimiters;
  52136. var transforms;
  52137. var preTransforms;
  52138. var postTransforms;
  52139. var platformIsPreTag;
  52140. var platformMustUseProp;
  52141. var platformGetTagNamespace;
  52142. var maybeComponent;
  52143. function createASTElement (
  52144. tag,
  52145. attrs,
  52146. parent
  52147. ) {
  52148. return {
  52149. type: 1,
  52150. tag: tag,
  52151. attrsList: attrs,
  52152. attrsMap: makeAttrsMap(attrs),
  52153. rawAttrsMap: {},
  52154. parent: parent,
  52155. children: []
  52156. }
  52157. }
  52158. /**
  52159. * Convert HTML string to AST.
  52160. */
  52161. function parse (
  52162. template,
  52163. options
  52164. ) {
  52165. warn$2 = options.warn || baseWarn;
  52166. platformIsPreTag = options.isPreTag || no;
  52167. platformMustUseProp = options.mustUseProp || no;
  52168. platformGetTagNamespace = options.getTagNamespace || no;
  52169. var isReservedTag = options.isReservedTag || no;
  52170. maybeComponent = function (el) { return !!el.component || !isReservedTag(el.tag); };
  52171. transforms = pluckModuleFunction(options.modules, 'transformNode');
  52172. preTransforms = pluckModuleFunction(options.modules, 'preTransformNode');
  52173. postTransforms = pluckModuleFunction(options.modules, 'postTransformNode');
  52174. delimiters = options.delimiters;
  52175. var stack = [];
  52176. var preserveWhitespace = options.preserveWhitespace !== false;
  52177. var whitespaceOption = options.whitespace;
  52178. var root;
  52179. var currentParent;
  52180. var inVPre = false;
  52181. var inPre = false;
  52182. var warned = false;
  52183. function warnOnce (msg, range) {
  52184. if (!warned) {
  52185. warned = true;
  52186. warn$2(msg, range);
  52187. }
  52188. }
  52189. function closeElement (element) {
  52190. trimEndingWhitespace(element);
  52191. if (!inVPre && !element.processed) {
  52192. element = processElement(element, options);
  52193. }
  52194. // tree management
  52195. if (!stack.length && element !== root) {
  52196. // allow root elements with v-if, v-else-if and v-else
  52197. if (root.if && (element.elseif || element.else)) {
  52198. {
  52199. checkRootConstraints(element);
  52200. }
  52201. addIfCondition(root, {
  52202. exp: element.elseif,
  52203. block: element
  52204. });
  52205. } else {
  52206. warnOnce(
  52207. "Component template should contain exactly one root element. " +
  52208. "If you are using v-if on multiple elements, " +
  52209. "use v-else-if to chain them instead.",
  52210. { start: element.start }
  52211. );
  52212. }
  52213. }
  52214. if (currentParent && !element.forbidden) {
  52215. if (element.elseif || element.else) {
  52216. processIfConditions(element, currentParent);
  52217. } else {
  52218. if (element.slotScope) {
  52219. // scoped slot
  52220. // keep it in the children list so that v-else(-if) conditions can
  52221. // find it as the prev node.
  52222. var name = element.slotTarget || '"default"'
  52223. ;(currentParent.scopedSlots || (currentParent.scopedSlots = {}))[name] = element;
  52224. }
  52225. currentParent.children.push(element);
  52226. element.parent = currentParent;
  52227. }
  52228. }
  52229. // final children cleanup
  52230. // filter out scoped slots
  52231. element.children = element.children.filter(function (c) { return !(c).slotScope; });
  52232. // remove trailing whitespace node again
  52233. trimEndingWhitespace(element);
  52234. // check pre state
  52235. if (element.pre) {
  52236. inVPre = false;
  52237. }
  52238. if (platformIsPreTag(element.tag)) {
  52239. inPre = false;
  52240. }
  52241. // apply post-transforms
  52242. for (var i = 0; i < postTransforms.length; i++) {
  52243. postTransforms[i](element, options);
  52244. }
  52245. }
  52246. function trimEndingWhitespace (el) {
  52247. // remove trailing whitespace node
  52248. if (!inPre) {
  52249. var lastNode;
  52250. while (
  52251. (lastNode = el.children[el.children.length - 1]) &&
  52252. lastNode.type === 3 &&
  52253. lastNode.text === ' '
  52254. ) {
  52255. el.children.pop();
  52256. }
  52257. }
  52258. }
  52259. function checkRootConstraints (el) {
  52260. if (el.tag === 'slot' || el.tag === 'template') {
  52261. warnOnce(
  52262. "Cannot use <" + (el.tag) + "> as component root element because it may " +
  52263. 'contain multiple nodes.',
  52264. { start: el.start }
  52265. );
  52266. }
  52267. if (el.attrsMap.hasOwnProperty('v-for')) {
  52268. warnOnce(
  52269. 'Cannot use v-for on stateful component root element because ' +
  52270. 'it renders multiple elements.',
  52271. el.rawAttrsMap['v-for']
  52272. );
  52273. }
  52274. }
  52275. parseHTML(template, {
  52276. warn: warn$2,
  52277. expectHTML: options.expectHTML,
  52278. isUnaryTag: options.isUnaryTag,
  52279. canBeLeftOpenTag: options.canBeLeftOpenTag,
  52280. shouldDecodeNewlines: options.shouldDecodeNewlines,
  52281. shouldDecodeNewlinesForHref: options.shouldDecodeNewlinesForHref,
  52282. shouldKeepComment: options.comments,
  52283. outputSourceRange: options.outputSourceRange,
  52284. start: function start (tag, attrs, unary, start$1, end) {
  52285. // check namespace.
  52286. // inherit parent ns if there is one
  52287. var ns = (currentParent && currentParent.ns) || platformGetTagNamespace(tag);
  52288. // handle IE svg bug
  52289. /* istanbul ignore if */
  52290. if (isIE && ns === 'svg') {
  52291. attrs = guardIESVGBug(attrs);
  52292. }
  52293. var element = createASTElement(tag, attrs, currentParent);
  52294. if (ns) {
  52295. element.ns = ns;
  52296. }
  52297. {
  52298. if (options.outputSourceRange) {
  52299. element.start = start$1;
  52300. element.end = end;
  52301. element.rawAttrsMap = element.attrsList.reduce(function (cumulated, attr) {
  52302. cumulated[attr.name] = attr;
  52303. return cumulated
  52304. }, {});
  52305. }
  52306. attrs.forEach(function (attr) {
  52307. if (invalidAttributeRE.test(attr.name)) {
  52308. warn$2(
  52309. "Invalid dynamic argument expression: attribute names cannot contain " +
  52310. "spaces, quotes, <, >, / or =.",
  52311. {
  52312. start: attr.start + attr.name.indexOf("["),
  52313. end: attr.start + attr.name.length
  52314. }
  52315. );
  52316. }
  52317. });
  52318. }
  52319. if (isForbiddenTag(element) && !isServerRendering()) {
  52320. element.forbidden = true;
  52321. warn$2(
  52322. 'Templates should only be responsible for mapping the state to the ' +
  52323. 'UI. Avoid placing tags with side-effects in your templates, such as ' +
  52324. "<" + tag + ">" + ', as they will not be parsed.',
  52325. { start: element.start }
  52326. );
  52327. }
  52328. // apply pre-transforms
  52329. for (var i = 0; i < preTransforms.length; i++) {
  52330. element = preTransforms[i](element, options) || element;
  52331. }
  52332. if (!inVPre) {
  52333. processPre(element);
  52334. if (element.pre) {
  52335. inVPre = true;
  52336. }
  52337. }
  52338. if (platformIsPreTag(element.tag)) {
  52339. inPre = true;
  52340. }
  52341. if (inVPre) {
  52342. processRawAttrs(element);
  52343. } else if (!element.processed) {
  52344. // structural directives
  52345. processFor(element);
  52346. processIf(element);
  52347. processOnce(element);
  52348. }
  52349. if (!root) {
  52350. root = element;
  52351. {
  52352. checkRootConstraints(root);
  52353. }
  52354. }
  52355. if (!unary) {
  52356. currentParent = element;
  52357. stack.push(element);
  52358. } else {
  52359. closeElement(element);
  52360. }
  52361. },
  52362. end: function end (tag, start, end$1) {
  52363. var element = stack[stack.length - 1];
  52364. // pop stack
  52365. stack.length -= 1;
  52366. currentParent = stack[stack.length - 1];
  52367. if (options.outputSourceRange) {
  52368. element.end = end$1;
  52369. }
  52370. closeElement(element);
  52371. },
  52372. chars: function chars (text, start, end) {
  52373. if (!currentParent) {
  52374. {
  52375. if (text === template) {
  52376. warnOnce(
  52377. 'Component template requires a root element, rather than just text.',
  52378. { start: start }
  52379. );
  52380. } else if ((text = text.trim())) {
  52381. warnOnce(
  52382. ("text \"" + text + "\" outside root element will be ignored."),
  52383. { start: start }
  52384. );
  52385. }
  52386. }
  52387. return
  52388. }
  52389. // IE textarea placeholder bug
  52390. /* istanbul ignore if */
  52391. if (isIE &&
  52392. currentParent.tag === 'textarea' &&
  52393. currentParent.attrsMap.placeholder === text
  52394. ) {
  52395. return
  52396. }
  52397. var children = currentParent.children;
  52398. if (inPre || text.trim()) {
  52399. text = isTextTag(currentParent) ? text : decodeHTMLCached(text);
  52400. } else if (!children.length) {
  52401. // remove the whitespace-only node right after an opening tag
  52402. text = '';
  52403. } else if (whitespaceOption) {
  52404. if (whitespaceOption === 'condense') {
  52405. // in condense mode, remove the whitespace node if it contains
  52406. // line break, otherwise condense to a single space
  52407. text = lineBreakRE.test(text) ? '' : ' ';
  52408. } else {
  52409. text = ' ';
  52410. }
  52411. } else {
  52412. text = preserveWhitespace ? ' ' : '';
  52413. }
  52414. if (text) {
  52415. if (!inPre && whitespaceOption === 'condense') {
  52416. // condense consecutive whitespaces into single space
  52417. text = text.replace(whitespaceRE$1, ' ');
  52418. }
  52419. var res;
  52420. var child;
  52421. if (!inVPre && text !== ' ' && (res = parseText(text, delimiters))) {
  52422. child = {
  52423. type: 2,
  52424. expression: res.expression,
  52425. tokens: res.tokens,
  52426. text: text
  52427. };
  52428. } else if (text !== ' ' || !children.length || children[children.length - 1].text !== ' ') {
  52429. child = {
  52430. type: 3,
  52431. text: text
  52432. };
  52433. }
  52434. if (child) {
  52435. if (options.outputSourceRange) {
  52436. child.start = start;
  52437. child.end = end;
  52438. }
  52439. children.push(child);
  52440. }
  52441. }
  52442. },
  52443. comment: function comment (text, start, end) {
  52444. // adding anyting as a sibling to the root node is forbidden
  52445. // comments should still be allowed, but ignored
  52446. if (currentParent) {
  52447. var child = {
  52448. type: 3,
  52449. text: text,
  52450. isComment: true
  52451. };
  52452. if (options.outputSourceRange) {
  52453. child.start = start;
  52454. child.end = end;
  52455. }
  52456. currentParent.children.push(child);
  52457. }
  52458. }
  52459. });
  52460. return root
  52461. }
  52462. function processPre (el) {
  52463. if (getAndRemoveAttr(el, 'v-pre') != null) {
  52464. el.pre = true;
  52465. }
  52466. }
  52467. function processRawAttrs (el) {
  52468. var list = el.attrsList;
  52469. var len = list.length;
  52470. if (len) {
  52471. var attrs = el.attrs = new Array(len);
  52472. for (var i = 0; i < len; i++) {
  52473. attrs[i] = {
  52474. name: list[i].name,
  52475. value: JSON.stringify(list[i].value)
  52476. };
  52477. if (list[i].start != null) {
  52478. attrs[i].start = list[i].start;
  52479. attrs[i].end = list[i].end;
  52480. }
  52481. }
  52482. } else if (!el.pre) {
  52483. // non root node in pre blocks with no attributes
  52484. el.plain = true;
  52485. }
  52486. }
  52487. function processElement (
  52488. element,
  52489. options
  52490. ) {
  52491. processKey(element);
  52492. // determine whether this is a plain element after
  52493. // removing structural attributes
  52494. element.plain = (
  52495. !element.key &&
  52496. !element.scopedSlots &&
  52497. !element.attrsList.length
  52498. );
  52499. processRef(element);
  52500. processSlotContent(element);
  52501. processSlotOutlet(element);
  52502. processComponent(element);
  52503. for (var i = 0; i < transforms.length; i++) {
  52504. element = transforms[i](element, options) || element;
  52505. }
  52506. processAttrs(element);
  52507. return element
  52508. }
  52509. function processKey (el) {
  52510. var exp = getBindingAttr(el, 'key');
  52511. if (exp) {
  52512. {
  52513. if (el.tag === 'template') {
  52514. warn$2(
  52515. "<template> cannot be keyed. Place the key on real elements instead.",
  52516. getRawBindingAttr(el, 'key')
  52517. );
  52518. }
  52519. if (el.for) {
  52520. var iterator = el.iterator2 || el.iterator1;
  52521. var parent = el.parent;
  52522. if (iterator && iterator === exp && parent && parent.tag === 'transition-group') {
  52523. warn$2(
  52524. "Do not use v-for index as key on <transition-group> children, " +
  52525. "this is the same as not using keys.",
  52526. getRawBindingAttr(el, 'key'),
  52527. true /* tip */
  52528. );
  52529. }
  52530. }
  52531. }
  52532. el.key = exp;
  52533. }
  52534. }
  52535. function processRef (el) {
  52536. var ref = getBindingAttr(el, 'ref');
  52537. if (ref) {
  52538. el.ref = ref;
  52539. el.refInFor = checkInFor(el);
  52540. }
  52541. }
  52542. function processFor (el) {
  52543. var exp;
  52544. if ((exp = getAndRemoveAttr(el, 'v-for'))) {
  52545. var res = parseFor(exp);
  52546. if (res) {
  52547. extend(el, res);
  52548. } else {
  52549. warn$2(
  52550. ("Invalid v-for expression: " + exp),
  52551. el.rawAttrsMap['v-for']
  52552. );
  52553. }
  52554. }
  52555. }
  52556. function parseFor (exp) {
  52557. var inMatch = exp.match(forAliasRE);
  52558. if (!inMatch) { return }
  52559. var res = {};
  52560. res.for = inMatch[2].trim();
  52561. var alias = inMatch[1].trim().replace(stripParensRE, '');
  52562. var iteratorMatch = alias.match(forIteratorRE);
  52563. if (iteratorMatch) {
  52564. res.alias = alias.replace(forIteratorRE, '').trim();
  52565. res.iterator1 = iteratorMatch[1].trim();
  52566. if (iteratorMatch[2]) {
  52567. res.iterator2 = iteratorMatch[2].trim();
  52568. }
  52569. } else {
  52570. res.alias = alias;
  52571. }
  52572. return res
  52573. }
  52574. function processIf (el) {
  52575. var exp = getAndRemoveAttr(el, 'v-if');
  52576. if (exp) {
  52577. el.if = exp;
  52578. addIfCondition(el, {
  52579. exp: exp,
  52580. block: el
  52581. });
  52582. } else {
  52583. if (getAndRemoveAttr(el, 'v-else') != null) {
  52584. el.else = true;
  52585. }
  52586. var elseif = getAndRemoveAttr(el, 'v-else-if');
  52587. if (elseif) {
  52588. el.elseif = elseif;
  52589. }
  52590. }
  52591. }
  52592. function processIfConditions (el, parent) {
  52593. var prev = findPrevElement(parent.children);
  52594. if (prev && prev.if) {
  52595. addIfCondition(prev, {
  52596. exp: el.elseif,
  52597. block: el
  52598. });
  52599. } else {
  52600. warn$2(
  52601. "v-" + (el.elseif ? ('else-if="' + el.elseif + '"') : 'else') + " " +
  52602. "used on element <" + (el.tag) + "> without corresponding v-if.",
  52603. el.rawAttrsMap[el.elseif ? 'v-else-if' : 'v-else']
  52604. );
  52605. }
  52606. }
  52607. function findPrevElement (children) {
  52608. var i = children.length;
  52609. while (i--) {
  52610. if (children[i].type === 1) {
  52611. return children[i]
  52612. } else {
  52613. if (children[i].text !== ' ') {
  52614. warn$2(
  52615. "text \"" + (children[i].text.trim()) + "\" between v-if and v-else(-if) " +
  52616. "will be ignored.",
  52617. children[i]
  52618. );
  52619. }
  52620. children.pop();
  52621. }
  52622. }
  52623. }
  52624. function addIfCondition (el, condition) {
  52625. if (!el.ifConditions) {
  52626. el.ifConditions = [];
  52627. }
  52628. el.ifConditions.push(condition);
  52629. }
  52630. function processOnce (el) {
  52631. var once$$1 = getAndRemoveAttr(el, 'v-once');
  52632. if (once$$1 != null) {
  52633. el.once = true;
  52634. }
  52635. }
  52636. // handle content being passed to a component as slot,
  52637. // e.g. <template slot="xxx">, <div slot-scope="xxx">
  52638. function processSlotContent (el) {
  52639. var slotScope;
  52640. if (el.tag === 'template') {
  52641. slotScope = getAndRemoveAttr(el, 'scope');
  52642. /* istanbul ignore if */
  52643. if (slotScope) {
  52644. warn$2(
  52645. "the \"scope\" attribute for scoped slots have been deprecated and " +
  52646. "replaced by \"slot-scope\" since 2.5. The new \"slot-scope\" attribute " +
  52647. "can also be used on plain elements in addition to <template> to " +
  52648. "denote scoped slots.",
  52649. el.rawAttrsMap['scope'],
  52650. true
  52651. );
  52652. }
  52653. el.slotScope = slotScope || getAndRemoveAttr(el, 'slot-scope');
  52654. } else if ((slotScope = getAndRemoveAttr(el, 'slot-scope'))) {
  52655. /* istanbul ignore if */
  52656. if (el.attrsMap['v-for']) {
  52657. warn$2(
  52658. "Ambiguous combined usage of slot-scope and v-for on <" + (el.tag) + "> " +
  52659. "(v-for takes higher priority). Use a wrapper <template> for the " +
  52660. "scoped slot to make it clearer.",
  52661. el.rawAttrsMap['slot-scope'],
  52662. true
  52663. );
  52664. }
  52665. el.slotScope = slotScope;
  52666. }
  52667. // slot="xxx"
  52668. var slotTarget = getBindingAttr(el, 'slot');
  52669. if (slotTarget) {
  52670. el.slotTarget = slotTarget === '""' ? '"default"' : slotTarget;
  52671. el.slotTargetDynamic = !!(el.attrsMap[':slot'] || el.attrsMap['v-bind:slot']);
  52672. // preserve slot as an attribute for native shadow DOM compat
  52673. // only for non-scoped slots.
  52674. if (el.tag !== 'template' && !el.slotScope) {
  52675. addAttr(el, 'slot', slotTarget, getRawBindingAttr(el, 'slot'));
  52676. }
  52677. }
  52678. // 2.6 v-slot syntax
  52679. {
  52680. if (el.tag === 'template') {
  52681. // v-slot on <template>
  52682. var slotBinding = getAndRemoveAttrByRegex(el, slotRE);
  52683. if (slotBinding) {
  52684. {
  52685. if (el.slotTarget || el.slotScope) {
  52686. warn$2(
  52687. "Unexpected mixed usage of different slot syntaxes.",
  52688. el
  52689. );
  52690. }
  52691. if (el.parent && !maybeComponent(el.parent)) {
  52692. warn$2(
  52693. "<template v-slot> can only appear at the root level inside " +
  52694. "the receiving component",
  52695. el
  52696. );
  52697. }
  52698. }
  52699. var ref = getSlotName(slotBinding);
  52700. var name = ref.name;
  52701. var dynamic = ref.dynamic;
  52702. el.slotTarget = name;
  52703. el.slotTargetDynamic = dynamic;
  52704. el.slotScope = slotBinding.value || emptySlotScopeToken; // force it into a scoped slot for perf
  52705. }
  52706. } else {
  52707. // v-slot on component, denotes default slot
  52708. var slotBinding$1 = getAndRemoveAttrByRegex(el, slotRE);
  52709. if (slotBinding$1) {
  52710. {
  52711. if (!maybeComponent(el)) {
  52712. warn$2(
  52713. "v-slot can only be used on components or <template>.",
  52714. slotBinding$1
  52715. );
  52716. }
  52717. if (el.slotScope || el.slotTarget) {
  52718. warn$2(
  52719. "Unexpected mixed usage of different slot syntaxes.",
  52720. el
  52721. );
  52722. }
  52723. if (el.scopedSlots) {
  52724. warn$2(
  52725. "To avoid scope ambiguity, the default slot should also use " +
  52726. "<template> syntax when there are other named slots.",
  52727. slotBinding$1
  52728. );
  52729. }
  52730. }
  52731. // add the component's children to its default slot
  52732. var slots = el.scopedSlots || (el.scopedSlots = {});
  52733. var ref$1 = getSlotName(slotBinding$1);
  52734. var name$1 = ref$1.name;
  52735. var dynamic$1 = ref$1.dynamic;
  52736. var slotContainer = slots[name$1] = createASTElement('template', [], el);
  52737. slotContainer.slotTarget = name$1;
  52738. slotContainer.slotTargetDynamic = dynamic$1;
  52739. slotContainer.children = el.children.filter(function (c) {
  52740. if (!c.slotScope) {
  52741. c.parent = slotContainer;
  52742. return true
  52743. }
  52744. });
  52745. slotContainer.slotScope = slotBinding$1.value || emptySlotScopeToken;
  52746. // remove children as they are returned from scopedSlots now
  52747. el.children = [];
  52748. // mark el non-plain so data gets generated
  52749. el.plain = false;
  52750. }
  52751. }
  52752. }
  52753. }
  52754. function getSlotName (binding) {
  52755. var name = binding.name.replace(slotRE, '');
  52756. if (!name) {
  52757. if (binding.name[0] !== '#') {
  52758. name = 'default';
  52759. } else {
  52760. warn$2(
  52761. "v-slot shorthand syntax requires a slot name.",
  52762. binding
  52763. );
  52764. }
  52765. }
  52766. return dynamicArgRE.test(name)
  52767. // dynamic [name]
  52768. ? { name: name.slice(1, -1), dynamic: true }
  52769. // static name
  52770. : { name: ("\"" + name + "\""), dynamic: false }
  52771. }
  52772. // handle <slot/> outlets
  52773. function processSlotOutlet (el) {
  52774. if (el.tag === 'slot') {
  52775. el.slotName = getBindingAttr(el, 'name');
  52776. if (el.key) {
  52777. warn$2(
  52778. "`key` does not work on <slot> because slots are abstract outlets " +
  52779. "and can possibly expand into multiple elements. " +
  52780. "Use the key on a wrapping element instead.",
  52781. getRawBindingAttr(el, 'key')
  52782. );
  52783. }
  52784. }
  52785. }
  52786. function processComponent (el) {
  52787. var binding;
  52788. if ((binding = getBindingAttr(el, 'is'))) {
  52789. el.component = binding;
  52790. }
  52791. if (getAndRemoveAttr(el, 'inline-template') != null) {
  52792. el.inlineTemplate = true;
  52793. }
  52794. }
  52795. function processAttrs (el) {
  52796. var list = el.attrsList;
  52797. var i, l, name, rawName, value, modifiers, syncGen, isDynamic;
  52798. for (i = 0, l = list.length; i < l; i++) {
  52799. name = rawName = list[i].name;
  52800. value = list[i].value;
  52801. if (dirRE.test(name)) {
  52802. // mark element as dynamic
  52803. el.hasBindings = true;
  52804. // modifiers
  52805. modifiers = parseModifiers(name.replace(dirRE, ''));
  52806. // support .foo shorthand syntax for the .prop modifier
  52807. if (modifiers) {
  52808. name = name.replace(modifierRE, '');
  52809. }
  52810. if (bindRE.test(name)) { // v-bind
  52811. name = name.replace(bindRE, '');
  52812. value = parseFilters(value);
  52813. isDynamic = dynamicArgRE.test(name);
  52814. if (isDynamic) {
  52815. name = name.slice(1, -1);
  52816. }
  52817. if (
  52818. value.trim().length === 0
  52819. ) {
  52820. warn$2(
  52821. ("The value for a v-bind expression cannot be empty. Found in \"v-bind:" + name + "\"")
  52822. );
  52823. }
  52824. if (modifiers) {
  52825. if (modifiers.prop && !isDynamic) {
  52826. name = camelize(name);
  52827. if (name === 'innerHtml') { name = 'innerHTML'; }
  52828. }
  52829. if (modifiers.camel && !isDynamic) {
  52830. name = camelize(name);
  52831. }
  52832. if (modifiers.sync) {
  52833. syncGen = genAssignmentCode(value, "$event");
  52834. if (!isDynamic) {
  52835. addHandler(
  52836. el,
  52837. ("update:" + (camelize(name))),
  52838. syncGen,
  52839. null,
  52840. false,
  52841. warn$2,
  52842. list[i]
  52843. );
  52844. if (hyphenate(name) !== camelize(name)) {
  52845. addHandler(
  52846. el,
  52847. ("update:" + (hyphenate(name))),
  52848. syncGen,
  52849. null,
  52850. false,
  52851. warn$2,
  52852. list[i]
  52853. );
  52854. }
  52855. } else {
  52856. // handler w/ dynamic event name
  52857. addHandler(
  52858. el,
  52859. ("\"update:\"+(" + name + ")"),
  52860. syncGen,
  52861. null,
  52862. false,
  52863. warn$2,
  52864. list[i],
  52865. true // dynamic
  52866. );
  52867. }
  52868. }
  52869. }
  52870. if ((modifiers && modifiers.prop) || (
  52871. !el.component && platformMustUseProp(el.tag, el.attrsMap.type, name)
  52872. )) {
  52873. addProp(el, name, value, list[i], isDynamic);
  52874. } else {
  52875. addAttr(el, name, value, list[i], isDynamic);
  52876. }
  52877. } else if (onRE.test(name)) { // v-on
  52878. name = name.replace(onRE, '');
  52879. isDynamic = dynamicArgRE.test(name);
  52880. if (isDynamic) {
  52881. name = name.slice(1, -1);
  52882. }
  52883. addHandler(el, name, value, modifiers, false, warn$2, list[i], isDynamic);
  52884. } else { // normal directives
  52885. name = name.replace(dirRE, '');
  52886. // parse arg
  52887. var argMatch = name.match(argRE);
  52888. var arg = argMatch && argMatch[1];
  52889. isDynamic = false;
  52890. if (arg) {
  52891. name = name.slice(0, -(arg.length + 1));
  52892. if (dynamicArgRE.test(arg)) {
  52893. arg = arg.slice(1, -1);
  52894. isDynamic = true;
  52895. }
  52896. }
  52897. addDirective(el, name, rawName, value, arg, isDynamic, modifiers, list[i]);
  52898. if (name === 'model') {
  52899. checkForAliasModel(el, value);
  52900. }
  52901. }
  52902. } else {
  52903. // literal attribute
  52904. {
  52905. var res = parseText(value, delimiters);
  52906. if (res) {
  52907. warn$2(
  52908. name + "=\"" + value + "\": " +
  52909. 'Interpolation inside attributes has been removed. ' +
  52910. 'Use v-bind or the colon shorthand instead. For example, ' +
  52911. 'instead of <div id="{{ val }}">, use <div :id="val">.',
  52912. list[i]
  52913. );
  52914. }
  52915. }
  52916. addAttr(el, name, JSON.stringify(value), list[i]);
  52917. // #6887 firefox doesn't update muted state if set via attribute
  52918. // even immediately after element creation
  52919. if (!el.component &&
  52920. name === 'muted' &&
  52921. platformMustUseProp(el.tag, el.attrsMap.type, name)) {
  52922. addProp(el, name, 'true', list[i]);
  52923. }
  52924. }
  52925. }
  52926. }
  52927. function checkInFor (el) {
  52928. var parent = el;
  52929. while (parent) {
  52930. if (parent.for !== undefined) {
  52931. return true
  52932. }
  52933. parent = parent.parent;
  52934. }
  52935. return false
  52936. }
  52937. function parseModifiers (name) {
  52938. var match = name.match(modifierRE);
  52939. if (match) {
  52940. var ret = {};
  52941. match.forEach(function (m) { ret[m.slice(1)] = true; });
  52942. return ret
  52943. }
  52944. }
  52945. function makeAttrsMap (attrs) {
  52946. var map = {};
  52947. for (var i = 0, l = attrs.length; i < l; i++) {
  52948. if (
  52949. map[attrs[i].name] && !isIE && !isEdge
  52950. ) {
  52951. warn$2('duplicate attribute: ' + attrs[i].name, attrs[i]);
  52952. }
  52953. map[attrs[i].name] = attrs[i].value;
  52954. }
  52955. return map
  52956. }
  52957. // for script (e.g. type="x/template") or style, do not decode content
  52958. function isTextTag (el) {
  52959. return el.tag === 'script' || el.tag === 'style'
  52960. }
  52961. function isForbiddenTag (el) {
  52962. return (
  52963. el.tag === 'style' ||
  52964. (el.tag === 'script' && (
  52965. !el.attrsMap.type ||
  52966. el.attrsMap.type === 'text/javascript'
  52967. ))
  52968. )
  52969. }
  52970. var ieNSBug = /^xmlns:NS\d+/;
  52971. var ieNSPrefix = /^NS\d+:/;
  52972. /* istanbul ignore next */
  52973. function guardIESVGBug (attrs) {
  52974. var res = [];
  52975. for (var i = 0; i < attrs.length; i++) {
  52976. var attr = attrs[i];
  52977. if (!ieNSBug.test(attr.name)) {
  52978. attr.name = attr.name.replace(ieNSPrefix, '');
  52979. res.push(attr);
  52980. }
  52981. }
  52982. return res
  52983. }
  52984. function checkForAliasModel (el, value) {
  52985. var _el = el;
  52986. while (_el) {
  52987. if (_el.for && _el.alias === value) {
  52988. warn$2(
  52989. "<" + (el.tag) + " v-model=\"" + value + "\">: " +
  52990. "You are binding v-model directly to a v-for iteration alias. " +
  52991. "This will not be able to modify the v-for source array because " +
  52992. "writing to the alias is like modifying a function local variable. " +
  52993. "Consider using an array of objects and use v-model on an object property instead.",
  52994. el.rawAttrsMap['v-model']
  52995. );
  52996. }
  52997. _el = _el.parent;
  52998. }
  52999. }
  53000. /* */
  53001. function preTransformNode (el, options) {
  53002. if (el.tag === 'input') {
  53003. var map = el.attrsMap;
  53004. if (!map['v-model']) {
  53005. return
  53006. }
  53007. var typeBinding;
  53008. if (map[':type'] || map['v-bind:type']) {
  53009. typeBinding = getBindingAttr(el, 'type');
  53010. }
  53011. if (!map.type && !typeBinding && map['v-bind']) {
  53012. typeBinding = "(" + (map['v-bind']) + ").type";
  53013. }
  53014. if (typeBinding) {
  53015. var ifCondition = getAndRemoveAttr(el, 'v-if', true);
  53016. var ifConditionExtra = ifCondition ? ("&&(" + ifCondition + ")") : "";
  53017. var hasElse = getAndRemoveAttr(el, 'v-else', true) != null;
  53018. var elseIfCondition = getAndRemoveAttr(el, 'v-else-if', true);
  53019. // 1. checkbox
  53020. var branch0 = cloneASTElement(el);
  53021. // process for on the main node
  53022. processFor(branch0);
  53023. addRawAttr(branch0, 'type', 'checkbox');
  53024. processElement(branch0, options);
  53025. branch0.processed = true; // prevent it from double-processed
  53026. branch0.if = "(" + typeBinding + ")==='checkbox'" + ifConditionExtra;
  53027. addIfCondition(branch0, {
  53028. exp: branch0.if,
  53029. block: branch0
  53030. });
  53031. // 2. add radio else-if condition
  53032. var branch1 = cloneASTElement(el);
  53033. getAndRemoveAttr(branch1, 'v-for', true);
  53034. addRawAttr(branch1, 'type', 'radio');
  53035. processElement(branch1, options);
  53036. addIfCondition(branch0, {
  53037. exp: "(" + typeBinding + ")==='radio'" + ifConditionExtra,
  53038. block: branch1
  53039. });
  53040. // 3. other
  53041. var branch2 = cloneASTElement(el);
  53042. getAndRemoveAttr(branch2, 'v-for', true);
  53043. addRawAttr(branch2, ':type', typeBinding);
  53044. processElement(branch2, options);
  53045. addIfCondition(branch0, {
  53046. exp: ifCondition,
  53047. block: branch2
  53048. });
  53049. if (hasElse) {
  53050. branch0.else = true;
  53051. } else if (elseIfCondition) {
  53052. branch0.elseif = elseIfCondition;
  53053. }
  53054. return branch0
  53055. }
  53056. }
  53057. }
  53058. function cloneASTElement (el) {
  53059. return createASTElement(el.tag, el.attrsList.slice(), el.parent)
  53060. }
  53061. var model$1 = {
  53062. preTransformNode: preTransformNode
  53063. };
  53064. var modules$1 = [
  53065. klass$1,
  53066. style$1,
  53067. model$1
  53068. ];
  53069. /* */
  53070. function text (el, dir) {
  53071. if (dir.value) {
  53072. addProp(el, 'textContent', ("_s(" + (dir.value) + ")"), dir);
  53073. }
  53074. }
  53075. /* */
  53076. function html (el, dir) {
  53077. if (dir.value) {
  53078. addProp(el, 'innerHTML', ("_s(" + (dir.value) + ")"), dir);
  53079. }
  53080. }
  53081. var directives$1 = {
  53082. model: model,
  53083. text: text,
  53084. html: html
  53085. };
  53086. /* */
  53087. var baseOptions = {
  53088. expectHTML: true,
  53089. modules: modules$1,
  53090. directives: directives$1,
  53091. isPreTag: isPreTag,
  53092. isUnaryTag: isUnaryTag,
  53093. mustUseProp: mustUseProp,
  53094. canBeLeftOpenTag: canBeLeftOpenTag,
  53095. isReservedTag: isReservedTag,
  53096. getTagNamespace: getTagNamespace,
  53097. staticKeys: genStaticKeys(modules$1)
  53098. };
  53099. /* */
  53100. var isStaticKey;
  53101. var isPlatformReservedTag;
  53102. var genStaticKeysCached = cached(genStaticKeys$1);
  53103. /**
  53104. * Goal of the optimizer: walk the generated template AST tree
  53105. * and detect sub-trees that are purely static, i.e. parts of
  53106. * the DOM that never needs to change.
  53107. *
  53108. * Once we detect these sub-trees, we can:
  53109. *
  53110. * 1. Hoist them into constants, so that we no longer need to
  53111. * create fresh nodes for them on each re-render;
  53112. * 2. Completely skip them in the patching process.
  53113. */
  53114. function optimize (root, options) {
  53115. if (!root) { return }
  53116. isStaticKey = genStaticKeysCached(options.staticKeys || '');
  53117. isPlatformReservedTag = options.isReservedTag || no;
  53118. // first pass: mark all non-static nodes.
  53119. markStatic$1(root);
  53120. // second pass: mark static roots.
  53121. markStaticRoots(root, false);
  53122. }
  53123. function genStaticKeys$1 (keys) {
  53124. return makeMap(
  53125. 'type,tag,attrsList,attrsMap,plain,parent,children,attrs,start,end,rawAttrsMap' +
  53126. (keys ? ',' + keys : '')
  53127. )
  53128. }
  53129. function markStatic$1 (node) {
  53130. node.static = isStatic(node);
  53131. if (node.type === 1) {
  53132. // do not make component slot content static. this avoids
  53133. // 1. components not able to mutate slot nodes
  53134. // 2. static slot content fails for hot-reloading
  53135. if (
  53136. !isPlatformReservedTag(node.tag) &&
  53137. node.tag !== 'slot' &&
  53138. node.attrsMap['inline-template'] == null
  53139. ) {
  53140. return
  53141. }
  53142. for (var i = 0, l = node.children.length; i < l; i++) {
  53143. var child = node.children[i];
  53144. markStatic$1(child);
  53145. if (!child.static) {
  53146. node.static = false;
  53147. }
  53148. }
  53149. if (node.ifConditions) {
  53150. for (var i$1 = 1, l$1 = node.ifConditions.length; i$1 < l$1; i$1++) {
  53151. var block = node.ifConditions[i$1].block;
  53152. markStatic$1(block);
  53153. if (!block.static) {
  53154. node.static = false;
  53155. }
  53156. }
  53157. }
  53158. }
  53159. }
  53160. function markStaticRoots (node, isInFor) {
  53161. if (node.type === 1) {
  53162. if (node.static || node.once) {
  53163. node.staticInFor = isInFor;
  53164. }
  53165. // For a node to qualify as a static root, it should have children that
  53166. // are not just static text. Otherwise the cost of hoisting out will
  53167. // outweigh the benefits and it's better off to just always render it fresh.
  53168. if (node.static && node.children.length && !(
  53169. node.children.length === 1 &&
  53170. node.children[0].type === 3
  53171. )) {
  53172. node.staticRoot = true;
  53173. return
  53174. } else {
  53175. node.staticRoot = false;
  53176. }
  53177. if (node.children) {
  53178. for (var i = 0, l = node.children.length; i < l; i++) {
  53179. markStaticRoots(node.children[i], isInFor || !!node.for);
  53180. }
  53181. }
  53182. if (node.ifConditions) {
  53183. for (var i$1 = 1, l$1 = node.ifConditions.length; i$1 < l$1; i$1++) {
  53184. markStaticRoots(node.ifConditions[i$1].block, isInFor);
  53185. }
  53186. }
  53187. }
  53188. }
  53189. function isStatic (node) {
  53190. if (node.type === 2) { // expression
  53191. return false
  53192. }
  53193. if (node.type === 3) { // text
  53194. return true
  53195. }
  53196. return !!(node.pre || (
  53197. !node.hasBindings && // no dynamic bindings
  53198. !node.if && !node.for && // not v-if or v-for or v-else
  53199. !isBuiltInTag(node.tag) && // not a built-in
  53200. isPlatformReservedTag(node.tag) && // not a component
  53201. !isDirectChildOfTemplateFor(node) &&
  53202. Object.keys(node).every(isStaticKey)
  53203. ))
  53204. }
  53205. function isDirectChildOfTemplateFor (node) {
  53206. while (node.parent) {
  53207. node = node.parent;
  53208. if (node.tag !== 'template') {
  53209. return false
  53210. }
  53211. if (node.for) {
  53212. return true
  53213. }
  53214. }
  53215. return false
  53216. }
  53217. /* */
  53218. var fnExpRE = /^([\w$_]+|\([^)]*?\))\s*=>|^function(?:\s+[\w$]+)?\s*\(/;
  53219. var fnInvokeRE = /\([^)]*?\);*$/;
  53220. var simplePathRE = /^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*|\['[^']*?']|\["[^"]*?"]|\[\d+]|\[[A-Za-z_$][\w$]*])*$/;
  53221. // KeyboardEvent.keyCode aliases
  53222. var keyCodes = {
  53223. esc: 27,
  53224. tab: 9,
  53225. enter: 13,
  53226. space: 32,
  53227. up: 38,
  53228. left: 37,
  53229. right: 39,
  53230. down: 40,
  53231. 'delete': [8, 46]
  53232. };
  53233. // KeyboardEvent.key aliases
  53234. var keyNames = {
  53235. // #7880: IE11 and Edge use `Esc` for Escape key name.
  53236. esc: ['Esc', 'Escape'],
  53237. tab: 'Tab',
  53238. enter: 'Enter',
  53239. // #9112: IE11 uses `Spacebar` for Space key name.
  53240. space: [' ', 'Spacebar'],
  53241. // #7806: IE11 uses key names without `Arrow` prefix for arrow keys.
  53242. up: ['Up', 'ArrowUp'],
  53243. left: ['Left', 'ArrowLeft'],
  53244. right: ['Right', 'ArrowRight'],
  53245. down: ['Down', 'ArrowDown'],
  53246. // #9112: IE11 uses `Del` for Delete key name.
  53247. 'delete': ['Backspace', 'Delete', 'Del']
  53248. };
  53249. // #4868: modifiers that prevent the execution of the listener
  53250. // need to explicitly return null so that we can determine whether to remove
  53251. // the listener for .once
  53252. var genGuard = function (condition) { return ("if(" + condition + ")return null;"); };
  53253. var modifierCode = {
  53254. stop: '$event.stopPropagation();',
  53255. prevent: '$event.preventDefault();',
  53256. self: genGuard("$event.target !== $event.currentTarget"),
  53257. ctrl: genGuard("!$event.ctrlKey"),
  53258. shift: genGuard("!$event.shiftKey"),
  53259. alt: genGuard("!$event.altKey"),
  53260. meta: genGuard("!$event.metaKey"),
  53261. left: genGuard("'button' in $event && $event.button !== 0"),
  53262. middle: genGuard("'button' in $event && $event.button !== 1"),
  53263. right: genGuard("'button' in $event && $event.button !== 2")
  53264. };
  53265. function genHandlers (
  53266. events,
  53267. isNative
  53268. ) {
  53269. var prefix = isNative ? 'nativeOn:' : 'on:';
  53270. var staticHandlers = "";
  53271. var dynamicHandlers = "";
  53272. for (var name in events) {
  53273. var handlerCode = genHandler(events[name]);
  53274. if (events[name] && events[name].dynamic) {
  53275. dynamicHandlers += name + "," + handlerCode + ",";
  53276. } else {
  53277. staticHandlers += "\"" + name + "\":" + handlerCode + ",";
  53278. }
  53279. }
  53280. staticHandlers = "{" + (staticHandlers.slice(0, -1)) + "}";
  53281. if (dynamicHandlers) {
  53282. return prefix + "_d(" + staticHandlers + ",[" + (dynamicHandlers.slice(0, -1)) + "])"
  53283. } else {
  53284. return prefix + staticHandlers
  53285. }
  53286. }
  53287. function genHandler (handler) {
  53288. if (!handler) {
  53289. return 'function(){}'
  53290. }
  53291. if (Array.isArray(handler)) {
  53292. return ("[" + (handler.map(function (handler) { return genHandler(handler); }).join(',')) + "]")
  53293. }
  53294. var isMethodPath = simplePathRE.test(handler.value);
  53295. var isFunctionExpression = fnExpRE.test(handler.value);
  53296. var isFunctionInvocation = simplePathRE.test(handler.value.replace(fnInvokeRE, ''));
  53297. if (!handler.modifiers) {
  53298. if (isMethodPath || isFunctionExpression) {
  53299. return handler.value
  53300. }
  53301. return ("function($event){" + (isFunctionInvocation ? ("return " + (handler.value)) : handler.value) + "}") // inline statement
  53302. } else {
  53303. var code = '';
  53304. var genModifierCode = '';
  53305. var keys = [];
  53306. for (var key in handler.modifiers) {
  53307. if (modifierCode[key]) {
  53308. genModifierCode += modifierCode[key];
  53309. // left/right
  53310. if (keyCodes[key]) {
  53311. keys.push(key);
  53312. }
  53313. } else if (key === 'exact') {
  53314. var modifiers = (handler.modifiers);
  53315. genModifierCode += genGuard(
  53316. ['ctrl', 'shift', 'alt', 'meta']
  53317. .filter(function (keyModifier) { return !modifiers[keyModifier]; })
  53318. .map(function (keyModifier) { return ("$event." + keyModifier + "Key"); })
  53319. .join('||')
  53320. );
  53321. } else {
  53322. keys.push(key);
  53323. }
  53324. }
  53325. if (keys.length) {
  53326. code += genKeyFilter(keys);
  53327. }
  53328. // Make sure modifiers like prevent and stop get executed after key filtering
  53329. if (genModifierCode) {
  53330. code += genModifierCode;
  53331. }
  53332. var handlerCode = isMethodPath
  53333. ? ("return " + (handler.value) + "($event)")
  53334. : isFunctionExpression
  53335. ? ("return (" + (handler.value) + ")($event)")
  53336. : isFunctionInvocation
  53337. ? ("return " + (handler.value))
  53338. : handler.value;
  53339. return ("function($event){" + code + handlerCode + "}")
  53340. }
  53341. }
  53342. function genKeyFilter (keys) {
  53343. return (
  53344. // make sure the key filters only apply to KeyboardEvents
  53345. // #9441: can't use 'keyCode' in $event because Chrome autofill fires fake
  53346. // key events that do not have keyCode property...
  53347. "if(!$event.type.indexOf('key')&&" +
  53348. (keys.map(genFilterCode).join('&&')) + ")return null;"
  53349. )
  53350. }
  53351. function genFilterCode (key) {
  53352. var keyVal = parseInt(key, 10);
  53353. if (keyVal) {
  53354. return ("$event.keyCode!==" + keyVal)
  53355. }
  53356. var keyCode = keyCodes[key];
  53357. var keyName = keyNames[key];
  53358. return (
  53359. "_k($event.keyCode," +
  53360. (JSON.stringify(key)) + "," +
  53361. (JSON.stringify(keyCode)) + "," +
  53362. "$event.key," +
  53363. "" + (JSON.stringify(keyName)) +
  53364. ")"
  53365. )
  53366. }
  53367. /* */
  53368. function on (el, dir) {
  53369. if (dir.modifiers) {
  53370. warn("v-on without argument does not support modifiers.");
  53371. }
  53372. el.wrapListeners = function (code) { return ("_g(" + code + "," + (dir.value) + ")"); };
  53373. }
  53374. /* */
  53375. function bind$1 (el, dir) {
  53376. el.wrapData = function (code) {
  53377. return ("_b(" + code + ",'" + (el.tag) + "'," + (dir.value) + "," + (dir.modifiers && dir.modifiers.prop ? 'true' : 'false') + (dir.modifiers && dir.modifiers.sync ? ',true' : '') + ")")
  53378. };
  53379. }
  53380. /* */
  53381. var baseDirectives = {
  53382. on: on,
  53383. bind: bind$1,
  53384. cloak: noop
  53385. };
  53386. /* */
  53387. var CodegenState = function CodegenState (options) {
  53388. this.options = options;
  53389. this.warn = options.warn || baseWarn;
  53390. this.transforms = pluckModuleFunction(options.modules, 'transformCode');
  53391. this.dataGenFns = pluckModuleFunction(options.modules, 'genData');
  53392. this.directives = extend(extend({}, baseDirectives), options.directives);
  53393. var isReservedTag = options.isReservedTag || no;
  53394. this.maybeComponent = function (el) { return !!el.component || !isReservedTag(el.tag); };
  53395. this.onceId = 0;
  53396. this.staticRenderFns = [];
  53397. this.pre = false;
  53398. };
  53399. function generate (
  53400. ast,
  53401. options
  53402. ) {
  53403. var state = new CodegenState(options);
  53404. var code = ast ? genElement(ast, state) : '_c("div")';
  53405. return {
  53406. render: ("with(this){return " + code + "}"),
  53407. staticRenderFns: state.staticRenderFns
  53408. }
  53409. }
  53410. function genElement (el, state) {
  53411. if (el.parent) {
  53412. el.pre = el.pre || el.parent.pre;
  53413. }
  53414. if (el.staticRoot && !el.staticProcessed) {
  53415. return genStatic(el, state)
  53416. } else if (el.once && !el.onceProcessed) {
  53417. return genOnce(el, state)
  53418. } else if (el.for && !el.forProcessed) {
  53419. return genFor(el, state)
  53420. } else if (el.if && !el.ifProcessed) {
  53421. return genIf(el, state)
  53422. } else if (el.tag === 'template' && !el.slotTarget && !state.pre) {
  53423. return genChildren(el, state) || 'void 0'
  53424. } else if (el.tag === 'slot') {
  53425. return genSlot(el, state)
  53426. } else {
  53427. // component or element
  53428. var code;
  53429. if (el.component) {
  53430. code = genComponent(el.component, el, state);
  53431. } else {
  53432. var data;
  53433. if (!el.plain || (el.pre && state.maybeComponent(el))) {
  53434. data = genData$2(el, state);
  53435. }
  53436. var children = el.inlineTemplate ? null : genChildren(el, state, true);
  53437. code = "_c('" + (el.tag) + "'" + (data ? ("," + data) : '') + (children ? ("," + children) : '') + ")";
  53438. }
  53439. // module transforms
  53440. for (var i = 0; i < state.transforms.length; i++) {
  53441. code = state.transforms[i](el, code);
  53442. }
  53443. return code
  53444. }
  53445. }
  53446. // hoist static sub-trees out
  53447. function genStatic (el, state) {
  53448. el.staticProcessed = true;
  53449. // Some elements (templates) need to behave differently inside of a v-pre
  53450. // node. All pre nodes are static roots, so we can use this as a location to
  53451. // wrap a state change and reset it upon exiting the pre node.
  53452. var originalPreState = state.pre;
  53453. if (el.pre) {
  53454. state.pre = el.pre;
  53455. }
  53456. state.staticRenderFns.push(("with(this){return " + (genElement(el, state)) + "}"));
  53457. state.pre = originalPreState;
  53458. return ("_m(" + (state.staticRenderFns.length - 1) + (el.staticInFor ? ',true' : '') + ")")
  53459. }
  53460. // v-once
  53461. function genOnce (el, state) {
  53462. el.onceProcessed = true;
  53463. if (el.if && !el.ifProcessed) {
  53464. return genIf(el, state)
  53465. } else if (el.staticInFor) {
  53466. var key = '';
  53467. var parent = el.parent;
  53468. while (parent) {
  53469. if (parent.for) {
  53470. key = parent.key;
  53471. break
  53472. }
  53473. parent = parent.parent;
  53474. }
  53475. if (!key) {
  53476. state.warn(
  53477. "v-once can only be used inside v-for that is keyed. ",
  53478. el.rawAttrsMap['v-once']
  53479. );
  53480. return genElement(el, state)
  53481. }
  53482. return ("_o(" + (genElement(el, state)) + "," + (state.onceId++) + "," + key + ")")
  53483. } else {
  53484. return genStatic(el, state)
  53485. }
  53486. }
  53487. function genIf (
  53488. el,
  53489. state,
  53490. altGen,
  53491. altEmpty
  53492. ) {
  53493. el.ifProcessed = true; // avoid recursion
  53494. return genIfConditions(el.ifConditions.slice(), state, altGen, altEmpty)
  53495. }
  53496. function genIfConditions (
  53497. conditions,
  53498. state,
  53499. altGen,
  53500. altEmpty
  53501. ) {
  53502. if (!conditions.length) {
  53503. return altEmpty || '_e()'
  53504. }
  53505. var condition = conditions.shift();
  53506. if (condition.exp) {
  53507. return ("(" + (condition.exp) + ")?" + (genTernaryExp(condition.block)) + ":" + (genIfConditions(conditions, state, altGen, altEmpty)))
  53508. } else {
  53509. return ("" + (genTernaryExp(condition.block)))
  53510. }
  53511. // v-if with v-once should generate code like (a)?_m(0):_m(1)
  53512. function genTernaryExp (el) {
  53513. return altGen
  53514. ? altGen(el, state)
  53515. : el.once
  53516. ? genOnce(el, state)
  53517. : genElement(el, state)
  53518. }
  53519. }
  53520. function genFor (
  53521. el,
  53522. state,
  53523. altGen,
  53524. altHelper
  53525. ) {
  53526. var exp = el.for;
  53527. var alias = el.alias;
  53528. var iterator1 = el.iterator1 ? ("," + (el.iterator1)) : '';
  53529. var iterator2 = el.iterator2 ? ("," + (el.iterator2)) : '';
  53530. if (state.maybeComponent(el) &&
  53531. el.tag !== 'slot' &&
  53532. el.tag !== 'template' &&
  53533. !el.key
  53534. ) {
  53535. state.warn(
  53536. "<" + (el.tag) + " v-for=\"" + alias + " in " + exp + "\">: component lists rendered with " +
  53537. "v-for should have explicit keys. " +
  53538. "See https://vuejs.org/guide/list.html#key for more info.",
  53539. el.rawAttrsMap['v-for'],
  53540. true /* tip */
  53541. );
  53542. }
  53543. el.forProcessed = true; // avoid recursion
  53544. return (altHelper || '_l') + "((" + exp + ")," +
  53545. "function(" + alias + iterator1 + iterator2 + "){" +
  53546. "return " + ((altGen || genElement)(el, state)) +
  53547. '})'
  53548. }
  53549. function genData$2 (el, state) {
  53550. var data = '{';
  53551. // directives first.
  53552. // directives may mutate the el's other properties before they are generated.
  53553. var dirs = genDirectives(el, state);
  53554. if (dirs) { data += dirs + ','; }
  53555. // key
  53556. if (el.key) {
  53557. data += "key:" + (el.key) + ",";
  53558. }
  53559. // ref
  53560. if (el.ref) {
  53561. data += "ref:" + (el.ref) + ",";
  53562. }
  53563. if (el.refInFor) {
  53564. data += "refInFor:true,";
  53565. }
  53566. // pre
  53567. if (el.pre) {
  53568. data += "pre:true,";
  53569. }
  53570. // record original tag name for components using "is" attribute
  53571. if (el.component) {
  53572. data += "tag:\"" + (el.tag) + "\",";
  53573. }
  53574. // module data generation functions
  53575. for (var i = 0; i < state.dataGenFns.length; i++) {
  53576. data += state.dataGenFns[i](el);
  53577. }
  53578. // attributes
  53579. if (el.attrs) {
  53580. data += "attrs:" + (genProps(el.attrs)) + ",";
  53581. }
  53582. // DOM props
  53583. if (el.props) {
  53584. data += "domProps:" + (genProps(el.props)) + ",";
  53585. }
  53586. // event handlers
  53587. if (el.events) {
  53588. data += (genHandlers(el.events, false)) + ",";
  53589. }
  53590. if (el.nativeEvents) {
  53591. data += (genHandlers(el.nativeEvents, true)) + ",";
  53592. }
  53593. // slot target
  53594. // only for non-scoped slots
  53595. if (el.slotTarget && !el.slotScope) {
  53596. data += "slot:" + (el.slotTarget) + ",";
  53597. }
  53598. // scoped slots
  53599. if (el.scopedSlots) {
  53600. data += (genScopedSlots(el, el.scopedSlots, state)) + ",";
  53601. }
  53602. // component v-model
  53603. if (el.model) {
  53604. data += "model:{value:" + (el.model.value) + ",callback:" + (el.model.callback) + ",expression:" + (el.model.expression) + "},";
  53605. }
  53606. // inline-template
  53607. if (el.inlineTemplate) {
  53608. var inlineTemplate = genInlineTemplate(el, state);
  53609. if (inlineTemplate) {
  53610. data += inlineTemplate + ",";
  53611. }
  53612. }
  53613. data = data.replace(/,$/, '') + '}';
  53614. // v-bind dynamic argument wrap
  53615. // v-bind with dynamic arguments must be applied using the same v-bind object
  53616. // merge helper so that class/style/mustUseProp attrs are handled correctly.
  53617. if (el.dynamicAttrs) {
  53618. data = "_b(" + data + ",\"" + (el.tag) + "\"," + (genProps(el.dynamicAttrs)) + ")";
  53619. }
  53620. // v-bind data wrap
  53621. if (el.wrapData) {
  53622. data = el.wrapData(data);
  53623. }
  53624. // v-on data wrap
  53625. if (el.wrapListeners) {
  53626. data = el.wrapListeners(data);
  53627. }
  53628. return data
  53629. }
  53630. function genDirectives (el, state) {
  53631. var dirs = el.directives;
  53632. if (!dirs) { return }
  53633. var res = 'directives:[';
  53634. var hasRuntime = false;
  53635. var i, l, dir, needRuntime;
  53636. for (i = 0, l = dirs.length; i < l; i++) {
  53637. dir = dirs[i];
  53638. needRuntime = true;
  53639. var gen = state.directives[dir.name];
  53640. if (gen) {
  53641. // compile-time directive that manipulates AST.
  53642. // returns true if it also needs a runtime counterpart.
  53643. needRuntime = !!gen(el, dir, state.warn);
  53644. }
  53645. if (needRuntime) {
  53646. hasRuntime = true;
  53647. 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))) : '') + "},";
  53648. }
  53649. }
  53650. if (hasRuntime) {
  53651. return res.slice(0, -1) + ']'
  53652. }
  53653. }
  53654. function genInlineTemplate (el, state) {
  53655. var ast = el.children[0];
  53656. if (el.children.length !== 1 || ast.type !== 1) {
  53657. state.warn(
  53658. 'Inline-template components must have exactly one child element.',
  53659. { start: el.start }
  53660. );
  53661. }
  53662. if (ast && ast.type === 1) {
  53663. var inlineRenderFns = generate(ast, state.options);
  53664. return ("inlineTemplate:{render:function(){" + (inlineRenderFns.render) + "},staticRenderFns:[" + (inlineRenderFns.staticRenderFns.map(function (code) { return ("function(){" + code + "}"); }).join(',')) + "]}")
  53665. }
  53666. }
  53667. function genScopedSlots (
  53668. el,
  53669. slots,
  53670. state
  53671. ) {
  53672. // by default scoped slots are considered "stable", this allows child
  53673. // components with only scoped slots to skip forced updates from parent.
  53674. // but in some cases we have to bail-out of this optimization
  53675. // for example if the slot contains dynamic names, has v-if or v-for on them...
  53676. var needsForceUpdate = el.for || Object.keys(slots).some(function (key) {
  53677. var slot = slots[key];
  53678. return (
  53679. slot.slotTargetDynamic ||
  53680. slot.if ||
  53681. slot.for ||
  53682. containsSlotChild(slot) // is passing down slot from parent which may be dynamic
  53683. )
  53684. });
  53685. // #9534: if a component with scoped slots is inside a conditional branch,
  53686. // it's possible for the same component to be reused but with different
  53687. // compiled slot content. To avoid that, we generate a unique key based on
  53688. // the generated code of all the slot contents.
  53689. var needsKey = !!el.if;
  53690. // OR when it is inside another scoped slot or v-for (the reactivity may be
  53691. // disconnected due to the intermediate scope variable)
  53692. // #9438, #9506
  53693. // TODO: this can be further optimized by properly analyzing in-scope bindings
  53694. // and skip force updating ones that do not actually use scope variables.
  53695. if (!needsForceUpdate) {
  53696. var parent = el.parent;
  53697. while (parent) {
  53698. if (
  53699. (parent.slotScope && parent.slotScope !== emptySlotScopeToken) ||
  53700. parent.for
  53701. ) {
  53702. needsForceUpdate = true;
  53703. break
  53704. }
  53705. if (parent.if) {
  53706. needsKey = true;
  53707. }
  53708. parent = parent.parent;
  53709. }
  53710. }
  53711. var generatedSlots = Object.keys(slots)
  53712. .map(function (key) { return genScopedSlot(slots[key], state); })
  53713. .join(',');
  53714. return ("scopedSlots:_u([" + generatedSlots + "]" + (needsForceUpdate ? ",null,true" : "") + (!needsForceUpdate && needsKey ? (",null,false," + (hash(generatedSlots))) : "") + ")")
  53715. }
  53716. function hash(str) {
  53717. var hash = 5381;
  53718. var i = str.length;
  53719. while(i) {
  53720. hash = (hash * 33) ^ str.charCodeAt(--i);
  53721. }
  53722. return hash >>> 0
  53723. }
  53724. function containsSlotChild (el) {
  53725. if (el.type === 1) {
  53726. if (el.tag === 'slot') {
  53727. return true
  53728. }
  53729. return el.children.some(containsSlotChild)
  53730. }
  53731. return false
  53732. }
  53733. function genScopedSlot (
  53734. el,
  53735. state
  53736. ) {
  53737. var isLegacySyntax = el.attrsMap['slot-scope'];
  53738. if (el.if && !el.ifProcessed && !isLegacySyntax) {
  53739. return genIf(el, state, genScopedSlot, "null")
  53740. }
  53741. if (el.for && !el.forProcessed) {
  53742. return genFor(el, state, genScopedSlot)
  53743. }
  53744. var slotScope = el.slotScope === emptySlotScopeToken
  53745. ? ""
  53746. : String(el.slotScope);
  53747. var fn = "function(" + slotScope + "){" +
  53748. "return " + (el.tag === 'template'
  53749. ? el.if && isLegacySyntax
  53750. ? ("(" + (el.if) + ")?" + (genChildren(el, state) || 'undefined') + ":undefined")
  53751. : genChildren(el, state) || 'undefined'
  53752. : genElement(el, state)) + "}";
  53753. // reverse proxy v-slot without scope on this.$slots
  53754. var reverseProxy = slotScope ? "" : ",proxy:true";
  53755. return ("{key:" + (el.slotTarget || "\"default\"") + ",fn:" + fn + reverseProxy + "}")
  53756. }
  53757. function genChildren (
  53758. el,
  53759. state,
  53760. checkSkip,
  53761. altGenElement,
  53762. altGenNode
  53763. ) {
  53764. var children = el.children;
  53765. if (children.length) {
  53766. var el$1 = children[0];
  53767. // optimize single v-for
  53768. if (children.length === 1 &&
  53769. el$1.for &&
  53770. el$1.tag !== 'template' &&
  53771. el$1.tag !== 'slot'
  53772. ) {
  53773. var normalizationType = checkSkip
  53774. ? state.maybeComponent(el$1) ? ",1" : ",0"
  53775. : "";
  53776. return ("" + ((altGenElement || genElement)(el$1, state)) + normalizationType)
  53777. }
  53778. var normalizationType$1 = checkSkip
  53779. ? getNormalizationType(children, state.maybeComponent)
  53780. : 0;
  53781. var gen = altGenNode || genNode;
  53782. return ("[" + (children.map(function (c) { return gen(c, state); }).join(',')) + "]" + (normalizationType$1 ? ("," + normalizationType$1) : ''))
  53783. }
  53784. }
  53785. // determine the normalization needed for the children array.
  53786. // 0: no normalization needed
  53787. // 1: simple normalization needed (possible 1-level deep nested array)
  53788. // 2: full normalization needed
  53789. function getNormalizationType (
  53790. children,
  53791. maybeComponent
  53792. ) {
  53793. var res = 0;
  53794. for (var i = 0; i < children.length; i++) {
  53795. var el = children[i];
  53796. if (el.type !== 1) {
  53797. continue
  53798. }
  53799. if (needsNormalization(el) ||
  53800. (el.ifConditions && el.ifConditions.some(function (c) { return needsNormalization(c.block); }))) {
  53801. res = 2;
  53802. break
  53803. }
  53804. if (maybeComponent(el) ||
  53805. (el.ifConditions && el.ifConditions.some(function (c) { return maybeComponent(c.block); }))) {
  53806. res = 1;
  53807. }
  53808. }
  53809. return res
  53810. }
  53811. function needsNormalization (el) {
  53812. return el.for !== undefined || el.tag === 'template' || el.tag === 'slot'
  53813. }
  53814. function genNode (node, state) {
  53815. if (node.type === 1) {
  53816. return genElement(node, state)
  53817. } else if (node.type === 3 && node.isComment) {
  53818. return genComment(node)
  53819. } else {
  53820. return genText(node)
  53821. }
  53822. }
  53823. function genText (text) {
  53824. return ("_v(" + (text.type === 2
  53825. ? text.expression // no need for () because already wrapped in _s()
  53826. : transformSpecialNewlines(JSON.stringify(text.text))) + ")")
  53827. }
  53828. function genComment (comment) {
  53829. return ("_e(" + (JSON.stringify(comment.text)) + ")")
  53830. }
  53831. function genSlot (el, state) {
  53832. var slotName = el.slotName || '"default"';
  53833. var children = genChildren(el, state);
  53834. var res = "_t(" + slotName + (children ? ("," + children) : '');
  53835. var attrs = el.attrs || el.dynamicAttrs
  53836. ? genProps((el.attrs || []).concat(el.dynamicAttrs || []).map(function (attr) { return ({
  53837. // slot props are camelized
  53838. name: camelize(attr.name),
  53839. value: attr.value,
  53840. dynamic: attr.dynamic
  53841. }); }))
  53842. : null;
  53843. var bind$$1 = el.attrsMap['v-bind'];
  53844. if ((attrs || bind$$1) && !children) {
  53845. res += ",null";
  53846. }
  53847. if (attrs) {
  53848. res += "," + attrs;
  53849. }
  53850. if (bind$$1) {
  53851. res += (attrs ? '' : ',null') + "," + bind$$1;
  53852. }
  53853. return res + ')'
  53854. }
  53855. // componentName is el.component, take it as argument to shun flow's pessimistic refinement
  53856. function genComponent (
  53857. componentName,
  53858. el,
  53859. state
  53860. ) {
  53861. var children = el.inlineTemplate ? null : genChildren(el, state, true);
  53862. return ("_c(" + componentName + "," + (genData$2(el, state)) + (children ? ("," + children) : '') + ")")
  53863. }
  53864. function genProps (props) {
  53865. var staticProps = "";
  53866. var dynamicProps = "";
  53867. for (var i = 0; i < props.length; i++) {
  53868. var prop = props[i];
  53869. var value = transformSpecialNewlines(prop.value);
  53870. if (prop.dynamic) {
  53871. dynamicProps += (prop.name) + "," + value + ",";
  53872. } else {
  53873. staticProps += "\"" + (prop.name) + "\":" + value + ",";
  53874. }
  53875. }
  53876. staticProps = "{" + (staticProps.slice(0, -1)) + "}";
  53877. if (dynamicProps) {
  53878. return ("_d(" + staticProps + ",[" + (dynamicProps.slice(0, -1)) + "])")
  53879. } else {
  53880. return staticProps
  53881. }
  53882. }
  53883. // #3895, #4268
  53884. function transformSpecialNewlines (text) {
  53885. return text
  53886. .replace(/\u2028/g, '\\u2028')
  53887. .replace(/\u2029/g, '\\u2029')
  53888. }
  53889. /* */
  53890. // these keywords should not appear inside expressions, but operators like
  53891. // typeof, instanceof and in are allowed
  53892. var prohibitedKeywordRE = new RegExp('\\b' + (
  53893. 'do,if,for,let,new,try,var,case,else,with,await,break,catch,class,const,' +
  53894. 'super,throw,while,yield,delete,export,import,return,switch,default,' +
  53895. 'extends,finally,continue,debugger,function,arguments'
  53896. ).split(',').join('\\b|\\b') + '\\b');
  53897. // these unary operators should not be used as property/method names
  53898. var unaryOperatorsRE = new RegExp('\\b' + (
  53899. 'delete,typeof,void'
  53900. ).split(',').join('\\s*\\([^\\)]*\\)|\\b') + '\\s*\\([^\\)]*\\)');
  53901. // strip strings in expressions
  53902. var stripStringRE = /'(?:[^'\\]|\\.)*'|"(?:[^"\\]|\\.)*"|`(?:[^`\\]|\\.)*\$\{|\}(?:[^`\\]|\\.)*`|`(?:[^`\\]|\\.)*`/g;
  53903. // detect problematic expressions in a template
  53904. function detectErrors (ast, warn) {
  53905. if (ast) {
  53906. checkNode(ast, warn);
  53907. }
  53908. }
  53909. function checkNode (node, warn) {
  53910. if (node.type === 1) {
  53911. for (var name in node.attrsMap) {
  53912. if (dirRE.test(name)) {
  53913. var value = node.attrsMap[name];
  53914. if (value) {
  53915. var range = node.rawAttrsMap[name];
  53916. if (name === 'v-for') {
  53917. checkFor(node, ("v-for=\"" + value + "\""), warn, range);
  53918. } else if (name === 'v-slot' || name[0] === '#') {
  53919. checkFunctionParameterExpression(value, (name + "=\"" + value + "\""), warn, range);
  53920. } else if (onRE.test(name)) {
  53921. checkEvent(value, (name + "=\"" + value + "\""), warn, range);
  53922. } else {
  53923. checkExpression(value, (name + "=\"" + value + "\""), warn, range);
  53924. }
  53925. }
  53926. }
  53927. }
  53928. if (node.children) {
  53929. for (var i = 0; i < node.children.length; i++) {
  53930. checkNode(node.children[i], warn);
  53931. }
  53932. }
  53933. } else if (node.type === 2) {
  53934. checkExpression(node.expression, node.text, warn, node);
  53935. }
  53936. }
  53937. function checkEvent (exp, text, warn, range) {
  53938. var stripped = exp.replace(stripStringRE, '');
  53939. var keywordMatch = stripped.match(unaryOperatorsRE);
  53940. if (keywordMatch && stripped.charAt(keywordMatch.index - 1) !== '$') {
  53941. warn(
  53942. "avoid using JavaScript unary operator as property name: " +
  53943. "\"" + (keywordMatch[0]) + "\" in expression " + (text.trim()),
  53944. range
  53945. );
  53946. }
  53947. checkExpression(exp, text, warn, range);
  53948. }
  53949. function checkFor (node, text, warn, range) {
  53950. checkExpression(node.for || '', text, warn, range);
  53951. checkIdentifier(node.alias, 'v-for alias', text, warn, range);
  53952. checkIdentifier(node.iterator1, 'v-for iterator', text, warn, range);
  53953. checkIdentifier(node.iterator2, 'v-for iterator', text, warn, range);
  53954. }
  53955. function checkIdentifier (
  53956. ident,
  53957. type,
  53958. text,
  53959. warn,
  53960. range
  53961. ) {
  53962. if (typeof ident === 'string') {
  53963. try {
  53964. new Function(("var " + ident + "=_"));
  53965. } catch (e) {
  53966. warn(("invalid " + type + " \"" + ident + "\" in expression: " + (text.trim())), range);
  53967. }
  53968. }
  53969. }
  53970. function checkExpression (exp, text, warn, range) {
  53971. try {
  53972. new Function(("return " + exp));
  53973. } catch (e) {
  53974. var keywordMatch = exp.replace(stripStringRE, '').match(prohibitedKeywordRE);
  53975. if (keywordMatch) {
  53976. warn(
  53977. "avoid using JavaScript keyword as property name: " +
  53978. "\"" + (keywordMatch[0]) + "\"\n Raw expression: " + (text.trim()),
  53979. range
  53980. );
  53981. } else {
  53982. warn(
  53983. "invalid expression: " + (e.message) + " in\n\n" +
  53984. " " + exp + "\n\n" +
  53985. " Raw expression: " + (text.trim()) + "\n",
  53986. range
  53987. );
  53988. }
  53989. }
  53990. }
  53991. function checkFunctionParameterExpression (exp, text, warn, range) {
  53992. try {
  53993. new Function(exp, '');
  53994. } catch (e) {
  53995. warn(
  53996. "invalid function parameter expression: " + (e.message) + " in\n\n" +
  53997. " " + exp + "\n\n" +
  53998. " Raw expression: " + (text.trim()) + "\n",
  53999. range
  54000. );
  54001. }
  54002. }
  54003. /* */
  54004. var range = 2;
  54005. function generateCodeFrame (
  54006. source,
  54007. start,
  54008. end
  54009. ) {
  54010. if ( start === void 0 ) start = 0;
  54011. if ( end === void 0 ) end = source.length;
  54012. var lines = source.split(/\r?\n/);
  54013. var count = 0;
  54014. var res = [];
  54015. for (var i = 0; i < lines.length; i++) {
  54016. count += lines[i].length + 1;
  54017. if (count >= start) {
  54018. for (var j = i - range; j <= i + range || end > count; j++) {
  54019. if (j < 0 || j >= lines.length) { continue }
  54020. res.push(("" + (j + 1) + (repeat$1(" ", 3 - String(j + 1).length)) + "| " + (lines[j])));
  54021. var lineLength = lines[j].length;
  54022. if (j === i) {
  54023. // push underline
  54024. var pad = start - (count - lineLength) + 1;
  54025. var length = end > count ? lineLength - pad : end - start;
  54026. res.push(" | " + repeat$1(" ", pad) + repeat$1("^", length));
  54027. } else if (j > i) {
  54028. if (end > count) {
  54029. var length$1 = Math.min(end - count, lineLength);
  54030. res.push(" | " + repeat$1("^", length$1));
  54031. }
  54032. count += lineLength + 1;
  54033. }
  54034. }
  54035. break
  54036. }
  54037. }
  54038. return res.join('\n')
  54039. }
  54040. function repeat$1 (str, n) {
  54041. var result = '';
  54042. if (n > 0) {
  54043. while (true) { // eslint-disable-line
  54044. if (n & 1) { result += str; }
  54045. n >>>= 1;
  54046. if (n <= 0) { break }
  54047. str += str;
  54048. }
  54049. }
  54050. return result
  54051. }
  54052. /* */
  54053. function createFunction (code, errors) {
  54054. try {
  54055. return new Function(code)
  54056. } catch (err) {
  54057. errors.push({ err: err, code: code });
  54058. return noop
  54059. }
  54060. }
  54061. function createCompileToFunctionFn (compile) {
  54062. var cache = Object.create(null);
  54063. return function compileToFunctions (
  54064. template,
  54065. options,
  54066. vm
  54067. ) {
  54068. options = extend({}, options);
  54069. var warn$$1 = options.warn || warn;
  54070. delete options.warn;
  54071. /* istanbul ignore if */
  54072. {
  54073. // detect possible CSP restriction
  54074. try {
  54075. new Function('return 1');
  54076. } catch (e) {
  54077. if (e.toString().match(/unsafe-eval|CSP/)) {
  54078. warn$$1(
  54079. 'It seems you are using the standalone build of Vue.js in an ' +
  54080. 'environment with Content Security Policy that prohibits unsafe-eval. ' +
  54081. 'The template compiler cannot work in this environment. Consider ' +
  54082. 'relaxing the policy to allow unsafe-eval or pre-compiling your ' +
  54083. 'templates into render functions.'
  54084. );
  54085. }
  54086. }
  54087. }
  54088. // check cache
  54089. var key = options.delimiters
  54090. ? String(options.delimiters) + template
  54091. : template;
  54092. if (cache[key]) {
  54093. return cache[key]
  54094. }
  54095. // compile
  54096. var compiled = compile(template, options);
  54097. // check compilation errors/tips
  54098. {
  54099. if (compiled.errors && compiled.errors.length) {
  54100. if (options.outputSourceRange) {
  54101. compiled.errors.forEach(function (e) {
  54102. warn$$1(
  54103. "Error compiling template:\n\n" + (e.msg) + "\n\n" +
  54104. generateCodeFrame(template, e.start, e.end),
  54105. vm
  54106. );
  54107. });
  54108. } else {
  54109. warn$$1(
  54110. "Error compiling template:\n\n" + template + "\n\n" +
  54111. compiled.errors.map(function (e) { return ("- " + e); }).join('\n') + '\n',
  54112. vm
  54113. );
  54114. }
  54115. }
  54116. if (compiled.tips && compiled.tips.length) {
  54117. if (options.outputSourceRange) {
  54118. compiled.tips.forEach(function (e) { return tip(e.msg, vm); });
  54119. } else {
  54120. compiled.tips.forEach(function (msg) { return tip(msg, vm); });
  54121. }
  54122. }
  54123. }
  54124. // turn code into functions
  54125. var res = {};
  54126. var fnGenErrors = [];
  54127. res.render = createFunction(compiled.render, fnGenErrors);
  54128. res.staticRenderFns = compiled.staticRenderFns.map(function (code) {
  54129. return createFunction(code, fnGenErrors)
  54130. });
  54131. // check function generation errors.
  54132. // this should only happen if there is a bug in the compiler itself.
  54133. // mostly for codegen development use
  54134. /* istanbul ignore if */
  54135. {
  54136. if ((!compiled.errors || !compiled.errors.length) && fnGenErrors.length) {
  54137. warn$$1(
  54138. "Failed to generate render function:\n\n" +
  54139. fnGenErrors.map(function (ref) {
  54140. var err = ref.err;
  54141. var code = ref.code;
  54142. return ((err.toString()) + " in\n\n" + code + "\n");
  54143. }).join('\n'),
  54144. vm
  54145. );
  54146. }
  54147. }
  54148. return (cache[key] = res)
  54149. }
  54150. }
  54151. /* */
  54152. function createCompilerCreator (baseCompile) {
  54153. return function createCompiler (baseOptions) {
  54154. function compile (
  54155. template,
  54156. options
  54157. ) {
  54158. var finalOptions = Object.create(baseOptions);
  54159. var errors = [];
  54160. var tips = [];
  54161. var warn = function (msg, range, tip) {
  54162. (tip ? tips : errors).push(msg);
  54163. };
  54164. if (options) {
  54165. if (options.outputSourceRange) {
  54166. // $flow-disable-line
  54167. var leadingSpaceLength = template.match(/^\s*/)[0].length;
  54168. warn = function (msg, range, tip) {
  54169. var data = { msg: msg };
  54170. if (range) {
  54171. if (range.start != null) {
  54172. data.start = range.start + leadingSpaceLength;
  54173. }
  54174. if (range.end != null) {
  54175. data.end = range.end + leadingSpaceLength;
  54176. }
  54177. }
  54178. (tip ? tips : errors).push(data);
  54179. };
  54180. }
  54181. // merge custom modules
  54182. if (options.modules) {
  54183. finalOptions.modules =
  54184. (baseOptions.modules || []).concat(options.modules);
  54185. }
  54186. // merge custom directives
  54187. if (options.directives) {
  54188. finalOptions.directives = extend(
  54189. Object.create(baseOptions.directives || null),
  54190. options.directives
  54191. );
  54192. }
  54193. // copy other options
  54194. for (var key in options) {
  54195. if (key !== 'modules' && key !== 'directives') {
  54196. finalOptions[key] = options[key];
  54197. }
  54198. }
  54199. }
  54200. finalOptions.warn = warn;
  54201. var compiled = baseCompile(template.trim(), finalOptions);
  54202. {
  54203. detectErrors(compiled.ast, warn);
  54204. }
  54205. compiled.errors = errors;
  54206. compiled.tips = tips;
  54207. return compiled
  54208. }
  54209. return {
  54210. compile: compile,
  54211. compileToFunctions: createCompileToFunctionFn(compile)
  54212. }
  54213. }
  54214. }
  54215. /* */
  54216. // `createCompilerCreator` allows creating compilers that use alternative
  54217. // parser/optimizer/codegen, e.g the SSR optimizing compiler.
  54218. // Here we just export a default compiler using the default parts.
  54219. var createCompiler = createCompilerCreator(function baseCompile (
  54220. template,
  54221. options
  54222. ) {
  54223. var ast = parse(template.trim(), options);
  54224. if (options.optimize !== false) {
  54225. optimize(ast, options);
  54226. }
  54227. var code = generate(ast, options);
  54228. return {
  54229. ast: ast,
  54230. render: code.render,
  54231. staticRenderFns: code.staticRenderFns
  54232. }
  54233. });
  54234. /* */
  54235. var ref$1 = createCompiler(baseOptions);
  54236. var compile = ref$1.compile;
  54237. var compileToFunctions = ref$1.compileToFunctions;
  54238. /* */
  54239. // check whether current browser encodes a char inside attribute values
  54240. var div;
  54241. function getShouldDecode (href) {
  54242. div = div || document.createElement('div');
  54243. div.innerHTML = href ? "<a href=\"\n\"/>" : "<div a=\"\n\"/>";
  54244. return div.innerHTML.indexOf('&#10;') > 0
  54245. }
  54246. // #3663: IE encodes newlines inside attribute values while other browsers don't
  54247. var shouldDecodeNewlines = inBrowser ? getShouldDecode(false) : false;
  54248. // #6828: chrome encodes content in a[href]
  54249. var shouldDecodeNewlinesForHref = inBrowser ? getShouldDecode(true) : false;
  54250. /* */
  54251. var idToTemplate = cached(function (id) {
  54252. var el = query(id);
  54253. return el && el.innerHTML
  54254. });
  54255. var mount = Vue.prototype.$mount;
  54256. Vue.prototype.$mount = function (
  54257. el,
  54258. hydrating
  54259. ) {
  54260. el = el && query(el);
  54261. /* istanbul ignore if */
  54262. if (el === document.body || el === document.documentElement) {
  54263. warn(
  54264. "Do not mount Vue to <html> or <body> - mount to normal elements instead."
  54265. );
  54266. return this
  54267. }
  54268. var options = this.$options;
  54269. // resolve template/el and convert to render function
  54270. if (!options.render) {
  54271. var template = options.template;
  54272. if (template) {
  54273. if (typeof template === 'string') {
  54274. if (template.charAt(0) === '#') {
  54275. template = idToTemplate(template);
  54276. /* istanbul ignore if */
  54277. if (!template) {
  54278. warn(
  54279. ("Template element not found or is empty: " + (options.template)),
  54280. this
  54281. );
  54282. }
  54283. }
  54284. } else if (template.nodeType) {
  54285. template = template.innerHTML;
  54286. } else {
  54287. {
  54288. warn('invalid template option:' + template, this);
  54289. }
  54290. return this
  54291. }
  54292. } else if (el) {
  54293. template = getOuterHTML(el);
  54294. }
  54295. if (template) {
  54296. /* istanbul ignore if */
  54297. if (config.performance && mark) {
  54298. mark('compile');
  54299. }
  54300. var ref = compileToFunctions(template, {
  54301. outputSourceRange: "development" !== 'production',
  54302. shouldDecodeNewlines: shouldDecodeNewlines,
  54303. shouldDecodeNewlinesForHref: shouldDecodeNewlinesForHref,
  54304. delimiters: options.delimiters,
  54305. comments: options.comments
  54306. }, this);
  54307. var render = ref.render;
  54308. var staticRenderFns = ref.staticRenderFns;
  54309. options.render = render;
  54310. options.staticRenderFns = staticRenderFns;
  54311. /* istanbul ignore if */
  54312. if (config.performance && mark) {
  54313. mark('compile end');
  54314. measure(("vue " + (this._name) + " compile"), 'compile', 'compile end');
  54315. }
  54316. }
  54317. }
  54318. return mount.call(this, el, hydrating)
  54319. };
  54320. /**
  54321. * Get outerHTML of elements, taking care
  54322. * of SVG elements in IE as well.
  54323. */
  54324. function getOuterHTML (el) {
  54325. if (el.outerHTML) {
  54326. return el.outerHTML
  54327. } else {
  54328. var container = document.createElement('div');
  54329. container.appendChild(el.cloneNode(true));
  54330. return container.innerHTML
  54331. }
  54332. }
  54333. Vue.compile = compileToFunctions;
  54334. module.exports = Vue;
  54335. /* 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))
  54336. /***/ }),
  54337. /***/ "./node_modules/vue/dist/vue.common.js":
  54338. /*!*********************************************!*\
  54339. !*** ./node_modules/vue/dist/vue.common.js ***!
  54340. \*********************************************/
  54341. /*! no static exports found */
  54342. /***/ (function(module, exports, __webpack_require__) {
  54343. if (false) {} else {
  54344. module.exports = __webpack_require__(/*! ./vue.common.dev.js */ "./node_modules/vue/dist/vue.common.dev.js")
  54345. }
  54346. /***/ }),
  54347. /***/ "./node_modules/webpack/buildin/global.js":
  54348. /*!***********************************!*\
  54349. !*** (webpack)/buildin/global.js ***!
  54350. \***********************************/
  54351. /*! no static exports found */
  54352. /***/ (function(module, exports) {
  54353. var g;
  54354. // This works in non-strict mode
  54355. g = (function() {
  54356. return this;
  54357. })();
  54358. try {
  54359. // This works if eval is allowed (see CSP)
  54360. g = g || new Function("return this")();
  54361. } catch (e) {
  54362. // This works if the window reference is available
  54363. if (typeof window === "object") g = window;
  54364. }
  54365. // g can still be undefined, but nothing to do about it...
  54366. // We return undefined, instead of nothing here, so it's
  54367. // easier to handle this case. if(!global) { ...}
  54368. module.exports = g;
  54369. /***/ }),
  54370. /***/ "./node_modules/webpack/buildin/module.js":
  54371. /*!***********************************!*\
  54372. !*** (webpack)/buildin/module.js ***!
  54373. \***********************************/
  54374. /*! no static exports found */
  54375. /***/ (function(module, exports) {
  54376. module.exports = function(module) {
  54377. if (!module.webpackPolyfill) {
  54378. module.deprecate = function() {};
  54379. module.paths = [];
  54380. // module.parent = undefined by default
  54381. if (!module.children) module.children = [];
  54382. Object.defineProperty(module, "loaded", {
  54383. enumerable: true,
  54384. get: function() {
  54385. return module.l;
  54386. }
  54387. });
  54388. Object.defineProperty(module, "id", {
  54389. enumerable: true,
  54390. get: function() {
  54391. return module.i;
  54392. }
  54393. });
  54394. module.webpackPolyfill = 1;
  54395. }
  54396. return module;
  54397. };
  54398. /***/ }),
  54399. /***/ "./resources/js/app.js":
  54400. /*!*****************************!*\
  54401. !*** ./resources/js/app.js ***!
  54402. \*****************************/
  54403. /*! no static exports found */
  54404. /***/ (function(module, exports, __webpack_require__) {
  54405. /**
  54406. * First we will load all of this project's JavaScript dependencies which
  54407. * includes Vue and other libraries. It is a great starting point when
  54408. * building robust, powerful web applications using Vue and Laravel.
  54409. */
  54410. __webpack_require__(/*! ./bootstrap */ "./resources/js/bootstrap.js");
  54411. window.Clipboard = __webpack_require__(/*! clipboard */ "./node_modules/clipboard/dist/clipboard.js");
  54412. __webpack_require__(/*! ./notify.min.js */ "./resources/js/notify.min.js");
  54413. window.Vue = __webpack_require__(/*! vue */ "./node_modules/vue/dist/vue.common.js");
  54414. /**
  54415. * The following block of code may be used to automatically register your
  54416. * Vue components. It will recursively scan this directory for the Vue
  54417. * components and automatically register them with their "basename".
  54418. *
  54419. * Eg. ./components/ExampleComponent.vue -> <example-component></example-component>
  54420. */
  54421. // const files = require.context('./', true, /\.vue$/i)
  54422. // files.keys().map(key => Vue.component(key.split('/').pop().split('.')[0], files(key).default))
  54423. Vue.component('example-component', __webpack_require__(/*! ./components/ExampleComponent.vue */ "./resources/js/components/ExampleComponent.vue")["default"]);
  54424. Vue.component('woinfo', __webpack_require__(/*! ./components/woinfo.vue */ "./resources/js/components/woinfo.vue")["default"]);
  54425. Vue.component('assetinfo', __webpack_require__(/*! ./components/assetinfo.vue */ "./resources/js/components/assetinfo.vue")["default"]);
  54426. Vue.component('credential', __webpack_require__(/*! ./components/credential.vue */ "./resources/js/components/credential.vue")["default"]);
  54427. Vue.component('notes', __webpack_require__(/*! ./components/notes.vue */ "./resources/js/components/notes.vue")["default"]);
  54428. Vue.component('modal', __webpack_require__(/*! ./components/modal.vue */ "./resources/js/components/modal.vue")["default"]);
  54429. /**
  54430. * Next, we will create a fresh Vue application instance and attach it to
  54431. * the page. Then, you may begin adding components to this application
  54432. * or customize the JavaScript scaffolding to fit your unique needs.
  54433. */
  54434. var app = new Vue({
  54435. el: '#app'
  54436. });
  54437. $(function () {
  54438. $('[data-toggle="tooltip"]').tooltip();
  54439. });
  54440. var clipboard = new Clipboard('.btn-clip');
  54441. clipboard.on('success', function (e) {
  54442. $('#' + e.trigger.getAttribute('id')).notify('Copied to Clipboard', {
  54443. position: "right",
  54444. className: 'success'
  54445. });
  54446. e.clearSelection();
  54447. });
  54448. /***/ }),
  54449. /***/ "./resources/js/bootstrap.js":
  54450. /*!***********************************!*\
  54451. !*** ./resources/js/bootstrap.js ***!
  54452. \***********************************/
  54453. /*! no exports provided */
  54454. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  54455. "use strict";
  54456. __webpack_require__.r(__webpack_exports__);
  54457. /* harmony import */ var laravel_echo__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! laravel-echo */ "./node_modules/laravel-echo/dist/echo.js");
  54458. window._ = __webpack_require__(/*! lodash */ "./node_modules/lodash/lodash.js");
  54459. /**
  54460. * We'll load jQuery and the Bootstrap jQuery plugin which provides support
  54461. * for JavaScript based Bootstrap features such as modals and tabs. This
  54462. * code may be modified to fit the specific needs of your application.
  54463. */
  54464. try {
  54465. window.Popper = __webpack_require__(/*! popper.js */ "./node_modules/popper.js/dist/esm/popper.js")["default"];
  54466. window.$ = window.jQuery = __webpack_require__(/*! jquery */ "./node_modules/jquery/dist/jquery.js");
  54467. __webpack_require__(/*! bootstrap */ "./node_modules/bootstrap/dist/js/bootstrap.js");
  54468. } catch (e) {}
  54469. /**
  54470. * We'll load the axios HTTP library which allows us to easily issue requests
  54471. * to our Laravel back-end. This library automatically handles sending the
  54472. * CSRF token as a header based on the value of the "XSRF" token cookie.
  54473. */
  54474. window.axios = __webpack_require__(/*! axios */ "./node_modules/axios/index.js");
  54475. window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';
  54476. /**
  54477. * Echo exposes an expressive API for subscribing to channels and listening
  54478. * for events that are broadcast by Laravel. Echo and event broadcasting
  54479. * allows your team to easily build robust real-time web applications.
  54480. */
  54481. window.Pusher = __webpack_require__(/*! pusher-js */ "./node_modules/pusher-js/dist/web/pusher.js");
  54482. window.Echo = new laravel_echo__WEBPACK_IMPORTED_MODULE_0__["default"]({
  54483. broadcaster: 'pusher',
  54484. key: "upccrt",
  54485. wsHost: window.location.hostname,
  54486. wsPort: 6001,
  54487. disableStats: true
  54488. });
  54489. /***/ }),
  54490. /***/ "./resources/js/components/ExampleComponent.vue":
  54491. /*!******************************************************!*\
  54492. !*** ./resources/js/components/ExampleComponent.vue ***!
  54493. \******************************************************/
  54494. /*! exports provided: default */
  54495. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  54496. "use strict";
  54497. __webpack_require__.r(__webpack_exports__);
  54498. /* 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&");
  54499. /* 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&");
  54500. /* 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");
  54501. /* normalize component */
  54502. var component = Object(_node_modules_vue_loader_lib_runtime_componentNormalizer_js__WEBPACK_IMPORTED_MODULE_2__["default"])(
  54503. _ExampleComponent_vue_vue_type_script_lang_js___WEBPACK_IMPORTED_MODULE_1__["default"],
  54504. _ExampleComponent_vue_vue_type_template_id_299e239e___WEBPACK_IMPORTED_MODULE_0__["render"],
  54505. _ExampleComponent_vue_vue_type_template_id_299e239e___WEBPACK_IMPORTED_MODULE_0__["staticRenderFns"],
  54506. false,
  54507. null,
  54508. null,
  54509. null
  54510. )
  54511. /* hot reload */
  54512. if (false) { var api; }
  54513. component.options.__file = "resources/js/components/ExampleComponent.vue"
  54514. /* harmony default export */ __webpack_exports__["default"] = (component.exports);
  54515. /***/ }),
  54516. /***/ "./resources/js/components/ExampleComponent.vue?vue&type=script&lang=js&":
  54517. /*!*******************************************************************************!*\
  54518. !*** ./resources/js/components/ExampleComponent.vue?vue&type=script&lang=js& ***!
  54519. \*******************************************************************************/
  54520. /*! exports provided: default */
  54521. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  54522. "use strict";
  54523. __webpack_require__.r(__webpack_exports__);
  54524. /* 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&");
  54525. /* 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"]);
  54526. /***/ }),
  54527. /***/ "./resources/js/components/ExampleComponent.vue?vue&type=template&id=299e239e&":
  54528. /*!*************************************************************************************!*\
  54529. !*** ./resources/js/components/ExampleComponent.vue?vue&type=template&id=299e239e& ***!
  54530. \*************************************************************************************/
  54531. /*! exports provided: render, staticRenderFns */
  54532. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  54533. "use strict";
  54534. __webpack_require__.r(__webpack_exports__);
  54535. /* 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&");
  54536. /* 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"]; });
  54537. /* 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"]; });
  54538. /***/ }),
  54539. /***/ "./resources/js/components/assetinfo.vue":
  54540. /*!***********************************************!*\
  54541. !*** ./resources/js/components/assetinfo.vue ***!
  54542. \***********************************************/
  54543. /*! exports provided: default */
  54544. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  54545. "use strict";
  54546. __webpack_require__.r(__webpack_exports__);
  54547. /* 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&");
  54548. /* 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&");
  54549. /* 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");
  54550. /* normalize component */
  54551. var component = Object(_node_modules_vue_loader_lib_runtime_componentNormalizer_js__WEBPACK_IMPORTED_MODULE_2__["default"])(
  54552. _assetinfo_vue_vue_type_script_lang_js___WEBPACK_IMPORTED_MODULE_1__["default"],
  54553. _assetinfo_vue_vue_type_template_id_4fe1d2e3___WEBPACK_IMPORTED_MODULE_0__["render"],
  54554. _assetinfo_vue_vue_type_template_id_4fe1d2e3___WEBPACK_IMPORTED_MODULE_0__["staticRenderFns"],
  54555. false,
  54556. null,
  54557. null,
  54558. null
  54559. )
  54560. /* hot reload */
  54561. if (false) { var api; }
  54562. component.options.__file = "resources/js/components/assetinfo.vue"
  54563. /* harmony default export */ __webpack_exports__["default"] = (component.exports);
  54564. /***/ }),
  54565. /***/ "./resources/js/components/assetinfo.vue?vue&type=script&lang=js&":
  54566. /*!************************************************************************!*\
  54567. !*** ./resources/js/components/assetinfo.vue?vue&type=script&lang=js& ***!
  54568. \************************************************************************/
  54569. /*! exports provided: default */
  54570. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  54571. "use strict";
  54572. __webpack_require__.r(__webpack_exports__);
  54573. /* 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&");
  54574. /* 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"]);
  54575. /***/ }),
  54576. /***/ "./resources/js/components/assetinfo.vue?vue&type=template&id=4fe1d2e3&":
  54577. /*!******************************************************************************!*\
  54578. !*** ./resources/js/components/assetinfo.vue?vue&type=template&id=4fe1d2e3& ***!
  54579. \******************************************************************************/
  54580. /*! exports provided: render, staticRenderFns */
  54581. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  54582. "use strict";
  54583. __webpack_require__.r(__webpack_exports__);
  54584. /* 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&");
  54585. /* 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"]; });
  54586. /* 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"]; });
  54587. /***/ }),
  54588. /***/ "./resources/js/components/credential.vue":
  54589. /*!************************************************!*\
  54590. !*** ./resources/js/components/credential.vue ***!
  54591. \************************************************/
  54592. /*! exports provided: default */
  54593. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  54594. "use strict";
  54595. __webpack_require__.r(__webpack_exports__);
  54596. /* harmony import */ var _credential_vue_vue_type_template_id_0f5cc562___WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./credential.vue?vue&type=template&id=0f5cc562& */ "./resources/js/components/credential.vue?vue&type=template&id=0f5cc562&");
  54597. /* harmony import */ var _credential_vue_vue_type_script_lang_js___WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./credential.vue?vue&type=script&lang=js& */ "./resources/js/components/credential.vue?vue&type=script&lang=js&");
  54598. /* 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");
  54599. /* normalize component */
  54600. var component = Object(_node_modules_vue_loader_lib_runtime_componentNormalizer_js__WEBPACK_IMPORTED_MODULE_2__["default"])(
  54601. _credential_vue_vue_type_script_lang_js___WEBPACK_IMPORTED_MODULE_1__["default"],
  54602. _credential_vue_vue_type_template_id_0f5cc562___WEBPACK_IMPORTED_MODULE_0__["render"],
  54603. _credential_vue_vue_type_template_id_0f5cc562___WEBPACK_IMPORTED_MODULE_0__["staticRenderFns"],
  54604. false,
  54605. null,
  54606. null,
  54607. null
  54608. )
  54609. /* hot reload */
  54610. if (false) { var api; }
  54611. component.options.__file = "resources/js/components/credential.vue"
  54612. /* harmony default export */ __webpack_exports__["default"] = (component.exports);
  54613. /***/ }),
  54614. /***/ "./resources/js/components/credential.vue?vue&type=script&lang=js&":
  54615. /*!*************************************************************************!*\
  54616. !*** ./resources/js/components/credential.vue?vue&type=script&lang=js& ***!
  54617. \*************************************************************************/
  54618. /*! exports provided: default */
  54619. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  54620. "use strict";
  54621. __webpack_require__.r(__webpack_exports__);
  54622. /* harmony import */ var _node_modules_babel_loader_lib_index_js_ref_4_0_node_modules_vue_loader_lib_index_js_vue_loader_options_credential_vue_vue_type_script_lang_js___WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! -!../../../node_modules/babel-loader/lib??ref--4-0!../../../node_modules/vue-loader/lib??vue-loader-options!./credential.vue?vue&type=script&lang=js& */ "./node_modules/babel-loader/lib/index.js?!./node_modules/vue-loader/lib/index.js?!./resources/js/components/credential.vue?vue&type=script&lang=js&");
  54623. /* empty/unused harmony star reexport */ /* harmony default export */ __webpack_exports__["default"] = (_node_modules_babel_loader_lib_index_js_ref_4_0_node_modules_vue_loader_lib_index_js_vue_loader_options_credential_vue_vue_type_script_lang_js___WEBPACK_IMPORTED_MODULE_0__["default"]);
  54624. /***/ }),
  54625. /***/ "./resources/js/components/credential.vue?vue&type=template&id=0f5cc562&":
  54626. /*!*******************************************************************************!*\
  54627. !*** ./resources/js/components/credential.vue?vue&type=template&id=0f5cc562& ***!
  54628. \*******************************************************************************/
  54629. /*! exports provided: render, staticRenderFns */
  54630. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  54631. "use strict";
  54632. __webpack_require__.r(__webpack_exports__);
  54633. /* harmony import */ var _node_modules_vue_loader_lib_loaders_templateLoader_js_vue_loader_options_node_modules_vue_loader_lib_index_js_vue_loader_options_credential_vue_vue_type_template_id_0f5cc562___WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! -!../../../node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!../../../node_modules/vue-loader/lib??vue-loader-options!./credential.vue?vue&type=template&id=0f5cc562& */ "./node_modules/vue-loader/lib/loaders/templateLoader.js?!./node_modules/vue-loader/lib/index.js?!./resources/js/components/credential.vue?vue&type=template&id=0f5cc562&");
  54634. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "render", function() { return _node_modules_vue_loader_lib_loaders_templateLoader_js_vue_loader_options_node_modules_vue_loader_lib_index_js_vue_loader_options_credential_vue_vue_type_template_id_0f5cc562___WEBPACK_IMPORTED_MODULE_0__["render"]; });
  54635. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "staticRenderFns", function() { return _node_modules_vue_loader_lib_loaders_templateLoader_js_vue_loader_options_node_modules_vue_loader_lib_index_js_vue_loader_options_credential_vue_vue_type_template_id_0f5cc562___WEBPACK_IMPORTED_MODULE_0__["staticRenderFns"]; });
  54636. /***/ }),
  54637. /***/ "./resources/js/components/modal.vue":
  54638. /*!*******************************************!*\
  54639. !*** ./resources/js/components/modal.vue ***!
  54640. \*******************************************/
  54641. /*! exports provided: default */
  54642. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  54643. "use strict";
  54644. __webpack_require__.r(__webpack_exports__);
  54645. /* harmony import */ var _modal_vue_vue_type_template_id_478d961c___WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./modal.vue?vue&type=template&id=478d961c& */ "./resources/js/components/modal.vue?vue&type=template&id=478d961c&");
  54646. /* harmony import */ var _node_modules_vue_loader_lib_runtime_componentNormalizer_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../node_modules/vue-loader/lib/runtime/componentNormalizer.js */ "./node_modules/vue-loader/lib/runtime/componentNormalizer.js");
  54647. var script = {}
  54648. /* normalize component */
  54649. var component = Object(_node_modules_vue_loader_lib_runtime_componentNormalizer_js__WEBPACK_IMPORTED_MODULE_1__["default"])(
  54650. script,
  54651. _modal_vue_vue_type_template_id_478d961c___WEBPACK_IMPORTED_MODULE_0__["render"],
  54652. _modal_vue_vue_type_template_id_478d961c___WEBPACK_IMPORTED_MODULE_0__["staticRenderFns"],
  54653. false,
  54654. null,
  54655. null,
  54656. null
  54657. )
  54658. /* hot reload */
  54659. if (false) { var api; }
  54660. component.options.__file = "resources/js/components/modal.vue"
  54661. /* harmony default export */ __webpack_exports__["default"] = (component.exports);
  54662. /***/ }),
  54663. /***/ "./resources/js/components/modal.vue?vue&type=template&id=478d961c&":
  54664. /*!**************************************************************************!*\
  54665. !*** ./resources/js/components/modal.vue?vue&type=template&id=478d961c& ***!
  54666. \**************************************************************************/
  54667. /*! exports provided: render, staticRenderFns */
  54668. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  54669. "use strict";
  54670. __webpack_require__.r(__webpack_exports__);
  54671. /* harmony import */ var _node_modules_vue_loader_lib_loaders_templateLoader_js_vue_loader_options_node_modules_vue_loader_lib_index_js_vue_loader_options_modal_vue_vue_type_template_id_478d961c___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!./modal.vue?vue&type=template&id=478d961c& */ "./node_modules/vue-loader/lib/loaders/templateLoader.js?!./node_modules/vue-loader/lib/index.js?!./resources/js/components/modal.vue?vue&type=template&id=478d961c&");
  54672. /* 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_modal_vue_vue_type_template_id_478d961c___WEBPACK_IMPORTED_MODULE_0__["render"]; });
  54673. /* 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_modal_vue_vue_type_template_id_478d961c___WEBPACK_IMPORTED_MODULE_0__["staticRenderFns"]; });
  54674. /***/ }),
  54675. /***/ "./resources/js/components/notes.vue":
  54676. /*!*******************************************!*\
  54677. !*** ./resources/js/components/notes.vue ***!
  54678. \*******************************************/
  54679. /*! exports provided: default */
  54680. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  54681. "use strict";
  54682. __webpack_require__.r(__webpack_exports__);
  54683. /* harmony import */ var _notes_vue_vue_type_template_id_73d141f4___WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./notes.vue?vue&type=template&id=73d141f4& */ "./resources/js/components/notes.vue?vue&type=template&id=73d141f4&");
  54684. /* harmony import */ var _notes_vue_vue_type_script_lang_js___WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./notes.vue?vue&type=script&lang=js& */ "./resources/js/components/notes.vue?vue&type=script&lang=js&");
  54685. /* 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");
  54686. /* normalize component */
  54687. var component = Object(_node_modules_vue_loader_lib_runtime_componentNormalizer_js__WEBPACK_IMPORTED_MODULE_2__["default"])(
  54688. _notes_vue_vue_type_script_lang_js___WEBPACK_IMPORTED_MODULE_1__["default"],
  54689. _notes_vue_vue_type_template_id_73d141f4___WEBPACK_IMPORTED_MODULE_0__["render"],
  54690. _notes_vue_vue_type_template_id_73d141f4___WEBPACK_IMPORTED_MODULE_0__["staticRenderFns"],
  54691. false,
  54692. null,
  54693. null,
  54694. null
  54695. )
  54696. /* hot reload */
  54697. if (false) { var api; }
  54698. component.options.__file = "resources/js/components/notes.vue"
  54699. /* harmony default export */ __webpack_exports__["default"] = (component.exports);
  54700. /***/ }),
  54701. /***/ "./resources/js/components/notes.vue?vue&type=script&lang=js&":
  54702. /*!********************************************************************!*\
  54703. !*** ./resources/js/components/notes.vue?vue&type=script&lang=js& ***!
  54704. \********************************************************************/
  54705. /*! exports provided: default */
  54706. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  54707. "use strict";
  54708. __webpack_require__.r(__webpack_exports__);
  54709. /* harmony import */ var _node_modules_babel_loader_lib_index_js_ref_4_0_node_modules_vue_loader_lib_index_js_vue_loader_options_notes_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!./notes.vue?vue&type=script&lang=js& */ "./node_modules/babel-loader/lib/index.js?!./node_modules/vue-loader/lib/index.js?!./resources/js/components/notes.vue?vue&type=script&lang=js&");
  54710. /* 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_notes_vue_vue_type_script_lang_js___WEBPACK_IMPORTED_MODULE_0__["default"]);
  54711. /***/ }),
  54712. /***/ "./resources/js/components/notes.vue?vue&type=template&id=73d141f4&":
  54713. /*!**************************************************************************!*\
  54714. !*** ./resources/js/components/notes.vue?vue&type=template&id=73d141f4& ***!
  54715. \**************************************************************************/
  54716. /*! exports provided: render, staticRenderFns */
  54717. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  54718. "use strict";
  54719. __webpack_require__.r(__webpack_exports__);
  54720. /* harmony import */ var _node_modules_vue_loader_lib_loaders_templateLoader_js_vue_loader_options_node_modules_vue_loader_lib_index_js_vue_loader_options_notes_vue_vue_type_template_id_73d141f4___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!./notes.vue?vue&type=template&id=73d141f4& */ "./node_modules/vue-loader/lib/loaders/templateLoader.js?!./node_modules/vue-loader/lib/index.js?!./resources/js/components/notes.vue?vue&type=template&id=73d141f4&");
  54721. /* 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_notes_vue_vue_type_template_id_73d141f4___WEBPACK_IMPORTED_MODULE_0__["render"]; });
  54722. /* 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_notes_vue_vue_type_template_id_73d141f4___WEBPACK_IMPORTED_MODULE_0__["staticRenderFns"]; });
  54723. /***/ }),
  54724. /***/ "./resources/js/components/woinfo.vue":
  54725. /*!********************************************!*\
  54726. !*** ./resources/js/components/woinfo.vue ***!
  54727. \********************************************/
  54728. /*! exports provided: default */
  54729. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  54730. "use strict";
  54731. __webpack_require__.r(__webpack_exports__);
  54732. /* 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&");
  54733. /* 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&");
  54734. /* 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");
  54735. /* normalize component */
  54736. var component = Object(_node_modules_vue_loader_lib_runtime_componentNormalizer_js__WEBPACK_IMPORTED_MODULE_2__["default"])(
  54737. _woinfo_vue_vue_type_script_lang_js___WEBPACK_IMPORTED_MODULE_1__["default"],
  54738. _woinfo_vue_vue_type_template_id_33ce32de___WEBPACK_IMPORTED_MODULE_0__["render"],
  54739. _woinfo_vue_vue_type_template_id_33ce32de___WEBPACK_IMPORTED_MODULE_0__["staticRenderFns"],
  54740. false,
  54741. null,
  54742. null,
  54743. null
  54744. )
  54745. /* hot reload */
  54746. if (false) { var api; }
  54747. component.options.__file = "resources/js/components/woinfo.vue"
  54748. /* harmony default export */ __webpack_exports__["default"] = (component.exports);
  54749. /***/ }),
  54750. /***/ "./resources/js/components/woinfo.vue?vue&type=script&lang=js&":
  54751. /*!*********************************************************************!*\
  54752. !*** ./resources/js/components/woinfo.vue?vue&type=script&lang=js& ***!
  54753. \*********************************************************************/
  54754. /*! exports provided: default */
  54755. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  54756. "use strict";
  54757. __webpack_require__.r(__webpack_exports__);
  54758. /* 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&");
  54759. /* 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"]);
  54760. /***/ }),
  54761. /***/ "./resources/js/components/woinfo.vue?vue&type=template&id=33ce32de&":
  54762. /*!***************************************************************************!*\
  54763. !*** ./resources/js/components/woinfo.vue?vue&type=template&id=33ce32de& ***!
  54764. \***************************************************************************/
  54765. /*! exports provided: render, staticRenderFns */
  54766. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  54767. "use strict";
  54768. __webpack_require__.r(__webpack_exports__);
  54769. /* 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&");
  54770. /* 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"]; });
  54771. /* 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"]; });
  54772. /***/ }),
  54773. /***/ "./resources/js/mixins/dateMixin.js":
  54774. /*!******************************************!*\
  54775. !*** ./resources/js/mixins/dateMixin.js ***!
  54776. \******************************************/
  54777. /*! exports provided: default */
  54778. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  54779. "use strict";
  54780. __webpack_require__.r(__webpack_exports__);
  54781. /* harmony default export */ __webpack_exports__["default"] = ({
  54782. methods: {
  54783. treatAsUTC: function treatAsUTC(date) {
  54784. var result = new Date(date);
  54785. result.setMinutes(result.getMinutes() - result.getTimezoneOffset());
  54786. return result;
  54787. },
  54788. daysSinceToday: function daysSinceToday(date) {
  54789. var currentDate = new Date();
  54790. var millisecondsPerDay = 24 * 60 * 60 * 1000;
  54791. return (this.treatAsUTC(currentDate) - this.treatAsUTC(date)) / millisecondsPerDay;
  54792. },
  54793. getHRDate: function getHRDate(dateString) {
  54794. var date = new Date(dateString);
  54795. return date.toLocaleString('default', {
  54796. month: 'short',
  54797. day: 'numeric',
  54798. year: 'numeric',
  54799. hour: 'numeric',
  54800. minute: 'numeric'
  54801. });
  54802. },
  54803. isZero: function isZero(dateString) {
  54804. return dateString === '0000-00-00 00:00:00';
  54805. }
  54806. }
  54807. });
  54808. /***/ }),
  54809. /***/ "./resources/js/notify.min.js":
  54810. /*!************************************!*\
  54811. !*** ./resources/js/notify.min.js ***!
  54812. \************************************/
  54813. /*! no static exports found */
  54814. /***/ (function(module, exports, __webpack_require__) {
  54815. var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  54816. (function (e) {
  54817. true ? !(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__(/*! jquery */ "./node_modules/jquery/dist/jquery.js")], __WEBPACK_AMD_DEFINE_FACTORY__ = (e),
  54818. __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ?
  54819. (__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__),
  54820. __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)) : undefined;
  54821. })(function (e) {
  54822. function A(t, n, i) {
  54823. typeof i == "string" && (i = {
  54824. className: i
  54825. }), this.options = E(w, e.isPlainObject(i) ? i : {}), this.loadHTML(), this.wrapper = e(h.html), this.options.clickToHide && this.wrapper.addClass(r + "-hidable"), this.wrapper.data(r, this), this.arrow = this.wrapper.find("." + r + "-arrow"), this.container = this.wrapper.find("." + r + "-container"), this.container.append(this.userContainer), t && t.length && (this.elementType = t.attr("type"), this.originalElement = t, this.elem = N(t), this.elem.data(r, this), this.elem.before(this.wrapper)), this.container.hide(), this.run(n);
  54826. }
  54827. var t = [].indexOf || function (e) {
  54828. for (var t = 0, n = this.length; t < n; t++) {
  54829. if (t in this && this[t] === e) return t;
  54830. }
  54831. return -1;
  54832. },
  54833. n = "notify",
  54834. r = n + "js",
  54835. i = n + "!blank",
  54836. s = {
  54837. t: "top",
  54838. m: "middle",
  54839. b: "bottom",
  54840. l: "left",
  54841. c: "center",
  54842. r: "right"
  54843. },
  54844. o = ["l", "c", "r"],
  54845. u = ["t", "m", "b"],
  54846. a = ["t", "b", "l", "r"],
  54847. f = {
  54848. t: "b",
  54849. m: null,
  54850. b: "t",
  54851. l: "r",
  54852. c: null,
  54853. r: "l"
  54854. },
  54855. l = function l(t) {
  54856. var n;
  54857. return n = [], e.each(t.split(/\W+/), function (e, t) {
  54858. var r;
  54859. r = t.toLowerCase().charAt(0);
  54860. if (s[r]) return n.push(r);
  54861. }), n;
  54862. },
  54863. c = {},
  54864. h = {
  54865. name: "core",
  54866. html: '<div class="' + r + '-wrapper">\n <div class="' + r + '-arrow"></div>\n <div class="' + r + '-container"></div>\n</div>',
  54867. css: "." + r + "-corner {\n position: fixed;\n margin: 5px;\n z-index: 1050;\n}\n\n." + r + "-corner ." + r + "-wrapper,\n." + r + "-corner ." + r + "-container {\n position: relative;\n display: block;\n height: inherit;\n width: inherit;\n margin: 3px;\n}\n\n." + r + "-wrapper {\n z-index: 1;\n position: absolute;\n display: inline-block;\n height: 0;\n width: 0;\n}\n\n." + r + "-container {\n display: none;\n z-index: 1;\n position: absolute;\n}\n\n." + r + "-hidable {\n cursor: pointer;\n}\n\n[data-notify-text],[data-notify-html] {\n position: relative;\n}\n\n." + r + "-arrow {\n position: absolute;\n z-index: 2;\n width: 0;\n height: 0;\n}"
  54868. },
  54869. p = {
  54870. "border-radius": ["-webkit-", "-moz-"]
  54871. },
  54872. d = function d(e) {
  54873. return c[e];
  54874. },
  54875. v = function v(e) {
  54876. if (!e) throw "Missing Style name";
  54877. c[e] && delete c[e];
  54878. },
  54879. m = function m(t, i) {
  54880. if (!t) throw "Missing Style name";
  54881. if (!i) throw "Missing Style definition";
  54882. if (!i.html) throw "Missing Style HTML";
  54883. var s = c[t];
  54884. s && s.cssElem && (window.console && console.warn(n + ": overwriting style '" + t + "'"), c[t].cssElem.remove()), i.name = t, c[t] = i;
  54885. var o = "";
  54886. i.classes && e.each(i.classes, function (t, n) {
  54887. return o += "." + r + "-" + i.name + "-" + t + " {\n", e.each(n, function (t, n) {
  54888. return p[t] && e.each(p[t], function (e, r) {
  54889. return o += " " + r + t + ": " + n + ";\n";
  54890. }), o += " " + t + ": " + n + ";\n";
  54891. }), o += "}\n";
  54892. }), i.css && (o += "/* styles for " + i.name + " */\n" + i.css), o && (i.cssElem = g(o), i.cssElem.attr("id", "notify-" + i.name));
  54893. var u = {},
  54894. a = e(i.html);
  54895. y("html", a, u), y("text", a, u), i.fields = u;
  54896. },
  54897. g = function g(t) {
  54898. var n, r, i;
  54899. r = x("style"), r.attr("type", "text/css"), e("head").append(r);
  54900. try {
  54901. r.html(t);
  54902. } catch (s) {
  54903. r[0].styleSheet.cssText = t;
  54904. }
  54905. return r;
  54906. },
  54907. y = function y(t, n, r) {
  54908. var s;
  54909. return t !== "html" && (t = "text"), s = "data-notify-" + t, b(n, "[" + s + "]").each(function () {
  54910. var n;
  54911. n = e(this).attr(s), n || (n = i), r[n] = t;
  54912. });
  54913. },
  54914. b = function b(e, t) {
  54915. return e.is(t) ? e : e.find(t);
  54916. },
  54917. w = {
  54918. clickToHide: !0,
  54919. autoHide: !0,
  54920. autoHideDelay: 5e3,
  54921. arrowShow: !0,
  54922. arrowSize: 5,
  54923. breakNewLines: !0,
  54924. elementPosition: "bottom",
  54925. globalPosition: "top right",
  54926. style: "bootstrap",
  54927. className: "error",
  54928. showAnimation: "slideDown",
  54929. showDuration: 400,
  54930. hideAnimation: "slideUp",
  54931. hideDuration: 200,
  54932. gap: 5
  54933. },
  54934. E = function E(t, n) {
  54935. var r;
  54936. return r = function r() {}, r.prototype = t, e.extend(!0, new r(), n);
  54937. },
  54938. S = function S(t) {
  54939. return e.extend(w, t);
  54940. },
  54941. x = function x(t) {
  54942. return e("<" + t + "></" + t + ">");
  54943. },
  54944. T = {},
  54945. N = function N(t) {
  54946. var n;
  54947. return t.is("[type=radio]") && (n = t.parents("form:first").find("[type=radio]").filter(function (n, r) {
  54948. return e(r).attr("name") === t.attr("name");
  54949. }), t = n.first()), t;
  54950. },
  54951. C = function C(e, t, n) {
  54952. var r, i;
  54953. if (typeof n == "string") n = parseInt(n, 10);else if (typeof n != "number") return;
  54954. if (isNaN(n)) return;
  54955. return r = s[f[t.charAt(0)]], i = t, e[r] !== undefined && (t = s[r.charAt(0)], n = -n), e[t] === undefined ? e[t] = n : e[t] += n, null;
  54956. },
  54957. k = function k(e, t, n) {
  54958. if (e === "l" || e === "t") return 0;
  54959. if (e === "c" || e === "m") return n / 2 - t / 2;
  54960. if (e === "r" || e === "b") return n - t;
  54961. throw "Invalid alignment";
  54962. },
  54963. L = function L(e) {
  54964. return L.e = L.e || x("div"), L.e.text(e).html();
  54965. };
  54966. A.prototype.loadHTML = function () {
  54967. var t;
  54968. t = this.getStyle(), this.userContainer = e(t.html), this.userFields = t.fields;
  54969. }, A.prototype.show = function (e, t) {
  54970. var n, r, i, s, o;
  54971. r = function (n) {
  54972. return function () {
  54973. !e && !n.elem && n.destroy();
  54974. if (t) return t();
  54975. };
  54976. }(this), o = this.container.parent().parents(":hidden").length > 0, i = this.container.add(this.arrow), n = [];
  54977. if (o && e) s = "show";else if (o && !e) s = "hide";else if (!o && e) s = this.options.showAnimation, n.push(this.options.showDuration);else {
  54978. if (!!o || !!e) return r();
  54979. s = this.options.hideAnimation, n.push(this.options.hideDuration);
  54980. }
  54981. return n.push(r), i[s].apply(i, n);
  54982. }, A.prototype.setGlobalPosition = function () {
  54983. var t = this.getPosition(),
  54984. n = t[0],
  54985. i = t[1],
  54986. o = s[n],
  54987. u = s[i],
  54988. a = n + "|" + i,
  54989. f = T[a];
  54990. if (!f || !document.body.contains(f[0])) {
  54991. f = T[a] = x("div");
  54992. var l = {};
  54993. l[o] = 0, u === "middle" ? l.top = "45%" : u === "center" ? l.left = "45%" : l[u] = 0, f.css(l).addClass(r + "-corner"), e("body").append(f);
  54994. }
  54995. return f.prepend(this.wrapper);
  54996. }, A.prototype.setElementPosition = function () {
  54997. var n, r, i, l, c, h, p, d, v, m, g, y, b, w, E, S, x, T, N, L, A, O, M, _, D, P, H, B, j;
  54998. H = this.getPosition(), _ = H[0], O = H[1], M = H[2], g = this.elem.position(), d = this.elem.outerHeight(), y = this.elem.outerWidth(), v = this.elem.innerHeight(), m = this.elem.innerWidth(), j = this.wrapper.position(), c = this.container.height(), h = this.container.width(), T = s[_], L = f[_], A = s[L], p = {}, p[A] = _ === "b" ? d : _ === "r" ? y : 0, C(p, "top", g.top - j.top), C(p, "left", g.left - j.left), B = ["top", "left"];
  54999. for (w = 0, S = B.length; w < S; w++) {
  55000. D = B[w], N = parseInt(this.elem.css("margin-" + D), 10), N && C(p, D, N);
  55001. }
  55002. b = Math.max(0, this.options.gap - (this.options.arrowShow ? i : 0)), C(p, A, b);
  55003. if (!this.options.arrowShow) this.arrow.hide();else {
  55004. i = this.options.arrowSize, r = e.extend({}, p), n = this.userContainer.css("border-color") || this.userContainer.css("border-top-color") || this.userContainer.css("background-color") || "white";
  55005. for (E = 0, x = a.length; E < x; E++) {
  55006. D = a[E], P = s[D];
  55007. if (D === L) continue;
  55008. l = P === T ? n : "transparent", r["border-" + P] = i + "px solid " + l;
  55009. }
  55010. C(p, s[L], i), t.call(a, O) >= 0 && C(r, s[O], i * 2);
  55011. }
  55012. t.call(u, _) >= 0 ? (C(p, "left", k(O, h, y)), r && C(r, "left", k(O, i, m))) : t.call(o, _) >= 0 && (C(p, "top", k(O, c, d)), r && C(r, "top", k(O, i, v))), this.container.is(":visible") && (p.display = "block"), this.container.removeAttr("style").css(p);
  55013. if (r) return this.arrow.removeAttr("style").css(r);
  55014. }, A.prototype.getPosition = function () {
  55015. var e, n, r, i, s, f, c, h;
  55016. h = this.options.position || (this.elem ? this.options.elementPosition : this.options.globalPosition), e = l(h), e.length === 0 && (e[0] = "b");
  55017. if (n = e[0], t.call(a, n) < 0) throw "Must be one of [" + a + "]";
  55018. if (e.length === 1 || (r = e[0], t.call(u, r) >= 0) && (i = e[1], t.call(o, i) < 0) || (s = e[0], t.call(o, s) >= 0) && (f = e[1], t.call(u, f) < 0)) e[1] = (c = e[0], t.call(o, c) >= 0) ? "m" : "l";
  55019. return e.length === 2 && (e[2] = e[1]), e;
  55020. }, A.prototype.getStyle = function (e) {
  55021. var t;
  55022. e || (e = this.options.style), e || (e = "default"), t = c[e];
  55023. if (!t) throw "Missing style: " + e;
  55024. return t;
  55025. }, A.prototype.updateClasses = function () {
  55026. var t, n;
  55027. return t = ["base"], e.isArray(this.options.className) ? t = t.concat(this.options.className) : this.options.className && t.push(this.options.className), n = this.getStyle(), t = e.map(t, function (e) {
  55028. return r + "-" + n.name + "-" + e;
  55029. }).join(" "), this.userContainer.attr("class", t);
  55030. }, A.prototype.run = function (t, n) {
  55031. var r, s, o, u, a;
  55032. e.isPlainObject(n) ? e.extend(this.options, n) : e.type(n) === "string" && (this.options.className = n);
  55033. if (this.container && !t) {
  55034. this.show(!1);
  55035. return;
  55036. }
  55037. if (!this.container && !t) return;
  55038. s = {}, e.isPlainObject(t) ? s = t : s[i] = t;
  55039. for (o in s) {
  55040. r = s[o], u = this.userFields[o];
  55041. if (!u) continue;
  55042. u === "text" && (r = L(r), this.options.breakNewLines && (r = r.replace(/\n/g, "<br/>"))), a = o === i ? "" : "=" + o, b(this.userContainer, "[data-notify-" + u + a + "]").html(r);
  55043. }
  55044. this.updateClasses(), this.elem ? this.setElementPosition() : this.setGlobalPosition(), this.show(!0), this.options.autoHide && (clearTimeout(this.autohideTimer), this.autohideTimer = setTimeout(this.show.bind(this, !1), this.options.autoHideDelay));
  55045. }, A.prototype.destroy = function () {
  55046. this.wrapper.data(r, null), this.wrapper.remove();
  55047. }, e[n] = function (t, r, i) {
  55048. return t && t.nodeName || t.jquery ? e(t)[n](r, i) : (i = r, r = t, new A(null, r, i)), t;
  55049. }, e.fn[n] = function (t, n) {
  55050. return e(this).each(function () {
  55051. var i = N(e(this)).data(r);
  55052. i && i.destroy();
  55053. var s = new A(e(this), t, n);
  55054. }), this;
  55055. }, e.extend(e[n], {
  55056. defaults: S,
  55057. addStyle: m,
  55058. removeStyle: v,
  55059. pluginOptions: w,
  55060. getStyle: d,
  55061. insertCSS: g
  55062. }), m("bootstrap", {
  55063. html: "<div>\n<span data-notify-text></span>\n</div>",
  55064. classes: {
  55065. base: {
  55066. "font-weight": "bold",
  55067. padding: "8px 15px 8px 14px",
  55068. "text-shadow": "0 1px 0 rgba(255, 255, 255, 0.5)",
  55069. "background-color": "#fcf8e3",
  55070. border: "1px solid #fbeed5",
  55071. "border-radius": "4px",
  55072. "white-space": "nowrap",
  55073. "padding-left": "25px",
  55074. "background-repeat": "no-repeat",
  55075. "background-position": "3px 7px"
  55076. },
  55077. error: {
  55078. color: "#B94A48",
  55079. "background-color": "#F2DEDE",
  55080. "border-color": "#EED3D7",
  55081. "background-image": "url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAtRJREFUeNqkVc1u00AQHq+dOD+0poIQfkIjalW0SEGqRMuRnHos3DjwAH0ArlyQeANOOSMeAA5VjyBxKBQhgSpVUKKQNGloFdw4cWw2jtfMOna6JOUArDTazXi/b3dm55socPqQhFka++aHBsI8GsopRJERNFlY88FCEk9Yiwf8RhgRyaHFQpPHCDmZG5oX2ui2yilkcTT1AcDsbYC1NMAyOi7zTX2Agx7A9luAl88BauiiQ/cJaZQfIpAlngDcvZZMrl8vFPK5+XktrWlx3/ehZ5r9+t6e+WVnp1pxnNIjgBe4/6dAysQc8dsmHwPcW9C0h3fW1hans1ltwJhy0GxK7XZbUlMp5Ww2eyan6+ft/f2FAqXGK4CvQk5HueFz7D6GOZtIrK+srupdx1GRBBqNBtzc2AiMr7nPplRdKhb1q6q6zjFhrklEFOUutoQ50xcX86ZlqaZpQrfbBdu2R6/G19zX6XSgh6RX5ubyHCM8nqSID6ICrGiZjGYYxojEsiw4PDwMSL5VKsC8Yf4VRYFzMzMaxwjlJSlCyAQ9l0CW44PBADzXhe7xMdi9HtTrdYjFYkDQL0cn4Xdq2/EAE+InCnvADTf2eah4Sx9vExQjkqXT6aAERICMewd/UAp/IeYANM2joxt+q5VI+ieq2i0Wg3l6DNzHwTERPgo1ko7XBXj3vdlsT2F+UuhIhYkp7u7CarkcrFOCtR3H5JiwbAIeImjT/YQKKBtGjRFCU5IUgFRe7fF4cCNVIPMYo3VKqxwjyNAXNepuopyqnld602qVsfRpEkkz+GFL1wPj6ySXBpJtWVa5xlhpcyhBNwpZHmtX8AGgfIExo0ZpzkWVTBGiXCSEaHh62/PoR0p/vHaczxXGnj4bSo+G78lELU80h1uogBwWLf5YlsPmgDEd4M236xjm+8nm4IuE/9u+/PH2JXZfbwz4zw1WbO+SQPpXfwG/BBgAhCNZiSb/pOQAAAAASUVORK5CYII=)"
  55082. },
  55083. success: {
  55084. color: "#468847",
  55085. "background-color": "#DFF0D8",
  55086. "border-color": "#D6E9C6",
  55087. "background-image": "url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAutJREFUeNq0lctPE0Ecx38zu/RFS1EryqtgJFA08YCiMZIAQQ4eRG8eDGdPJiYeTIwHTfwPiAcvXIwXLwoXPaDxkWgQ6islKlJLSQWLUraPLTv7Gme32zoF9KSTfLO7v53vZ3d/M7/fIth+IO6INt2jjoA7bjHCJoAlzCRw59YwHYjBnfMPqAKWQYKjGkfCJqAF0xwZjipQtA3MxeSG87VhOOYegVrUCy7UZM9S6TLIdAamySTclZdYhFhRHloGYg7mgZv1Zzztvgud7V1tbQ2twYA34LJmF4p5dXF1KTufnE+SxeJtuCZNsLDCQU0+RyKTF27Unw101l8e6hns3u0PBalORVVVkcaEKBJDgV3+cGM4tKKmI+ohlIGnygKX00rSBfszz/n2uXv81wd6+rt1orsZCHRdr1Imk2F2Kob3hutSxW8thsd8AXNaln9D7CTfA6O+0UgkMuwVvEFFUbbAcrkcTA8+AtOk8E6KiQiDmMFSDqZItAzEVQviRkdDdaFgPp8HSZKAEAL5Qh7Sq2lIJBJwv2scUqkUnKoZgNhcDKhKg5aH+1IkcouCAdFGAQsuWZYhOjwFHQ96oagWgRoUov1T9kRBEODAwxM2QtEUl+Wp+Ln9VRo6BcMw4ErHRYjH4/B26AlQoQQTRdHWwcd9AH57+UAXddvDD37DmrBBV34WfqiXPl61g+vr6xA9zsGeM9gOdsNXkgpEtTwVvwOklXLKm6+/p5ezwk4B+j6droBs2CsGa/gNs6RIxazl4Tc25mpTgw/apPR1LYlNRFAzgsOxkyXYLIM1V8NMwyAkJSctD1eGVKiq5wWjSPdjmeTkiKvVW4f2YPHWl3GAVq6ymcyCTgovM3FzyRiDe2TaKcEKsLpJvNHjZgPNqEtyi6mZIm4SRFyLMUsONSSdkPeFtY1n0mczoY3BHTLhwPRy9/lzcziCw9ACI+yql0VLzcGAZbYSM5CCSZg1/9oc/nn7+i8N9p/8An4JMADxhH+xHfuiKwAAAABJRU5ErkJggg==)"
  55088. },
  55089. info: {
  55090. color: "#3A87AD",
  55091. "background-color": "#D9EDF7",
  55092. "border-color": "#BCE8F1",
  55093. "background-image": "url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH3QYFAhkSsdes/QAAA8dJREFUOMvVlGtMW2UYx//POaWHXg6lLaW0ypAtw1UCgbniNOLcVOLmAjHZolOYlxmTGXVZdAnRfXQm+7SoU4mXaOaiZsEpC9FkiQs6Z6bdCnNYruM6KNBw6YWewzl9z+sHImEWv+vz7XmT95f/+3/+7wP814v+efDOV3/SoX3lHAA+6ODeUFfMfjOWMADgdk+eEKz0pF7aQdMAcOKLLjrcVMVX3xdWN29/GhYP7SvnP0cWfS8caSkfHZsPE9Fgnt02JNutQ0QYHB2dDz9/pKX8QjjuO9xUxd/66HdxTeCHZ3rojQObGQBcuNjfplkD3b19Y/6MrimSaKgSMmpGU5WevmE/swa6Oy73tQHA0Rdr2Mmv/6A1n9w9suQ7097Z9lM4FlTgTDrzZTu4StXVfpiI48rVcUDM5cmEksrFnHxfpTtU/3BFQzCQF/2bYVoNbH7zmItbSoMj40JSzmMyX5qDvriA7QdrIIpA+3cdsMpu0nXI8cV0MtKXCPZev+gCEM1S2NHPvWfP/hL+7FSr3+0p5RBEyhEN5JCKYr8XnASMT0xBNyzQGQeI8fjsGD39RMPk7se2bd5ZtTyoFYXftF6y37gx7NeUtJJOTFlAHDZLDuILU3j3+H5oOrD3yWbIztugaAzgnBKJuBLpGfQrS8wO4FZgV+c1IxaLgWVU0tMLEETCos4xMzEIv9cJXQcyagIwigDGwJgOAtHAwAhisQUjy0ORGERiELgG4iakkzo4MYAxcM5hAMi1WWG1yYCJIcMUaBkVRLdGeSU2995TLWzcUAzONJ7J6FBVBYIggMzmFbvdBV44Corg8vjhzC+EJEl8U1kJtgYrhCzgc/vvTwXKSib1paRFVRVORDAJAsw5FuTaJEhWM2SHB3mOAlhkNxwuLzeJsGwqWzf5TFNdKgtY5qHp6ZFf67Y/sAVadCaVY5YACDDb3Oi4NIjLnWMw2QthCBIsVhsUTU9tvXsjeq9+X1d75/KEs4LNOfcdf/+HthMnvwxOD0wmHaXr7ZItn2wuH2SnBzbZAbPJwpPx+VQuzcm7dgRCB57a1uBzUDRL4bfnI0RE0eaXd9W89mpjqHZnUI5Hh2l2dkZZUhOqpi2qSmpOmZ64Tuu9qlz/SEXo6MEHa3wOip46F1n7633eekV8ds8Wxjn37Wl63VVa+ej5oeEZ/82ZBETJjpJ1Rbij2D3Z/1trXUvLsblCK0XfOx0SX2kMsn9dX+d+7Kf6h8o4AIykuffjT8L20LU+w4AZd5VvEPY+XpWqLV327HR7DzXuDnD8r+ovkBehJ8i+y8YAAAAASUVORK5CYII=)"
  55094. },
  55095. warn: {
  55096. color: "#C09853",
  55097. "background-color": "#FCF8E3",
  55098. "border-color": "#FBEED5",
  55099. "background-image": "url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAMAAAC6V+0/AAABJlBMVEXr6eb/2oD/wi7/xjr/0mP/ykf/tQD/vBj/3o7/uQ//vyL/twebhgD/4pzX1K3z8e349vK6tHCilCWbiQymn0jGworr6dXQza3HxcKkn1vWvV/5uRfk4dXZ1bD18+/52YebiAmyr5S9mhCzrWq5t6ufjRH54aLs0oS+qD751XqPhAybhwXsujG3sm+Zk0PTwG6Shg+PhhObhwOPgQL4zV2nlyrf27uLfgCPhRHu7OmLgAafkyiWkD3l49ibiAfTs0C+lgCniwD4sgDJxqOilzDWowWFfAH08uebig6qpFHBvH/aw26FfQTQzsvy8OyEfz20r3jAvaKbhgG9q0nc2LbZxXanoUu/u5WSggCtp1anpJKdmFz/zlX/1nGJiYmuq5Dx7+sAAADoPUZSAAAAAXRSTlMAQObYZgAAAAFiS0dEAIgFHUgAAAAJcEhZcwAACxMAAAsTAQCanBgAAAAHdElNRQfdBgUBGhh4aah5AAAAlklEQVQY02NgoBIIE8EUcwn1FkIXM1Tj5dDUQhPU502Mi7XXQxGz5uVIjGOJUUUW81HnYEyMi2HVcUOICQZzMMYmxrEyMylJwgUt5BljWRLjmJm4pI1hYp5SQLGYxDgmLnZOVxuooClIDKgXKMbN5ggV1ACLJcaBxNgcoiGCBiZwdWxOETBDrTyEFey0jYJ4eHjMGWgEAIpRFRCUt08qAAAAAElFTkSuQmCC)"
  55100. }
  55101. }
  55102. }), e(function () {
  55103. g(h.css).attr("id", "core-notify"), e(document).on("click", "." + r + "-hidable", function (t) {
  55104. e(this).trigger("notify-hide");
  55105. }), e(document).on("notify-hide", "." + r + "-wrapper", function (t) {
  55106. var n = e(this).data(r);
  55107. n && n.show(!1);
  55108. });
  55109. });
  55110. });
  55111. /***/ }),
  55112. /***/ "./resources/sass/app.scss":
  55113. /*!*********************************!*\
  55114. !*** ./resources/sass/app.scss ***!
  55115. \*********************************/
  55116. /*! no static exports found */
  55117. /***/ (function(module, exports) {
  55118. // removed by extract-text-webpack-plugin
  55119. /***/ }),
  55120. /***/ 0:
  55121. /*!*************************************************************!*\
  55122. !*** multi ./resources/js/app.js ./resources/sass/app.scss ***!
  55123. \*************************************************************/
  55124. /*! no static exports found */
  55125. /***/ (function(module, exports, __webpack_require__) {
  55126. __webpack_require__(/*! /home/vagrant/upccrt/resources/js/app.js */"./resources/js/app.js");
  55127. module.exports = __webpack_require__(/*! /home/vagrant/upccrt/resources/sass/app.scss */"./resources/sass/app.scss");
  55128. /***/ })
  55129. /******/ });